-
Notifications
You must be signed in to change notification settings - Fork 2
/
final_project_initial_values.st
417 lines (408 loc) · 15.2 KB
/
final_project_initial_values.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
PROGRAM Sludge
VAR
InletValveStatus AT %IX12 : BOOL := 1;
OverflowSensor AT %IX13 : BOOL := 0;
PumpStatus AT %IX14 : BOOL := 1;
DisinfectantStatus AT %IX17 : BOOL := 1;
GasHighVolumeAlert AT %IX25 : BOOL := 1;
InletControl AT %QX1 : BOOL := 0;
OutletControl AT %QX2 : BOOL := 0;
SludgeOutPump AT %QX5 : BOOL := 0;
ActivatePumpAdjust AT %QX6 : BOOL := 0;
OverflowValveOpen AT %QX13 : BOOL := 0;
SolidWasteAlarm AT %QX15 : BOOL := 0;
FiltrationControl AT %QX16 : BOOL := 1;
ThickeningPump AT %QX20 : BOOL := 0;
DigesterPump AT %QX22 : BOOL := 0;
HotWaterPumpIn AT %QX23 : BOOL := 0;
HotWaterPumpOut AT %QX24 : BOOL := 0;
GasPumpToTransport AT %QX25 : BOOL := 1;
pHValid AT %QX26 : BOOL := 1;
UVLowerStrength AT %QX27 : BOOL := 0;
UVIncreaseStrength AT %QX28 : BOOL := 0;
InflowSensor AT %MW1 : INT := 10000;
DissolvedO2 AT %MW3 : INT := 9800;
pHSensor AT %MW4 : INT := 6;
TurbiditySensor AT %MW5 : INT := 1;
TSSSensor AT %MW7 : INT := 1;
O2Demand AT %MW8 : INT := 6;
UVPower AT %MW9 : INT := 8000;
SludgePumpVolume AT %MW35 : INT := 60;
TurbidityThreshold AT %MW36 : INT := 60;
pHUpper AT %MW37 : INT := 8;
pHLower AT %MW38 : INT := 6;
TSSThreshold AT %MW39 : INT := 275;
UVUpper AT %MW40 : INT := 10500;
UVLower AT %MW41 : INT := 9999;
Const5 AT %MW42 : INT := 5;
Const500 AT %MW43 : INT := 500;
Const10000 AT %MW44 : INT := 10000;
END_VAR
VAR
_TMP_GT8_OUT : BOOL;
_TMP_GT21_OUT : BOOL;
_TMP_GE27_OUT : BOOL;
_TMP_GT33_OUT : BOOL;
_TMP_GT15_OUT : BOOL;
_TMP_LT46_OUT : BOOL;
_TMP_LT38_OUT : BOOL;
_TMP_AND44_OUT : BOOL;
_TMP_LT40_OUT : BOOL;
_TMP_GT56_OUT : BOOL;
_TMP_AND57_OUT : BOOL;
_TMP_LT50_OUT : BOOL;
_TMP_GT65_OUT : BOOL;
_TMP_AND52_OUT : BOOL;
_TMP_LT62_OUT : BOOL;
_TMP_GT72_OUT : BOOL;
_TMP_SUB39_OUT : INT;
_TMP_LE77_OUT : BOOL;
END_VAR
ThickeningPump := OverflowSensor;
DigesterPump := OverflowSensor AND SolidWasteAlarm;
_TMP_GT8_OUT := GT(DissolvedO2, O2Demand);
HotWaterPumpOut := _TMP_GT8_OUT;
_TMP_GT21_OUT := GT(O2Demand, DissolvedO2);
HotWaterPumpIn := _TMP_GT21_OUT;
GasPumpToTransport := GasHighVolumeAlert;
_TMP_GE27_OUT := GE(SludgePumpVolume, Const5);
SludgeOutPump := _TMP_GE27_OUT OR NOT(OverflowSensor) AND PumpStatus;
_TMP_GT33_OUT := GT(Const10000, InflowSensor);
InletControl := _TMP_GT33_OUT;
InletValveStatus := InletControl;
_TMP_GT15_OUT := GT(InflowSensor, Const10000);
ActivatePumpAdjust := _TMP_GT15_OUT;
OverflowValveOpen := OverflowSensor;
_TMP_LT46_OUT := LT(TurbiditySensor, TurbidityThreshold);
_TMP_LT38_OUT := LT(TSSSensor, TSSThreshold);
_TMP_AND44_OUT := AND(_TMP_LT46_OUT, _TMP_LT38_OUT);
FiltrationControl := pHValid AND _TMP_AND44_OUT;
_TMP_LT40_OUT := LT(pHUpper, pHSensor);
_TMP_GT56_OUT := GT(pHSensor, pHLower);
_TMP_AND57_OUT := AND(_TMP_LT40_OUT, _TMP_GT56_OUT);
pHValid := _TMP_AND57_OUT;
PumpStatus := pHValid AND _TMP_AND44_OUT;
_TMP_LT50_OUT := LT(UVUpper, UVPower);
_TMP_GT65_OUT := GT(UVPower, UVLower);
_TMP_AND52_OUT := AND(_TMP_LT50_OUT, _TMP_GT65_OUT);
OutletControl := DisinfectantStatus AND _TMP_AND52_OUT;
_TMP_LT62_OUT := LT(UVLower, UVPower);
UVIncreaseStrength := _TMP_LT62_OUT;
_TMP_GT72_OUT := GT(UVPower, UVUpper);
UVLowerStrength := _TMP_GT72_OUT;
DisinfectantStatus := _TMP_LT62_OUT;
_TMP_SUB39_OUT := SUB(InflowSensor, Const10000);
_TMP_LE77_OUT := LE(_TMP_SUB39_OUT, Const500);
InletControl := _TMP_LE77_OUT;
END_PROGRAM
PROGRAM influent
VAR
InfluentWaterFlow AT %IX0.1 : INT;
EffluentWaterFlow AT %IX0.2 : INT;
AirFlow AT %IX0.3 : INT;
PretreatmentUnitFlow AT %IX0.4 : INT;
ClarifierWaterDepth AT %IX0.5 : INT := 4;
ClarifierWaterTemp AT %IX0.6 : INT;
AerobicSurface AT %IX0.7 : INT;
AerobicReactorAirflow AT %IX0.8 : LINT;
AerobicWaterLevel AT %IX0.9 : INT;
TSS AT %IX0.11 : INT;
SandContainerFlow AT %IX0.18 : INT;
SandWaterLevelHigh AT %IX0.19 : BOOL := 0;
SecondaryClarifierWaterDepth AT %IX0.20 : INT := 0;
BOD5 AT %IX0.21 : INT := 0;
AirBlower AT %QX0.3 : BOOL;
FerrousChemicalDeploy AT %QX0.4 : BOOL;
PretreatInletControlStatus AT %QX1.1 : BOOL;
PretreatOutletControlStatus AT %QX1.2 : BOOL;
ScreeningContainerEffluentValve AT %QX1.3 : BOOL;
SandContainerEffluentValve AT %QX1.4 : BOOL;
ScreeningContSludgeEffluentValve AT %QX1.5 : BOOL;
ClarifierOutletValve AT %QX1.6 : BOOL;
SecondaryClarifierOutletValve AT %QX1.7 : BOOL;
SecondaryClarifierSludgeValve AT %QX1.8 : BOOL;
AirMinFlow AT %MW1.1 : LINT := 49923;
AirMaxFlow AT %MW1.2 : LINT := 186302;
TempMin AT %MW1.3 : INT := 17;
TempMax AT %MW1.4 : INT := 30;
DesignFlow AT %MW1.5 : INT := 10000;
DryWeatherFlow AT %MW1.6 : INT := 27702;
TSSThreshold AT %MW1.7 : INT := 275;
BOD5Threshold AT %MW1.8 : INT := 313;
InfluentFlowValveStatus AT %MW1.9 : BOOL := 0;
ClarifierWaterDepthThreshold AT %MW1.10 : INT := 4;
ClarifierSurface AT %MW1.11 : INT := 144;
SecondClarifierDepthThresh AT %MW1.12 : INT := 4;
END_VAR
VAR
_TMP_LE7_OUT : BOOL;
_TMP_GT15_OUT : BOOL;
_TMP_LT17_OUT : BOOL;
_TMP_GT21_OUT : BOOL;
_TMP_GT27_OUT : BOOL;
_TMP_GT12_OUT : BOOL;
_TMP_GT4_OUT : BOOL;
END_VAR
_TMP_LE7_OUT := LE(InfluentWaterFlow, DryWeatherFlow);
PretreatInletControlStatus := _TMP_LE7_OUT;
SandContainerEffluentValve := SandWaterLevelHigh;
ScreeningContainerEffluentValve := SandWaterLevelHigh;
_TMP_GT15_OUT := GT(ClarifierWaterDepth, ClarifierWaterDepthThreshold);
ClarifierOutletValve := _TMP_GT15_OUT;
_TMP_LT17_OUT := LT(AerobicReactorAirflow, AirMinFlow);
AirBlower := _TMP_LT17_OUT;
_TMP_GT21_OUT := GT(AerobicReactorAirflow, AirMaxFlow);
AirBlower := NOT(_TMP_GT21_OUT);
_TMP_GT27_OUT := GT(TSS, TSSThreshold);
_TMP_GT12_OUT := GT(BOD5, BOD5Threshold);
FerrousChemicalDeploy := _TMP_GT12_OUT OR _TMP_GT27_OUT;
_TMP_GT4_OUT := GT(SecondaryClarifierWaterDepth, SecondClarifierDepthThresh);
SecondaryClarifierSludgeValve := _TMP_GT4_OUT;
SecondaryClarifierOutletValve := _TMP_GT4_OUT;
END_PROGRAM
PROGRAM Humus
VAR
FilterPresureSwitchHigh AT %IX0.15 : INT;
FilterPressureSwitchLow AT %IX0.16 : INT;
RoughingTricklingFilterVolume AT %MW0.0 : INT := 1063;
RoughingCircularHumusTank AT %MW0.1 : INT := 144;
Const144 AT %MW0.2 : INT := 144;
Const1063 AT %MW0.3 : INT := 1063;
SludgePumpControl AT %QX0.5 : BOOL;
MixerControl AT %QX0.6 : BOOL;
FilterFlowControlvalve AT %QX0.8 : BOOL;
FilterationControl AT %QX0.16 : BOOL;
END_VAR
VAR
_TMP_GT3_OUT : BOOL;
_TMP_LT7_OUT : BOOL;
_TMP_GE14_OUT : BOOL;
_TMP_GE21_OUT : BOOL;
END_VAR
_TMP_GT3_OUT := GT(FilterPresureSwitchHigh, Const144);
FilterationControl := _TMP_GT3_OUT;
_TMP_LT7_OUT := LT(FilterPressureSwitchLow, Const144);
FilterationControl := _TMP_LT7_OUT;
_TMP_GE14_OUT := GE(RoughingTricklingFilterVolume, Const1063);
FilterFlowControlvalve := _TMP_GE14_OUT;
FilterFlowControlvalve := MixerControl;
_TMP_GE21_OUT := GE(RoughingCircularHumusTank, Const144);
SludgePumpControl := _TMP_GE21_OUT;
END_PROGRAM
CONFIGURATION Config0
RESOURCE Res0 ON PLC
TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
PROGRAM instance0 WITH task0 : Sludge;
END_RESOURCE
END_CONFIGURATION
(*DBG:char md5[] = "d3db68d7e7992e0c267ab3d7c063079b";*)
(*DBG:/**)
(*DBG: * This file is part of OpenPLC Runtime*)
(*DBG: **)
(*DBG: * Copyright (C) 2023 Autonomy, GP Orcullo*)
(*DBG: * Based on the work by GP Orcullo on Beremiz for uC*)
(*DBG: **)
(*DBG: * This program is free software; you can redistribute it and/or*)
(*DBG: * modify it under the terms of the GNU General Public License*)
(*DBG: * as published by the Free Software Foundation; either version 2*)
(*DBG: * of the License, or (at your option) any later version.*)
(*DBG: **)
(*DBG: * This program is distributed in the hope that it will be useful,*)
(*DBG: * but WITHOUT ANY WARRANTY; without even the implied warranty of*)
(*DBG: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the*)
(*DBG: * GNU General Public License for more details.*)
(*DBG: **)
(*DBG: * You should have received a copy of the GNU General Public License*)
(*DBG: * along with this program; If not, see <http://www.gnu.org/licenses/>.*)
(*DBG: **)
(*DBG: */*)
(*DBG:*)
(*DBG:#include <stdbool.h>*)
(*DBG:*)
(*DBG:#include "iec_types_all.h"*)
(*DBG:#include "POUS.h"*)
(*DBG:*)
(*DBG:#define SAME_ENDIANNESS 0*)
(*DBG:#define REVERSE_ENDIANNESS 1*)
(*DBG:*)
(*DBG:uint8_t endianness;*)
(*DBG:*)
(*DBG:*)
(*DBG:extern SLUDGE RES0__INSTANCE0;*)
(*DBG:*)
(*DBG:static const struct {*)
(*DBG: void *ptr;*)
(*DBG: __IEC_types_enum type;*)
(*DBG:} debug_vars[] = {*)
(*DBG: {&(RES0__INSTANCE0.INLETVALVESTATUS), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.OVERFLOWSENSOR), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.PUMPSTATUS), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.DISINFECTANTSTATUS), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.GASHIGHVOLUMEALERT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.INLETCONTROL), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.OUTLETCONTROL), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.SLUDGEOUTPUMP), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.ACTIVATEPUMPADJUST), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.OVERFLOWVALVEOPEN), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.SOLIDWASTEALARM), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.FILTRATIONCONTROL), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.THICKENINGPUMP), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.DIGESTERPUMP), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.HOTWATERPUMPIN), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.HOTWATERPUMPOUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.GASPUMPTOTRANSPORT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.PHVALID), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.UVLOWERSTRENGTH), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.UVINCREASESTRENGTH), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.INFLOWSENSOR), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.DISSOLVEDO2), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.PHSENSOR), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.TURBIDITYSENSOR), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.TSSSENSOR), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.O2DEMAND), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.UVPOWER), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.SLUDGEPUMPVOLUME), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.TURBIDITYTHRESHOLD), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.PHUPPER), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.PHLOWER), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.TSSTHRESHOLD), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.UVUPPER), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.UVLOWER), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.CONST5), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.CONST500), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0.CONST10000), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_GT8_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_GT21_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_GE27_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_GT33_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_GT15_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_LT46_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_LT38_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_AND44_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_LT40_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_GT56_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_AND57_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_LT50_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_GT65_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_AND52_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_LT62_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_GT72_OUT), BOOL_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_SUB39_OUT), INT_ENUM},*)
(*DBG: {&(RES0__INSTANCE0._TMP_LE77_OUT), BOOL_ENUM},*)
(*DBG:};*)
(*DBG:*)
(*DBG:#define VAR_COUNT 55*)
(*DBG:*)
(*DBG:uint16_t get_var_count(void)*)
(*DBG:{*)
(*DBG: return VAR_COUNT;*)
(*DBG:}*)
(*DBG:*)
(*DBG:size_t get_var_size(size_t idx)*)
(*DBG:{*)
(*DBG: if (idx >= VAR_COUNT)*)
(*DBG: {*)
(*DBG: return 0;*)
(*DBG: }*)
(*DBG: switch (debug_vars[idx].type) {*)
(*DBG: case INT_ENUM:*)
(*DBG: return sizeof(INT);*)
(*DBG: case BOOL_ENUM:*)
(*DBG: return sizeof(BOOL);*)
(*DBG: default:*)
(*DBG: return 0;*)
(*DBG: }*)
(*DBG:}*)
(*DBG:*)
(*DBG:void *get_var_addr(size_t idx)*)
(*DBG:{*)
(*DBG: void *ptr = debug_vars[idx].ptr;*)
(*DBG:*)
(*DBG: switch (debug_vars[idx].type) {*)
(*DBG: case INT_ENUM:*)
(*DBG: return (void *)&((__IEC_INT_t *) ptr)->value;*)
(*DBG: case BOOL_ENUM:*)
(*DBG: return (void *)&((__IEC_BOOL_t *) ptr)->value;*)
(*DBG: default:*)
(*DBG: return 0;*)
(*DBG: }*)
(*DBG:}*)
(*DBG:*)
(*DBG:void force_var(size_t idx, bool forced, void *val)*)
(*DBG:{*)
(*DBG: void *ptr = debug_vars[idx].ptr;*)
(*DBG:*)
(*DBG: if (forced) {*)
(*DBG: size_t var_size = get_var_size(idx);*)
(*DBG: switch (debug_vars[idx].type) {*)
(*DBG: case INT_ENUM: {*)
(*DBG: memcpy(&((__IEC_INT_t *) ptr)->value, val, var_size);*)
(*DBG: //((__IEC_INT_t *) ptr)->value = *((INT *) val);*)
(*DBG: ((__IEC_INT_t *) ptr)->flags |= __IEC_FORCE_FLAG;*)
(*DBG: break;*)
(*DBG: }*)
(*DBG: case BOOL_ENUM: {*)
(*DBG: memcpy(&((__IEC_BOOL_t *) ptr)->value, val, var_size);*)
(*DBG: //((__IEC_BOOL_t *) ptr)->value = *((BOOL *) val);*)
(*DBG: ((__IEC_BOOL_t *) ptr)->flags |= __IEC_FORCE_FLAG;*)
(*DBG: break;*)
(*DBG: }*)
(*DBG: default:*)
(*DBG: break;*)
(*DBG: }*)
(*DBG: } else {*)
(*DBG: switch (debug_vars[idx].type) {*)
(*DBG: case INT_ENUM:*)
(*DBG: ((__IEC_INT_t *) ptr)->flags &= ~__IEC_FORCE_FLAG;*)
(*DBG: break;*)
(*DBG: case BOOL_ENUM:*)
(*DBG: ((__IEC_BOOL_t *) ptr)->flags &= ~__IEC_FORCE_FLAG;*)
(*DBG: break;*)
(*DBG: default:*)
(*DBG: break;*)
(*DBG: }*)
(*DBG: }*)
(*DBG:}*)
(*DBG:*)
(*DBG:void swap_bytes(void *ptr, size_t size) *)
(*DBG:{*)
(*DBG: uint8_t *bytePtr = (uint8_t *)ptr;*)
(*DBG: size_t i;*)
(*DBG: for (i = 0; i < size / 2; ++i) *)
(*DBG: {*)
(*DBG: uint8_t temp = bytePtr[i];*)
(*DBG: bytePtr[i] = bytePtr[size - 1 - i];*)
(*DBG: bytePtr[size - 1 - i] = temp;*)
(*DBG: }*)
(*DBG:}*)
(*DBG:*)
(*DBG:void trace_reset(void)*)
(*DBG:{*)
(*DBG: for (size_t i=0; i < VAR_COUNT; i++) *)
(*DBG: {*)
(*DBG: force_var(i, false, 0);*)
(*DBG: }*)
(*DBG:}*)
(*DBG:*)
(*DBG:void set_trace(size_t idx, bool forced, void *val)*)
(*DBG:{*)
(*DBG: if (idx >= 0 && idx < VAR_COUNT) *)
(*DBG: {*)
(*DBG: if (endianness == REVERSE_ENDIANNESS)*)
(*DBG: {*)
(*DBG: // Aaaaarghhhh... Stupid AVR is Big Endian.*)
(*DBG: swap_bytes(val, get_var_size(idx));*)
(*DBG: }*)
(*DBG:*)
(*DBG: force_var(idx, forced, val);*)
(*DBG: }*)
(*DBG:}*)
(*DBG:*)
(*DBG:void set_endianness(uint8_t value)*)
(*DBG:{*)
(*DBG: if (value == SAME_ENDIANNESS || value == REVERSE_ENDIANNESS)*)
(*DBG: {*)
(*DBG: endianness = value;*)
(*DBG: }*)
(*DBG:}*)
(*DBG:*)