foxBMS - Unit Tests  1.4.0
The foxBMS Unit Tests API Documentation
debug_default.h
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 debug_default.h
44  * @author foxBMS Team
45  * @date 2020-09-17 (date of creation)
46  * @updated 2022-07-28 (date of last update)
47  * @version v1.4.0
48  * @ingroup DRIVERS
49  * @prefix FAKE
50  *
51  * @brief Header for the driver of the fake AFE driver
52  *
53  */
54 
55 #ifndef FOXBMS__DEBUG_DEFAULT_H_
56 #define FOXBMS__DEBUG_DEFAULT_H_
57 
58 /*========== Includes =======================================================*/
59 #include "general.h"
60 
61 #include "database_cfg.h"
62 
63 /*========== Macros and Definitions =========================================*/
64 
65 /** States of the state machine */
66 typedef enum {
67  FAKE_FSM_STATE_DUMMY, /*!< dummy state - always the first state */
68  FAKE_FSM_STATE_HAS_NEVER_RUN, /*!< never run state - always the second state */
69  FAKE_FSM_STATE_UNINITIALIZED, /*!< uninitialized state */
70  FAKE_FSM_STATE_INITIALIZATION, /*!< initializing the state machine */
71  FAKE_FSM_STATE_RUNNING, /*!< operational mode of the state machine */
72  FAKE_FSM_STATE_ERROR, /*!< state for error processing */
74 
75 /** Substates of the state machine */
76 typedef enum {
77  FAKE_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */
78  FAKE_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */
79  FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT, /*!< finish the first fake measurement */
80  FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED, /*!< cleanup substate after the first fake measurement */
81  FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT, /*!< last initialization substate */
82  FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA, /*!< state to continuously save the measurement data */
83  FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA, /*!< state to continuously save the measurement data */
85 
86 /** This struct contains pointer to used data buffers */
87 typedef struct {
88  DATA_BLOCK_CELL_VOLTAGE_s *cellVoltage; /*!< cell voltage */
92  DATA_BLOCK_SLAVE_CONTROL_s *slaveControl; /*!< slave control */
93  DATA_BLOCK_ALL_GPIO_VOLTAGES_s *allGpioVoltages; /*!< voltage of the slaves' GPIOs */
94  DATA_BLOCK_OPEN_WIRE_s *openWire; /*!< open wire status */
96 
97 /** This struct describes the state of the monitoring instance */
98 typedef struct {
99  uint16_t timer; /*!< timer of the state */
100  uint8_t triggerEntry; /*!< trigger entry of the state */
101  FAKE_FSM_STATES_e nextState; /*!< next state of the FSM */
102  FAKE_FSM_STATES_e currentState; /*!< current state of the FSM */
103  FAKE_FSM_STATES_e previousState; /*!< previous state of the FSM */
104  FAKE_FSM_SUBSTATES_e nextSubstate; /*!< next substate of the FSM */
105  FAKE_FSM_SUBSTATES_e currentSubstate; /*!< current substate of the FSM */
106  FAKE_FSM_SUBSTATES_e previousSubstate; /*!< previous substate of the FSM */
107  bool firstMeasurementFinished; /*!< indicator if the fist measurement has been successful */
108  FAKE_DATABASE_ENTRIES_s data; /*!< contains pointers to the local data buffer */
109 } FAKE_STATE_s;
110 
111 /*========== Extern Constant and Variable Declarations ======================*/
112 
113 /** state of the fake state machine */
114 extern FAKE_STATE_s fake_state;
115 
116 /*========== Extern Function Prototypes =====================================*/
117 
118 /** @brief initialize driver */
120 
121 /**
122  * @brief return whether the first measurement cycle is finished
123  * @param pFakeState current state of the fake driver
124  * @returns true if the first measurement cycle was successfully finished,
125  * false otherwise
126  */
127 extern bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState);
128 
129 /**
130  * @brief Trigger function for the driver, called to advance the
131  * state machine
132  * @param pFakeState current state of the fake driver
133  * @returns returns always #STD_OK
134  */
136 
137 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
138 #ifdef UNITY_UNIT_TEST
139 extern bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState);
140 
142 
143 extern void TEST_FAKE_SetState(
144  FAKE_STATE_s *pFakeState,
145  FAKE_FSM_STATES_e nextState,
146  FAKE_FSM_SUBSTATES_e nextSubstate,
147  uint16_t idleTime);
148 
150 
152 
153 #endif
154 
155 #endif /* FOXBMS__DEBUG_DEFAULT_H_ */
Database configuration header.
STD_RETURN_TYPE_e TEST_FAKE_SaveFakeVoltageMeasurementData(FAKE_STATE_s *pFakeState)
STD_RETURN_TYPE_e FAKE_Initialize(void)
initialize driver
FAKE_STATE_s fake_state
STD_RETURN_TYPE_e FAKE_TriggerAfe(FAKE_STATE_s *pFakeState)
Trigger function for the driver, called to advance the state machine.
FAKE_FSM_SUBSTATES_e
Definition: debug_default.h:76
@ FAKE_FSM_SUBSTATE_DUMMY
Definition: debug_default.h:77
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT
Definition: debug_default.h:79
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED
Definition: debug_default.h:80
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA
Definition: debug_default.h:83
@ FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT
Definition: debug_default.h:81
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA
Definition: debug_default.h:82
@ FAKE_FSM_SUBSTATE_ENTRY
Definition: debug_default.h:78
STD_RETURN_TYPE_e TEST_FAKE_SaveFakeTemperatureMeasurementData(FAKE_STATE_s *pFakeState)
FAKE_FSM_STATES_e
Definition: debug_default.h:66
@ FAKE_FSM_STATE_DUMMY
Definition: debug_default.h:67
@ FAKE_FSM_STATE_HAS_NEVER_RUN
Definition: debug_default.h:68
@ FAKE_FSM_STATE_ERROR
Definition: debug_default.h:72
@ FAKE_FSM_STATE_RUNNING
Definition: debug_default.h:71
@ FAKE_FSM_STATE_UNINITIALIZED
Definition: debug_default.h:69
@ FAKE_FSM_STATE_INITIALIZATION
Definition: debug_default.h:70
bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
return whether the first measurement cycle is finished
void TEST_FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState)
void TEST_FAKE_SetState(FAKE_STATE_s *pFakeState, FAKE_FSM_STATES_e nextState, FAKE_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime)
bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState)
STD_RETURN_TYPE_e
Definition: fstd_types.h:81
General macros and definitions for the whole platform.
DATA_BLOCK_BALANCING_CONTROL_s * balancingControl
Definition: debug_default.h:91
DATA_BLOCK_SLAVE_CONTROL_s * slaveControl
Definition: debug_default.h:92
DATA_BLOCK_OPEN_WIRE_s * openWire
Definition: debug_default.h:94
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltage
Definition: debug_default.h:88
DATA_BLOCK_BALANCING_FEEDBACK_s * balancingFeedback
Definition: debug_default.h:90
DATA_BLOCK_CELL_TEMPERATURE_s * cellTemperature
Definition: debug_default.h:89
DATA_BLOCK_ALL_GPIO_VOLTAGES_s * allGpioVoltages
Definition: debug_default.h:93
FAKE_FSM_SUBSTATES_e nextSubstate
FAKE_FSM_STATES_e currentState
FAKE_FSM_SUBSTATES_e previousSubstate
uint16_t timer
Definition: debug_default.h:99
FAKE_FSM_STATES_e nextState
FAKE_FSM_STATES_e previousState
FAKE_DATABASE_ENTRIES_s data
uint8_t triggerEntry
FAKE_FSM_SUBSTATES_e currentSubstate
bool firstMeasurementFinished