foxBMS - Unit Tests  1.5.0
The foxBMS Unit Tests API Documentation
debug_default.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, 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 2023-02-03 (date of last update)
47  * @version v1.5.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 
60 #include "database_cfg.h"
61 
62 #include "fstd_types.h"
63 
64 #include <stdbool.h>
65 #include <stdint.h>
66 
67 /*========== Macros and Definitions =========================================*/
68 
69 /** States of the state machine */
70 typedef enum {
71  FAKE_FSM_STATE_DUMMY, /*!< dummy state - always the first state */
72  FAKE_FSM_STATE_HAS_NEVER_RUN, /*!< never run state - always the second state */
73  FAKE_FSM_STATE_UNINITIALIZED, /*!< uninitialized state */
74  FAKE_FSM_STATE_INITIALIZATION, /*!< initializing the state machine */
75  FAKE_FSM_STATE_RUNNING, /*!< operational mode of the state machine */
76  FAKE_FSM_STATE_ERROR, /*!< state for error processing */
78 
79 /** Substates of the state machine */
80 typedef enum {
81  FAKE_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */
82  FAKE_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */
83  FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT, /*!< finish the first fake measurement */
84  FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED, /*!< cleanup substate after the first fake measurement */
85  FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT, /*!< last initialization substate */
86  FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA, /*!< state to continuously save the measurement data */
87  FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA, /*!< state to continuously save the measurement data */
89 
90 /** This struct contains pointer to used data buffers */
91 typedef struct {
92  DATA_BLOCK_CELL_VOLTAGE_s *cellVoltage; /*!< cell voltage */
96  DATA_BLOCK_SLAVE_CONTROL_s *slaveControl; /*!< slave control */
97  DATA_BLOCK_ALL_GPIO_VOLTAGES_s *allGpioVoltages; /*!< voltage of the slaves' GPIOs */
98  DATA_BLOCK_OPEN_WIRE_s *openWire; /*!< open wire status */
100 
101 /** This struct describes the state of the monitoring instance */
102 typedef struct {
103  uint16_t timer; /*!< timer of the state */
104  uint8_t triggerEntry; /*!< trigger entry of the state */
105  FAKE_FSM_STATES_e nextState; /*!< next state of the FSM */
106  FAKE_FSM_STATES_e currentState; /*!< current state of the FSM */
107  FAKE_FSM_STATES_e previousState; /*!< previous state of the FSM */
108  FAKE_FSM_SUBSTATES_e nextSubstate; /*!< next substate of the FSM */
109  FAKE_FSM_SUBSTATES_e currentSubstate; /*!< current substate of the FSM */
110  FAKE_FSM_SUBSTATES_e previousSubstate; /*!< previous substate of the FSM */
111  bool firstMeasurementFinished; /*!< indicator if the fist measurement has been successful */
112  FAKE_DATABASE_ENTRIES_s data; /*!< contains pointers to the local data buffer */
113 } FAKE_STATE_s;
114 
115 /*========== Extern Constant and Variable Declarations ======================*/
116 
117 /** state of the fake state machine */
118 extern FAKE_STATE_s fake_state;
119 
120 /*========== Extern Function Prototypes =====================================*/
121 
122 /** @brief initialize driver */
124 
125 /**
126  * @brief return whether the first measurement cycle is finished
127  * @param pFakeState current state of the fake driver
128  * @returns true if the first measurement cycle was successfully finished,
129  * false otherwise
130  */
131 extern bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState);
132 
133 /**
134  * @brief Trigger function for the driver, called to advance the
135  * state machine
136  * @param pFakeState current state of the fake driver
137  * @returns returns always #STD_OK
138  */
140 
141 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
142 #ifdef UNITY_UNIT_TEST
143 extern bool TEST_FAKE_CheckMultipleCalls(FAKE_STATE_s *pFakeState);
144 
146 
147 extern void TEST_FAKE_SetState(
148  FAKE_STATE_s *pFakeState,
149  FAKE_FSM_STATES_e nextState,
150  FAKE_FSM_SUBSTATES_e nextSubstate,
151  uint16_t idleTime);
152 
154 
156 
157 #endif
158 
159 #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:80
@ FAKE_FSM_SUBSTATE_DUMMY
Definition: debug_default.h:81
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT
Definition: debug_default.h:83
@ FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED
Definition: debug_default.h:84
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_TEMPERATURE_MEASUREMENT_DATA
Definition: debug_default.h:87
@ FAKE_FSM_SUBSTATE_INITIALIZATION_EXIT
Definition: debug_default.h:85
@ FAKE_FSM_SUBSTATE_RUNNING_SAVE_VOLTAGE_MEASUREMENT_DATA
Definition: debug_default.h:86
@ FAKE_FSM_SUBSTATE_ENTRY
Definition: debug_default.h:82
STD_RETURN_TYPE_e TEST_FAKE_SaveFakeTemperatureMeasurementData(FAKE_STATE_s *pFakeState)
FAKE_FSM_STATES_e
Definition: debug_default.h:70
@ FAKE_FSM_STATE_DUMMY
Definition: debug_default.h:71
@ FAKE_FSM_STATE_HAS_NEVER_RUN
Definition: debug_default.h:72
@ FAKE_FSM_STATE_ERROR
Definition: debug_default.h:76
@ FAKE_FSM_STATE_RUNNING
Definition: debug_default.h:75
@ FAKE_FSM_STATE_UNINITIALIZED
Definition: debug_default.h:73
@ FAKE_FSM_STATE_INITIALIZATION
Definition: debug_default.h:74
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)
Definition of foxBMS standard types.
STD_RETURN_TYPE_e
Definition: fstd_types.h:82
DATA_BLOCK_BALANCING_CONTROL_s * balancingControl
Definition: debug_default.h:95
DATA_BLOCK_SLAVE_CONTROL_s * slaveControl
Definition: debug_default.h:96
DATA_BLOCK_OPEN_WIRE_s * openWire
Definition: debug_default.h:98
DATA_BLOCK_CELL_VOLTAGE_s * cellVoltage
Definition: debug_default.h:92
DATA_BLOCK_BALANCING_FEEDBACK_s * balancingFeedback
Definition: debug_default.h:94
DATA_BLOCK_CELL_TEMPERATURE_s * cellTemperature
Definition: debug_default.h:93
DATA_BLOCK_ALL_GPIO_VOLTAGES_s * allGpioVoltages
Definition: debug_default.h:97
FAKE_FSM_SUBSTATES_e nextSubstate
FAKE_FSM_STATES_e currentState
FAKE_FSM_SUBSTATES_e previousSubstate
uint16_t timer
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