GCC Code Coverage Report


Directory: ./
File: unit_tests/logicdata.cpp
Date: 2025-10-24 14:26:41
Coverage Exec Excl Total
Lines: 99.1% 327 0 330
Functions: 100.0% 20 0 20
Branches: 97.2% 137 0 141
Decisions: 97.6% 80 - 82

Line Branch Decision Exec Source
1 /*
2 * @file logicdata.cpp
3 *
4 * Based on LogicdataStreamFile.java by andreika
5 *
6 * Created on: Jul 19, 2020
7 * @author Andrey Belomutskiy, (c) 2012-2020
8 */
9
10 #include "logicdata.h"
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <cstdint>
14 #include <string.h>
15
16 #define frequency 1000000
17 #define frequencyDiv 10
18 #define magic 0x7f
19
20 #define BLOCK 0x15
21 #define CHANNEL_BLOCK 0x16
22 #define SUB 0x54
23
24 #define title "Data save2"
25
26 #define FLAG_NOTEMPTY 2
27 #define FLAG_NOTEMPTY_LONG 3
28 #define FLAG_EMPTY 5
29
30 #define LOGIC4 0x40FD
31 #define LOGIC8 0x673B
32
33 #define SIGN_FLAG 0x80000000L
34
35 // todo: numChannels 7 or numChannels 8 does not work? :(
36 #define numChannels 6
37 #define reservedDurationInSamples 10
38
39 static const char *channelNames[] = { "Primary", "Secondary", "TDC",
40 "Sync", "Coil", "Injector", "Channel 6", "Channel 7" };
41
42 static int CHANNEL_FLAGS[] = { 0x13458b, 0x0000ff, 0x00a0f9, 0x00ffff, 0x00ff00,
43 0xff0000, 0xf020a0, };
44
45 static FILE *ptr;
46
47 static uint32_t realDurationInSamples;
48 static uint32_t scaledDurationInSamples;
49
50 440966 static void writeByte(uint8_t value) {
51 440966 fwrite(&value, 1, sizeof(value), ptr);
52 440966 }
53
54 28222 static void writeAs(int64_t value, int numBytes) {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28222 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 28222 times.
28222 if (value == 0) {
56 writeByte(0);
57 } else {
58 28222 writeByte(numBytes);
59
2/2
✓ Branch 0 taken 40558 times.
✓ Branch 1 taken 28222 times.
2/2
✓ Decision 'true' taken 40558 times.
✓ Decision 'false' taken 28222 times.
68780 for (int i = 0; i < numBytes; i++) {
60 40558 writeByte((uint8_t) ((value >> (i * 8)) & 0xff));
61 }
62 }
63 28222 }
64
65 // This is the main secret of this format! :)
66 69072 static void write(int64_t value) {
67
3/4
✓ Branch 0 taken 68923 times.
✓ Branch 1 taken 149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68923 times.
2/2
✓ Decision 'true' taken 149 times.
✓ Decision 'false' taken 68923 times.
69072 if (value < 0 || value > 0xFFFFFFFFL) {
68 149 writeAs(value, 8);
69
2/2
✓ Branch 0 taken 40850 times.
✓ Branch 1 taken 28073 times.
2/2
✓ Decision 'true' taken 40850 times.
✓ Decision 'false' taken 28073 times.
68923 } else if (value == 0) {
70 40850 writeByte(0);
71
2/2
✓ Branch 0 taken 21807 times.
✓ Branch 1 taken 6266 times.
2/2
✓ Decision 'true' taken 21807 times.
✓ Decision 'false' taken 6266 times.
28073 } else if (value <= 0xff) {
72 21807 writeAs(value, 1);
73
2/2
✓ Branch 0 taken 3282 times.
✓ Branch 1 taken 2984 times.
2/2
✓ Decision 'true' taken 3282 times.
✓ Decision 'false' taken 2984 times.
6266 } else if (value <= 0xffff) {
74 3282 writeAs(value, 2);
75
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 2043 times.
2/2
✓ Decision 'true' taken 941 times.
✓ Decision 'false' taken 2043 times.
2984 } else if (value <= 0xffffff) {
76 941 writeAs(value, 3);
77 } else {
78 2043 writeAs(value, 4);
79 }
80 69072 }
81
82 1120 static void writeString(const char *value) {
83 1120 int len = strlen(value);
84 1120 write(len);
85
2/2
✓ Branch 0 taken 7504 times.
✓ Branch 1 taken 1120 times.
2/2
✓ Decision 'true' taken 7504 times.
✓ Decision 'false' taken 1120 times.
8624 for (int i = 0; i < len; i++) {
86 7504 writeByte(value[i]);
87 }
88 1120 }
89
90 // todo: some C++ magic would allow us to drop 'count' parameter
91 // todo: Look at efi::size in util
92 448 static void write(int values[], int count) {
93
2/2
✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 448 times.
2/2
✓ Decision 'true' taken 2016 times.
✓ Decision 'false' taken 448 times.
2464 for (int i = 0; i < count; i++) {
94 2016 write(values[i]);
95 }
96 448 }
97
98 5712 static void write(int value, int num) {
99
2/2
✓ Branch 0 taken 31569 times.
✓ Branch 1 taken 5712 times.
2/2
✓ Decision 'true' taken 31569 times.
✓ Decision 'false' taken 5712 times.
37281 for (int i = 0; i < num; i++)
100 31569 write(value);
101 5712 }
102
103 3136 static void writeId(int i1, int i2) {
104 3136 write((numChannels == 4) ? LOGIC4 : LOGIC8);
105 3136 write(i1);
106 3136 write(i2);
107 3136 }
108
109 112 static void writeHeader() {
110 112 writeByte(magic);
111 112 write(strlen(title));
112 112 writeString(title);
113
114 112 write(BLOCK);
115 112 write(SUB);
116 112 write(frequency);
117 112 write(0);
118 112 write(reservedDurationInSamples);
119 112 write(frequency / frequencyDiv);
120 112 write(0, 2);
121 112 write(numChannels);
122
123 112 write(BLOCK);
124 112 write(0);
125
126 112 write(BLOCK);
127
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 112 times.
2/2
✓ Decision 'true' taken 672 times.
✓ Decision 'false' taken 112 times.
784 for (int i = 0; i < numChannels; i++) {
128 672 writeId(i, 1);
129 }
130 112 write(0);
131
132 112 write(BLOCK);
133
134 112 writeId(0, 0);
135 112 write(0);
136 112 write(0);
137
138 112 }
139
140 2128 static void writeDouble(double value) {
141 static_assert(sizeof(double) == 8);
142
143
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 784 times.
2/2
✓ Decision 'true' taken 1344 times.
✓ Decision 'false' taken 784 times.
2128 if (value == 0.0) {
144 1344 writeByte(0);
145 } else {
146 784 writeByte(8);
147 784 char *ptr = (char*) (void*) &value;
148
149
2/2
✓ Branch 0 taken 6272 times.
✓ Branch 1 taken 784 times.
2/2
✓ Decision 'true' taken 6272 times.
✓ Decision 'false' taken 784 times.
7056 for (int i = 0; i < 8; i++) {
150 6272 writeByte(ptr[i]);
151 }
152 }
153 2128 }
154
155 672 static void writeChannelHeader(int ch) {
156 672 write(0xff);
157 672 write(ch);
158 672 writeString(channelNames[ch]);
159 672 write(0, 2);
160 672 writeDouble(1.0);
161 672 write(0);
162 672 writeDouble(0.0);
163 672 write(1); // or 2
164 672 writeDouble(0.0); // or 1.0
165
166 // this part sounds like the 'next' pointer?
167
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 560 times.
2/2
✓ Decision 'true' taken 112 times.
✓ Decision 'false' taken 560 times.
672 if (ch == numChannels - 1) {
168 112 write(0);
169 } else {
170 560 writeId(1 + ch, 1);
171
2/2
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 560 times.
2/2
✓ Decision 'true' taken 1680 times.
✓ Decision 'false' taken 560 times.
2240 for (int i = 0; i < 3; i++) {
172 1680 write((CHANNEL_FLAGS[ch] >> (i * 8)) & 0xff);
173 }
174 }
175 672 }
176
177 672 static void writeEdges(int64_t *chDeltas, bool useLongDeltas, int numEdges) {
178
2/2
✓ Branch 0 taken 77247 times.
✓ Branch 1 taken 672 times.
2/2
✓ Decision 'true' taken 77247 times.
✓ Decision 'false' taken 672 times.
77919 for (int i = 0; i < numEdges; i++) {
179 77247 uint64_t d = chDeltas[i];
180
181 // set 16-bit 'sign' flag
182
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 77237 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 5 times.
2/2
✓ Decision 'true' taken 5 times.
✓ Decision 'false' taken 77242 times.
77247 if (!useLongDeltas && (d & SIGN_FLAG) == SIGN_FLAG)
183 5 d = (d & 0x7fff) | (SIGN_FLAG >> 16);
184 77247 writeByte((uint8_t) (d & 0xff));
185 77247 writeByte((uint8_t) ((d >> 8) & 0xff));
186
2/2
✓ Branch 0 taken 77237 times.
✓ Branch 1 taken 10 times.
2/2
✓ Decision 'true' taken 77237 times.
✓ Decision 'false' taken 10 times.
77247 if (useLongDeltas) {
187 77237 writeByte((uint8_t) ((d >> 16) & 0xff));
188 77237 writeByte((uint8_t) ((d >> 24) & 0xff));
189 }
190 }
191 672 writeByte(0x00);
192 672 }
193
194 1065 static void writeRaw(int value, int num) {
195
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 1065 times.
2/2
✓ Decision 'true' taken 5680 times.
✓ Decision 'false' taken 1065 times.
6745 for (int i = 0; i < num; i++) {
196 5680 writeByte(value);
197 }
198 1065 }
199
200 672 static void writeChannelData(int ch, int64_t *chDeltas, int chLastState,
201 int lastRecord, bool useLongDeltas, int numEdges) {
202
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 355 times.
2/2
✓ Decision 'true' taken 317 times.
✓ Decision 'false' taken 355 times.
672 if (numEdges == 0)
203 317 lastRecord = 0;
204 672 write(CHANNEL_BLOCK);
205 // channel#0 is somehow special...
206
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 560 times.
2/2
✓ Decision 'true' taken 112 times.
✓ Decision 'false' taken 560 times.
672 if (ch == 0) {
207 112 write(SUB);
208 112 write(BLOCK);
209 }
210
211 672 write(ch + 1);
212 672 write(0);
213 672 write(realDurationInSamples);
214 672 write(1);
215 672 write(lastRecord);
216
217 672 uint32_t numSamplesLeft = realDurationInSamples - lastRecord;
218 672 write(numSamplesLeft);
219
220 672 write(chLastState);
221
222 672 int chFlag =
223
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 317 times.
1027 (numEdges == 0) ?
224 FLAG_EMPTY :
225
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 2 times.
355 (useLongDeltas ? FLAG_NOTEMPTY_LONG : FLAG_NOTEMPTY);
226 672 write(chFlag);
227
228
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 560 times.
2/2
✓ Decision 'true' taken 112 times.
✓ Decision 'false' taken 560 times.
672 if (ch == 0) {
229 112 write(0);
230 112 write(BLOCK);
231 112 write(0, 11);
232
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 2 times.
2/2
✓ Decision 'true' taken 110 times.
✓ Decision 'false' taken 2 times.
112 if (useLongDeltas) {
233 110 write(BLOCK);
234 110 write(0, 6);
235 }
236 112 write(BLOCK);
237 } else {
238 560 write(0, 10);
239
2/2
✓ Branch 0 taken 553 times.
✓ Branch 1 taken 7 times.
2/2
✓ Decision 'true' taken 553 times.
✓ Decision 'false' taken 7 times.
560 if (useLongDeltas) {
240 553 write(0, 5);
241 }
242 }
243
244 672 write(numEdges);
245 672 write(0);
246 672 write(numEdges);
247 672 write(0);
248 672 write(numEdges);
249
250 672 writeEdges(chDeltas, useLongDeltas, numEdges);
251
252
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 560 times.
2/2
✓ Decision 'true' taken 112 times.
✓ Decision 'false' taken 560 times.
672 if (ch == 0) {
253 112 write(BLOCK);
254 112 write(0, 6);
255
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 110 times.
2/2
✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 110 times.
112 if (!useLongDeltas) {
256 2 write(BLOCK);
257 2 write(0, 6);
258 }
259 112 write(BLOCK);
260 } else {
261 560 write(0, 4);
262
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 553 times.
2/2
✓ Decision 'true' taken 7 times.
✓ Decision 'false' taken 553 times.
560 if (!useLongDeltas) {
263 7 write(0, 5);
264 }
265 }
266
267
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 355 times.
2/2
✓ Decision 'true' taken 317 times.
✓ Decision 'false' taken 355 times.
672 if (numEdges == 0) {
268 317 write(0, 5);
269 317 return;
270 }
271
272 355 write(1);
273 355 write(0);
274 355 write(1);
275 355 write(0);
276 355 write(1);
277 355 write(0, 16);
278
279 355 writeRaw(0xFF, 8);
280 355 writeRaw(chFlag, 1);
281 355 writeRaw(0x00, 7);
282 }
283
284 112 static void writeChannelDataHeader() {
285
1/1
✓ Branch 1 taken 112 times.
112 write(BLOCK);
286
1/1
✓ Branch 1 taken 112 times.
112 write(scaledDurationInSamples);
287
1/1
✓ Branch 1 taken 112 times.
112 write(0, 5);
288
1/1
✓ Branch 1 taken 112 times.
112 write(numChannels);
289
1/1
✓ Branch 1 taken 112 times.
112 write(0, 3);
290
1/1
✓ Branch 1 taken 112 times.
112 writeId(0, 1);
291
1/1
✓ Branch 1 taken 112 times.
112 write(0);
292
293
1/1
✓ Branch 1 taken 112 times.
112 write(BLOCK);
294
1/1
✓ Branch 1 taken 112 times.
112 write(0, 3);
295
296
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 112 times.
2/2
✓ Decision 'true' taken 672 times.
✓ Decision 'false' taken 112 times.
784 for (int i = 0; i < numChannels; i++) {
297
1/1
✓ Branch 1 taken 672 times.
672 writeChannelHeader(i);
298 }
299
300
1/1
✓ Branch 1 taken 112 times.
112 write(BLOCK);
301 112 int SUB_ARRAY[] = { SUB, SUB, 0, SUB, 0, SUB };
302
1/1
✓ Branch 1 taken 112 times.
112 write(SUB_ARRAY, 6);
303
1/1
✓ Branch 1 taken 112 times.
112 write(0, 6);
304
305
1/1
✓ Branch 1 taken 112 times.
112 write(BLOCK);
306
1/1
✓ Branch 1 taken 112 times.
112 write(0, 2);
307
1/1
✓ Branch 1 taken 112 times.
112 write(realDurationInSamples);
308
1/1
✓ Branch 1 taken 112 times.
112 write(0);
309
1/1
✓ Branch 1 taken 112 times.
112 write(SUB);
310
1/1
✓ Branch 1 taken 112 times.
112 write(reservedDurationInSamples);
311
1/1
✓ Branch 1 taken 112 times.
112 write(frequency / frequencyDiv);
312
1/1
✓ Branch 1 taken 112 times.
112 write(0, 2);
313
1/1
✓ Branch 1 taken 112 times.
112 write(SUB);
314
1/1
✓ Branch 1 taken 112 times.
112 write(0, 2);
315
1/1
✓ Branch 1 taken 112 times.
112 write(1);
316
1/1
✓ Branch 1 taken 112 times.
112 write(0, 3);
317
1/1
✓ Branch 1 taken 112 times.
112 writeId(0, 0);
318
319
1/1
✓ Branch 1 taken 112 times.
112 write(BLOCK);
320 112 int SAM_ARRAY[] = { (int)realDurationInSamples, (int)realDurationInSamples,
321 112 (int)realDurationInSamples };
322
1/1
✓ Branch 1 taken 112 times.
112 write(SAM_ARRAY, 3);
323
1/1
✓ Branch 1 taken 112 times.
112 write(0);
324
1/1
✓ Branch 1 taken 112 times.
112 write(SUB);
325
1/1
✓ Branch 1 taken 112 times.
112 write(0);
326
327
1/1
✓ Branch 1 taken 112 times.
112 write(BLOCK);
328
1/1
✓ Branch 1 taken 112 times.
112 write(0);
329
330
1/1
✓ Branch 1 taken 112 times.
112 write(BLOCK);
331
1/1
✓ Branch 1 taken 112 times.
112 write(SUB, 4);
332
1/1
✓ Branch 1 taken 112 times.
112 write(0);
333
334
1/1
✓ Branch 1 taken 112 times.
112 write(BLOCK);
335
1/1
✓ Branch 1 taken 112 times.
112 write(frequency);
336
1/1
✓ Branch 1 taken 112 times.
112 write(0, 3);
337
1/1
✓ Branch 1 taken 112 times.
112 write(1);
338
1/1
✓ Branch 1 taken 112 times.
112 write(0, 3);
339
1/1
✓ Branch 1 taken 112 times.
112 writeId(0, 0);
340 112 int ARR_6[] = { 0, 1, 1, 0, 1, 0x13 };
341
1/1
✓ Branch 1 taken 112 times.
112 write(ARR_6, 6);
342
1/1
✓ Branch 1 taken 112 times.
112 write(SUB);
343
344
1/1
✓ Branch 1 taken 112 times.
112 write(BLOCK);
345
1/1
✓ Branch 1 taken 112 times.
112 write(0);
346
1/1
✓ Branch 1 taken 112 times.
112 write(realDurationInSamples);
347
1/1
✓ Branch 1 taken 112 times.
112 write(0, 2);
348
1/1
✓ Branch 1 taken 112 times.
112 write(numChannels);
349 112 int ARR_3[] = { 1, 0, 1 };
350
1/1
✓ Branch 1 taken 112 times.
112 write(ARR_3, 3);
351 112 }
352
353 112 static void writeTimingMarker() {
354 112 write(BLOCK);
355 112 write(numChannels + 2);
356 112 write(0, 4);
357 112 writeString("Timing Marker Pair");
358 112 writeString("A1");
359 112 writeString("A2");
360 112 write(0, 2);
361 112 write(SUB);
362 112 write(0, 9);
363 112 }
364
365 112 static void writeChannelDataFooter() {
366 112 write(0, 3);
367 112 write(1);
368 112 write(1);
369 112 write(0);
370 112 write(numChannels);
371 112 }
372
373 996816 int getChannelState(int ch, const CompositeEvent* event) {
374
6/7
✓ Branch 0 taken 166136 times.
✓ Branch 1 taken 166136 times.
✓ Branch 2 taken 166136 times.
✓ Branch 3 taken 166136 times.
✓ Branch 4 taken 166136 times.
✓ Branch 5 taken 166136 times.
✗ Branch 6 not taken.
996816 switch (ch) {
375
1/1
✓ Decision 'true' taken 166136 times.
166136 case 0:
376 166136 return event->primaryTrigger;
377
1/1
✓ Decision 'true' taken 166136 times.
166136 case 1:
378 166136 return event->secondaryTrigger;
379
1/1
✓ Decision 'true' taken 166136 times.
166136 case 2:
380 166136 return event->isTDC;
381
1/1
✓ Decision 'true' taken 166136 times.
166136 case 3:
382 166136 return event->sync;
383
1/1
✓ Decision 'true' taken 166136 times.
166136 case 4:
384 166136 return event->coil;
385
1/1
✓ Decision 'true' taken 166136 times.
166136 case 5:
386 166136 return event->injector;
387 }
388 return -1;
389 }
390
391 112 static void writeEvents(const std::vector<CompositeEvent>& events) {
392 112 size_t count = events.size();
393 // we need at least 2 records
394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 112 times.
112 if (count < 2)
395 return;
396 112 uint32_t firstRecordTs = events[1].timestamp;
397 112 uint32_t lastRecordTs = events[count - 1].timestamp;
398 // we don't know the total duration, so we create a margin after the last record which equals to the duration of the first event
399 112 realDurationInSamples = lastRecordTs + firstRecordTs;
400 112 scaledDurationInSamples = realDurationInSamples / 4;
401
402 112 writeChannelDataHeader();
403
404 112 int64_t *chDeltas = (int64_t*) malloc(sizeof(int64_t) * count);
405
406 112 bool useLongDeltas = false;
407
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 112 times.
2/2
✓ Decision 'true' taken 672 times.
✓ Decision 'false' taken 112 times.
784 for (int ch = 0; ch < numChannels; ch++) {
408 672 int chPrevState = -1;
409 672 uint32_t prevTs = 0;
410 672 int deltaCount = 0;
411
412
2/2
✓ Branch 0 taken 498408 times.
✓ Branch 1 taken 672 times.
2/2
✓ Decision 'true' taken 498408 times.
✓ Decision 'false' taken 672 times.
499080 for (size_t i = 0; i < count; i++) {
413 498408 const CompositeEvent* event = &events[i];
414
415 498408 int chState = getChannelState(ch, event);
416 498408 uint32_t ts = event->timestamp;
417
418
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 497736 times.
2/2
✓ Decision 'true' taken 672 times.
✓ Decision 'false' taken 497736 times.
498408 if (chPrevState == -1) {
419 672 chPrevState = chState;
420 }
421
2/2
✓ Branch 0 taken 77247 times.
✓ Branch 1 taken 421161 times.
2/2
✓ Decision 'true' taken 77247 times.
✓ Decision 'false' taken 421161 times.
498408 if (chState != chPrevState) {
422 77247 int64_t delta = ts - prevTs;
423
2/2
✓ Branch 0 taken 70960 times.
✓ Branch 1 taken 6287 times.
2/2
✓ Decision 'true' taken 70960 times.
✓ Decision 'false' taken 6287 times.
77247 if (delta > 0x7fff) {
424 70960 useLongDeltas = true;
425 }
426 // encode state
427
2/2
✓ Branch 0 taken 38602 times.
✓ Branch 1 taken 38645 times.
2/2
✓ Decision 'true' taken 38602 times.
✓ Decision 'false' taken 38645 times.
77247 if (chState == 0)
428 38602 delta |= SIGN_FLAG;
429
430 77247 chDeltas[deltaCount++] = delta;
431
432 77247 prevTs = ts;
433 77247 chPrevState = chState;
434 }
435 }
436 672 writeChannelData(ch, chDeltas, chPrevState, prevTs, useLongDeltas,
437 deltaCount);
438 }
439
440 112 free(chDeltas);
441
442 112 writeChannelDataFooter();
443 }
444
445 112 static void writeFooter() {
446 112 write(BLOCK);
447
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 112 times.
2/2
✓ Decision 'true' taken 672 times.
✓ Decision 'false' taken 112 times.
784 for (int i = 0; i < numChannels; i++) {
448 672 writeId(i, 1);
449 }
450 112 write(1);
451 112 writeId(numChannels, 0x15);
452
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 112 times.
2/2
✓ Decision 'true' taken 672 times.
✓ Decision 'false' taken 112 times.
784 for (int i = 0; i < numChannels; i++) {
453 672 writeId(i, 1);
454 }
455 112 write(1);
456 112 write(0);
457 112 write(frequency);
458 112 write(0, 16);
459 112 write(0x01);
460 112 write(0x23); // ???
461 112 write(SUB);
462
463 112 write(BLOCK);
464 112 write(numChannels + 1);
465 112 write(0);
466 112 write(0xFFFFFFFFFFFFFFFFL);
467 112 write(0xFFFFFFFFL);
468 112 write(1);
469 112 write(0, 3);
470
471 112 write(BLOCK);
472 112 write(0);
473
474 112 write(BLOCK);
475 112 write(0);
476 112 writeDouble(1.0);
477 112 write(SUB);
478 112 write(0, 6);
479 112 write(1);
480 112 write(0, 4);
481
482 112 write(1);
483 112 write(0x29); // ???
484 112 write(SUB);
485
486 112 writeTimingMarker();
487 112 }
488
489 112 void writeLogicDataFile(const char * fileName, const std::vector<CompositeEvent>& events) {
490
491 112 ptr = fopen(fileName, "wb");
492
493 112 writeHeader();
494 112 writeEvents(events);
495 112 writeFooter();
496
497 112 fclose(ptr);
498
499 112 }
500