foxBMS  1.4.0
The foxBMS Battery Management System API Documentation
redundancy.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file redundancy.c
44  * @author foxBMS Team
45  * @date 2020-07-31 (date of creation)
46  * @updated 2022-07-28 (date of last update)
47  * @version v1.4.0
48  * @ingroup APPLICATION
49  * @prefix MRC
50  *
51  * @brief Source file for handling redundancy between redundant cell voltage
52  * and cell temperature measurements
53  *
54  */
55 
56 /*========== Includes =======================================================*/
57 #include "redundancy.h"
58 
59 #include "bms.h"
60 #include "database.h"
61 #include "diag.h"
62 #include "foxmath.h"
63 #include "os.h"
64 #include "plausibility.h"
65 
66 /*========== Macros and Definitions =========================================*/
67 
68 /*========== Static Constant and Variable Definitions =======================*/
69 /** local copies of database tables */
70 /**@{*/
75 /**@}*/
76 
77 /** state of the redundancy module */
80  .lastRedundancy0CellVoltageTimestamp = 0u,
81  .lastBaseCelltemperatureTimestamp = 0u,
82  .lastRedundancy0CelltemperatureTimestamp = 0u,
83  .lastStringCurrentTimestamp = {0u},
84 };
85 
86 /*========== Extern Constant and Variable Definitions =======================*/
87 
88 /*========== Static Function Prototypes =====================================*/
89 /**
90  * @brief Check timestamp if measurement has been updated at least once.
91  * @param[in] timestamp timestamp of last measurement update
92  * @param[in] previousTimestamp timestamp of previously updated measurement
93  * @return true if measurement has been updated at least once, otherwise false
94  */
95 static bool MRC_MeasurementUpdatedAtLeastOnce(uint32_t timestamp, uint32_t previousTimestamp);
96 
97 /**
98  * @brief Check timestamp if measurement has been updated recently.
99  * @param[in] timestamp timestamp of last measurement update
100  * @param[in] previousTimestamp timestamp of previously updated measurement
101  * @param[in] timeInterval in systicks (type: uint32_t)
102  * @return true if measurement has recently been updated, otherwise false
103  */
105  uint32_t timestamp,
106  uint32_t previousTimestamp,
107  uint32_t timeInterval);
108 
109 /**
110  * @brief Function to validate results of cell voltage measurement
111  * @param[in] pCellVoltageBase base cell voltage measurement
112  * @param[in] pCellVoltageRedundancy0 redundant cell voltage measurement
113  * @return bool true, if measurement has been validated successfully and
114  * database entry needs to be updated, otherwise false.
115  */
117  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageBase,
118  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageRedundancy0);
119 
120 /**
121  * @brief Function to validate results of cell temperature measurement
122  * @param[in] pCellTemperatureBase base cell temperature measurement
123  * @param[in] pCellTemperatureRedundancy0 redundant cell temperature measurement
124  * @return bool true, if measurement has been validated successfully and
125  * database entry needs to be updated, otherwise false.
126  */
128  DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureBase,
129  DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureRedundancy0);
130 
131 /**
132  * @brief Function to validate results of current measurement
133  * @param[in] pTableCurrentSensor pointer to current measurements
134  */
135 static void MRC_ValidateCurrentMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor);
136 
137 /**
138  * @brief Function to validate results of string voltage measurement
139  * @param[in] pTableCurrentSensor pointer current sensor high voltage measurements
140  * @param[in] pTableCellVoltage pointer to cell voltage measurements
141  */
143  DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor,
144  DATA_BLOCK_CELL_VOLTAGE_s *pTableCellVoltage);
145 
146 /**
147  * @brief Function to validate HV battery voltage measurement
148  */
149 static void MRC_ValidateBatteryVoltageMeasurement(void);
150 
151 /**
152  * @brief Function to validate results of high voltage measurement and calculate
153  * battery voltage and high voltage bus voltage.
154  * @param[in] pTableCurrentSensor pointer current sensor high voltage measurements
155  */
157 
158 /**
159  * @brief Function to validate results of power measurement
160  * @param[in] pTableCurrentSensor pointer to power/current measurements
161  */
162 static void MRC_ValidatePowerMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor);
163 
164 /**
165  * @brief Function calculates minimum, maximum and average cell voltages.
166  * @param[in] pValidatedVoltages validated voltages from base and/or redundant measurements
167  * @param[out] pMinMaxAverageValues calculated cell voltage min/max/average values
168  * @return #STD_NOT_OK if all cell voltage are invalid and no minimum, maximum
169  * and average cell voltage values could be calculated, otherwise #STD_OK
170  */
172  const DATA_BLOCK_CELL_VOLTAGE_s *const pValidatedVoltages,
173  DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues);
174 
175 /**
176  * @brief Function calculates minimum, maximum and average cell temperatures.
177  * @param[in] pValidatedTemperatures validated temperatures from base and/or redundant measurements
178  * @param[out] pMinMaxAverageValues calculated cell temperature min/max/average values
179  * @return #STD_NOT_OK if all cell temperatures are invalid and no minimum, maximum
180  * and average cell temperature values could be calculated, otherwise #STD_OK
181  */
183  DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures,
184  DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues);
185 
186 /**
187  * @brief Function compares cell voltage measurements from base measurement with
188  * one redundant measurement and writes result in pValidatedVoltages.
189  * @param[in] pCellVoltageBase base cell voltage measurement
190  * @param[in] pCellVoltageRedundancy0 redundant cell voltage measurement
191  * @param[out] pValidatedVoltages validated voltages from redundant measurement values
192  * @return #STD_NOT_OK if not all cell voltages could be validated, otherwise
193  * #STD_OK
194  */
196  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageBase,
197  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageRedundancy0,
198  DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages);
199 
200 /**
201  * @brief Function updates validated cell voltage measurement with data from a
202  * single measurement source. This can be the case if no redundancy is
203  * used at all or if one or more of the redundant measurements are not
204  * working properly.
205  * @param[in] pCellVoltage cell voltage measurement
206  * @param[out] pValidatedVoltages validated voltage values
207  * @return #STD_NOT_OK if not all cell voltages could be validated, otherwise
208  * #STD_OK
209  */
211  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltage,
212  DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages);
213 
214 /**
215  * @brief Function compares cell temperature measurements from base measurement
216  * with one redundant measurement and writes result in pValidatedTemperatures.
217  * @param[in] pCelltemperatureBase base cell temperature measurement
218  * @param[in] pCelltemperatureRedundancy0 redundant cell temperature measurement
219  * @param[out] pValidatedTemperatures validated temperatures from redundant measurement values
220  * @return #STD_NOT_OK if not all cell voltages could be validated, otherwise
221  * #STD_OK
222  */
224  DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureBase,
225  DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureRedundancy0,
226  DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures);
227 
228 /**
229  * @brief Function updates validated cell temperature measurement with data from a
230  * single measurement source. This can be the case if no redundancy is
231  * used at all or if one or more of the redundant measurements are not
232  * working properly.
233  * @param[in] pCellTemperature cell temperature measurement
234  * @param[out] pValidatedTemperature validated temperature values
235  * @return #STD_NOT_OK if not all cell voltages could be validated, otherwise
236  * #STD_OK
237  */
239  DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperature,
240  DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperature);
241 
242 /*========== Static Function Implementations ================================*/
243 static bool MRC_MeasurementUpdatedAtLeastOnce(uint32_t timestamp, uint32_t previousTimestamp) {
244  bool retval = false;
245  if (!((timestamp == 0u) && (previousTimestamp == 0u))) {
246  /* Only possibility for timestamp AND previous timestamp to be 0 is, if
247  the measurement has never been updated. Thus, if this is not the case
248  the measurement must have been updated */
249  retval = true;
250  }
251  return retval;
252 }
253 
255  uint32_t timestamp,
256  uint32_t previousTimestamp,
257  uint32_t timeInterval) {
258  STD_RETURN_TYPE_e retval = STD_NOT_OK;
259  uint32_t currentTimestamp = OS_GetTickCount();
260 
261  /* Unsigned integer arithmetic also works correctly if currentTimestamp is
262  larger than pHeader->timestamp (timer overflow), thus no need to use abs() */
263  if (((currentTimestamp - timestamp) <= timeInterval) &&
264  (MRC_MeasurementUpdatedAtLeastOnce(timestamp, previousTimestamp) == true)) {
265  /* Difference between current timestamp and last update timestamp is
266  smaller than passed time interval */
267  retval = STD_OK;
268  }
269  return retval;
270 }
271 
273  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageBase,
274  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageRedundancy0) {
275  FAS_ASSERT(pCellVoltageBase != NULL_PTR);
276  FAS_ASSERT(pCellVoltageRedundancy0 != NULL_PTR);
277 
278  bool updatedValidatedVoltageDatbaseEntry = false;
279 
280  bool baseCellVoltageUpdated = false;
281 
282  bool useCellVoltageRedundancy = false;
283  bool baseCellVoltageMeasurementTimeoutReached = true;
284  bool redundancy0CellVoltageMeasurementTimeoutReached = true;
285 
286  /* Following decision will be undertaken:
287  *
288  * - Use redundancy only if timestamp of redundant database entry != 0
289  * - Perform redundant check if both timestamps have been updated
290  * - Add timeout and trigger error if timestamps have not been updated in the last XXXXms
291  * - If timeout reached and only one of the two redundant measurements has been updated use this measurement value
292  * but throw an error that one measurement has not been updated recently.
293  */
294 
295  /* -------------- Check if cell voltage redundant measurement is used -- */
296  /* Use redundant cell voltage measurements if measurement values have been acquired once */
297  useCellVoltageRedundancy = DATA_DatabaseEntryUpdatedAtLeastOnce(pCellVoltageRedundancy0->header);
298 
299  /* ----------------- Check timestamp of base measurements--------------- */
301  baseCellVoltageMeasurementTimeoutReached = false;
303  } else {
304  baseCellVoltageMeasurementTimeoutReached = true;
305  /* Set error flag */
307  }
308 
309  /* Check if base measurement values have been updated since last MRC */
310  if (mrc_state.lastBaseCellVoltageTimestamp != pCellVoltageBase->header.timestamp) {
311  baseCellVoltageUpdated = true;
312  } else {
313  baseCellVoltageUpdated = false;
314  }
315 
316  /* ----------------- Check timestamp of redundant measurements --------- */
318  false) &&
319  (useCellVoltageRedundancy == true)) {
320  redundancy0CellVoltageMeasurementTimeoutReached = true;
321  /* Set error flag */
323  } else {
324  redundancy0CellVoltageMeasurementTimeoutReached = false;
326  }
327 
328  /* ----------------- Validate cell voltages ---------------------------- */
329  if (useCellVoltageRedundancy == true) {
330  bool redundany0CellVoltageUpdated = false;
331  /* Check if redundant measurement values have been updated since last MRC */
332  if (mrc_state.lastRedundancy0CellVoltageTimestamp != pCellVoltageRedundancy0->header.timestamp) {
333  redundany0CellVoltageUpdated = true;
334  } else {
335  redundany0CellVoltageUpdated = false;
336  }
337  /* Make sure cell voltage timestamps have been updated since last call */
338  if ((baseCellVoltageUpdated == true) && (redundany0CellVoltageUpdated == true)) {
339  /* Update timestamp */
342 
343  /* Validate cell voltages */
344  MRC_ValidateCellVoltage(pCellVoltageBase, pCellVoltageRedundancy0, &mrc_tableCellVoltages);
345  /* Set to true for following minimum, maximum and average calculation */
346  updatedValidatedVoltageDatbaseEntry = true;
347  } else if ((baseCellVoltageUpdated == true) || (redundany0CellVoltageUpdated == true)) {
348  /* At least one measurement has been updated */
349  if (baseCellVoltageUpdated == true) {
350  /* Has redundant measurement timeout been reached? If yes, update. */
351  if (redundancy0CellVoltageMeasurementTimeoutReached == true) {
352  /* Copy cell voltage base measurement values into validated database struct */
354  /* Set to true for following minimum, maximum and average calculation */
355  updatedValidatedVoltageDatbaseEntry = true;
356  }
357  } else if (redundany0CellVoltageUpdated == true) {
358  /* Has base measurement timeout been reached? If yes, update. */
359  if (baseCellVoltageMeasurementTimeoutReached == true) {
360  /* Copy cell voltage base measurement values into validated database struct */
361  MRC_UpdateCellVoltageValidation(pCellVoltageRedundancy0, &mrc_tableCellVoltages);
362  /* Set to true for following minimum, maximum and average calculation */
363  updatedValidatedVoltageDatbaseEntry = true;
364  }
365  } else {
367  }
368  } else {
369  /* No cell voltage measurement has been updated -> do nothing */
370  }
371  } else {
372  if (baseCellVoltageUpdated == true) {
373  /* Only update database entries if new raw data has been acquired */
374  /* Update timestamp */
376 
377  /* Copy cell voltage base measurement values into validated database struct */
379 
380  /* Set to true for following minimum, maximum and average calculation */
381  updatedValidatedVoltageDatbaseEntry = true;
382  }
383  }
384 
385  if (updatedValidatedVoltageDatbaseEntry == true) {
386  /* Calculate min/max/average cell voltages */
388 
389  /* Individual cell voltages validated and min/max/average calculated -> check voltage spread */
391  /* Recalculate min/max/average cell voltages as at least one cell voltage has been detected as invalid */
393  }
394  }
395 
396  return updatedValidatedVoltageDatbaseEntry;
397 }
398 
400  DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureBase,
401  DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureRedundancy0) {
402  FAS_ASSERT(pCellTemperatureBase != NULL_PTR);
403  FAS_ASSERT(pCellTemperatureRedundancy0 != NULL_PTR);
404 
405  bool baseCelltemperatureUpdated = false;
406  bool useCelltemperatureRedundancy = false;
407  bool updatedValidatedTemperatureDatbaseEntry = false;
408 
409  bool baseCellTemperatureMeasurementTimeoutReached = true;
410  bool redundancy0CellTemperatureMeasurementTimeoutReached = true;
411 
412  /* Following decision will be undertaken:
413  *
414  * - Use redundancy only if timestamp of redundant database entry != 0
415  * - Perform redundant check if both timestamps have been updated
416  * - Add timeout and trigger error if timestamps have not been updated in the last XXXXms
417  * - If timeout reached and only one of the two redundant measurements has been updated use this measurement value
418  * but throw an error that one measurement has not been updated recently.
419  */
420 
421  /* -------------- Check if cell cell temperature redundant measurement is used ---------- */
422  /* Use redundant cell voltage measurements if measurement values have been acquired once */
423  useCelltemperatureRedundancy = DATA_DatabaseEntryUpdatedAtLeastOnce(pCellTemperatureRedundancy0->header);
424 
425  /* ----------------- Check timestamp of base measurements--------------- */
427  baseCellTemperatureMeasurementTimeoutReached = false;
429  } else {
430  baseCellTemperatureMeasurementTimeoutReached = true;
431  /* Set error flag */
433  }
434  /* Check if base measurement values have been updated since last MRC */
435  if (mrc_state.lastBaseCelltemperatureTimestamp != pCellTemperatureBase->header.timestamp) {
436  baseCelltemperatureUpdated = true;
437  } else {
438  baseCelltemperatureUpdated = false;
439  }
440 
441  /* ----------------- Check timestamp of redundant measurements --------- */
443  false) &&
444  (useCelltemperatureRedundancy == true)) {
445  redundancy0CellTemperatureMeasurementTimeoutReached = true;
446  /* Set error flag */
447  (void)DIAG_Handler(
449  } else {
450  redundancy0CellTemperatureMeasurementTimeoutReached = false;
452  }
453 
454  /* ----------------- Validate cell temperatures ------------------------ */
455  if (useCelltemperatureRedundancy == true) {
456  bool redundancy0CelltemperatureUpdated = false;
457  /* Check if redundant measurement values have been updated since last MRC */
458  if (mrc_state.lastRedundancy0CelltemperatureTimestamp != pCellTemperatureRedundancy0->header.timestamp) {
459  redundancy0CelltemperatureUpdated = true;
460  } else {
461  redundancy0CelltemperatureUpdated = false;
462  }
463  /* Make sure cell voltage timestamps have been updated since last call */
464  if ((baseCelltemperatureUpdated == true) && (redundancy0CelltemperatureUpdated == true)) {
465  /* Update timestamp */
467  mrc_state.lastRedundancy0CelltemperatureTimestamp = pCellTemperatureRedundancy0->header.timestamp;
468 
469  /* Validate cell temperatures */
470  MRC_ValidateCellTemperature(pCellTemperatureBase, pCellTemperatureRedundancy0, &mrc_tableCellTemperatures);
471  /* Set to true for following minimum, maximum and average calculation */
472  updatedValidatedTemperatureDatbaseEntry = true;
473  } else if ((baseCelltemperatureUpdated == true) || (redundancy0CelltemperatureUpdated == true)) {
474  /* At least one measurement has been updated */
475  if (baseCelltemperatureUpdated == true) {
476  /* Has redundant measurement timeout been reached? If yes, update. */
477  if (redundancy0CellTemperatureMeasurementTimeoutReached == true) {
478  /* Copy cell temperature base measurement values into validated database struct */
480  /* Set to true for following minimum, maximum and average calculation */
481  updatedValidatedTemperatureDatbaseEntry = true;
482  }
483  } else if (redundancy0CelltemperatureUpdated == true) {
484  /* Has base measurement timeout been reached? If yes, update. */
485  if (baseCellTemperatureMeasurementTimeoutReached == true) {
486  /* Copy cell temperature redundant measurement values into validated database struct */
487  MRC_UpdateCellTemperatureValidation(pCellTemperatureRedundancy0, &mrc_tableCellTemperatures);
488  /* Set to true for following minimum, maximum and average calculation */
489  updatedValidatedTemperatureDatbaseEntry = true;
490  }
491  } else {
493  }
494  } else {
495  /* No cell temperature measurement has been updated -> do nothing */
496  }
497  } else { /* useCelltemperatureRedundancy == true */
498  if (baseCelltemperatureUpdated == true) {
499  /* Only update database entries if new raw data has been acquired */
500  /* Update timestamp */
502 
503  /* Copy cell temperature base measurement values into validated database struct */
505 
506  /* Set to true for following minimum, maximum and average calculation */
507  updatedValidatedTemperatureDatbaseEntry = true;
508  }
509  }
510 
511  if (updatedValidatedTemperatureDatbaseEntry == true) {
512  /* Calculate min/max/average cell temperatures */
514 
515  /* Individual cell temperatures validated and min/max/average calculated -> check temperature spread */
517  /* Recalculate min/max/average temperatures as at least one temperature has been detected as invalid */
519  }
520  }
521 
522  return updatedValidatedTemperatureDatbaseEntry;
523 }
524 
526  FAS_ASSERT(pTableCurrentSensor != NULL_PTR);
527  int32_t packCurrent_mA = 0;
528 
529  /* Validate pack current. Will be invalidated if not all current measurement values are valid */
531 
532  /* Iterate over all strings to calculate pack current */
533  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
534  /* Check timestamp of measurement */
536  pTableCurrentSensor->timestampCurrent[s],
537  pTableCurrentSensor->previousTimestampCurrent[s],
540 
541  if (noTimeout == STD_OK) {
542  /* Check if current entry has been updated since last call */
543  if (mrc_state.lastStringCurrentTimestamp[s] != pTableCurrentSensor->timestampCurrent[s]) {
544  mrc_state.lastStringCurrentTimestamp[s] = pTableCurrentSensor->timestampCurrent[s];
545  mrc_tablePackValues.stringCurrent_mA[s] = pTableCurrentSensor->current_mA[s];
546  if (pTableCurrentSensor->invalidCurrentMeasurement[s] == 0u) {
547  /* String current measurement valid -> set valid flag */
550  } else {
551  /* String current measurement invalid -> set invalid flag */
554  }
555  } else {
556  /* Nothing to do. Measurement has not been updated but still within timeout */
557  }
558  } else {
559  /* Measurement timeout reached -> set string current invalid */
561  }
562 
564  packCurrent_mA += mrc_tablePackValues.stringCurrent_mA[s];
565  } else {
566  /* One string current is invalid -> pack current cannot be correct.
567  * Set pack current invalid */
569  }
570  }
571  mrc_tablePackValues.packCurrent_mA = packCurrent_mA;
572 }
573 
575  DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor,
576  DATA_BLOCK_CELL_VOLTAGE_s *pTableCellVoltage) {
577  /* Pointer validity check */
578  FAS_ASSERT(pTableCurrentSensor != NULL_PTR);
579  FAS_ASSERT(pTableCellVoltage != NULL_PTR);
580 
581  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
582  /* Check timeout of current sensor measurement */
584  pTableCurrentSensor->timestampHighVoltage[s][0u],
585  pTableCurrentSensor->previousTimestampHighVoltage[s][0u],
588 
589  /* Perform plausibility check if AFE and new current sensor measurement is valid */
590  if ((updatedMeasurement == STD_OK) && (pTableCurrentSensor->invalidHighVoltageMeasurement[s][0u] == 0u) &&
591  (pTableCellVoltage->nrValidCellVoltages[s] == BS_NR_OF_CELL_BLOCKS_PER_STRING)) {
592  STD_RETURN_TYPE_e voltagePlausible =
593  PL_CheckStringVoltage(pTableCellVoltage->packVoltage_mV[s], pTableCurrentSensor->highVoltage_mV[s][0u]);
595 
596  /* Use current sensor measurement */ /* TODO: use really current sensor? Average of both? AFE measurement? */
597  mrc_tablePackValues.stringVoltage_mV[s] = pTableCurrentSensor->highVoltage_mV[s][0u];
598 
599  if (voltagePlausible == STD_OK) {
601  } else {
603  }
604  } else {
605  /* Plausibility check cannot be performed if we do not have valid
606  * values from AFE and current sensor measurement */
608 
609  if ((updatedMeasurement == STD_OK) && (pTableCurrentSensor->invalidHighVoltageMeasurement[s][0u] == 0u)) {
610  /* Current sensor measurement valid -> use this measurement */
611  mrc_tablePackValues.stringVoltage_mV[s] = pTableCurrentSensor->highVoltage_mV[s][0u];
613  } else if (pTableCellVoltage->nrValidCellVoltages[s] == BS_NR_OF_CELL_BLOCKS_PER_STRING) {
614  /* AFE measurement valid -> use this measurement */
615  mrc_tablePackValues.stringVoltage_mV[s] = pTableCellVoltage->packVoltage_mV[s];
617  } else {
618  /* AFE and current sensor measurement invalid -> try to construct
619  * a valid from the number of valid cell voltages and substitute
620  * invalid cell voltages with the average cell voltage. */
621  uint16_t numberInvalidCellVoltages =
622  (BS_NR_OF_CELL_BLOCKS_PER_STRING - pTableCellVoltage->nrValidCellVoltages[s]);
623 
625  pTableCellVoltage->packVoltage_mV[s] +
626  (mrc_tableMinimumMaximumValues.averageCellVoltage_mV[s] * (int16_t)numberInvalidCellVoltages);
627 
628  /* Only use this as valid value if not more than five cell voltages are invalid */
629  if (numberInvalidCellVoltages > MRC_ALLOWED_NUMBER_OF_INVALID_CELL_VOLTAGES) {
631  } else {
633  }
634  }
635  }
636  }
637 }
638 
640  int64_t sumOfStringValues_mV = 0;
641  int8_t numberOfValidStringVoltages = 0;
642  uint8_t numberOfConnectedStrings = BMS_GetNumberOfConnectedStrings();
643 
644  if (0u != numberOfConnectedStrings) {
645  /* Iterate over all strings to see which strings are connected */
646  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
647  bool isStringConnected = BMS_IsStringClosed(s);
648  if ((mrc_tablePackValues.invalidStringVoltage[s] == 0u) && (isStringConnected == true)) {
649  /* AXIVION Disable Style MisraC2012Directive-4.1: Values start with 0, iteration is less than UINT8_MAX; overflow impossible */
650  sumOfStringValues_mV += mrc_tablePackValues.stringVoltage_mV[s];
651  numberOfValidStringVoltages++;
652  /* AXIVION Enable Style MisraC2012Directive-4.1: */
653  }
654  }
655  } else {
656  /* Take average of all strings if no strings are connected */
657  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
659  /* AXIVION Disable Style MisraC2012Directive-4.1: Values start with 0, iteration is less than UINT8_MAX; overflow impossible */
660  sumOfStringValues_mV += mrc_tablePackValues.stringVoltage_mV[s];
661  numberOfValidStringVoltages++;
662  /* AXIVION Enable Style MisraC2012Directive-4.1: */
663  }
664  }
665  }
666 
667  /* Only calculate average if at least one string voltage is valid */
668  if (0 != numberOfValidStringVoltages) {
669  /* AXIVION Next Codeline Style MisraC2012Directive-4.1: truncation impossible;
670  we sum INT32 values x times and divide by x, resulting in INT32 */
671  mrc_tablePackValues.batteryVoltage_mV = (int32_t)(sumOfStringValues_mV / numberOfValidStringVoltages);
672  } else {
674  }
675 }
676 
678  FAS_ASSERT(pTableCurrentSensor != NULL_PTR);
679 
680  int32_t sum_mV = 0;
681  uint8_t validVoltages = 0u;
682  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
683  /* Check timeout of current sensor measurement */
685  pTableCurrentSensor->timestampHighVoltage[s][2u],
686  pTableCurrentSensor->previousTimestampHighVoltage[s][2u],
689 
690  const bool stringClosed = BMS_IsStringClosed(s);
691  const bool stringPrecharging = BMS_IsStringPrecharging(s);
692  if (((stringPrecharging == true) || (stringClosed == true)) && (updatedMeasurement == STD_OK)) {
693  /* Only voltages of connected strings can be used */
694  if (pTableCurrentSensor->invalidHighVoltageMeasurement[s][2] == 0u) {
695  /* Measured high voltage is valid */
696  validVoltages++;
697  sum_mV += pTableCurrentSensor->highVoltage_mV[s][2];
698  }
699  }
700  }
701 
702  if (validVoltages > 0u) {
703  mrc_tablePackValues.highVoltageBusVoltage_mV = (sum_mV / (int32_t)validVoltages);
705  } else {
706  /* TODO: do we want to write special data if no valid values can be read? */
708  }
709 }
710 
712  FAS_ASSERT(pTableCurrentSensor != NULL_PTR);
713  bool calculatePower = false;
714  int32_t packPower_W = 0;
715 
716  /* Validate pack power. Will be invalidated if not all power measurement values are valid */
718 
719  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
720  /* Check timeout of current sensor measurement */
722  pTableCurrentSensor->timestampPower[s],
723  pTableCurrentSensor->previousTimestampPower[s],
726 
727  if (noTimeout == STD_OK) {
728  /* Check if current sensor measurement has been updated */
729  if (pTableCurrentSensor->timestampPower[s] != mrc_state.lastStringPowerTimestamp[s]) {
730  mrc_state.lastStringPowerTimestamp[s] = pTableCurrentSensor->timestampPower[s];
731  /* Check if measurement is valid */
732  if (pTableCurrentSensor->invalidPowerMeasurement[s] == 0u) {
733  mrc_tablePackValues.stringPower_W[s] = pTableCurrentSensor->power_W[s];
735  } else {
736  /* Measurement has been updated but value is invalid -> calculate from current and string voltage */
737  calculatePower = true;
738  /* TODO: do we want to calculate values by hand if we are within time limit but value is invalid? */
739  }
740  } else {
741  /* Nothing to do. Measurement has not been updated but still within timeout */
742  }
743  } else {
744  /* Timeout reached. Set invalid flag */
745  calculatePower = true;
747  }
748  if ((calculatePower == true) && (mrc_tablePackValues.invalidStringCurrent[s] == 0u) &&
750  /* Power measurement is invalid, but current and string voltage measurement are valid */
751  int64_t stringPower_W =
753  (UNIT_CONVERSION_FACTOR_1000_INTEGER * /* convert: mV -> V */
754  UNIT_CONVERSION_FACTOR_1000_INTEGER)); /* convert: mA -> A */
755  mrc_tablePackValues.stringPower_W[s] = (int32_t)stringPower_W;
757  }
759  packPower_W += mrc_tablePackValues.stringPower_W[s];
761  } else {
762  /* One string power is invalid -> pack power cannot be correct.
763  * Set pack power invalid */
766  }
767  }
768  mrc_tablePackValues.packPower_W = packPower_W;
769 }
770 
772  const DATA_BLOCK_CELL_VOLTAGE_s *const pValidatedVoltages,
773  DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues) {
774  /* Pointer validity check */
775  FAS_ASSERT(pValidatedVoltages != NULL_PTR);
776  FAS_ASSERT(pMinMaxAverageValues != NULL_PTR);
777 
778  STD_RETURN_TYPE_e retval = STD_OK;
779 
780  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
781  uint16_t nrValidCellVoltages = 0u;
782  int16_t min = INT16_MAX;
783  int16_t max = INT16_MIN;
784  int32_t sum = 0;
785  uint16_t moduleNumberMinimum = 0u;
786  uint16_t cellNumberMinimum = 0u;
787  uint16_t moduleNumberMaximum = 0u;
788  uint16_t cellNumberMaximum = 0u;
789  /* Iterate over all cells in each string */
790  for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) {
791  for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) {
792  if ((pValidatedVoltages->invalidCellVoltage[s][m] & (0x01u << c)) == 0u) {
793  /* Cell voltage is valid -> use this voltage for subsequent calculations */
794  nrValidCellVoltages++;
795  sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c];
796 
797  if (pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] < min) {
798  min = pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c];
799  moduleNumberMinimum = m;
800  cellNumberMinimum = c;
801  }
802  if (pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] > max) {
803  max = pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c];
804  moduleNumberMaximum = m;
805  cellNumberMaximum = c;
806  }
807  }
808  }
809  }
810  pMinMaxAverageValues->minimumCellVoltage_mV[s] = min;
811  pMinMaxAverageValues->nrCellMinimumCellVoltage[s] = cellNumberMinimum;
812  pMinMaxAverageValues->nrModuleMinimumCellVoltage[s] = moduleNumberMinimum;
813  pMinMaxAverageValues->maximumCellVoltage_mV[s] = max;
814  pMinMaxAverageValues->nrCellMaximumCellVoltage[s] = cellNumberMaximum;
815  pMinMaxAverageValues->nrModuleMaximumCellVoltage[s] = moduleNumberMaximum;
816  pMinMaxAverageValues->validMeasuredCellVoltages[s] = nrValidCellVoltages;
817 
818  /* Prevent division by 0, if all cell voltages are invalid */
819  if (nrValidCellVoltages > 0u) {
820  pMinMaxAverageValues->averageCellVoltage_mV[s] = (int16_t)(sum / (int32_t)nrValidCellVoltages);
821  } else {
822  pMinMaxAverageValues->averageCellVoltage_mV[s] = 0;
823  retval = STD_NOT_OK;
824  }
825  }
826  return retval;
827 }
828 
830  DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures,
831  DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues) {
832  /* Pointer validity check */
833  FAS_ASSERT(pValidatedTemperatures != NULL_PTR);
834  FAS_ASSERT(pMinMaxAverageValues != NULL_PTR);
835 
836  STD_RETURN_TYPE_e retval = STD_OK;
837 
838  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
839  uint16_t moduleNumberMinimum = 0u;
840  uint16_t sensorNumberMinimum = 0u;
841  uint16_t moduleNumberMaximum = 0u;
842  uint16_t sensorNumberMaximum = 0u;
843  uint16_t nrValidCelltemperatures = 0u;
844  int16_t min = INT16_MAX;
845  int16_t max = INT16_MIN;
846  float sum_ddegC = 0.0f;
847 
848  for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) {
849  for (uint8_t c = 0u; c < BS_NR_OF_TEMP_SENSORS_PER_MODULE; c++) {
850  if ((pValidatedTemperatures->invalidCellTemperature[s][m] & (0x01u << c)) == 0u) {
851  /* Cell temperature is valid -> use this voltage for subsequent calculations */
852  nrValidCelltemperatures++;
853  sum_ddegC += (float)pValidatedTemperatures
854  ->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c];
855 
856  if (pValidatedTemperatures->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c] <
857  min) {
858  min = pValidatedTemperatures
860  moduleNumberMinimum = m;
861  sensorNumberMinimum = c;
862  }
863  if (pValidatedTemperatures->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c] >
864  max) {
865  max = pValidatedTemperatures
867  moduleNumberMaximum = m;
868  sensorNumberMaximum = c;
869  }
870  }
871  }
872  }
873  pMinMaxAverageValues->minimumTemperature_ddegC[s] = min;
874  pMinMaxAverageValues->nrSensorMinimumTemperature[s] = sensorNumberMinimum;
875  pMinMaxAverageValues->nrModuleMinimumTemperature[s] = moduleNumberMinimum;
876  pMinMaxAverageValues->maximumTemperature_ddegC[s] = max;
877  pMinMaxAverageValues->nrSensorMaximumTemperature[s] = sensorNumberMaximum;
878  pMinMaxAverageValues->nrModuleMaximumTemperature[s] = moduleNumberMaximum;
879  pMinMaxAverageValues->validMeasuredCellTemperatures[s] = nrValidCelltemperatures;
880 
881  /* Prevent division by 0, if all cell voltages are invalid */
882  if (nrValidCelltemperatures > 0u) {
883  pMinMaxAverageValues->averageTemperature_ddegC[s] = (sum_ddegC / (float)nrValidCelltemperatures);
884  } else {
885  pMinMaxAverageValues->averageTemperature_ddegC[s] = 0.0f;
886  retval = STD_NOT_OK;
887  }
888  }
889  return retval;
890 }
891 
893  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageBase,
894  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageRedundancy0,
895  DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages) {
896  /* Pointer validity check */
897  FAS_ASSERT(pCellVoltageBase != NULL_PTR);
898  FAS_ASSERT(pCellVoltageRedundancy0 != NULL_PTR);
899  FAS_ASSERT(pValidatedVoltages != NULL_PTR);
900 
901  uint16_t numberValidMeasurements = 0u;
902  STD_RETURN_TYPE_e noPlausibilityIssueDetected = STD_OK; /* Flag if implausible value detected */
903  STD_RETURN_TYPE_e retval = STD_OK;
904 
905  /* Iterate over all cell measurements */
906  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
907  int32_t sum = 0;
908  for (uint8_t m = 0; m < BS_NR_OF_MODULES_PER_STRING; m++) {
909  for (uint8_t c = 0; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) {
910  if (((pCellVoltageBase->invalidCellVoltage[s][m] & (1u << c)) == 0u) &&
911  ((pCellVoltageRedundancy0->invalidCellVoltage[s][m] & (1u << c)) == 0u)) {
912  /* Check if cell voltage of base AND redundant measurement is valid -> do plausibility check */
913  if (STD_OK ==
915  pCellVoltageBase->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c],
916  pCellVoltageRedundancy0->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c],
917  &pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c])) {
918  /* Clear valid flag */
919  pValidatedVoltages->invalidCellVoltage[s][m] = pValidatedVoltages->invalidCellVoltage[s][m] &
920  (~(1u << c));
921  numberValidMeasurements++;
922  sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c];
923  } else {
924  /* Set invalid flag */
925  noPlausibilityIssueDetected = STD_NOT_OK;
926  pValidatedVoltages->invalidCellVoltage[s][m] |= (1u << c);
927  /* Set return value to #STD_NOT_OK as not all cell voltages have a valid measurement value */
928  retval = STD_NOT_OK;
929  }
930  } else if ((pCellVoltageBase->invalidCellVoltage[s][m] & (1u << c)) == 0u) {
931  /* Only base measurement value is valid -> use this voltage without further plausibility checks */
932  pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] =
933  pCellVoltageBase->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c];
934  /* Reset valid flag */
935  pValidatedVoltages->invalidCellVoltage[s][m] = pValidatedVoltages->invalidCellVoltage[s][m] &
936  (~(1u << c));
937  numberValidMeasurements++;
938  sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c];
939  } else if ((pCellVoltageRedundancy0->invalidCellVoltage[s][m] & (1u << c)) == 0u) {
940  /* Only redundant measurement value is valid -> use this voltage without further plausibility checks */
941  pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] =
942  pCellVoltageRedundancy0->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c];
943  /* Reset valid flag */
944  pValidatedVoltages->invalidCellVoltage[s][m] = pValidatedVoltages->invalidCellVoltage[s][m] &
945  (~(1u << c));
946  numberValidMeasurements++;
947  sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c];
948  } else {
949  /* Both, base and redundant measurement value are invalid */
950  /* Save average cell voltage value of base and redundant */
951  pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] =
952  (pCellVoltageBase->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] +
953  pCellVoltageRedundancy0->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]) /
954  2u;
955  /* Set invalid flag */
956  pValidatedVoltages->invalidCellVoltage[s][m] |= (1u << c);
957  /* Set return value to #STD_NOT_OK as not all cell voltages have a valid measurement value */
958  retval = STD_NOT_OK;
959  }
960  }
961  }
962  pValidatedVoltages->nrValidCellVoltages[s] = numberValidMeasurements;
963  pValidatedVoltages->packVoltage_mV[s] = sum;
964  numberValidMeasurements = 0u; /* Reset counter for next string */
965 
966  (void)DIAG_CheckEvent(noPlausibilityIssueDetected, DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE, DIAG_STRING, s);
967  noPlausibilityIssueDetected = STD_OK; /* Reset flag for next string */
968  }
969  return retval;
970 }
971 
973  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltage,
974  DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages) {
975  /* Pointer validity check */
976  FAS_ASSERT(pCellVoltage != NULL_PTR);
977  FAS_ASSERT(pValidatedVoltages != NULL_PTR);
978 
979  /* Save header struct to copy to correct database entry */
980  DATA_BLOCK_HEADER_s tmpHeader = pValidatedVoltages->header;
981  /* Copy whole database entry */
982  *pValidatedVoltages = *pCellVoltage;
983  /* Restore previous header */
984  pValidatedVoltages->header = tmpHeader;
985 
986  return STD_OK;
987 }
988 
990  DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureBase,
991  DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureRedundancy0,
992  DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures) {
993  /* Pointer validity check */
994  FAS_ASSERT(pCelltemperatureBase != NULL_PTR);
995  FAS_ASSERT(pCelltemperatureRedundancy0 != NULL_PTR);
996  FAS_ASSERT(pValidatedTemperatures != NULL_PTR);
997 
998  uint16_t numberValidMeasurements = 0u;
999  STD_RETURN_TYPE_e noPlausibilityIssueDetected = STD_OK; /* Flag if implausible value detected */
1000  STD_RETURN_TYPE_e retval = STD_OK;
1001 
1002  /* Iterate over all cell measurements */
1003  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
1004  for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) {
1005  for (uint8_t c = 0u; c < BS_NR_OF_TEMP_SENSORS_PER_MODULE; c++) {
1006  if (((pCelltemperatureBase->invalidCellTemperature[s][m] & (1u << c)) == 0u) &&
1007  ((pCelltemperatureRedundancy0->invalidCellTemperature[s][m] & (1u << c)) == 0u)) {
1008  /* Check if cell voltage of base AND redundant measurement is valid -> do plausibility check */
1009  if (STD_OK ==
1011  pCelltemperatureBase->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c],
1012  pCelltemperatureRedundancy0
1014  &pValidatedTemperatures
1016  /* Clear valid flag */
1017  pValidatedTemperatures->invalidCellTemperature[s][m] =
1018  pValidatedTemperatures->invalidCellTemperature[s][m] & (~(1u << c));
1019  numberValidMeasurements++;
1020  } else {
1021  /* Set invalid flag */
1022  noPlausibilityIssueDetected = STD_NOT_OK;
1023  pValidatedTemperatures->invalidCellTemperature[s][m] |= (1u << c);
1024  /* Set return value to #STD_NOT_OK as not all cell temperatures have a valid measurement value */
1025  retval = STD_NOT_OK;
1026  }
1027  } else if ((pCelltemperatureBase->invalidCellTemperature[s][m] & (1u << c)) == 0u) {
1028  /* Only base measurement value is valid -> use this temperature without further plausibility checks */
1029  pValidatedTemperatures->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c] =
1030  pCelltemperatureBase->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c];
1031  /* Reset valid flag */
1032  pValidatedTemperatures->invalidCellTemperature[s][m] =
1033  pValidatedTemperatures->invalidCellTemperature[s][m] & (~(1u << c));
1034  numberValidMeasurements++;
1035  } else if ((pCelltemperatureRedundancy0->invalidCellTemperature[s][m] & (1u << c)) == 0u) {
1036  /* Only redundant measurement value is valid -> use this temperature without further plausibility checks */
1037  pValidatedTemperatures->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c] =
1038  pCelltemperatureRedundancy0
1039  ->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c];
1040  /* Reset valid flag */
1041  pValidatedTemperatures->invalidCellTemperature[s][m] =
1042  pValidatedTemperatures->invalidCellTemperature[s][m] & (~(1u << c));
1043  numberValidMeasurements++;
1044  } else {
1045  /* Both, base and redundant measurement value are invalid */
1046  /* Save average cell voltage value of base and redundant */
1047  pValidatedTemperatures->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c] =
1048  (pCelltemperatureBase->cellTemperature_ddegC[s][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c] +
1049  pCelltemperatureRedundancy0
1051  2u;
1052  /* Set invalid flag */
1053  pValidatedTemperatures->invalidCellTemperature[s][m] |= (1u << c);
1054  /* Set return value to #STD_NOT_OK as not all cell temperatures have a valid measurement value */
1055  retval = STD_NOT_OK;
1056  }
1057  }
1058  }
1059  pValidatedTemperatures->nrValidTemperatures[s] = numberValidMeasurements;
1060  numberValidMeasurements = 0u; /* Reset counter for next string */
1061 
1062  (void)DIAG_CheckEvent(noPlausibilityIssueDetected, DIAG_ID_PLAUSIBILITY_CELL_TEMP, DIAG_STRING, s);
1063  noPlausibilityIssueDetected = STD_OK; /* Reset flag for next string */
1064  }
1065 
1066  return retval;
1067 }
1068 
1070  DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperature,
1071  DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperature) {
1072  /* Pointer validity check */
1073  FAS_ASSERT(pCellTemperature != NULL_PTR);
1074  FAS_ASSERT(pValidatedTemperature != NULL_PTR);
1075 
1076  /* Save header struct to copy to correct database entry */
1077  DATA_BLOCK_HEADER_s tmpHeader = pValidatedTemperature->header;
1078  /* Copy whole database entry */
1079  *pValidatedTemperature = *pCellTemperature;
1080  /* Restore previous header */
1081  pValidatedTemperature->header = tmpHeader;
1082  return STD_OK;
1083 }
1084 
1085 /*========== Extern Function Implementations ================================*/
1087  STD_RETURN_TYPE_e retval = STD_NOT_OK;
1088  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
1089  for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) {
1090  /* Invalidate cell voltage values */
1091  mrc_tableCellVoltages.invalidCellVoltage[s][m] = 0xFFFFFFFFFFFFFFFFULL;
1093  /* Invalidate cell temperature values */
1095  }
1096  /* Invalidate string values */
1100  }
1101  /* Invalidate pack values */
1102  mrc_tablePackValues.invalidPackCurrent = 0x01; /*!< bitmask if current is valid. 0->valid, 1->invalid */
1103  mrc_tablePackValues.invalidBatteryVoltage = 0x01; /*!< bitmask if voltage is valid. 0->valid, 1->invalid */
1104  mrc_tablePackValues.invalidHvBusVoltage = 0x01; /*!< bitmask if voltage is valid. 0->valid, 1->invalid */
1105  mrc_tablePackValues.invalidPackPower = 0x01; /*!< bitmask if power is valid. 0->valid, 1->invalid */
1106 
1108  return retval;
1109 }
1110 
1112  STD_RETURN_TYPE_e retval = STD_OK;
1113 
1114  /* Database entries are declared static, so that they are placed in the data segment and not on the stack */
1115  static DATA_BLOCK_CELL_VOLTAGE_s mrc_tableCellVoltageBase = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE};
1116  static DATA_BLOCK_CELL_VOLTAGE_s mrc_tableCellVoltageRedundancy0 = {
1118 
1119  static DATA_BLOCK_CELL_TEMPERATURE_s mrc_tableCelltemperatureBase = {
1121  static DATA_BLOCK_CELL_TEMPERATURE_s mrc_tableCelltemperatureRedundancy0 = {
1123 
1124  /* Get measurement values */
1126  &mrc_tableCellVoltageBase,
1127  &mrc_tableCellVoltageRedundancy0,
1128  &mrc_tableCelltemperatureBase,
1129  &mrc_tableCelltemperatureRedundancy0);
1130 
1131  /* Perform validation of cell voltage measurement */
1132  bool updateCellVoltages =
1133  MRC_ValidateCellVoltageMeasurement(&mrc_tableCellVoltageBase, &mrc_tableCellVoltageRedundancy0);
1134 
1135  /* Perform validation of cell temperature measurement */
1136  bool updateCellTemperatures =
1137  MRC_ValidateCellTemperatureMeasurement(&mrc_tableCelltemperatureBase, &mrc_tableCelltemperatureRedundancy0);
1138 
1139  /* Update database entries if necessary */
1140  if ((updateCellVoltages == true) && (updateCellTemperatures == true)) {
1142  } else if (updateCellVoltages == true) {
1144  } else if (updateCellTemperatures == true) {
1146  } else {
1147  retval = STD_NOT_OK;
1148  }
1149  return retval;
1150 }
1151 
1153  STD_RETURN_TYPE_e retval = STD_OK;
1155 
1156  DATA_READ_DATA(&tableCurrentSensor);
1157 
1158  MRC_ValidateCurrentMeasurement(&tableCurrentSensor);
1161  MRC_ValidateHighVoltageBusMeasurement(&tableCurrentSensor);
1162  MRC_ValidatePowerMeasurement(&tableCurrentSensor);
1163 
1165 
1166  return retval;
1167 }
1168 
1169 /*========== Externalized Static Function Implementations (Unit Test) =======*/
1170 #ifdef UNITY_UNIT_TEST
1171 extern bool TEST_MRC_MeasurementUpdatedAtLeastOnce(uint32_t timestamp, uint32_t previousTimestamp) {
1172  return MRC_MeasurementUpdatedAtLeastOnce(timestamp, previousTimestamp);
1173 }
1174 extern STD_RETURN_TYPE_e TEST_MRC_MeasurementUpdatedRecently(
1175  uint32_t timestamp,
1176  uint32_t previousTimestamp,
1177  uint32_t timeInterval) {
1178  return MRC_MeasurementUpdatedRecently(timestamp, previousTimestamp, timeInterval);
1179 }
1180 extern bool TEST_MRC_ValidateCellVoltageMeasurement(
1181  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageBase,
1182  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageRedundancy0) {
1183  return MRC_ValidateCellVoltageMeasurement(pCellVoltageBase, pCellVoltageRedundancy0);
1184 }
1185 extern bool TEST_MRC_ValidateCellTemperatureMeasurement(
1186  DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureBase,
1187  DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureRedundancy0) {
1188  return MRC_ValidateCellTemperatureMeasurement(pCellTemperatureBase, pCellTemperatureRedundancy0);
1189 }
1190 
1191 extern void TEST_MRC_ValidateCurrentMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor) {
1192  MRC_ValidateCurrentMeasurement(pTableCurrentSensor);
1193 }
1194 
1195 extern void TEST_MRC_ValidatePowerMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor) {
1196  MRC_ValidatePowerMeasurement(pTableCurrentSensor);
1197 }
1198 extern void TEST_MRC_ValidateStringVoltageMeasurement(
1199  DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor,
1200  DATA_BLOCK_CELL_VOLTAGE_s *pTableCellVoltage) {
1201  MRC_ValidateStringVoltageMeasurement(pTableCurrentSensor, pTableCellVoltage);
1202 }
1203 extern void TEST_MRC_ValidateBatteryVoltageMeasurement(void) {
1205 }
1206 extern void TEST_MRC_ValidateHighVoltageMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor) {
1207  MRC_ValidateHighVoltageBusMeasurement(pTableCurrentSensor);
1208 }
1209 extern STD_RETURN_TYPE_e TEST_MRC_CalculateCellVoltageMinMaxAverage(
1210  DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages,
1211  DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues) {
1212  return MRC_CalculateCellVoltageMinMaxAverage(pValidatedVoltages, pMinMaxAverageValues);
1213 }
1214 extern STD_RETURN_TYPE_e TEST_MRC_CalculateCellTemperatureMinMaxAverage(
1215  DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures,
1216  DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues) {
1217  return MRC_CalculateCellTemperatureMinMaxAverage(pValidatedTemperatures, pMinMaxAverageValues);
1218 }
1219 extern STD_RETURN_TYPE_e TEST_MRC_ValidateCellVoltage(
1220  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageBase,
1221  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageRedundancy0,
1222  DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages) {
1223  return MRC_ValidateCellVoltage(pCellVoltageBase, pCellVoltageRedundancy0, pValidatedVoltages);
1224 }
1225 extern STD_RETURN_TYPE_e TEST_MRC_UpdateCellVoltageValidation(
1226  DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltage,
1227  DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages) {
1228  return MRC_UpdateCellVoltageValidation(pCellVoltage, pValidatedVoltages);
1229 }
1230 extern STD_RETURN_TYPE_e TEST_MRC_ValidateCellTemperature(
1231  DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureBase,
1232  DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureRedundancy0,
1233  DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures) {
1234  return MRC_ValidateCellTemperature(pCelltemperatureBase, pCelltemperatureRedundancy0, pValidatedTemperatures);
1235 }
1236 extern STD_RETURN_TYPE_e TEST_MRC_UpdateCellTemperatureValidation(
1237  DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperature,
1238  DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperature) {
1239  return MRC_UpdateCellTemperatureValidation(pCellTemperature, pValidatedTemperature);
1240 }
1241 #endif
#define BS_NR_OF_CELL_BLOCKS_PER_MODULE
number of cells per module
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
#define BS_NR_OF_TEMP_SENSORS_PER_MODULE
number of temperature sensors per battery module
#define BS_NR_OF_CELL_BLOCKS_PER_STRING
#define BS_NR_OF_MODULES_PER_STRING
number of modules in a string
bool BMS_IsStringPrecharging(uint8_t stringNumber)
Returns if string is currently precharging or not.
Definition: bms.c:1312
uint8_t BMS_GetNumberOfConnectedStrings(void)
Returns number of connected strings.
Definition: bms.c:1321
bool BMS_IsStringClosed(uint8_t stringNumber)
Returns string state (closed or open)
Definition: bms.c:1303
bms driver header
Database module header.
#define DATA_READ_DATA(...)
Definition: database.h:83
#define DATA_WRITE_DATA(...)
Definition: database.h:93
@ DATA_BLOCK_ID_CELL_VOLTAGE_REDUNDANCY0
Definition: database_cfg.h:99
@ DATA_BLOCK_ID_MIN_MAX
Definition: database_cfg.h:78
@ DATA_BLOCK_ID_CELL_VOLTAGE
Definition: database_cfg.h:76
@ DATA_BLOCK_ID_CELL_TEMPERATURE_REDUNDANCY0
Definition: database_cfg.h:100
@ DATA_BLOCK_ID_CELL_TEMPERATURE_BASE
Definition: database_cfg.h:98
@ DATA_BLOCK_ID_CURRENT_SENSOR
Definition: database_cfg.h:79
@ DATA_BLOCK_ID_CELL_VOLTAGE_BASE
Definition: database_cfg.h:97
@ DATA_BLOCK_ID_PACK_VALUES
Definition: database_cfg.h:105
@ DATA_BLOCK_ID_CELL_TEMPERATURE
Definition: database_cfg.h:77
bool DATA_DatabaseEntryUpdatedAtLeastOnce(DATA_BLOCK_HEADER_s dataBlockHeader)
Checks if passed database entry has been updated at least once.
bool DATA_EntryUpdatedWithinInterval(DATA_BLOCK_HEADER_s dataBlockHeader, uint32_t timeInterval)
Checks if passed database entry has been updated within the last time interval.
STD_RETURN_TYPE_e DIAG_CheckEvent(STD_RETURN_TYPE_e cond, DIAG_ID_e diagId, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_CheckEvent provides a simple interface to check an event for STD_OK.
Definition: diag.c:359
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diagId, DIAG_EVENT_e event, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_Handler provides generic error handling, based on diagnosis group.
Definition: diag.c:231
Diagnosis driver header.
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:239
@ DIAG_EVENT_OK
Definition: diag_cfg.h:238
@ DIAG_SYSTEM
Definition: diag_cfg.h:251
@ DIAG_STRING
Definition: diag_cfg.h:252
@ DIAG_ID_POWER_MEASUREMENT_ERROR
Definition: diag_cfg.h:226
@ DIAG_ID_CURRENT_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:221
@ DIAG_ID_BASE_CELL_TEMPERATURE_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:219
@ DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE
Definition: diag_cfg.h:211
@ DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE
Definition: diag_cfg.h:170
@ DIAG_ID_PLAUSIBILITY_CELL_TEMP
Definition: diag_cfg.h:173
@ DIAG_ID_CURRENT_SENSOR_POWER_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:225
@ DIAG_ID_BASE_CELL_VOLTAGE_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:217
@ DIAG_ID_CURRENT_SENSOR_V1_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:223
@ DIAG_ID_CURRENT_SENSOR_V3_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:224
@ DIAG_ID_REDUNDANCY0_CELL_VOLTAGE_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:218
@ DIAG_ID_CURRENT_MEASUREMENT_ERROR
Definition: diag_cfg.h:222
@ DIAG_ID_REDUNDANCY0_CELL_TEMPERATURE_MEASUREMENT_TIMEOUT
Definition: diag_cfg.h:220
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:252
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:126
math library for often used math functions
#define UNIT_CONVERSION_FACTOR_1000_INTEGER
Definition: foxmath.h:75
STD_RETURN_TYPE_e
Definition: fstd_types.h:81
@ STD_NOT_OK
Definition: fstd_types.h:83
@ STD_OK
Definition: fstd_types.h:82
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:76
Declaration of the OS wrapper interface.
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
Definition: os_freertos.c:139
STD_RETURN_TYPE_e PL_CheckTemperatureSpread(DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatures, DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues)
Cell temperature spread plausibility check.
Definition: plausibility.c:155
STD_RETURN_TYPE_e PL_CheckCelltemperature(int16_t baseCelltemperature, int16_t redundancy0Celltemperature, int16_t *pCelltemperature)
Cell temperature plausibility check between two redundant cell temperature measurement values.
Definition: plausibility.c:104
STD_RETURN_TYPE_e PL_CheckStringVoltage(int32_t voltageAfe_mV, int32_t voltageCurrentSensor_mV)
Pack voltage plausibility check between LTC and current sensor values.
Definition: plausibility.c:74
STD_RETURN_TYPE_e PL_CheckCellVoltage(int16_t baseCellVoltage, int16_t redundancy0CellVoltage, int16_t *pCellVoltage)
Cell voltage plausibility check between two redundant cell voltage measurement values.
Definition: plausibility.c:86
STD_RETURN_TYPE_e PL_CheckVoltageSpread(DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltages, DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues)
Cell voltage spread plausibility check.
Definition: plausibility.c:123
plausibility checks for cell voltage and cell temperatures
static DATA_BLOCK_CELL_TEMPERATURE_s mrc_tableCellTemperatures
Definition: redundancy.c:73
static DATA_BLOCK_CELL_VOLTAGE_s mrc_tableCellVoltages
Definition: redundancy.c:72
static STD_RETURN_TYPE_e MRC_UpdateCellVoltageValidation(DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltage, DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages)
Function updates validated cell voltage measurement with data from a single measurement source....
Definition: redundancy.c:972
static DATA_BLOCK_MIN_MAX_s mrc_tableMinimumMaximumValues
Definition: redundancy.c:71
static void MRC_ValidatePowerMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor)
Function to validate results of power measurement.
Definition: redundancy.c:711
static STD_RETURN_TYPE_e MRC_ValidateCellVoltage(DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageBase, DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageRedundancy0, DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages)
Function compares cell voltage measurements from base measurement with one redundant measurement and ...
Definition: redundancy.c:892
static void MRC_ValidateStringVoltageMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor, DATA_BLOCK_CELL_VOLTAGE_s *pTableCellVoltage)
Function to validate results of string voltage measurement.
Definition: redundancy.c:574
STD_RETURN_TYPE_e MRC_Initialize(void)
Function to initalize redundancy module.
Definition: redundancy.c:1086
static void MRC_ValidateHighVoltageBusMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor)
Function to validate results of high voltage measurement and calculate battery voltage and high volta...
Definition: redundancy.c:677
static DATA_BLOCK_PACK_VALUES_s mrc_tablePackValues
Definition: redundancy.c:74
static bool MRC_ValidateCellTemperatureMeasurement(DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureBase, DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureRedundancy0)
Function to validate results of cell temperature measurement.
Definition: redundancy.c:399
static void MRC_ValidateCurrentMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor)
Function to validate results of current measurement.
Definition: redundancy.c:525
static bool MRC_MeasurementUpdatedAtLeastOnce(uint32_t timestamp, uint32_t previousTimestamp)
Check timestamp if measurement has been updated at least once.
Definition: redundancy.c:243
STD_RETURN_TYPE_e MRC_ValidateAfeMeasurement(void)
Function to validate the measurement between redundant measurement values for cell voltage and cell t...
Definition: redundancy.c:1111
STD_RETURN_TYPE_e MRC_ValidatePackMeasurement(void)
Function to validate the measurements of pack values (string values, pack values)
Definition: redundancy.c:1152
static STD_RETURN_TYPE_e MRC_CalculateCellVoltageMinMaxAverage(const DATA_BLOCK_CELL_VOLTAGE_s *const pValidatedVoltages, DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues)
Function calculates minimum, maximum and average cell voltages.
Definition: redundancy.c:771
static STD_RETURN_TYPE_e MRC_UpdateCellTemperatureValidation(DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperature, DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperature)
Function updates validated cell temperature measurement with data from a single measurement source....
Definition: redundancy.c:1069
static STD_RETURN_TYPE_e MRC_ValidateCellTemperature(DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureBase, DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureRedundancy0, DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures)
Function compares cell temperature measurements from base measurement with one redundant measurement ...
Definition: redundancy.c:989
static MRC_STATE_s mrc_state
Definition: redundancy.c:78
static STD_RETURN_TYPE_e MRC_CalculateCellTemperatureMinMaxAverage(DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures, DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues)
Function calculates minimum, maximum and average cell temperatures.
Definition: redundancy.c:829
static void MRC_ValidateBatteryVoltageMeasurement(void)
Function to validate HV battery voltage measurement.
Definition: redundancy.c:639
static bool MRC_ValidateCellVoltageMeasurement(DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageBase, DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageRedundancy0)
Function to validate results of cell voltage measurement.
Definition: redundancy.c:272
static STD_RETURN_TYPE_e MRC_MeasurementUpdatedRecently(uint32_t timestamp, uint32_t previousTimestamp, uint32_t timeInterval)
Check timestamp if measurement has been updated recently.
Definition: redundancy.c:254
Header fileS for handling redundancy between redundant cell voltage and cell temperature measurements...
#define MRC_ALLOWED_NUMBER_OF_INVALID_CELL_VOLTAGES
Definition: redundancy.h:111
#define MRC_CURRENT_MEASUREMENT_PERIOD_TIMEOUT_ms
Definition: redundancy.h:74
#define MRC_CURRENT_SENSOR_MEASUREMENT_TIMEOUT_ms
Definition: redundancy.h:101
#define MRC_AFE_MEASUREMENT_PERIOD_TIMEOUT_ms
Definition: redundancy.h:88
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:146
int16_t cellTemperature_ddegC[BS_NR_OF_STRINGS][BS_NR_OF_TEMP_SENSORS_PER_STRING]
Definition: database_cfg.h:148
uint16_t nrValidTemperatures[BS_NR_OF_STRINGS]
Definition: database_cfg.h:151
uint16_t invalidCellTemperature[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING]
Definition: database_cfg.h:150
int32_t packVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:131
bool validModuleVoltage[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING]
Definition: database_cfg.h:138
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:129
uint64_t invalidCellVoltage[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING]
Definition: database_cfg.h:135
uint16_t nrValidCellVoltages[BS_NR_OF_STRINGS]
Definition: database_cfg.h:136
int16_t cellVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_CELL_BLOCKS_PER_STRING]
Definition: database_cfg.h:132
uint32_t previousTimestampCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:215
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:216
uint32_t previousTimestampHighVoltage[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
Definition: database_cfg.h:237
int32_t current_mA[BS_NR_OF_STRINGS]
Definition: database_cfg.h:212
uint32_t timestampHighVoltage[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
Definition: database_cfg.h:239
uint32_t previousTimestampPower[BS_NR_OF_STRINGS]
Definition: database_cfg.h:222
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:211
uint32_t timestampPower[BS_NR_OF_STRINGS]
Definition: database_cfg.h:223
int32_t highVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
Definition: database_cfg.h:234
uint8_t invalidCurrentMeasurement[BS_NR_OF_STRINGS]
Definition: database_cfg.h:213
uint8_t invalidHighVoltageMeasurement[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
Definition: database_cfg.h:233
int32_t power_W[BS_NR_OF_STRINGS]
Definition: database_cfg.h:219
uint8_t invalidPowerMeasurement[BS_NR_OF_STRINGS]
Definition: database_cfg.h:220
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:119
int16_t minimumTemperature_ddegC[BS_NR_OF_STRINGS]
Definition: database_cfg.h:172
uint16_t nrSensorMinimumTemperature[BS_NR_OF_STRINGS]
Definition: database_cfg.h:174
uint16_t nrModuleMinimumTemperature[BS_NR_OF_STRINGS]
Definition: database_cfg.h:173
uint16_t nrModuleMaximumTemperature[BS_NR_OF_STRINGS]
Definition: database_cfg.h:176
int16_t maximumTemperature_ddegC[BS_NR_OF_STRINGS]
Definition: database_cfg.h:175
int16_t averageCellVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:161
uint16_t nrSensorMaximumTemperature[BS_NR_OF_STRINGS]
Definition: database_cfg.h:177
uint16_t validMeasuredCellVoltages[BS_NR_OF_STRINGS]
Definition: database_cfg.h:170
float averageTemperature_ddegC[BS_NR_OF_STRINGS]
Definition: database_cfg.h:171
uint16_t validMeasuredCellTemperatures[BS_NR_OF_STRINGS]
Definition: database_cfg.h:178
uint16_t nrCellMaximumCellVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:169
uint16_t nrCellMinimumCellVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:167
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:159
uint16_t nrModuleMinimumCellVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:166
uint16_t nrModuleMaximumCellVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:168
int16_t maximumCellVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:164
int16_t minimumCellVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:162
int32_t stringVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:198
int32_t stringPower_W[BS_NR_OF_STRINGS]
Definition: database_cfg.h:202
uint8_t invalidStringPower[BS_NR_OF_STRINGS]
Definition: database_cfg.h:203
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:187
int32_t stringCurrent_mA[BS_NR_OF_STRINGS]
Definition: database_cfg.h:200
uint8_t invalidStringCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:201
uint8_t invalidStringVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:199
uint32_t lastBaseCelltemperatureTimestamp
Definition: redundancy.h:120
uint32_t lastStringCurrentTimestamp[BS_NR_OF_STRINGS]
Definition: redundancy.h:122
uint32_t lastRedundancy0CelltemperatureTimestamp
Definition: redundancy.h:121
uint32_t lastRedundancy0CellVoltageTimestamp
Definition: redundancy.h:119
uint32_t lastStringPowerTimestamp[BS_NR_OF_STRINGS]
Definition: redundancy.h:123
uint32_t lastBaseCellVoltageTimestamp
Definition: redundancy.h:118