Skip to content

Commit 770ef29

Browse files
committed
Run clang-format on all source files
1 parent 71b5f93 commit 770ef29

File tree

5 files changed

+75
-153
lines changed

5 files changed

+75
-153
lines changed

otsdaq-mu2e-calorimeter/FEInterfaces/MZB.C

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,23 @@
66

77
// #include "otsdaq-mu2e/FEInterfaces/ROCPolarFireCoreInterface.h"
88

9-
uint8_t* MZB_Encode_CMD_Command_raw(MZB_OSCMDCODE_t cmdCode, float* params)
10-
{
9+
uint8_t* MZB_Encode_CMD_Command_raw(MZB_OSCMDCODE_t cmdCode, float* params) {
1110
int i;
1211

1312
// Create structure and fill only to ease the checksum calculation
1413

1514
#ifdef GNU_COMP
16-
static struct __attribute__((__packed__)) ems
17-
{
15+
static struct __attribute__((__packed__)) ems {
1816
#else
19-
__packed __align(4) struct ems
20-
{
17+
__packed __align(4) struct ems {
2118
#endif
2219
short dummy;
2320
short adr;
2421

2522
#ifdef GNU_COMP
26-
struct __attribute__((__packed__))
27-
{
23+
struct __attribute__((__packed__)) {
2824
#else
29-
__packed struct
30-
{
25+
__packed struct {
3126
#endif
3227
unsigned short functionReq_tag; // 'CD'
3328
unsigned short functionReq;
@@ -60,8 +55,7 @@ uint8_t* MZB_Encode_CMD_Command_raw(MZB_OSCMDCODE_t cmdCode, float* params)
6055
em.cmdReq.functionReq = cmdCode | 0x8000;
6156

6257
// 9 parameters (float)
63-
for(i = 0; i < CT_MAXP; i++)
64-
{
58+
for(i = 0; i < CT_MAXP; i++) {
6559
em.cmdReq.P[i] = params[i];
6660
}
6761

@@ -70,13 +64,10 @@ uint8_t* MZB_Encode_CMD_Command_raw(MZB_OSCMDCODE_t cmdCode, float* params)
7064

7165
// Print for debug
7266
int debug = 0;
73-
if(debug)
74-
{
67+
if(debug) {
7568
uint8_t* p = (uint8_t*)&em.adr;
76-
for(size_t i = 0; i < (sizeof(em) - offsetof(struct ems, adr)); i += 8)
77-
{
78-
for(int j = 0; j < 8; j++)
79-
{
69+
for(size_t i = 0; i < (sizeof(em) - offsetof(struct ems, adr)); i += 8) {
70+
for(int j = 0; j < 8; j++) {
8071
printf("%02x ", *p++);
8172
}
8273
printf("\n");
@@ -86,17 +77,15 @@ uint8_t* MZB_Encode_CMD_Command_raw(MZB_OSCMDCODE_t cmdCode, float* params)
8677
return (uint8_t*)&em.adr;
8778
}
8879

89-
unsigned ees_chksum(void* ptr, int len)
90-
{
80+
unsigned ees_chksum(void* ptr, int len) {
9181
unsigned* src = (unsigned*)ptr;
9282
unsigned sum;
9383
unsigned tmp;
9484

9585
for(sum = 0; len >= 4; len -= 4)
9686
sum += *src++;
9787

98-
if(len)
99-
{
88+
if(len) {
10089
tmp = 0;
10190
memcpy(&tmp, src, len);
10291
sum += tmp;
@@ -105,12 +94,9 @@ unsigned ees_chksum(void* ptr, int len)
10594
return sum;
10695
}
10796

108-
MZB_OSCMDCODE_t mz_string_to_enum(const char* str)
109-
{
110-
for(size_t i = 0; i < sizeof(code_map) / sizeof(code_map[0]); i++)
111-
{
112-
if(code_map[i].str == str)
113-
{
97+
MZB_OSCMDCODE_t mz_string_to_enum(const char* str) {
98+
for(size_t i = 0; i < sizeof(code_map) / sizeof(code_map[0]); i++) {
99+
if(code_map[i].str == str) {
114100
return code_map[i].code;
115101
}
116102
}

scripts/converter.C

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ ifstream filein;
1111
ofstream fileheader;
1212
ofstream filepayload;
1313

14-
int read_header()
15-
{
14+
int read_header() {
1615
int nlines;
1716
char data[16];
1817
unsigned int* data_int = (unsigned int*)data;
19-
for(int i = 0; i < 9; i++)
20-
{
21-
for(int j = 0; j < 2; j++)
22-
{
18+
for(int i = 0; i < 9; i++) {
19+
for(int j = 0; j < 2; j++) {
2320
filein.read(data, 4);
2421
cout << data << endl;
2522
if(filein.eof())
@@ -33,17 +30,14 @@ int read_header()
3330
return nlines;
3431
}
3532

36-
void read_event(int nlines)
37-
{
33+
void read_event(int nlines) {
3834
filepayload << "E" << dec << nlines << endl;
3935

4036
char data[16];
4137
unsigned int* data_int = (unsigned int*)data;
42-
for(int i = 0; i < nlines; i++)
43-
{
38+
for(int i = 0; i < nlines; i++) {
4439
string b = "";
45-
for(int j = 0; j < 8; j++)
46-
{
40+
for(int j = 0; j < 8; j++) {
4741
filein.read(data, 4);
4842
filepayload << setfill('0') << setw(8) << hex << data_int[0];
4943
}
@@ -54,8 +48,7 @@ void read_event(int nlines)
5448
return;
5549
}
5650

57-
int converter(string run_num)
58-
{
51+
int converter(string run_num) {
5952
string filetype = "macroOutput";
6053

6154
string file_in = filetype + "_" + run_num + ".bin";
@@ -70,8 +63,7 @@ int converter(string run_num)
7063
std::string(getenv("OTSDAQ_DATA")) + "/" + "payload_" + run_num + ".txt";
7164
filepayload.open(file_payload.c_str());
7265

73-
while(true)
74-
{
66+
while(true) {
7567
int nlines = read_header();
7668
if(nlines == -1)
7769
break;

0 commit comments

Comments
 (0)