comparison Discovery/Src/check_warning.c @ 273:5fe136480a47

Merged in janlmulder/ostc4/write-from-sim (pull request #20) Cleanup and debug capabilty to write logbook from simulator
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Sun, 28 Apr 2019 07:05:23 +0000
parents 74a8296a2318
children 58200d756365
comparison
equal deleted inserted replaced
267:cf6ad20380fb 273:5fe136480a47
36 #include "check_warning.h" 36 #include "check_warning.h"
37 #include "settings.h" 37 #include "settings.h"
38 #include "decom.h" 38 #include "decom.h"
39 #include "tCCR.h" 39 #include "tCCR.h"
40 40
41 /* Private variables wit access ----------------------------------------------*/ 41 /* Private variables with access ----------------------------------------------*/
42 uint8_t betterGasId = 0; 42 static uint8_t betterGasId = 0;
43 uint8_t betterSetpointId = 0; 43 static uint8_t betterSetpointId = 0;
44 int8_t fallback = 0; 44 static int8_t fallback = 0;
45 45
46 /* Private function prototypes -----------------------------------------------*/ 46 /* Private function prototypes -----------------------------------------------*/
47 int8_t check_fallback(SDiveState * pDiveState); 47 static int8_t check_fallback(SDiveState * pDiveState);
48 int8_t check_ppO2(SDiveState * pDiveState); 48 static int8_t check_ppO2(SDiveState * pDiveState);
49 int8_t check_O2_sensors(SDiveState * pDiveState); 49 static int8_t check_O2_sensors(SDiveState * pDiveState);
50 int8_t check_CNS(SDiveState * pDiveState); 50 static int8_t check_CNS(SDiveState * pDiveState);
51 int8_t check_Deco(SDiveState * pDiveState); 51 static int8_t check_Deco(SDiveState * pDiveState);
52 int8_t check_AscentRate(SDiveState * pDiveState); 52 static int8_t check_AscentRate(SDiveState * pDiveState);
53 int8_t check_aGF(SDiveState * pDiveState); 53 static int8_t check_aGF(SDiveState * pDiveState);
54 int8_t check_BetterGas(SDiveState * pDiveState); 54 static int8_t check_BetterGas(SDiveState * pDiveState);
55 int8_t check_BetterSetpoint(SDiveState * pDiveState); 55 static int8_t check_BetterSetpoint(SDiveState * pDiveState);
56 int8_t check_Battery(SDiveState * pDiveState); 56 static int8_t check_Battery(SDiveState * pDiveState);
57 57
58 int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2); 58 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2);
59 59
60 /* Exported functions --------------------------------------------------------*/ 60 /* Exported functions --------------------------------------------------------*/
61 61
62 void check_warning(void) 62 void check_warning(void)
63 { 63 {
64 SDiveState * pDiveState; 64 check_warning2(stateUsedWrite);
65
66 if(stateUsed == stateRealGetPointer())
67 pDiveState = stateRealGetPointerWrite();
68 else
69 pDiveState = stateSimGetPointerWrite();
70
71 check_warning2(pDiveState);
72 } 65 }
73 66
74 67
75 void check_warning2(SDiveState * pDiveState) 68 void check_warning2(SDiveState * pDiveState)
76 { 69 {
121 return 1; 114 return 1;
122 } 115 }
123 116
124 117
125 /* Private functions ---------------------------------------------------------*/ 118 /* Private functions ---------------------------------------------------------*/
126 int8_t check_fallback(SDiveState * pDiveState) 119 static int8_t check_fallback(SDiveState * pDiveState)
127 { 120 {
128 if(fallback && ((pDiveState->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR))) 121 if(fallback && ((pDiveState->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR)))
129 fallback = 0; 122 fallback = 0;
130 123
131 pDiveState->warnings.fallback = fallback; 124 pDiveState->warnings.fallback = fallback;
132 return pDiveState->warnings.fallback; 125 return pDiveState->warnings.fallback;
133 } 126 }
134 127
135 128
136 int8_t check_ppO2(SDiveState * pDiveState) 129 static int8_t check_ppO2(SDiveState * pDiveState)
137 { 130 {
138 if(pDiveState->mode != MODE_DIVE) 131 if(pDiveState->mode != MODE_DIVE)
139 { 132 {
140 pDiveState->warnings.ppO2Low = 0; 133 pDiveState->warnings.ppO2Low = 0;
141 pDiveState->warnings.ppO2High = 0; 134 pDiveState->warnings.ppO2High = 0;
169 162
170 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High; 163 return pDiveState->warnings.ppO2Low + pDiveState->warnings.ppO2High;
171 } 164 }
172 165
173 166
174 int8_t check_O2_sensors(SDiveState * pDiveState) 167 static int8_t check_O2_sensors(SDiveState * pDiveState)
175 { 168 {
176 pDiveState->warnings.sensorLinkLost = 0; 169 pDiveState->warnings.sensorLinkLost = 0;
177 pDiveState->warnings.sensorOutOfBounds[0] = 0; 170 pDiveState->warnings.sensorOutOfBounds[0] = 0;
178 pDiveState->warnings.sensorOutOfBounds[1] = 0; 171 pDiveState->warnings.sensorOutOfBounds[1] = 0;
179 pDiveState->warnings.sensorOutOfBounds[2] = 0; 172 pDiveState->warnings.sensorOutOfBounds[2] = 0;
191 + pDiveState->warnings.sensorOutOfBounds[1] 184 + pDiveState->warnings.sensorOutOfBounds[1]
192 + pDiveState->warnings.sensorOutOfBounds[2]; 185 + pDiveState->warnings.sensorOutOfBounds[2];
193 } 186 }
194 187
195 188
196 int8_t check_BetterGas(SDiveState * pDiveState) 189 static int8_t check_BetterGas(SDiveState * pDiveState)
197 { 190 {
198 if(stateUsed->mode != MODE_DIVE) 191 if(stateUsed->mode != MODE_DIVE)
199 { 192 {
200 pDiveState->warnings.betterGas = 0; 193 pDiveState->warnings.betterGas = 0;
201 betterGasId = 0; 194 betterGasId = 0;
274 return pDiveState->warnings.betterGas; 267 return pDiveState->warnings.betterGas;
275 } 268 }
276 269
277 /* check for better travel!!! setpoint hw 151210 270 /* check for better travel!!! setpoint hw 151210
278 */ 271 */
279 int8_t check_BetterSetpoint(SDiveState * pDiveState) 272 static int8_t check_BetterSetpoint(SDiveState * pDiveState)
280 { 273 {
281 pDiveState->warnings.betterSetpoint = 0; 274 pDiveState->warnings.betterSetpoint = 0;
282 betterSetpointId = 0; 275 betterSetpointId = 0;
283 276
284 if((stateUsed->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR) || (pDiveState->diveSettings.CCR_Mode != CCRMODE_FixedSetpoint)) 277 if((stateUsed->mode != MODE_DIVE) || (pDiveState->diveSettings.diveMode != DIVEMODE_CCR) || (pDiveState->diveSettings.CCR_Mode != CCRMODE_FixedSetpoint))
313 } 306 }
314 307
315 308
316 /* hw 151030 309 /* hw 151030
317 */ 310 */
318 int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2) 311 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2)
319 { 312 {
320 if(gas1->helium_percentage != gas2->helium_percentage) 313 if(gas1->helium_percentage != gas2->helium_percentage)
321 return 0; 314 return 0;
322 else 315 else
323 if(gas1->oxygen_percentage != gas2->oxygen_percentage) 316 if(gas1->oxygen_percentage != gas2->oxygen_percentage)
325 else 318 else
326 return 1; 319 return 1;
327 } 320 }
328 321
329 322
330 int8_t check_CNS(SDiveState * pDiveState) 323 static int8_t check_CNS(SDiveState * pDiveState)
331 { 324 {
332 if(stateUsed->mode != MODE_DIVE) 325 if(stateUsed->mode != MODE_DIVE)
333 { 326 {
334 pDiveState->warnings.cnsHigh = 0; 327 pDiveState->warnings.cnsHigh = 0;
335 return 0; 328 return 0;
341 pDiveState->warnings.cnsHigh = 0; 334 pDiveState->warnings.cnsHigh = 0;
342 return pDiveState->warnings.cnsHigh; 335 return pDiveState->warnings.cnsHigh;
343 } 336 }
344 337
345 338
346 int8_t check_Battery(SDiveState * pDiveState) 339 static int8_t check_Battery(SDiveState * pDiveState)
347 { 340 {
348 if(pDiveState->lifeData.battery_charge < 10) 341 if(pDiveState->lifeData.battery_charge < 10)
349 pDiveState->warnings.lowBattery = 1; 342 pDiveState->warnings.lowBattery = 1;
350 else 343 else
351 pDiveState->warnings.lowBattery = 0; 344 pDiveState->warnings.lowBattery = 0;
352 345
353 return pDiveState->warnings.lowBattery; 346 return pDiveState->warnings.lowBattery;
354 } 347 }
355 348
356 349
357 int8_t check_Deco(SDiveState * pDiveState) 350 static int8_t check_Deco(SDiveState * pDiveState)
358 { 351 {
359 if(stateUsed->mode != MODE_DIVE) 352 if(stateUsed->mode != MODE_DIVE)
360 { 353 {
361 pDiveState->warnings.decoMissed = 0; 354 pDiveState->warnings.decoMissed = 0;
362 return 0; 355 return 0;
374 367
375 return pDiveState->warnings.decoMissed; 368 return pDiveState->warnings.decoMissed;
376 } 369 }
377 370
378 371
379 int8_t check_AscentRate(SDiveState * pDiveState) 372 static int8_t check_AscentRate(SDiveState * pDiveState)
380 { 373 {
381 if(stateUsed->mode != MODE_DIVE) 374 if(stateUsed->mode != MODE_DIVE)
382 { 375 {
383 pDiveState->warnings.ascentRateHigh = 0; 376 pDiveState->warnings.ascentRateHigh = 0;
384 return 0; 377 return 0;
394 pDiveState->warnings.ascentRateHigh = 0; 387 pDiveState->warnings.ascentRateHigh = 0;
395 return pDiveState->warnings.ascentRateHigh; 388 return pDiveState->warnings.ascentRateHigh;
396 } 389 }
397 390
398 391
399 int8_t check_aGF(SDiveState * pDiveState) 392 static int8_t check_aGF(SDiveState * pDiveState)
400 { 393 {
401 if(stateUsed->mode != MODE_DIVE) 394 if(stateUsed->mode != MODE_DIVE)
402 { 395 {
403 pDiveState->warnings.aGf = 0; 396 pDiveState->warnings.aGf = 0;
404 return 0; 397 return 0;