Mercurial > public > ostc4
annotate Discovery/Src/logbook.c @ 455:928a14568689 minor_improvments
Reactivated samples for bottle pressure information:
I previous versions (and also in the upcommings) the bottle pressure informations are not added to the log information. However for alfatesting of a potential pressure measurement the function may now be reactivated by a compile switch
Added the possibility to create dummy profiles based on the max depth, time and temperature values stored in the dive header:
In case the sample information belonging to a dive is no longer available a dummy profile shall be provided to the consumers (infolog view as well as external read requests).
author | ideenmodellierer |
---|---|
date | Tue, 24 Mar 2020 22:12:08 +0100 |
parents | ee1434824c3f |
children | 4bd01f48c285 |
rev | line source |
---|---|
38 | 1 /** |
2 ****************************************************************************** | |
3 * @copyright heinrichs weikamp | |
4 * @file logbook.c | |
5 * @author heinrichs weikamp gmbh and heinrichs weikamp gmbh | |
6 * @date 22-Apr-2014 | |
7 * @version V0.0.3 | |
8 * @since 03-Feb-2016 | |
9 * @brief Everything about creating and evaluating the logbook | |
10 * without the flash part which is included in externLogbookFlash.c | |
11 * and the USB/Bluetooth part in tComm.c | |
12 * CHANGE V0.0.3 hw: ppO2 sensor values | |
13 * CHANGE V0.0.4 hw: fix event bytes according to hwos_interface.odt dated 160610 in bitbucket hwOS | |
14 * @bug | |
15 * @warning | |
16 @verbatim | |
17 ============================================================================== | |
18 ##### Header ##### | |
19 ============================================================================== | |
20 [..] SLogbookHeader | |
21 The order has changed in comparsion to OSTC3 for perfect alignment | |
22 with 16bit and 32bit. The header is 256kB as well. | |
23 DO NOT rearrange anything but add new data to a second page | |
24 beyond diveHeaderEnd. Use extraPagesWithData to indicate that there is | |
25 data available that was not available in the OSTC3 256KB | |
26 This data will be behind the diveHeaderEnd. DO NOT delete diveHeaderEnd. | |
27 | |
28 [..] SLogbookHeaderOSTC3 | |
29 is the format used by the OSTC3. | |
30 logbook_getHeaderOSTC3() does the job using the global headers in logbook.c | |
31 | |
32 [..] SSmallHeader | |
33 - is the format used by the OSTC3 | |
34 | |
35 [..] Summary | |
36 The header format is not perfect and might be optimized prior to | |
37 releasing the diving computer. For now it is good to be compatible | |
38 with PC software available for checking the content of the logbook | |
39 | |
40 | |
41 @endverbatim | |
42 ****************************************************************************** | |
43 * @attention | |
44 * | |
45 * <h2><center>© COPYRIGHT(c) 2014 heinrichs weikamp</center></h2> | |
46 * | |
47 ****************************************************************************** | |
48 */ | |
49 | |
50 /* Includes ------------------------------------------------------------------*/ | |
51 #include <stdint.h> | |
52 #include <string.h> | |
53 #include "logbook.h" | |
54 //#include "test_vpm.h" | |
55 #include "externLogbookFlash.h" | |
56 #include "data_exchange.h" | |
57 #include "decom.h" | |
58 #include "tHome.h" // for tHome_findNextStop() | |
445 | 59 #include "settings.h" |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
60 #include "configuration.h" |
38 | 61 |
62 /* Private types -------------------------------------------------------------*/ | |
63 | |
64 #define LOGBOOK_VERSION (0x30) | |
65 #define LOGBOOK_VERSION_OSTC3 (0x24) | |
66 | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
67 #define DEFAULT_SAMPLES (100) /* Number of sample data bytes in case of an broken header information */ |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
68 #define DUMMY_SAMPLES (1000) /* Maximum number of samples profided by a dummy dive profile */ |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
69 |
38 | 70 typedef struct /* don't forget to adjust void clear_divisor(void) */ |
71 { | |
72 uint8_t temperature; | |
73 uint8_t deco_ndl; | |
74 uint8_t gradientFactor; | |
75 uint8_t ppo2; | |
76 uint8_t decoplan; | |
77 uint8_t cns; | |
78 uint8_t tank; | |
79 } SDivisor; | |
80 | |
81 /* Exported variables --------------------------------------------------------*/ | |
82 | |
83 /* Private variables ---------------------------------------------------------*/ | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
84 static SLogbookHeader gheader; |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
85 static SLogbookHeaderOSTC3 headerOSTC3; |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
86 static SLogbookHeaderOSTC3compact headerOSTC3compact; |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
87 static SSmallHeader smallHeader; |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
88 static SDivisor divisor; |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
89 static SDivisor divisorBackup; |
38 | 90 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
91 static SSmallHeader smallDummyHeader; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
92 static uint16_t dummyWriteIdx; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
93 static uint16_t dummyReadIdx; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
94 static uint8_t dummyMemoryBuffer[1000*4]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
95 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
96 |
38 | 97 /* Private function prototypes -----------------------------------------------*/ |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
98 static void clear_divisor(void); |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
99 static void logbook_SetAverageDepth(float average_depth_meter); |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
100 static void logbook_SetMinTemperature(float min_temperature_celsius); |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
101 static void logbook_SetMaxCNS(float max_cns_percentage); |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
102 static void logbook_SetCompartmentDesaturation(const SDiveState * pStateReal); |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
103 static void logbook_SetLastStop(float last_stop_depth_bar); |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
104 static void logbook_writedata(void * data, int length_byte); |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
105 static void logbook_UpdateHeader(const SDiveState * pStateReal); |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
106 static void logbook_createDummyProfile(uint16_t maxDepth, uint8_t lastDecostop_m, int16_t minTemp, uint16_t length, uint16_t* depth, int16_t* temperature); |
38 | 107 |
108 /* Exported functions --------------------------------------------------------*/ | |
109 | |
110 void logbook_EndDive(void) | |
111 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
112 ext_flash_close_new_dive_log((uint8_t*) &gheader); |
38 | 113 } |
114 | |
115 | |
116 // =============================================================================== | |
117 // logbook_last_totalDiveCount | |
118 /// @brief Fix setting issues | |
119 /// @date 04-April-2016 | |
120 /// | |
121 /// @return diveNumber (totalDiveCounter) of latest log entry, 0 if not a valid header | |
122 // =============================================================================== | |
123 uint16_t logbook_lastDive_diveNumber(void) | |
124 { | |
125 SLogbookHeader tempLogbookHeader; | |
126 if(logbook_getHeader(0, &tempLogbookHeader)) | |
127 { | |
128 return tempLogbookHeader.diveNumber; | |
129 } | |
130 else | |
131 { | |
132 return 0; | |
133 } | |
134 } | |
135 | |
136 | |
137 /** | |
138 ****************************************************************************** | |
139 * @brief logbook_getCurrentHeader. / | |
281 | 140 * @author heinrichs weikamp |
38 | 141 * @version V0.0.1 |
142 * @date 22-April-2014 | |
143 ****************************************************************************** | |
144 * | |
145 * @return SLogbookHeader*: | |
146 */ | |
147 SLogbookHeader* logbook_getCurrentHeader(void) | |
148 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
149 return &gheader; |
38 | 150 } |
151 | |
152 /** | |
153 ****************************************************************************** | |
154 * @brief logbook_getNumberOfHeaders. / | |
155 * @author heinrichs weikamp gmbh | |
156 * @version V0.0.1 | |
157 * @date 18-May-2016 | |
158 ****************************************************************************** | |
159 * | |
160 * @return uint8_t : number of valid headers (0xFAFA) found. | |
161 */ | |
162 uint8_t logbook_getNumberOfHeaders(void) | |
163 { | |
164 return ext_flash_count_dive_headers(); | |
165 } | |
166 | |
167 | |
168 /** | |
169 ****************************************************************************** | |
170 * @brief logbook_getHeader. / | |
281 | 171 * @author heinrichs weikamp |
38 | 172 * @version V0.0.1 |
173 * @date 22-April-2014 | |
174 ****************************************************************************** | |
175 * | |
176 * @param StepBackwards : 0 Last lokbook entry, 1 second to last entry, etc. | |
177 * @param SSLogbookHeader* pLogbookHeader: Output found LogbookHeader | |
178 * @return uint8_t : 1 = success | |
179 */ | |
180 uint8_t logbook_getHeader(uint8_t StepBackwards,SLogbookHeader* pLogbookHeader) | |
181 { | |
182 ext_flash_read_dive_header((uint8_t *)pLogbookHeader, StepBackwards); | |
183 if(pLogbookHeader->diveHeaderStart != 0xFAFA) | |
184 return 0; | |
185 else | |
186 return 1; | |
187 } | |
188 | |
189 /** | |
190 ****************************************************************************** | |
191 * @brief logbook_initNewdiveProfile. / | |
192 * creates header and smallHeader from diveState and global Settings | |
193 * and writes new lookboock entry on flash device | |
194 * diveState | |
281 | 195 * @author heinrichs weikamp |
38 | 196 * @version V0.0.1 |
197 * @date 22-April-2014 | |
198 ****************************************************************************** | |
199 * | |
200 * @param SDiveState* pInfo: Input | |
201 * @param SSettings* pSettings: Input | |
202 */ | |
203 | |
204 void logbook_initNewdiveProfile(const SDiveState* pInfo, SSettings* pSettings) | |
205 { | |
206 RTC_DateTypeDef Sdate; | |
207 RTC_TimeTypeDef Stime; | |
208 | |
209 for(int i = 0; i < sizeof(SLogbookHeader); i++) | |
210 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
211 ((uint8_t*)(&gheader))[i] = 0; |
38 | 212 } |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
213 gheader.diveHeaderStart = 0xFAFA; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
214 gheader.diveHeaderEnd = 0xFBFB; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
215 gheader.samplingRate = 2; |
38 | 216 if(pInfo->diveSettings.diveMode == DIVEMODE_OC) |
217 { | |
218 for(int i = 0; i < 5; i++) | |
219 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
220 gheader.gasordil[i].oxygen_percentage = pSettings->gas[i+1].oxygen_percentage; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
221 gheader.gasordil[i].helium_percentage = pSettings->gas[i+1].helium_percentage; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
222 gheader.gasordil[i].note.uw = pSettings->gas[i+1].note.uw; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
223 gheader.gasordil[i].depth_meter = pSettings->gas[i+1].depth_meter; |
38 | 224 } |
225 } | |
226 else | |
227 { | |
228 for(int i = 0; i < 5; i++) | |
229 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
230 gheader.gasordil[i].oxygen_percentage = pSettings->gas[i+6].oxygen_percentage; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
231 gheader.gasordil[i].helium_percentage = pSettings->gas[i+6].helium_percentage; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
232 gheader.gasordil[i].note.uw = pSettings->gas[i+6].note.uw; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
233 gheader.gasordil[i].depth_meter = pSettings->gas[i+6].depth_meter; |
38 | 234 } |
235 | |
236 for(int i = 0; i < 5; i++) | |
237 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
238 gheader.setpoint[i].setpoint_cbar = pSettings->setpoint[i+1].setpoint_cbar; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
239 gheader.setpoint[i].depth_meter = pSettings->setpoint[i+1].depth_meter; |
38 | 240 } |
241 } | |
242 // header.gasordil[pInfo->lifeData.actualGas.GasIdInSettings].depth_meter = 0; | |
243 | |
244 translateDate(pInfo->lifeData.dateBinaryFormat, &Sdate); | |
245 translateTime(pInfo->lifeData.timeBinaryFormat, &Stime); | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
246 gheader.dateYear = Sdate.Year; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
247 gheader.dateMonth = Sdate.Month; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
248 gheader.dateDay = Sdate.Date; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
249 gheader.timeHour = Stime.Hours; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
250 gheader.timeMinute = Stime.Minutes; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
251 gheader.cnsAtBeginning = (uint16_t)pInfo->lifeData.cns; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
252 gheader.surfacePressure_mbar = (uint16_t)(pInfo->lifeData.pressure_surface_bar * 1000); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
253 gheader.firmwareVersionHigh = firmwareVersion_16bit_high(); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
254 gheader.firmwareVersionLow = firmwareVersion_16bit_low(); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
255 gheader.logbookProfileVersion = LOGBOOK_VERSION; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
256 gheader.salinity = pSettings->salinity; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
257 gheader.diveNumber = pSettings->totalDiveCounter; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
258 gheader.personalDiveCount = pSettings->personalDiveCount; |
38 | 259 |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
260 gheader.diveMode = pInfo->diveSettings.diveMode; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
261 gheader.CCRmode = pInfo->diveSettings.CCR_Mode; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
262 gheader.lastDecostop_m = pSettings->last_stop_depth_meter; |
38 | 263 |
264 if(pInfo->diveSettings.deco_type.ub.standard == GF_MODE) | |
265 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
266 gheader.decoModel = 1; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
267 gheader.gfLow_or_Vpm_conservatism = pInfo->diveSettings.gf_low; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
268 gheader.gfHigh = pInfo->diveSettings.gf_high; |
38 | 269 } |
270 else | |
271 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
272 gheader.decoModel = 2; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
273 gheader.gfLow_or_Vpm_conservatism = pInfo->diveSettings.vpm_conservatism; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
274 gheader.gfHigh = 0; |
38 | 275 } |
276 | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
277 memcpy(gheader.n2Compartments, pInfo->lifeData.tissue_nitrogen_bar, 64); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
278 memcpy(gheader.heCompartments, pInfo->lifeData.tissue_helium_bar, 64); |
38 | 279 |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
280 logbook_SetCompartmentDesaturation(pInfo); |
38 | 281 |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
282 ext_flash_start_new_dive_log_and_set_actualPointerSample((uint8_t*)&gheader); |
38 | 283 |
284 smallHeader.profileLength[0] = 0xFF; | |
285 smallHeader.profileLength[1] = 0xFF; | |
286 smallHeader.profileLength[2] = 0xFF; | |
287 smallHeader.samplingRate_seconds = 2; | |
288 smallHeader.numDivisors = 7; | |
289 | |
290 smallHeader.tempType = 0; | |
291 smallHeader.tempLength = 2; | |
292 smallHeader.tempDivisor = 6; | |
293 | |
294 smallHeader.deco_ndlType = 1; | |
295 smallHeader.deco_ndlLength = 2; | |
296 smallHeader.deco_ndlDivisor = 6; //= 6; | |
297 | |
298 /* GF in % at actual position */ | |
299 smallHeader.gfType = 2; | |
300 smallHeader.gfLength = 1; | |
301 smallHeader.gfDivisor = 0; //12; | |
302 | |
303 /* 3 Sensors: 8bit ppO2 in 0.01bar, 16bit voltage in 0,1mV */ | |
304 smallHeader.ppo2Type = 3; | |
305 smallHeader.ppo2Length = 9; | |
306 smallHeader.ppo2Divisor = 2; //2 | |
307 | |
308 /* last 15 stops in minutes (last, second_to_last, ... */ | |
309 /* last stop depth is defined in header */ | |
310 smallHeader.decoplanType = 4; | |
311 smallHeader.decoplanLength = 15; | |
312 smallHeader.decoplanDivisor = 12;//12; | |
313 | |
314 smallHeader.cnsType = 5; | |
315 smallHeader.cnsLength = 2; | |
316 smallHeader.cnsDivisor = 12; | |
317 | |
318 smallHeader.tankType = 6; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
319 #ifdef ENABLE_BOTTLE_SENSOR |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
320 smallHeader.tankLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
321 smallHeader.tankDivisor = 30; /* log tank data once a minute */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
322 #else |
38 | 323 smallHeader.tankLength = 0; |
324 smallHeader.tankDivisor = 0; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
325 #endif |
38 | 326 logbook_writedata((void *) &smallHeader,sizeof(smallHeader)); |
327 | |
328 clear_divisor(); | |
329 } | |
330 | |
331 /** | |
332 ****************************************************************************** | |
333 * @brief clear_divisor / clears divisor struct | |
281 | 334 * @author heinrichs weikamp |
38 | 335 * @version V0.0.1 |
336 * @date 22-April-2014 | |
337 ****************************************************************************** | |
338 * | |
339 */ | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
340 static void clear_divisor(void) |
38 | 341 { |
342 divisor.cns = smallHeader.cnsDivisor - 1; | |
343 divisor.decoplan = smallHeader.decoplanDivisor - 1; | |
344 divisor.deco_ndl = smallHeader.deco_ndlDivisor - 1; | |
345 divisor.gradientFactor = smallHeader.gfDivisor -1 ; | |
346 divisor.ppo2 = smallHeader.ppo2Divisor - 1; | |
347 divisor.tank = smallHeader.tankDivisor - 1; | |
348 divisor.temperature = smallHeader.tempDivisor - 1; | |
349 } | |
350 | |
351 | |
352 /** | |
353 ****************************************************************************** | |
354 * @brief add16. / adds 16 bit variable to 8 bit array | |
281 | 355 * @author heinrichs weikamp |
38 | 356 * @version V0.0.1 |
357 * @date 22-April-2014 | |
358 ****************************************************************************** | |
359 * | |
360 * @param uint8_t *pos: Output 8 bit array | |
361 * @param uint16_t var: 16 bit variable | |
362 */ | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
363 static void addU16(uint8_t *pos, uint16_t var) |
38 | 364 { |
365 *((uint16_t*)pos) = var; | |
366 } | |
367 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
368 static void addS16(uint8_t *pos, int16_t var) |
38 | 369 { |
370 *((int16_t*)pos) = var; | |
371 } | |
372 | |
373 /** | |
374 ****************************************************************************** | |
375 * @brief logbook_writeSample. / Writes one logbook sampl | |
281 | 376 * @author heinrichs weikamp |
38 | 377 * @date 22-April-2014 |
378 * @version V0.0.2 | |
379 * @since 20-June-2016 | |
380 * @bug Deco/NDL Status fixed in V0.0.2 | |
381 | |
382 | |
383 ****************************************************************************** | |
384 * | |
385 * @param SDiveState state: | |
386 */ | |
387 | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
388 void logbook_writeSample(const SDiveState *state) |
38 | 389 { |
390 uint8_t sample[256]; | |
391 // int position = 0; | |
392 int length = 0; | |
393 // _Bool bEvent = 0; | |
394 uint8_t nextstopDepthMeter = 0; | |
395 uint16_t nextstopLengthSeconds = 0; | |
396 uint8_t nextstopLengthMinutes = 0; | |
397 bit8_Type eventByte1, eventByte2; | |
398 bit8_Type profileByteFlag; | |
399 int i = 0; | |
400 for(i = 0; i <256 ;i++) | |
401 sample[i] = 0; | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
402 addU16(sample, (uint16_t)(state->lifeData.depth_meter * 100)); |
38 | 403 length += 2; |
404 sample[2] = 0; | |
405 length++; | |
406 eventByte1.uw = 0; | |
407 eventByte2.uw = 0; | |
408 //uint16_t tmpU16 = 0; | |
130
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
38
diff
changeset
|
409 const SDecoinfo * pDecoinfo; // new hw 160620 |
38 | 410 |
411 //BuildEevntyte 1 | |
412 // sub old 0-3 only one at a time | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
413 if(state->events.manualMarker) |
38 | 414 { |
415 eventByte1.uw = 6; | |
416 } | |
417 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
418 if(state->warnings.decoMissed) |
38 | 419 { |
420 eventByte1.uw = 2; | |
421 } | |
422 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
423 if(state->warnings.ppO2Low) |
38 | 424 { |
425 eventByte1.uw = 4; | |
426 } | |
427 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
428 if(state->warnings.ppO2High) |
38 | 429 { |
430 eventByte1.uw = 5; | |
431 } | |
432 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
433 if(state->warnings.lowBattery) |
38 | 434 { |
435 eventByte1.uw = 7; | |
436 } | |
437 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
438 if(state->warnings.slowWarning) |
38 | 439 { |
440 eventByte1.uw = 1; | |
441 } | |
442 // sub bit 4 to 7 | |
281 | 443 if(state->events.manualGasSet) |
38 | 444 { |
445 eventByte1.ub.bit4 = 1; | |
446 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
447 if(state->events.gasChange) |
38 | 448 { |
449 eventByte1.ub.bit5 = 1; | |
450 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
451 if(state->events.setpointChange) |
38 | 452 { |
453 eventByte1.ub.bit6 = 1; | |
454 } | |
455 // sub bit 7 + eventbyte2 | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
456 if(state->events.bailout) |
38 | 457 { |
458 eventByte1.ub.bit7 = 1; | |
459 eventByte2.ub.bit0 = 1; | |
460 } | |
461 //Add EventByte 1 | |
462 if(eventByte1.uw > 0) | |
463 { | |
464 sample[length] = eventByte1.uw; | |
465 length++; | |
466 } | |
467 if(eventByte2.uw > 0) | |
468 { | |
469 sample[length] = eventByte2.uw; | |
470 length++; | |
471 } | |
472 //Add EventInfos | |
281 | 473 if(state->events.manualGasSet) |
38 | 474 { |
475 //manual gas in %O2 & %He | |
281 | 476 sample[length] = state->events.info_manualGasSetO2; |
38 | 477 length += 1; |
281 | 478 sample[length] = state->events.info_manualGasSetHe; |
38 | 479 length += 1; |
480 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
481 if(state->events.gasChange) |
38 | 482 { |
483 //Current gas (gasid) | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
484 sample[length] = state->events.info_GasChange; |
38 | 485 length += 1; |
486 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
487 if(state->events.setpointChange) |
38 | 488 { |
489 //New setpoint in cbar | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
490 sample[length] = state->events.info_SetpointChange; |
38 | 491 length += 1; |
492 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
493 if(state->events.bailout) |
38 | 494 { |
495 //bailout gas in % O2 & %He | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
496 sample[length] = state->events.info_bailoutO2; |
38 | 497 length += 1; |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
498 sample[length] = state->events.info_bailoutHe; |
38 | 499 length += 1; |
500 } | |
501 | |
502 | |
503 if(divisor.temperature == 0) | |
504 { | |
505 divisor.temperature = smallHeader.tempDivisor - 1; | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
506 addS16(&sample[length], (int16_t)((state->lifeData.temperature_celsius * 10.0f) + 0.5f)); |
38 | 507 length += 2; |
508 } | |
509 else | |
510 { | |
511 divisor.temperature--; | |
512 } | |
513 | |
514 | |
515 if(smallHeader.deco_ndlDivisor > 0) | |
516 { | |
517 if(divisor.deco_ndl == 0) | |
518 { | |
519 divisor.deco_ndl = smallHeader.deco_ndlDivisor - 1; | |
520 | |
521 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) | |
522 pDecoinfo = &stateUsed->decolistBuehlmann; | |
523 else if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) | |
524 pDecoinfo = &stateUsed->decolistVPM; | |
525 else // should not happen as only GF and VPM at the moment | |
526 { | |
527 sample[length] = 0; | |
528 length += 1; | |
529 sample[length] = 0; | |
530 length += 1; | |
531 } | |
532 | |
533 if(pDecoinfo->output_ndl_seconds > 0) | |
534 { | |
535 sample[length] = 0; | |
536 length += 1; | |
283
04cdeff80254
Bugfix: write NDL in logbook correctly
Jan Mulder <jlmulder@xs4all.nl>
parents:
281
diff
changeset
|
537 sample[length] = (uint8_t)(pDecoinfo->output_ndl_seconds / 60); |
281 | 538 |
539 // Limit stored sample within 0 to 240 mins (Since it's 8bit UINT only) | |
540 if ((pDecoinfo->output_ndl_seconds / 60) > 240) sample[length] = 240; | |
541 if ((pDecoinfo->output_ndl_seconds / 60) < 0) sample[length] = 0; | |
542 | |
38 | 543 length += 1; |
544 } | |
545 else if(pDecoinfo->output_time_to_surface_seconds) | |
546 { | |
547 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds); | |
548 nextstopLengthMinutes = (nextstopLengthSeconds +59 ) / 60; | |
549 | |
550 sample[length] = nextstopDepthMeter; | |
551 length += 1; | |
552 sample[length] = nextstopLengthMinutes; | |
553 length += 1; | |
554 } | |
555 else | |
556 { | |
557 sample[length] = 0; | |
558 length += 1; | |
559 sample[length] = 0; | |
560 length += 1; | |
561 } | |
562 } | |
563 else | |
564 { | |
565 divisor.deco_ndl --; | |
566 } | |
567 } | |
568 | |
569 | |
570 if(smallHeader.ppo2Divisor) | |
571 { | |
572 if(divisor.ppo2 == 0) | |
573 { | |
574 divisor.ppo2 = smallHeader.ppo2Divisor - 1; | |
575 | |
576 for(int i = 0; i <3; i++) | |
577 { | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
578 sample[length] = (uint8_t)(state->lifeData.ppO2Sensor_bar[i] * 100.0f + 0.5f); |
38 | 579 length += 1; |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
580 addU16(&sample[length], (uint16_t)(state->lifeData.sensorVoltage_mV[i] * 10.0f + 0.5f)); |
38 | 581 length += 2; |
582 } | |
583 } | |
584 else | |
585 { | |
586 divisor.ppo2--; | |
587 } | |
588 } | |
589 | |
590 | |
591 if(smallHeader.decoplanDivisor) | |
592 { | |
593 if(divisor.decoplan == 0) | |
594 { | |
595 divisor.decoplan = smallHeader.decoplanDivisor - 1; | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
596 if(state->diveSettings.deco_type.ub.standard == VPM_MODE) |
38 | 597 { |
598 for(int i = 0; i <15; i++) | |
599 { | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
600 sample[length] = state->decolistVPM.output_stop_length_seconds[i] / 60; |
38 | 601 length += 1; |
602 } | |
603 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
604 else if(state->diveSettings.deco_type.ub.standard == GF_MODE) |
38 | 605 { |
606 for(int i = 0; i <15; i++) | |
607 { | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
608 sample[length] = state->decolistBuehlmann.output_stop_length_seconds[i] / 60; |
38 | 609 length += 1; |
610 } | |
611 } | |
612 else | |
613 { | |
614 for(int i = 0; i <15; i++) | |
615 { | |
616 sample[length] = 0; | |
617 length += 1; | |
618 } | |
619 } | |
620 // add16(&sample[length], state.temperature); | |
621 //length += 2; | |
622 } | |
623 else | |
624 { | |
625 divisor.decoplan --; | |
626 } | |
627 } | |
628 if(divisor.cns == 0) | |
629 { | |
630 divisor.cns = smallHeader.cnsDivisor - 1; | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
631 addU16(&sample[length], (uint16_t)state->lifeData.cns); |
38 | 632 length += 2; |
633 } | |
634 else | |
635 { | |
636 divisor.cns--; | |
637 } | |
638 | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
639 #ifdef ENABLE_BOTTLE_SENSOR |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
640 if(smallHeader.tankDivisor) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
641 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
642 if(divisor.tank == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
643 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
644 divisor.tank = smallHeader.tankDivisor - 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
645 addS16(&sample[length], ((state->lifeData.bottle_bar[state->lifeData.actualGas.GasIdInSettings]))); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
646 length += smallHeader.tankLength; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
647 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
648 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
649 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
650 divisor.tank--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
651 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
652 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
653 #endif |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
654 |
38 | 655 profileByteFlag.uw = length - 3; |
656 if(eventByte1.uw) | |
657 { | |
658 profileByteFlag.ub.bit7 = 1; | |
659 } | |
660 sample[2] = profileByteFlag.uw; | |
661 logbook_writedata((void *) sample,length); | |
662 | |
663 } | |
664 | |
665 /** | |
666 ****************************************************************************** | |
667 * @brief readSample. / Reads data of one logbook sample | |
281 | 668 * @author heinrichs weikamp |
38 | 669 * @version V0.0.1 |
670 * @date 22-April-2014 | |
671 ****************************************************************************** | |
672 * | |
673 * @param int32_t* depth: output Value | |
674 * @param int16_t * gasid: output Value | |
675 * @param int32_t* temperature: output Value | |
676 * @param int32_t* sensor1, sensor2, sensor3: output Value | |
677 * @param int32_t* cns: output Value | |
678 * @return bytes read / 0 = reading Error | |
679 */ | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
680 static uint16_t readSample(int32_t* depth, int16_t * gasid, int16_t* setpoint_cbar, int32_t* temperature, int32_t* sensor1, int32_t* sensor2, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
681 int32_t* sensor3, int32_t* cns, SManualGas* manualGas, int16_t* bailout, int16_t* decostopDepth, uint16_t* tank) |
38 | 682 { |
683 int length = 0; | |
684 _Bool bEvent = 0; | |
685 bit8_Type eventByte1, eventByte2; | |
686 bit8_Type profileByteFlag; | |
687 | |
688 eventByte1.uw = 0; | |
689 eventByte2.uw = 0; | |
690 uint8_t tempU8 = 0; | |
691 uint16_t temp = 0; | |
692 uint16_t bytesRead = 0; | |
693 | |
694 if(gasid) | |
695 *gasid = -1; | |
696 if(temperature) | |
697 *temperature = -1000; | |
698 if(sensor1) | |
699 *sensor1 = -1; | |
700 if(sensor2) | |
701 *sensor2 = -1; | |
702 if(sensor3) | |
703 *sensor3 = -1; | |
704 if(cns) | |
705 *cns = -1; | |
706 if(setpoint_cbar) | |
707 *setpoint_cbar = -1; | |
708 if(bailout) | |
709 *bailout = -1; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
710 if(tank) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
711 *tank = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
712 |
38 | 713 if(manualGas) |
714 { | |
715 manualGas->percentageO2 =-1; | |
716 manualGas->percentageHe =-1; | |
717 } | |
718 if(decostopDepth) | |
719 *decostopDepth = -1; | |
720 | |
721 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); | |
722 if(depth) | |
723 *depth = (int32_t)temp; | |
724 bytesRead += 2; | |
725 | |
726 ext_flash_read_next_sample_part( &profileByteFlag.uw, 1); | |
727 bytesRead ++; | |
728 | |
729 bEvent = profileByteFlag.ub.bit7; | |
730 profileByteFlag.ub.bit7 = 0; | |
731 length = profileByteFlag.uw; | |
732 | |
733 if(bEvent) | |
734 { | |
735 ext_flash_read_next_sample_part( &eventByte1.uw, 1); | |
736 bytesRead ++; | |
737 | |
738 length--; | |
739 | |
740 //second event byte | |
741 if(eventByte1.ub.bit7) | |
742 { | |
743 ext_flash_read_next_sample_part( &eventByte2.uw, 1); | |
744 bytesRead ++; | |
745 length--; | |
746 } | |
747 else | |
748 { | |
749 eventByte2.uw = 0; | |
750 } | |
751 | |
752 //manual Gas Set | |
753 if( eventByte1.ub.bit4) | |
754 { | |
755 //Evaluate manual Gas | |
756 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); | |
757 bytesRead +=1; | |
758 length -= 1; | |
759 manualGas->percentageO2 = tempU8; | |
760 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); | |
761 bytesRead +=1; | |
762 length -= 1; | |
763 manualGas->percentageHe = tempU8; | |
764 if(gasid) | |
765 *gasid = 0; | |
766 } | |
767 //gas change | |
768 if( eventByte1.ub.bit5) | |
769 { | |
770 ext_flash_read_next_sample_part( &tempU8, 1); | |
771 bytesRead +=1; | |
772 length -= 1; | |
773 if(gasid) | |
774 *gasid = (uint16_t)tempU8; | |
775 } | |
776 //SetpointChange | |
777 if( eventByte1.ub.bit6) | |
778 { | |
779 ext_flash_read_next_sample_part( &tempU8, 1); | |
780 *setpoint_cbar = tempU8; | |
781 bytesRead +=1; | |
782 length -= 1; | |
783 } | |
784 | |
785 // second event Byte | |
786 //bailout | |
298
50c26a4442af
Bugfix: fix drawing of CCR bailout profile
Jan Mulder <jlmulder@xs4all.nl>
parents:
283
diff
changeset
|
787 if(eventByte2.ub.bit0) |
38 | 788 { |
789 //evaluate bailout gas Gas | |
790 *bailout = 1; | |
791 | |
792 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); | |
793 bytesRead +=1; | |
794 length -= 1; | |
795 manualGas->percentageO2 = tempU8; | |
796 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); | |
797 bytesRead +=1; | |
798 length -= 1; | |
799 manualGas->percentageHe = tempU8; | |
800 | |
801 if(gasid) | |
802 *gasid = 0; | |
803 } | |
804 } | |
805 | |
806 if(divisor.temperature == 0) | |
807 { | |
808 divisor.temperature = smallHeader.tempDivisor - 1; | |
809 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); | |
810 bytesRead +=2; | |
811 length -= 2; | |
812 if(temperature) | |
813 { | |
814 *temperature = (int32_t)temp; | |
815 } | |
816 } | |
817 else | |
818 { | |
819 divisor.temperature--; | |
820 } | |
821 | |
822 if(smallHeader.deco_ndlDivisor > 0) | |
823 { | |
824 if(divisor.deco_ndl == 0) | |
825 { | |
826 divisor.deco_ndl = smallHeader.deco_ndlDivisor - 1; | |
827 ext_flash_read_next_sample_part( &tempU8, 1); | |
828 if(decostopDepth) | |
829 { | |
830 *decostopDepth = tempU8 * 100; | |
831 } | |
832 ext_flash_read_next_sample_part( &tempU8, 1); | |
833 bytesRead += 2; | |
834 length -= 2; | |
835 } | |
836 else | |
837 { | |
838 divisor.deco_ndl--; | |
839 } | |
840 } | |
841 | |
842 if(divisor.ppo2 == 0) | |
843 { | |
844 int32_t ppO2Tmp = 0; | |
845 divisor.ppo2 = smallHeader.ppo2Divisor -1; | |
846 for(int i = 0; i <3 ; i++) | |
847 { | |
848 ext_flash_read_next_sample_part( &tempU8, 1); | |
849 ppO2Tmp += tempU8; | |
850 bytesRead +=1; | |
851 length -= 1; | |
852 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); | |
853 bytesRead +=2; | |
854 length -= 2; | |
855 if(sensor1 && (i==0)) | |
856 *sensor1 = (((int32_t)tempU8) * 0xFFFF) + temp; | |
857 if(sensor2 && (i==1)) | |
858 *sensor2 = (((int32_t)tempU8) * 0xFFFF) + temp; | |
859 if(sensor3 && (i==2)) | |
860 *sensor3 = (((int32_t)tempU8) * 0xFFFF) + temp; | |
861 } | |
862 } | |
863 else | |
864 { | |
865 divisor.ppo2--; | |
866 } | |
867 | |
868 if(smallHeader.decoplanDivisor > 0) | |
869 { | |
870 if(divisor.decoplan == 0) | |
871 { | |
872 divisor.decoplan = smallHeader.decoplanDivisor - 1; | |
873 for(int i = 0; i <15; i++) | |
874 ext_flash_read_next_sample_part( &tempU8, 1); | |
875 bytesRead += 15; | |
876 length -= 15; | |
877 } | |
878 else | |
879 { | |
880 divisor.decoplan--; | |
881 } | |
882 } | |
883 | |
884 | |
885 | |
886 if(divisor.cns == 0) | |
887 { | |
888 divisor.cns = smallHeader.cnsDivisor - 1; | |
889 | |
890 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); | |
891 bytesRead +=2; | |
892 length -= 2; | |
893 if(cns) | |
894 { | |
895 *cns = (int32_t)temp; | |
896 } | |
897 } | |
898 else | |
899 { | |
900 divisor.cns--; | |
901 } | |
902 | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
903 #ifdef ENABLE_BOTTLE_SENSOR |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
904 if(smallHeader.tankDivisor) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
905 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
906 if(divisor.tank == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
907 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
908 divisor.tank = smallHeader.tankDivisor - 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
909 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
910 bytesRead +=2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
911 length -= 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
912 if(tank) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
913 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
914 *tank = (uint16_t)temp; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
915 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
916 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
917 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
918 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
919 divisor.tank--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
920 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
921 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
922 #endif |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
923 |
38 | 924 if (length != 0) |
925 return 0; | |
926 | |
927 return bytesRead; | |
928 } | |
929 /** | |
930 ****************************************************************************** | |
931 * @brief logbook_readSampleData. / Reads sample data of whole logbook entry | |
281 | 932 * @author heinrichs weikamp |
38 | 933 * @version V0.0.1 |
934 * @date 22-April-2014 | |
935 ****************************************************************************** | |
936 * | |
937 * @param uint8_t StepBackwards: witch lookbook entry? | |
938 * @param uint16_t length : maxlength of output arrays | |
939 * @param int32_t* depth : output array | |
940 * @param int16_t * gasid : output array | |
941 * @param int32_t* temperature : output array | |
942 * @param int32_t* ppo2 : output array | |
943 * @param int32_t* cns : output array | |
944 * @return length of output | |
945 */ | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
946 uint16_t logbook_readSampleData(uint8_t StepBackwards, uint16_t length,uint16_t* depth, uint8_t* gasid, int16_t* temperature, uint16_t* ppo2, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
947 uint16_t* setpoint, uint16_t* sensor1, uint16_t* sensor2, uint16_t* sensor3, uint16_t* cns, uint8_t* bailout, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
948 uint16_t* decostopDepth, uint16_t* tank) |
38 | 949 { |
950 //Test read | |
951 //SLogbookHeader header; | |
952 | |
953 //logbook_getHeader(&header); | |
954 SLogbookHeader header; | |
955 int iNum; | |
956 int firstgasid = 0; | |
957 int retVal = 0; | |
958 int compression = 0; | |
959 int i; | |
960 // uint32_t diveTime_seconds; | |
961 int32_t depthVal = 0; | |
962 int16_t gasidVal = 0; | |
963 int16_t setPointVal = 0; | |
964 int16_t bailoutVal = 0; | |
965 int16_t bailoutLast = 0; | |
966 uint16_t setPointLast = 0; | |
967 int32_t temperatureVal = 0; | |
968 int32_t sensor1Val = 0; | |
969 int32_t sensor2Val = 0; | |
970 int32_t sensor3Val = 0; | |
971 int32_t sensor1Last = 0; | |
972 int32_t sensor2Last = 0; | |
973 int32_t sensor3Last = 0; | |
974 int32_t cnsVal = 0; | |
975 int32_t depthLast = 0; | |
976 int16_t gasidLast = 0; | |
977 int32_t temperatureLast = 0; | |
978 int32_t temperatureFirst = 0; | |
979 int32_t cnsLast = 0; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
980 int16_t decostepDepthVal = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
981 int16_t decostepDepthLast = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
982 int16_t tankVal = 0; |
38 | 983 |
984 SManualGas manualGasVal; | |
985 SManualGas manualGasLast; | |
986 manualGasLast.percentageO2 = 0; | |
987 manualGasLast.percentageHe = 0; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
988 uint16_t numSamples = 0; |
38 | 989 |
990 float ambiant_pressure_bar = 0; | |
991 float ppO2 = 0; | |
992 ext_flash_read_dive_header((uint8_t*)&header, StepBackwards); | |
993 for(i = 0;i< 5;i++) | |
994 { | |
995 if(header.gasordil[i].note.ub.first) | |
996 break; | |
997 } | |
998 firstgasid = i + 1; | |
999 if(header.diveMode == DIVEMODE_CCR) | |
1000 setPointLast = header.setpoint[0].setpoint_cbar; | |
1001 else | |
1002 setPointLast = 0; | |
1003 //diveTime_seconds = header.diveTime_seconds ; | |
1004 for(compression = 1; compression < 100; compression ++) | |
1005 { | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1006 numSamples = (header.total_diveTime_seconds / header.samplingRate)/compression; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1007 if(numSamples <= length) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1008 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1009 break; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1010 } |
38 | 1011 } |
1012 | |
1013 | |
1014 for(i = 0;i< length;i++) | |
1015 { | |
1016 if(depth) | |
1017 depth[i] = 0; | |
1018 if(temperature) | |
1019 temperature[i] = 0; | |
1020 if(gasid) | |
1021 gasid[i] = 0; | |
1022 if(ppo2) | |
1023 ppo2[i] = 0; | |
1024 if(setpoint) | |
1025 setpoint[i] = 0; | |
1026 if(sensor1) | |
1027 sensor1[i] = 0; | |
1028 if(sensor2) | |
1029 sensor2[i] = 0; | |
1030 if(sensor3) | |
1031 sensor3[i] = 0; | |
1032 if(cns) | |
1033 cns[i] = 0; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1034 if(tank) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1035 tank[i] = 0; |
38 | 1036 } |
1037 //We start with fist gasid | |
1038 gasidLast = firstgasid; | |
1039 | |
1040 | |
1041 //uint16_t* ppo2, uint16_t* cns# | |
1042 uint32_t totalNumberOfBytes = 0; | |
1043 uint32_t bytesRead = 0; | |
1044 ext_flash_open_read_sample( StepBackwards,&totalNumberOfBytes); | |
1045 ext_flash_read_next_sample_part((uint8_t*)&smallHeader, sizeof(SSmallHeader)); | |
1046 bytesRead += sizeof(SSmallHeader); | |
1047 | |
1048 clear_divisor(); | |
1049 | |
1050 iNum = 0; | |
1051 int counter = 0; | |
1052 temperatureLast = -1000; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1053 if(totalNumberOfBytes > 2) /* read real data */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1054 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1055 while ((bytesRead < totalNumberOfBytes) && (iNum < length)) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1056 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1057 ext_flash_set_entry_point(); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1058 divisorBackup = divisor; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1059 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1060 &bailoutVal, &decostepDepthVal, &tankVal); |
38 | 1061 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1062 if(retVal == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1063 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1064 //Error try to read again!!! |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1065 ext_flash_reopen_read_sample_at_entry_point(); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1066 divisor = divisorBackup; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1067 retVal = readSample(&depthVal,&gasidVal,&setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1068 &manualGasVal, &bailoutVal, &decostepDepthVal, &tankVal); |
38 | 1069 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1070 if(retVal == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1071 break; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1072 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1073 bytesRead +=retVal; |
38 | 1074 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1075 //if for some variable no new value is in the sample for (z.B. gasidVal = -1), we take the last value |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1076 if(depthVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1077 depthVal = depthLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1078 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1079 depthLast = depthVal; |
38 | 1080 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1081 if(gasidVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1082 gasidVal = gasidLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1083 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1084 gasidLast = gasidVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1085 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1086 if(temperatureVal == -1000) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1087 temperatureVal = temperatureLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1088 else |
38 | 1089 { |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1090 if(temperatureLast == -1000) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1091 temperatureFirst = temperatureVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1092 temperatureLast = temperatureVal; |
38 | 1093 } |
1094 | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1095 if(setPointVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1096 setPointVal = setPointLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1097 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1098 setPointLast = setPointVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1099 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1100 if(sensor1Val == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1101 sensor1Val = sensor1Last; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1102 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1103 sensor1Last = sensor1Val; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1104 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1105 if(sensor2Val == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1106 sensor2Val = sensor2Last; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1107 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1108 sensor2Last = sensor2Val; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1109 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1110 if(sensor3Val == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1111 sensor3Val = sensor3Last; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1112 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1113 sensor3Last = sensor3Val; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1114 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1115 if(cnsVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1116 cnsVal = cnsLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1117 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1118 cnsLast = cnsVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1119 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1120 if(manualGasVal.percentageO2 == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1121 manualGasVal = manualGasLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1122 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1123 manualGasLast = manualGasVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1124 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1125 if(bailoutVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1126 bailoutVal = bailoutLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1127 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1128 bailoutLast = bailoutVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1129 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1130 if(decostepDepthVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1131 decostepDepthVal = decostepDepthLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1132 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1133 decostepDepthLast = decostepDepthVal; |
38 | 1134 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1135 counter++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1136 // Heed compression |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1137 // Write here to arrays |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1138 if(counter == compression) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1139 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1140 if(depth) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1141 depth[iNum] = depthVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1142 if(gasid) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1143 gasid[iNum] = gasidVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1144 if(temperature) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1145 temperature[iNum] = temperatureVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1146 if(cns) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1147 cns[iNum] = cnsVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1148 if(bailout) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1149 bailout[iNum] = bailoutVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1150 if(decostopDepth) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1151 decostopDepth[iNum] = decostepDepthVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1152 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1153 if(ppo2) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1154 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1155 //Calc ppo2 - Values |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1156 SGas gas; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1157 gas.setPoint_cbar = setPointVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1158 if(gasidVal > 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1159 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1160 gas.helium_percentage = header.gasordil[gasidVal - 1].helium_percentage; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1161 gas.nitrogen_percentage = 100 - gas.helium_percentage - header.gasordil[gasidVal - 1].oxygen_percentage; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1162 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1163 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1164 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1165 gas.helium_percentage = manualGasVal.percentageHe; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1166 gas.nitrogen_percentage = 100 - gas.helium_percentage - manualGasVal.percentageO2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1167 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1168 ambiant_pressure_bar =((float)(depthVal + header.surfacePressure_mbar))/1000; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1169 ppO2 = decom_calc_ppO2(ambiant_pressure_bar, &gas ); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1170 ppo2[iNum] = (uint16_t) ( ppO2 * 100); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1171 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1172 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1173 if(tank) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1174 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1175 tank[iNum] = tankVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1176 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1177 if(setpoint) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1178 setpoint[iNum] = setPointVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1179 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1180 if(sensor1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1181 sensor1[iNum] = (sensor1Val / 0xFFFF) & 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1182 if(sensor2) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1183 sensor2[iNum] = (sensor2Val / 0xFFFF) & 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1184 if(sensor3) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1185 sensor3[iNum] = (sensor3Val / 0xFFFF) & 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1186 iNum++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1187 counter = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1188 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1189 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1190 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1191 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1192 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1193 logbook_createDummyProfile(header.maxDepth, header.lastDecostop_m, header.minTemp, numSamples, depth, temperature); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1194 iNum = numSamples; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1195 } |
38 | 1196 |
1197 // Fix first Temperature Entries 150930 hw | |
1198 if(temperature) | |
1199 { | |
1200 int i = 0; | |
1201 while((temperature[i] == -1000) && (i < iNum)) | |
1202 temperature[i++] = temperatureFirst; | |
1203 } | |
1204 | |
1205 ext_flash_close_read_sample(); | |
1206 return iNum; | |
1207 } | |
1208 | |
1209 | |
1210 /******************************************************************************** | |
1211 * @brief logbook_InitAndWrite. / Controls writing of logbook | |
1212 * Should be called ten times per second | |
1213 * Automatically Initializes logbook at beginning of dive, | |
1214 * write samples every 2 seconds | |
1215 * and finishes logbook after end of dive | |
1216 *********************************************************************************/ | |
1217 | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1218 void logbook_InitAndWrite(const SDiveState *pStateReal) |
38 | 1219 { |
1220 SSettings *pSettings = settingsGetPointer(); | |
1221 static uint8_t bDiveMode = 0; | |
1222 static uint32_t tickstart = 0; | |
1223 uint32_t ticksdiff = 0; | |
1224 uint32_t lasttick = 0; | |
1225 static float min_temperature_float_celsius = 0; | |
1226 | |
1227 if(!bDiveMode) | |
1228 { | |
1229 if((pStateReal->mode == MODE_DIVE) && (pStateReal->diveSettings.diveMode != DIVEMODE_Apnea) && (pStateReal->lifeData.dive_time_seconds >= 5)) | |
1230 { | |
1231 //InitdiveProfile | |
1232 pSettings->totalDiveCounter++; | |
1233 logbook_initNewdiveProfile(pStateReal,settingsGetPointer()); | |
1234 min_temperature_float_celsius = pStateReal->lifeData.temperature_celsius; | |
1235 //Write logbook sample | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
1236 logbook_writeSample(pStateReal); |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1237 resetEvents(pStateReal); |
38 | 1238 tickstart = HAL_GetTick(); |
1239 bDiveMode = 1; | |
1240 } | |
1241 } | |
1242 else if((pStateReal->mode == MODE_DIVE) && (pStateReal->diveSettings.diveMode != DIVEMODE_Apnea)) | |
1243 { | |
1244 lasttick = HAL_GetTick(); | |
1245 ticksdiff = time_elapsed_ms(tickstart,lasttick); | |
1246 // | |
1247 if(ticksdiff >= 2000) | |
1248 { | |
1249 //Write logbook sample | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
1250 logbook_writeSample(pStateReal); |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1251 resetEvents(pStateReal); |
38 | 1252 if(min_temperature_float_celsius > pStateReal->lifeData.temperature_celsius) |
1253 min_temperature_float_celsius = pStateReal->lifeData.temperature_celsius; | |
1254 tickstart = lasttick; | |
1255 if((bDiveMode == 1) && (pStateReal->lifeData.dive_time_seconds >= pSettings->divetimeToCreateLogbook)) | |
1256 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1257 ext_flash_create_new_dive_log((uint8_t*)&gheader); |
38 | 1258 /** save settings |
1259 * with new lastDiveLogId and time and day | |
1260 */ | |
1261 pSettings->personalDiveCount++; | |
1262 if(pSettings->logbookOffset) | |
1263 { | |
1264 pSettings->logbookOffset++; | |
1265 } | |
427 | 1266 ext_flash_write_settings(0); |
38 | 1267 ext_flash_disable_protection_for_logbook(); |
426
514e6269256f
Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents:
411
diff
changeset
|
1268 |
514e6269256f
Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents:
411
diff
changeset
|
1269 ext_flash_CloseSector(); /* this is just a repair function which invalidates a not used sector in case a log maintenance was called before dive */ |
38 | 1270 bDiveMode = 3; |
1271 } | |
1272 if(bDiveMode == 3) | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1273 logbook_UpdateHeader(pStateReal); |
38 | 1274 } |
1275 } | |
1276 else if(bDiveMode == 3) | |
1277 { | |
1278 //End of Dive | |
1279 logbook_SetAverageDepth(pStateReal->lifeData.average_depth_meter); | |
1280 logbook_SetMinTemperature(min_temperature_float_celsius); | |
1281 logbook_SetMaxCNS(pStateReal->lifeData.cns); | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1282 logbook_SetCompartmentDesaturation(pStateReal); |
38 | 1283 logbook_SetLastStop(pStateReal->diveSettings.last_stop_depth_bar); |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1284 gheader.batteryVoltage = pStateReal->lifeData.battery_voltage * 1000; |
38 | 1285 logbook_EndDive(); |
1286 bDiveMode = 0; | |
1287 } else | |
1288 { | |
1289 ext_flash_enable_protection(); | |
1290 } | |
1291 } | |
1292 | |
1293 | |
1294 /* Private functions ---------------------------------------------------------*/ | |
1295 | |
1296 /******************************************************************************** | |
1297 * @brief logbook_UpdateHeader. / | |
1298 * set date, time, max depth. etc. pp. | |
1299 * the internal pointer to the end of profile and length will be set by | |
1300 ext_flash_close_new_dive_log() in externLogbookFlash.c | |
1301 * @author heinrichs weikamp gmbh | |
1302 * @version V0.0.1 | |
1303 * @date 27-Nov-2014 | |
1304 *********************************************************************************/ | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1305 static void logbook_UpdateHeader(const SDiveState *pStateReal) |
38 | 1306 { |
1307 // uint16_t secondsAtShallow = 0; | |
1308 RTC_DateTypeDef Sdate; | |
1309 RTC_TimeTypeDef Stime; | |
1310 uint32_t time1_u32, time2_u32; | |
1311 uint32_t divetimeHelper; | |
1312 | |
1313 /* time and day */ | |
1314 /* don't update CHANGE 160224 hw, maybe save actual time and date at other place | |
1315 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); | |
1316 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); | |
1317 | |
1318 header.dateYear = Sdate.Year; | |
1319 header.dateMonth = Sdate.Month; | |
1320 header.dateDay = Sdate.Date; | |
1321 header.timeHour = Stime.Hours; | |
1322 header.timeMinute = Stime.Minutes; | |
1323 */ | |
1324 /// 160315 Quick fix for empty date problem | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1325 if((!(gheader.dateYear)) || (!(gheader.dateMonth)) || (!(gheader.dateDay))) |
38 | 1326 { |
1327 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); | |
1328 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); | |
1329 | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1330 gheader.dateYear = Sdate.Year; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1331 gheader.dateMonth = Sdate.Month; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1332 gheader.dateDay = Sdate.Date; |
38 | 1333 |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1334 time1_u32 = (uint32_t)gheader.timeMinute + (uint32_t)(gheader.timeHour * 60); |
38 | 1335 time2_u32 = (uint32_t)Stime.Minutes + (uint32_t)(Stime.Hours * 60); |
1336 if(time2_u32 < time1_u32) | |
1337 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1338 if(gheader.dateDay > 1) |
38 | 1339 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1340 gheader.dateDay -= 1; |
38 | 1341 } |
1342 else | |
1343 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1344 gheader.dateMonth --; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1345 if(!gheader.dateMonth) |
38 | 1346 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1347 gheader.dateYear--; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1348 gheader.dateMonth = 12; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1349 gheader.dateDay = 31; |
38 | 1350 } |
1351 else | |
1352 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1353 if(gheader.dateMonth == 2) |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1354 gheader.dateDay = 28; |
38 | 1355 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1356 if((gheader.dateMonth == 4) || (gheader.dateMonth == 6) || (gheader.dateMonth == 9) || (gheader.dateMonth == 11)) |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1357 gheader.dateDay = 30; |
38 | 1358 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1359 gheader.dateDay = 31; |
38 | 1360 } |
1361 } | |
1362 } | |
1363 } | |
1364 | |
1365 /* duration */ | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1366 gheader.total_diveTime_seconds = pStateReal->lifeData.dive_time_seconds; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1367 gheader.maxDepth = pStateReal->lifeData.max_depth_meter * 100; |
38 | 1368 |
1369 /* old: | |
1370 | |
1371 secondsAtShallow = pSettings->timeoutDiveReachedZeroDepth; | |
1372 if(pStateReal->lifeData.dive_time_seconds <= secondsAtShallow) | |
1373 secondsAtShallow = 0; | |
1374 header.diveTimeMinutes = (header.total_diveTime_seconds - secondsAtShallow )/ 60; | |
1375 header.diveTimeSeconds = header.total_diveTime_seconds - secondsAtShallow - (header.diveTimeMinutes * 60); | |
1376 */ | |
1377 divetimeHelper = pStateReal->lifeData.dive_time_seconds_without_surface_time; | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1378 gheader.diveTimeMinutes = (uint16_t)(divetimeHelper/60); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1379 divetimeHelper -= 60 * (uint32_t)gheader.diveTimeMinutes; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1380 gheader.diveTimeSeconds = (uint16_t)divetimeHelper; |
38 | 1381 |
1382 /* deco algorithm (final) */ | |
1383 if(pStateReal->diveSettings.deco_type.ub.standard == GF_MODE) | |
1384 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1385 gheader.decoModel = 1; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1386 gheader.gfLow_or_Vpm_conservatism = pStateReal->diveSettings.gf_low; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1387 gheader.gfHigh = pStateReal->diveSettings.gf_high; |
38 | 1388 } |
1389 else | |
1390 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1391 gheader.decoModel = 2; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1392 gheader.gfLow_or_Vpm_conservatism = pStateReal->diveSettings.vpm_conservatism; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1393 gheader.gfHigh = 0; |
38 | 1394 } |
1395 | |
1396 /* tissue load */ | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1397 memcpy(gheader.n2Compartments, pStateReal->lifeData.tissue_nitrogen_bar, 64); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1398 memcpy(gheader.heCompartments, pStateReal->lifeData.tissue_helium_bar, 64); |
38 | 1399 |
1400 } | |
1401 | |
1402 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1403 static void logbook_SetAverageDepth(float average_depth_meter) |
38 | 1404 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1405 gheader.averageDepth_mbar = (uint16_t)(average_depth_meter * 100); |
38 | 1406 } |
1407 | |
1408 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1409 static void logbook_SetMinTemperature(float min_temperature_celsius) |
38 | 1410 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1411 gheader.minTemp = (int16_t)((min_temperature_celsius * 10.0f) + 0.5f); |
38 | 1412 } |
1413 | |
1414 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1415 static void logbook_SetMaxCNS(float max_cns_percentage) |
38 | 1416 { |
1417 if(max_cns_percentage < 9999) | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1418 gheader.maxCNS = (uint16_t)(max_cns_percentage); |
38 | 1419 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1420 gheader.maxCNS = 9999; |
38 | 1421 } |
1422 | |
1423 | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1424 static void logbook_SetCompartmentDesaturation(const SDiveState * pStateReal) |
38 | 1425 { |
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
199
diff
changeset
|
1426 SLifeData2 secondaryInformation = { 0 }; |
38 | 1427 |
1428 decom_tissues_desaturation_time(&pStateReal->lifeData, &secondaryInformation); | |
1429 for(int i=0;i<16;i++) | |
1430 { | |
1431 if(secondaryInformation.tissue_nitrogen_desaturation_time_minutes[i] <= (15 * 255)) | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1432 gheader.n2CompartDesatTime_min[i] = (uint8_t)((secondaryInformation.tissue_nitrogen_desaturation_time_minutes[i] + 14) / 15); |
38 | 1433 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1434 gheader.n2CompartDesatTime_min[i] = 255; |
38 | 1435 if(secondaryInformation.tissue_helium_desaturation_time_minutes[i] <= (15 * 255)) |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1436 gheader.heCompartDesatTime_min[i] = (uint8_t)((secondaryInformation.tissue_helium_desaturation_time_minutes[i] + 14 )/ 15); |
38 | 1437 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1438 gheader.heCompartDesatTime_min[i] = 255; |
38 | 1439 } |
1440 } | |
1441 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1442 static void logbook_SetLastStop(float last_stop_depth_bar) |
38 | 1443 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1444 gheader.lastDecostop_m = (uint8_t)(last_stop_depth_bar / 10.0f); |
38 | 1445 } |
1446 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1447 static void logbook_writedata(void * data, int length_byte) |
38 | 1448 { |
1449 ext_flash_write_sample(data, length_byte); | |
1450 } | |
1451 | |
1452 /******************************************************************************** | |
1453 * @brief logbook_build_ostc3header. / | |
1454 * @author heinrichs weikamp gmbh | |
1455 * @version V0.0.2 | |
1456 * @date 27-Nov-2014 | |
1457 *********************************************************************************/ | |
1458 SLogbookHeaderOSTC3 * logbook_build_ostc3header(SLogbookHeader* pHead) | |
1459 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1460 convert_Type data,data2; |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1461 uint16_t dummyLength = 0; |
38 | 1462 |
1463 memcpy(headerOSTC3.diveHeaderStart, &pHead->diveHeaderStart, 2); | |
1464 memcpy(headerOSTC3.pBeginProfileData, &pHead->pBeginProfileData, 3); | |
1465 memcpy(headerOSTC3.pEndProfileData, &pHead->pEndProfileData, 3); | |
1466 | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1467 |
38 | 1468 data.u8bit.byteHigh = 0; |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1469 data.u8bit.byteLow = pHead->pBeginProfileData[0]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1470 data.u8bit.byteMidLow = pHead->pBeginProfileData[1]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1471 data.u8bit.byteMidHigh = pHead->pBeginProfileData[2]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1472 |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1473 data2.u8bit.byteHigh = 0; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1474 data2.u8bit.byteLow = pHead->pEndProfileData[0]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1475 data2.u8bit.byteMidLow = pHead->pEndProfileData[1]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1476 data2.u8bit.byteMidHigh = pHead->pEndProfileData[2]; |
38 | 1477 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1478 if( (pHead->pBeginProfileData[0] == 0) /* no sample data available => use dummy */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1479 &&(pHead->pBeginProfileData[1] == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1480 &&(pHead->pBeginProfileData[2] == 0)) |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1481 { |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1482 dummyLength = logbook_fillDummySampleBuffer(pHead->diveTimeMinutes, pHead->diveTimeSeconds,pHead->maxDepth |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1483 ,pHead->lastDecostop_m, pHead->minTemp); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1484 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1485 data2.u32bit = data.u32bit + dummyLength; /* calc new end address (which is equal to dummyLength) */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1486 data.u32bit = data2.u32bit; /* data is used below to represent the length */ |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1487 } |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1488 else |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1489 { |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1490 /* check if sample address information are corrupted by address range. */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1491 /* TODO: Workaround. Better solution would be to check end of ring for 0xFF pattern */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1492 if((data.u32bit > data2.u32bit) && (data.u32bit < (SAMPLESTOP - 0x9000))) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1493 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1494 data2.u32bit = data.u32bit + DEFAULT_SAMPLES; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1495 pHead->pEndProfileData[0] = data2.u8bit.byteLow; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1496 pHead->pEndProfileData[1] = data2.u8bit.byteMidLow; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1497 pHead->pEndProfileData[2] = data2.u8bit.byteMidHigh; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1498 data.u32bit = DEFAULT_SAMPLES; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1499 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1500 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1501 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1502 data.u8bit.byteHigh = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1503 data.u8bit.byteLow = pHead->profileLength[0]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1504 data.u8bit.byteMidLow = pHead->profileLength[1]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1505 data.u8bit.byteMidHigh = pHead->profileLength[2]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1506 } |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1507 } |
38 | 1508 if(data.u32bit != 0xFFFFFF) |
1509 data.u32bit += 3; | |
1510 | |
1511 headerOSTC3.profileLength[0] = data.u8bit.byteLow; | |
1512 headerOSTC3.profileLength[1] = data.u8bit.byteMidLow; | |
1513 headerOSTC3.profileLength[2] = data.u8bit.byteMidHigh; | |
1514 | |
1515 memcpy(headerOSTC3.gasordil, pHead->gasordil, 20); | |
1516 | |
1517 if(pHead->logbookProfileVersion == LOGBOOK_VERSION) | |
1518 { | |
1519 headerOSTC3.logbookProfileVersion = LOGBOOK_VERSION_OSTC3; | |
1520 memcpy(headerOSTC3.personalDiveCount, &pHead->personalDiveCount, 2); | |
1521 headerOSTC3.safetyDistance_10cm = 0; | |
1522 | |
1523 for(int i=0;i<5;i++) | |
1524 { | |
1525 if(!pHead->gasordil[i].note.ub.active) | |
1526 headerOSTC3.gasordil[3 + (i*4)] = 0; | |
1527 else if(pHead->gasordil[i].note.ub.first) | |
1528 { | |
1529 /* depth = 0, note = 1 */ | |
1530 headerOSTC3.gasordil[2 + (i*4)] = 0; | |
1531 headerOSTC3.gasordil[3 + (i*4)] = 1; | |
1532 } | |
1533 else if( pHead->gasordil[i].depth_meter) | |
1534 { | |
1535 /* note = 3 */ | |
1536 headerOSTC3.gasordil[3 + (i*4)] = 3; | |
1537 } | |
1538 } | |
1539 } | |
1540 else | |
1541 { | |
1542 headerOSTC3.logbookProfileVersion = 0xFF; | |
1543 headerOSTC3.personalDiveCount[0] = 0xFF; | |
1544 headerOSTC3.personalDiveCount[1] = 0xFF; | |
1545 headerOSTC3.safetyDistance_10cm = 0xFF; | |
1546 } | |
1547 | |
1548 headerOSTC3.dateYear = pHead->dateYear; | |
1549 headerOSTC3.dateMonth = pHead->dateMonth; | |
1550 headerOSTC3.dateDay = pHead->dateDay; | |
1551 headerOSTC3.timeHour = pHead->timeHour; | |
1552 headerOSTC3.timeMinute = pHead->timeMinute; | |
1553 | |
1554 | |
1555 memcpy(headerOSTC3.maxDepth, &pHead->maxDepth, 2); | |
1556 memcpy(headerOSTC3.diveTimeMinutes, &pHead->diveTimeMinutes, 2); | |
1557 | |
1558 headerOSTC3.diveTimeSeconds = pHead->diveTimeSeconds; | |
1559 | |
1560 memcpy(headerOSTC3.minTemp, &pHead->minTemp, 2); | |
1561 memcpy(headerOSTC3.surfacePressure_mbar,&pHead->surfacePressure_mbar, 2); | |
1562 memcpy(headerOSTC3.desaturationTime, &pHead->desaturationTime, 2); | |
1563 | |
1564 headerOSTC3.firmwareVersionHigh = pHead->firmwareVersionHigh; | |
1565 headerOSTC3.firmwareVersionLow = pHead->firmwareVersionLow; | |
1566 | |
1567 memcpy(headerOSTC3.batteryVoltage, &pHead->batteryVoltage, 2); | |
1568 | |
1569 headerOSTC3.samplingRate = pHead->samplingRate; | |
1570 | |
1571 memcpy(headerOSTC3.cnsAtBeginning, &pHead->cnsAtBeginning, 2); | |
1572 | |
1573 headerOSTC3.gfAtBeginning = pHead->gfAtBeginning; | |
1574 headerOSTC3.gfAtEnd = pHead->gfAtEnd; | |
1575 | |
1576 memcpy(headerOSTC3.setpoint, pHead->setpoint, 10); | |
1577 | |
1578 headerOSTC3.salinity = pHead->salinity; | |
1579 | |
1580 memcpy(headerOSTC3.maxCNS, &pHead->maxCNS, 2); | |
1581 memcpy(headerOSTC3.averageDepth_mbar, &pHead->averageDepth_mbar, 2); | |
1582 memcpy(headerOSTC3.total_diveTime_seconds,&pHead->total_diveTime_seconds, 2); | |
1583 | |
1584 headerOSTC3.gfLow_or_Vpm_conservatism = pHead->gfLow_or_Vpm_conservatism; | |
1585 headerOSTC3.gfHigh = pHead->gfHigh; | |
1586 headerOSTC3.decoModel = pHead->decoModel; | |
1587 | |
1588 memcpy(headerOSTC3.diveNumber, &pHead->diveNumber, 2); | |
1589 | |
1590 headerOSTC3.diveMode = pHead->diveMode; | |
1591 headerOSTC3.CCRmode = pHead->CCRmode; | |
1592 | |
1593 memcpy(headerOSTC3.n2CompartDesatTime_min,pHead->n2CompartDesatTime_min, 16); | |
1594 memcpy(headerOSTC3.n2Compartments, pHead->n2Compartments, 64); | |
1595 memcpy(headerOSTC3.heCompartDesatTime_min,pHead->heCompartDesatTime_min, 16); | |
1596 memcpy(headerOSTC3.heCompartments, pHead->heCompartments, 64); | |
1597 | |
1598 headerOSTC3.lastDecostop_m = pHead->lastDecostop_m; | |
1599 | |
1600 memcpy(headerOSTC3.hwHudBattery_mV, &pHead->hwHudBattery_mV, 2); | |
1601 | |
1602 headerOSTC3.hwHudLastStatus = pHead->hwHudLastStatus; | |
1603 | |
1604 memcpy(headerOSTC3.batteryGaugeRegisters,&pHead->batteryGaugeRegisters, 6); | |
1605 | |
1606 | |
1607 memcpy(headerOSTC3.diveHeaderEnd, &pHead->diveHeaderEnd, 2); | |
1608 | |
1609 return &headerOSTC3; | |
1610 } | |
1611 | |
1612 | |
1613 /******************************************************************************** | |
1614 * @brief logbook_build_ostc3header_compact. / | |
1615 * @author heinrichs weikamp gmbh | |
1616 * @version V0.0.1 | |
1617 * @date 31-Juli-2015 | |
1618 *********************************************************************************/ | |
1619 SLogbookHeaderOSTC3compact * logbook_build_ostc3header_compact(SLogbookHeader* pHead) | |
1620 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1621 convert_Type data, data2; |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1622 uint32_t dummyLength = 0; |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1623 |
38 | 1624 |
1625 data.u8bit.byteHigh = 0; | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1626 data.u8bit.byteLow = pHead->pBeginProfileData[0]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1627 data.u8bit.byteMidLow = pHead->pBeginProfileData[1]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1628 data.u8bit.byteMidHigh = pHead->pBeginProfileData[2]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1629 |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1630 data2.u8bit.byteHigh = 0; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1631 data2.u8bit.byteLow = pHead->pEndProfileData[0]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1632 data2.u8bit.byteMidLow = pHead->pEndProfileData[1]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1633 data2.u8bit.byteMidHigh = pHead->pEndProfileData[2]; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1634 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1635 if( (pHead->pBeginProfileData[0] == 0) /* no sample data available => use dummy */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1636 &&(pHead->pBeginProfileData[1] == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1637 &&(pHead->pBeginProfileData[2] == 0)) |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1638 { |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1639 dummyLength = logbook_fillDummySampleBuffer(pHead->diveTimeMinutes, pHead->diveTimeSeconds,pHead->maxDepth |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1640 ,pHead->lastDecostop_m, pHead->minTemp); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1641 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1642 data2.u32bit = data.u32bit + dummyLength; /* calc new end address (which is equal to dummyLength) */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1643 data.u32bit = data2.u32bit; /* data is used below to represent the length */ |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1644 } |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1645 else |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1646 { |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1647 /* check if sample address information are corrupted by address range. */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1648 /* TODO: Workaround. Better solution would be to check end of ring for 0xFF pattern */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1649 if((data.u32bit > data2.u32bit) && (data.u32bit < (SAMPLESTOP - 0x9000))) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1650 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1651 data2.u32bit = data.u32bit + DEFAULT_SAMPLES; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1652 pHead->pEndProfileData[0] = data2.u8bit.byteLow; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1653 pHead->pEndProfileData[1] = data2.u8bit.byteMidLow; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1654 pHead->pEndProfileData[2] = data2.u8bit.byteMidHigh; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1655 data.u32bit = DEFAULT_SAMPLES; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1656 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1657 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1658 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1659 data.u8bit.byteHigh = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1660 data.u8bit.byteLow = pHead->profileLength[0]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1661 data.u8bit.byteMidLow = pHead->profileLength[1]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1662 data.u8bit.byteMidHigh = pHead->profileLength[2]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1663 } |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1664 } |
38 | 1665 if(data.u32bit != 0xFFFFFF) |
1666 { | |
1667 data.u32bit += 3; | |
1668 | |
1669 headerOSTC3compact.profileLength[0] = data.u8bit.byteLow; | |
1670 headerOSTC3compact.profileLength[1] = data.u8bit.byteMidLow; | |
1671 headerOSTC3compact.profileLength[2] = data.u8bit.byteMidHigh; | |
1672 | |
1673 headerOSTC3compact.dateYear = pHead->dateYear; | |
1674 headerOSTC3compact.dateMonth = pHead->dateMonth; | |
1675 headerOSTC3compact.dateDay = pHead->dateDay; | |
1676 headerOSTC3compact.timeHour = pHead->timeHour; | |
1677 headerOSTC3compact.timeMinute = pHead->timeMinute; | |
1678 | |
1679 memcpy(headerOSTC3compact.maxDepth, &pHead->maxDepth, 2); | |
1680 memcpy(headerOSTC3compact.diveTimeMinutes, &pHead->diveTimeMinutes, 2); | |
1681 | |
1682 headerOSTC3compact.diveTimeSeconds = pHead->diveTimeSeconds; | |
1683 | |
1684 | |
1685 headerOSTC3compact.totalDiveNumberLow = pHead->diveNumber & 0xFF; | |
1686 headerOSTC3compact.totalDiveNumberHigh = (uint8_t)(pHead->diveNumber/256); | |
1687 headerOSTC3compact.profileVersion = 0x24; // Logbook-Profile version, 0x24 = date and time is start not end | |
1688 } | |
1689 else | |
1690 { | |
1691 memset(&headerOSTC3compact, 0xFF, sizeof(SLogbookHeaderOSTC3compact)); | |
1692 } | |
1693 return &headerOSTC3compact; | |
1694 } | |
1695 | |
1696 | |
1697 /** | |
1698 ****************************************************************************** | |
1699 * @brief logbook_readSampleData. / Reads sample data of whole logbook entry | |
281 | 1700 * @author heinrichs weikamp |
38 | 1701 * @version V0.0.1 |
1702 * @date 22-April-2014 | |
1703 ****************************************************************************** | |
1704 * | |
1705 * @param uint8_t StepBackwards: witch lookbook entry? | |
1706 * @param uint16_t length : maxlength of output arrays | |
1707 * @param int32_t* depth : output array | |
1708 * @param int16_t * gasid : output array | |
1709 * @param int32_t* temperature : output array | |
1710 * @param int32_t* ppo2 : output array | |
1711 * @param int32_t* cns : output array | |
1712 * @return length of output | |
1713 */ | |
1714 void logbook_recover_brokenlog(uint8_t headerId) | |
1715 { | |
1716 int16_t retVal; | |
1717 int32_t depthVal = 0; | |
1718 int16_t gasidVal = 0; | |
1719 int16_t setPointVal = 0; | |
1720 int16_t bailoutVal = 0; | |
1721 int32_t temperatureVal = 0; | |
1722 int32_t sensor1Val = 0; | |
1723 int32_t sensor2Val = 0; | |
1724 int32_t sensor3Val = 0; | |
1725 int32_t cnsVal = 0; | |
1726 SManualGas manualGasVal; | |
1727 | |
1728 //uint16_t* ppo2, uint16_t* cns# | |
1729 uint32_t bytesRead = 0; | |
1730 | |
1731 ext_flash_read_block_start(); | |
1732 ext_flash_read_next_sample_part((uint8_t*)&smallHeader, sizeof(SSmallHeader)); | |
1733 bytesRead += sizeof(SSmallHeader); | |
1734 | |
1735 clear_divisor(); | |
1736 | |
1737 | |
1738 int sampleCounter = 0; | |
1739 int maxdepth = 0; | |
1740 uint32_t avrdepth = 0; | |
1741 while (true) | |
1742 { | |
1743 | |
1744 ext_flash_set_entry_point(); | |
1745 divisorBackup = divisor; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1746 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL); |
38 | 1747 if(retVal == 0) |
1748 { | |
1749 //Error try to read again!!! | |
1750 ext_flash_reopen_read_sample_at_entry_point(); | |
1751 divisor = divisorBackup; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1752 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL); |
38 | 1753 |
1754 if(retVal == 0) | |
1755 { | |
1756 //Error try to read again!!! | |
1757 ext_flash_reopen_read_sample_at_entry_point(); | |
1758 divisor = divisorBackup; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1759 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL); |
38 | 1760 |
1761 if(retVal == 0) | |
1762 { | |
1763 ext_flash_reopen_read_sample_at_entry_point(); | |
1764 break; | |
1765 } | |
1766 | |
1767 } | |
1768 } | |
1769 if(depthVal > maxdepth) | |
1770 maxdepth = depthVal; | |
1771 avrdepth += depthVal; | |
1772 sampleCounter++; | |
1773 bytesRead +=retVal; | |
1774 } | |
1775 avrdepth/= sampleCounter; | |
1776 ext_flash_close_read_sample(); | |
1777 SLogbookHeader header; | |
1778 | |
1779 ext_flash_read_dive_header2((uint8_t*) &header, headerId, false); | |
1780 header.total_diveTime_seconds = sampleCounter * header.samplingRate; | |
1781 header.diveTimeMinutes = header.total_diveTime_seconds /60; | |
1782 header.diveTimeSeconds = header.total_diveTime_seconds - header.diveTimeMinutes * 60; | |
1783 header.maxDepth = maxdepth; | |
1784 header.averageDepth_mbar = avrdepth; | |
1785 SSettings * settings = settingsGetPointer(); | |
1786 settings->lastDiveLogId = headerId; | |
1787 ext_flash_close_new_dive_log((uint8_t *)&header); | |
1788 } | |
1789 | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1790 void logbook_createDummyProfile(uint16_t maxDepth, uint8_t lastDecostop_m, int16_t minTemp, uint16_t length, uint16_t* depth, int16_t* temperature) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1791 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1792 uint8_t drawDeco = 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1793 uint16_t index = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1794 uint16_t indexDescenStop = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1795 uint16_t indexAscendStart = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1796 uint16_t simDecentDepth = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1797 uint16_t simDecentStep = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1798 uint16_t simAcentDepth = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1799 uint16_t simAcentStep = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1800 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1801 simDecentStep = maxDepth / (length / 6); /* first 1/6 for descend */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1802 simAcentStep = maxDepth / (length / 3); /* first 1/3 for ascend */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1803 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1804 while((index < length) && (simDecentDepth < maxDepth)) /* draw decent */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1805 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1806 depth[index] = simDecentDepth; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1807 temperature[index] = minTemp; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1808 index++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1809 simDecentDepth += simDecentStep; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1810 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1811 indexDescenStop = index; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1812 index = length -1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1813 while((index > indexDescenStop) && (simAcentDepth < maxDepth)) /* draw ascend including max deco stop */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1814 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1815 depth[index] = simAcentDepth; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1816 temperature[index] = minTemp; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1817 if((drawDeco) && (simAcentDepth < lastDecostop_m)) /* draw deco step */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1818 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1819 drawDeco = length / 10; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1820 while (drawDeco) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1821 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1822 index--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1823 depth[index] = simAcentDepth; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1824 temperature[index] = minTemp; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1825 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1826 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1827 index--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1828 simAcentDepth += simAcentStep; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1829 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1830 indexAscendStart = index; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1831 index = indexDescenStop; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1832 while(index <= indexAscendStart) /* draw isobar dive phase */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1833 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1834 depth[index] = maxDepth; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1835 temperature[index] = minTemp; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1836 index++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1837 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1838 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1839 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1840 void logbook_resetDummy() |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1841 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1842 dummyWriteIdx = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1843 dummyReadIdx = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1844 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1845 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1846 void logbook_writeDummy(void* data, uint16_t length) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1847 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1848 memcpy(&dummyMemoryBuffer[dummyWriteIdx],(uint8_t *)data, length); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1849 dummyWriteIdx += length; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1850 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1851 void logbook_writeDummySample(uint16_t depth, int16_t temperature) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1852 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1853 uint8_t sample[10]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1854 int length = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1855 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1856 int i = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1857 for(i = 0; i <10 ;i++) sample[i] = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1858 addU16(sample, depth); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1859 length += 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1860 sample[2] = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1861 length++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1862 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1863 if(divisor.temperature == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1864 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1865 divisor.temperature = smallHeader.tempDivisor - 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1866 addS16(&sample[length], temperature); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1867 length += 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1868 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1869 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1870 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1871 divisor.temperature--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1872 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1873 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1874 logbook_writeDummy((void *) &smallDummyHeader,sizeof(smallDummyHeader)); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1875 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1876 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1877 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1878 uint16_t logbook_fillDummySampleBuffer(uint16_t diveMinutes, uint8_t diveSeconds, uint16_t maxDepth, uint8_t lastDecostop_m, int16_t minTemp) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1879 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1880 uint16_t depthArray[DUMMY_SAMPLES]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1881 int16_t temperatureArray[DUMMY_SAMPLES]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1882 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1883 uint16_t index = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1884 uint16_t dummyBufferSize = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1885 uint16_t dummyProfileLength = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1886 uint32_t overallSecond = diveMinutes * 60 + diveSeconds; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1887 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1888 logbook_resetDummy(); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1889 clear_divisor(); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1890 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1891 smallDummyHeader.profileLength[0] = 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1892 smallDummyHeader.profileLength[1] = 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1893 smallDummyHeader.profileLength[2] = 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1894 smallDummyHeader.samplingRate_seconds = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1895 smallDummyHeader.numDivisors = 7; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1896 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1897 smallDummyHeader.tempType = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1898 smallDummyHeader.tempLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1899 smallDummyHeader.tempDivisor = 6; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1900 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1901 smallDummyHeader.deco_ndlType = 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1902 smallDummyHeader.deco_ndlLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1903 smallDummyHeader.deco_ndlDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1904 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1905 /* GF in % at actual position */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1906 smallDummyHeader.gfType = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1907 smallDummyHeader.gfLength = 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1908 smallDummyHeader.gfDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1909 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1910 /* 3 Sensors: 8bit ppO2 in 0.01bar, 16bit voltage in 0,1mV */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1911 smallDummyHeader.ppo2Type = 3; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1912 smallDummyHeader.ppo2Length = 9; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1913 smallDummyHeader.ppo2Divisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1914 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1915 /* last 15 stops in minutes (last, second_to_last, ... */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1916 /* last stop depth is defined in header */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1917 smallDummyHeader.decoplanType = 4; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1918 smallDummyHeader.decoplanLength = 15; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1919 smallDummyHeader.decoplanDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1920 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1921 smallDummyHeader.cnsType = 5; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1922 smallDummyHeader.cnsLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1923 smallDummyHeader.cnsDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1924 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1925 smallDummyHeader.tankType = 6; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1926 smallDummyHeader.tankLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1927 smallDummyHeader.tankDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1928 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1929 if((overallSecond / smallDummyHeader.samplingRate_seconds) > DUMMY_SAMPLES) /* reduce sample interval to keep buffer size */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1930 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1931 smallDummyHeader.samplingRate_seconds = overallSecond / DUMMY_SAMPLES; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1932 dummyProfileLength = DUMMY_SAMPLES; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1933 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1934 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1935 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1936 dummyProfileLength = overallSecond / smallDummyHeader.samplingRate_seconds; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1937 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1938 logbook_writeDummy((void *) &smallDummyHeader,sizeof(smallDummyHeader)); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1939 logbook_createDummyProfile(maxDepth, lastDecostop_m, minTemp, dummyProfileLength, depthArray, temperatureArray); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1940 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1941 for (index = 0; index < dummyProfileLength; index++) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1942 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1943 logbook_writeDummySample(depthArray[index], temperatureArray[index]); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1944 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1945 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1946 dummyBufferSize = dummyWriteIdx; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1947 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1948 return dummyBufferSize; /* return size of dummy buffer */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1949 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1950 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1951 void logbook_readDummySamples(uint8_t* pTarget, uint16_t length) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1952 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1953 memcpy(pTarget,&dummyMemoryBuffer[dummyReadIdx],length); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1954 dummyReadIdx += length; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1955 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1956 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1957 |
38 | 1958 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |