foxBMS-UnitTests  1.0.0
The foxBMS Unit Tests API Documentation
debug_default.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
38  * ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file debug_default.h
44  * @author foxBMS Team
45  * @date 2020-09-17 (date of creation)
46  * @updated 2020-11-09 (date of last update)
47  * @ingroup DRIVERS
48  * @prefix FAKE
49  *
50  * @brief Header for the driver of the fake measurement IC driver
51  *
52  */
53 
54 #ifndef FOXBMS__DEBUG_DEFAULT_H_
55 #define FOXBMS__DEBUG_DEFAULT_H_
56 
57 /*========== Includes =======================================================*/
58 #include "general.h"
59 
60 #include "database_cfg.h"
61 
62 /*========== Macros and Definitions =========================================*/
63 
64 /** States of the state machine */
65 typedef enum FAKE_FSM_STATES {
66  FAKE_FSM_STATE_DUMMY, /*!< dummy state - always the first state */
67  FAKE_FSM_STATE_HAS_NEVER_RUN, /*!< never run state - always the second state */
68  FAKE_FSM_STATE_UNINITIALIZED, /*!< uninitialized state */
69  FAKE_FSM_STATE_INITIALIZATION, /*!< initializing the state machine */
70  FAKE_FSM_STATE_RUNNING, /*!< operational mode of the state machine */
71  FAKE_FSM_STATE_ERROR, /*!< state for error processing */
73 
74 /** Substates of the state machine */
75 typedef enum FAKE_FSM_SUBSTATES {
76  FAKE_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */
77  FAKE_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */
78  FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT, /*!< finish the first fake measurement */
79  FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED, /*!< cleanup substate after the first fake measurement */
80  FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT, /*!< last initialization substate */
81  FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA, /*!< state to continuously save the measurement data */
82  FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA, /*!< state to continuously save the measurement data */
84 
85 /** This struct contains pointer to used data buffers */
86 typedef struct FAKE_DATABASE_ENTRIES {
87  DATA_BLOCK_CELL_VOLTAGE_s *cellVoltage; /*!< cell voltage */
91  DATA_BLOCK_SLAVE_CONTROL_s *slaveControl; /*!< slave control */
92  DATA_BLOCK_ALL_GPIO_VOLTAGES_s *allGpioVoltages; /*!< voltage of the slaves' GPIOs */
93  DATA_BLOCK_OPEN_WIRE_s *openWire; /*!< open wire status */
95 
96 /** This struct describes the state of the monitoring instance */
97 typedef struct FAKE_STATE {
98  uint16_t timer; /*!< timer of the state */
99  uint8_t triggerEntry; /*!< trigger entry of the state */
100  FAKE_FSM_STATES_e nextState; /*!< next state of the FSM */
101  FAKE_FSM_STATES_e currentState; /*!< current state of the FSM */
102  FAKE_FSM_STATES_e previousState; /*!< previous state of the FSM */
103  FAKE_FSM_SUBSTATES_e nextSubstate; /*!< next substate of the FSM */
104  FAKE_FSM_SUBSTATES_e currentSubstate; /*!< current substate of the FSM */
105  FAKE_FSM_SUBSTATES_e previousSubstate; /*!< previous substate of the FSM */
106  bool firstMeasurementFinished; /*!< indicator if the fist measurement has been successfull */
107  FAKE_DATABASE_ENTRIES_s data; /*!< contains pointers to the local data buffer */
109 
110 /*========== Extern Constant and Variable Declarations ======================*/
111 
112 /** state of the fake state machine */
113 extern FAKE_STATE_s fake_state;
114 
115 /*========== Extern Function Prototypes =====================================*/
116 
117 /** @brief initialize driver */
119 
120 /**
121  * @brief return whether the first measurement cycle is finished
122  * @param pFakeState current state of the fake driver
123  * @returns true if the first measurement cycle was successfully finished,
124  * false otherwise
125  */
126 extern bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState);
127 
128 /**
129  * @brief Trigger function for the driver, called to advance the
130  * state machine
131  * @param pFakeState current state of the fake driver
132  * @returns returns always #STD_OK
133  */
135 
136 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
137 #ifdef UNITY_UNIT_TEST
138 extern bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState);
139 
141 
142 extern void TEST_FAKE_SetState(
143  FAKE_STATE_s *pFakeState,
144  FAKE_FSM_STATES_e nextState,
145  FAKE_FSM_SUBSTATES_e nextSubstate,
146  uint16_t idleTime);
147 
149 
151 
152 #endif
153 
154 #endif /* FOXBMS__DEBUG_DEFAULT_H_ */
FAKE_DATABASE_ENTRIES::cellTemperature
DATA_BLOCK_CELL_TEMPERATURE_s * cellTemperature
Definition: debug_default.h:88
FAKE_FSM_STATES
FAKE_FSM_STATES
Definition: debug_default.h:65
FAKE_STATE::nextState
FAKE_FSM_STATES_e nextState
Definition: debug_default.h:100
TEST_FAKE_CheckMultipleCalls
bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState)
Definition: debug_default.c:558
general.h
TODO.
DATA_BLOCK_OPENWIRE
Definition: database_cfg.h:296
FAKE_STATE::nextSubstate
FAKE_FSM_SUBSTATES_e nextSubstate
Definition: debug_default.h:103
FAKE_DATABASE_ENTRIES::cellVoltage
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltage
Definition: debug_default.h:87
FAKE_DATABASE_ENTRIES::balancingFeedback
DATA_BLOCK_BALANCING_FEEDBACK_s * balancingFeedback
Definition: debug_default.h:89
FAKE_DATABASE_ENTRIES::allGpioVoltages
DATA_BLOCK_ALL_GPIO_VOLTAGES_s * allGpioVoltages
Definition: debug_default.h:92
FAKE_STATE::previousState
FAKE_FSM_STATES_e previousState
Definition: debug_default.h:102
TEST_FAKE_SetFirstMeasurementCycleFinished
void TEST_FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
Definition: debug_default.c:562
STD_RETURN_TYPE_e
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
FAKE_FSM_SUBSTATES_e
enum FAKE_FSM_SUBSTATES FAKE_FSM_SUBSTATES_e
DATA_BLOCK_SLAVE_CONTROL
Definition: database_cfg.h:258
FAKE_DATABASE_ENTRIES::balancingControl
DATA_BLOCK_BALANCING_CONTROL_s * balancingControl
Definition: debug_default.h:90
FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT
Definition: debug_default.h:78
TEST_FAKE_SaveFakeVoltageMeasurementData
STD_RETURN_TYPE_e TEST_FAKE_SaveFakeVoltageMeasurementData(FAKE_STATE_s *pFakeState)
Definition: debug_default.c:574
FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT
@ FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT
Definition: debug_default.h:80
FAKE_FSM_STATES_e
enum FAKE_FSM_STATES FAKE_FSM_STATES_e
FAKE_FSM_SUBSTATES
FAKE_FSM_SUBSTATES
Definition: debug_default.h:75
FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA
Definition: debug_default.h:81
FAKE_DATABASE_ENTRIES_s
struct FAKE_DATABASE_ENTRIES FAKE_DATABASE_ENTRIES_s
FAKE_STATE::previousSubstate
FAKE_FSM_SUBSTATES_e previousSubstate
Definition: debug_default.h:105
FAKE_FSM_SUBSTATE_DUMMY
@ FAKE_FSM_SUBSTATE_DUMMY
Definition: debug_default.h:76
FAKE_STATE
Definition: debug_default.h:97
fake_state
FAKE_STATE_s fake_state
Definition: debug_default.c:114
DATA_BLOCK_BALANCING_FEEDBACK
Definition: database_cfg.h:276
FAKE_FSM_SUBSTATE_ENTRY
@ FAKE_FSM_SUBSTATE_ENTRY
Definition: debug_default.h:77
FAKE_STATE_s
struct FAKE_STATE FAKE_STATE_s
FAKE_FSM_STATE_UNINITIALIZED
@ FAKE_FSM_STATE_UNINITIALIZED
Definition: debug_default.h:68
FAKE_TriggerMeasurementIc
STD_RETURN_TYPE_e FAKE_TriggerMeasurementIc(FAKE_STATE_s *pFakeState)
Trigger function for the driver, called to advance the state machine.
Definition: debug_default.c:527
TEST_FAKE_SaveFakeTemperatureMeasurementData
STD_RETURN_TYPE_e TEST_FAKE_SaveFakeTemperatureMeasurementData(FAKE_STATE_s *pFakeState)
Definition: debug_default.c:578
FAKE_FSM_STATE_HAS_NEVER_RUN
@ FAKE_FSM_STATE_HAS_NEVER_RUN
Definition: debug_default.h:67
FAKE_DATABASE_ENTRIES::openWire
DATA_BLOCK_OPEN_WIRE_s * openWire
Definition: debug_default.h:93
FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA
Definition: debug_default.h:82
FAKE_STATE::firstMeasurementFinished
bool firstMeasurementFinished
Definition: debug_default.h:106
FAKE_IsFirstMeasurementCycleFinished
bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
return whether the first measurement cycle is finished
Definition: debug_default.c:518
FAKE_Initialize
STD_RETURN_TYPE_e FAKE_Initialize(void)
initialize driver
Definition: debug_default.c:514
FAKE_FSM_STATE_INITIALIZATION
@ FAKE_FSM_STATE_INITIALIZATION
Definition: debug_default.h:69
FAKE_FSM_STATE_RUNNING
@ FAKE_FSM_STATE_RUNNING
Definition: debug_default.h:70
FAKE_DATABASE_ENTRIES::slaveControl
DATA_BLOCK_SLAVE_CONTROL_s * slaveControl
Definition: debug_default.h:91
FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED
Definition: debug_default.h:79
DATA_BLOCK_CELL_TEMPERATURE
Definition: database_cfg.h:131
DATA_BLOCK_CELL_VOLTAGE
Definition: database_cfg.h:115
FAKE_STATE::currentState
FAKE_FSM_STATES_e currentState
Definition: debug_default.h:101
FAKE_FSM_STATE_DUMMY
@ FAKE_FSM_STATE_DUMMY
Definition: debug_default.h:66
FAKE_STATE::data
FAKE_DATABASE_ENTRIES_s data
Definition: debug_default.h:107
FAKE_STATE::timer
uint16_t timer
Definition: debug_default.h:98
FAKE_STATE::triggerEntry
uint8_t triggerEntry
Definition: debug_default.h:99
DATA_BLOCK_ALL_GPIO_VOLTAGES
Definition: database_cfg.h:308
TEST_FAKE_SetState
void TEST_FAKE_SetState(FAKE_STATE_s *pFakeState, FAKE_FSM_STATES_e nextState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime)
Definition: debug_default.c:566
DATA_BLOCK_BALANCING_CONTROL
Definition: database_cfg.h:245
FAKE_STATE::currentSubstate
FAKE_FSM_SUBSTATES_e currentSubstate
Definition: debug_default.h:104
FAKE_DATABASE_ENTRIES
Definition: debug_default.h:86
database_cfg.h
Database configuration header.
FAKE_FSM_STATE_ERROR
@ FAKE_FSM_STATE_ERROR
Definition: debug_default.h:71