Index: firmware/.launches/HD.launch
===================================================================
diff -u -rf5f00981805e265ce63058f650d784f06db4d188 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/.launches/HD.launch (.../HD.launch) (revision f5f00981805e265ce63058f650d784f06db4d188)
+++ firmware/.launches/HD.launch (.../HD.launch) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -7,6 +7,7 @@
+
@@ -23,15 +24,18 @@
+
+
+
Index: firmware/App/Modes/ModeFault.c
===================================================================
diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6)
+++ firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -35,6 +35,9 @@
// ********** private data **********
+// TODO expand this later
+static HD_FAULT_STATE_T faultState = HD_FAULT_STATE_START; ///< Currently active fault state.
+
// ********** private function prototypes **********
/*********************************************************************//**
@@ -54,9 +57,9 @@
* The transitionToFaultMode function prepares for transition to fault mode.
* @details Inputs: none
* @details Outputs:
- * @return none
+ * @return initial state
*************************************************************************/
-void transitionToFaultMode( void )
+U32 transitionToFaultMode( void )
{
HD_OP_MODE_T previousOpMode = getPreviousOperationMode();
@@ -77,6 +80,8 @@
collectTreatmentLogData();
sendTreatmentLogDataToUI();
}
+
+ return faultState;
}
/*********************************************************************//**
@@ -96,8 +101,7 @@
signalDialInPumpHardStop();
signalDialOutPumpHardStop();
stopSyringePump();
- // Request trimmer heater turned off
- cmdStopDGTrimmerHeater();
+
// Ensure all valves are in safe position
setValveAirTrap( STATE_CLOSED );
setValvePosition( VDI, VALVE_POSITION_C_CLOSE );
@@ -155,7 +159,7 @@
button_state = stop;
#endif
- return 0; // Fault mode has no sub-modes
+ return faultState; // TODO expand the states later
}
/*********************************************************************//**
Index: firmware/App/Modes/ModeFault.h
===================================================================
diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304)
+++ firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -32,7 +32,7 @@
// ********** public function prototypes **********
void initFaultMode( void ); // Initialize this module
-void transitionToFaultMode( void ); // Prepares for transition to fault mode
+U32 transitionToFaultMode( void ); // Prepares for transition to fault mode
U32 execFaultMode( void ); // Execute the fault mode state machine (call from OperationModes)
void signalAlarmActionToFaultMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for fault mode
Index: firmware/App/Modes/ModeInitPOST.c
===================================================================
diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6)
+++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -42,6 +42,8 @@
// ********** private definitions **********
+#define START_POST_DELAY_COUNT ( ( 1 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Start POST delay in count.
+
/// Delay (in task intervals) after POST completes.
#define POST_COMPLETED_DELAY ( 2 * MS_PER_SECOND / TASK_GENERAL_INTERVAL )
@@ -64,10 +66,12 @@
static UI_VERSIONS_T uiVersion = { 0, 0, 0, 0, 0 }; ///< Version and compatibility information reported by UI.
static DG_VERSIONS_T dgVersion = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ///< Version and compatibility information reported by DG.
+static U32 startPOSTDelayCounter = 0; ///< Start POST delay counter.
// ********** private function prototypes **********
static HD_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus );
+static HD_POST_STATE_T handlePOSTStateStart( void );
static SELF_TEST_STATUS_T execFWCompatibilityTest( void );
static SELF_TEST_STATUS_T execUITest( void );
@@ -80,16 +84,17 @@
*************************************************************************/
void initInitAndPOSTMode( void )
{
- postState = POST_STATE_START;
- postCompleted = FALSE;
- postPassed = FALSE;
- tempPOSTPassed = TRUE;
- uiPOSTPassed = FALSE;
- dgPOSTPassed = FALSE;
- uiPOSTResultReceived = FALSE;
- dgPOSTResultReceived = FALSE;
- waitForUIPostTimerCtr = 0;
+ postState = POST_STATE_START;
+ postCompleted = FALSE;
+ postPassed = FALSE;
+ tempPOSTPassed = TRUE;
+ uiPOSTPassed = FALSE;
+ dgPOSTPassed = FALSE;
+ uiPOSTResultReceived = FALSE;
+ dgPOSTResultReceived = FALSE;
+ waitForUIPostTimerCtr = 0;
postCompleteDelayTimerCtr = 0;
+ startPOSTDelayCounter = 0;
}
/*********************************************************************//**
@@ -98,14 +103,16 @@
* initialize & POST mode.
* @details Inputs: none
* @details Outputs: none
- * @return none
+ * @return initial state
*************************************************************************/
-void transitionToInitAndPOSTMode( void )
+U32 transitionToInitAndPOSTMode( void )
{
// Set user alarm recovery actions allowed in this mode
setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE );
setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE );
setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE );
+
+ return postState;
}
/*********************************************************************//**
@@ -130,9 +137,7 @@
switch ( postState )
{
case POST_STATE_START:
- sendUIVersionRequest();
- SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_STARTUP, 0, 0 )
- postState = POST_STATE_FW_INTEGRITY;
+ postState = handlePOSTStateStart();
break;
case POST_STATE_FW_INTEGRITY:
@@ -408,6 +413,38 @@
/*********************************************************************//**
* @brief
+ * The handlePOSTStateStart function handles the POST start state.
+ * @details Inputs: startPOSTDelayCounter
+ * @details Outputs: startPOSTDelayCounter
+ * @return next POST state
+ *************************************************************************/
+static HD_POST_STATE_T handlePOSTStateStart( void )
+{
+ HD_POST_STATE_T state = POST_STATE_START;
+
+ // There is a delay before starting POST to make sure the CAN bus is up and listening so
+ // when the event data can be sent
+ if ( ++startPOSTDelayCounter > START_POST_DELAY_COUNT )
+ {
+ sendUIVersionRequest();
+
+ // Send the startup event
+ SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_STARTUP, 0, 0 )
+ // Send the first submode change event. It is the mode Init and it does not start from a previous
+ // mode previous and current are both published as Init
+ SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_OP_MODE_CHANGE, MODE_INIT, MODE_INIT )
+ state = POST_STATE_FW_INTEGRITY;
+#ifdef SKIP_POST
+ state = DG_POST_STATE_COMPLETED;
+#endif
+ startPOSTDelayCounter = 0;
+ }
+
+ return state;
+}
+
+/*********************************************************************//**
+ * @brief
* The execFWCompatibilityTest function executes the firmware compatibility test.
* @details Inputs: none
* @details Outputs: none
Index: firmware/App/Modes/ModeInitPOST.h
===================================================================
diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304)
+++ firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -33,7 +33,7 @@
// ********** public function prototypes **********
void initInitAndPOSTMode( void ); // Initialize this module
-void transitionToInitAndPOSTMode( void ); // Prepares for transition to init. & POST mode
+U32 transitionToInitAndPOSTMode( void ); // Prepares for transition to init. & POST mode
U32 execInitAndPOSTMode( void ); // Execute the init. & POST mode state machine (call from OperationModes)
BOOL isPOSTCompleted( void ); // Determine whether POST has completed yet
BOOL isPOSTPassed( void ); // Determine whether POST has passed
Index: firmware/App/Modes/ModePostTreat.c
===================================================================
diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6)
+++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -116,9 +116,9 @@
* post-treatment mode.
* @details Inputs: none
* @details Outputs: none
- * @return none
+ * @return initial state
*************************************************************************/
-void transitionToPostTreatmentMode( void )
+U32 transitionToPostTreatmentMode( void )
{
initPostTreatmentMode();
@@ -144,6 +144,8 @@
signalDialInPumpHardStop();
collectTreatmentLogData();
+
+ return currentPostTreatmentState;
}
/*********************************************************************//**
Index: firmware/App/Modes/ModePostTreat.h
===================================================================
diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModePostTreat.h (.../ModePostTreat.h) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304)
+++ firmware/App/Modes/ModePostTreat.h (.../ModePostTreat.h) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -78,7 +78,7 @@
// ********** public function prototypes **********
void initPostTreatmentMode( void ); // Initialize this module
-void transitionToPostTreatmentMode( void ); // Prepares for transition to post-treatment mode
+U32 transitionToPostTreatmentMode( void ); // Prepares for transition to post-treatment mode
U32 execPostTreatmentMode( void ); // Execute the post-treatment mode state machine (call from OperationModes)
void collectTreatmentLogData( void );
Index: firmware/App/Modes/ModePreTreat.c
===================================================================
diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6)
+++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -151,9 +151,9 @@
* pre-treatment mode.
* @details Inputs: none
* @details Outputs: none
- * @return none
+ * @return initial state
*************************************************************************/
-void transitionToPreTreatmentMode( void )
+U32 transitionToPreTreatmentMode( void )
{
F32 const trimmerHeaterTemp = getTreatmentParameterF32( TREATMENT_PARAM_DIALYSATE_TEMPERATURE );
F32 const primaryHeaterTemp = trimmerHeaterTemp + PRIMARY_HEATER_TARGET_TEMP_OFFSET;
@@ -166,6 +166,8 @@
setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE );
setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE );
setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE );
+
+ return currentPreTreatmentState;
}
/*********************************************************************//**
Index: firmware/App/Modes/ModePreTreat.h
===================================================================
diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModePreTreat.h (.../ModePreTreat.h) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304)
+++ firmware/App/Modes/ModePreTreat.h (.../ModePreTreat.h) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -49,7 +49,7 @@
// ********** public function prototypes **********
void initPreTreatmentMode( void ); // Initialize this module
-void transitionToPreTreatmentMode( void ); // Prepares for transition to pre-treatment mode
+U32 transitionToPreTreatmentMode( void ); // Prepares for transition to pre-treatment mode
U32 execPreTreatmentMode( void ); // Execute the pre-treatment mode state machine (call from OperationModes)
void signalUserConfirmInstallation( void ); // Signal that user confirms disposable has been installed
Index: firmware/App/Modes/ModeService.c
===================================================================
diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeService.c (.../ModeService.c) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304)
+++ firmware/App/Modes/ModeService.c (.../ModeService.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -44,14 +44,16 @@
* The transitionToServiceMode function prepares for transition to service mode.
* @details Inputs: none
* @details Outputs: none
- * @return none
+ * @return initial state
*************************************************************************/
-void transitionToServiceMode( void )
+U32 transitionToServiceMode( void )
{
// Set user alarm recovery actions allowed in this mode
setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE );
setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE );
setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE );
+
+ return 0;
}
/*********************************************************************//**
Index: firmware/App/Modes/ModeService.h
===================================================================
diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeService.h (.../ModeService.h) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304)
+++ firmware/App/Modes/ModeService.h (.../ModeService.h) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -32,7 +32,7 @@
// ********** public function prototypes **********
void initServiceMode( void ); // Initialize this module
-void transitionToServiceMode( void ); // Prepares for transition to service mode
+U32 transitionToServiceMode( void ); // Prepares for transition to service mode
U32 execServiceMode( void ); // Execute the service mode state machine (call from OperationModes)
void signalAlarmActionToServiceMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for Service mode
Index: firmware/App/Modes/ModeStandby.c
===================================================================
diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6)
+++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -95,9 +95,9 @@
* @details Inputs: none
* @details Outputs: Standby Mode module re-initialized, DG interface initialized,
* blood & dialysate pumps shut off.
- * @return none
+ * @return initial state
*************************************************************************/
-void transitionToStandbyMode( void )
+U32 transitionToStandbyMode( void )
{
// Re-initialize when transitioning to standby mode
initStandbyMode();
@@ -120,6 +120,8 @@
setValvePosition( VDO, VALVE_POSITION_A_INSERT_EJECT );
setValvePosition( VBA, VALVE_POSITION_A_INSERT_EJECT );
setValvePosition( VBV, VALVE_POSITION_A_INSERT_EJECT );
+
+ return currentStandbyState;
}
/*********************************************************************//**
Index: firmware/App/Modes/ModeStandby.h
===================================================================
diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304)
+++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -43,7 +43,7 @@
// ********** public function prototypes **********
void initStandbyMode( void ); // Initialize this module
-void transitionToStandbyMode( void ); // Prepares for transition to standby mode
+U32 transitionToStandbyMode( void ); // Prepares for transition to standby mode
U32 execStandbyMode( void ); // Execute the standby mode state machine (call from OperationModes)
BOOL signalUserInitiateTreatment( void ); // User has initiated a treatment - go to treatment parameters mode
Index: firmware/App/Modes/ModeTreatment.c
===================================================================
diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6)
+++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -228,9 +228,9 @@
* The transitionToTreatmentMode function prepares for transition to treatment mode.
* @details Inputs: none
* @details Outputs:
- * @return none
+ * @return initial state
*************************************************************************/
-void transitionToTreatmentMode( void )
+U32 transitionToTreatmentMode( void )
{
// Initialize treatment mode each time we transition to it
initTreatmentMode();
@@ -242,6 +242,8 @@
initRinseback();
initTreatmentRecirc();
initTreatmentEnd();
+
+ return currentTreatmentState;
}
/*********************************************************************//**
Index: firmware/App/Modes/ModeTreatment.h
===================================================================
diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304)
+++ firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -95,7 +95,7 @@
// ********** public function prototypes **********
void initTreatmentMode( void ); // Initialize this module
-void transitionToTreatmentMode( void ); // Prepares for transition to treatment mode
+U32 transitionToTreatmentMode( void ); // Prepares for transition to treatment mode
U32 execTreatmentMode( void ); // Execute the treatment mode state machine (call from OperationModes)
void signalAlarmActionToTreatmentMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for Treatment mode
void signalGoToTreatmentStopped( void ); // Rinseback or Re-circ sub-mode is signaling to return to treatment stopped sub-mode
Index: firmware/App/Modes/ModeTreatmentParams.c
===================================================================
diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6)
+++ firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -116,9 +116,9 @@
* parameters mode.
* @details Inputs: none
* @details Outputs: Treatment Parameters mode reset prior to starting
- * @return none
+ * @return initial state
*************************************************************************/
-void transitionToTreatParamsMode( void )
+U32 transitionToTreatParamsMode( void )
{
// Reset this mode
initTreatParamsMode();
@@ -138,6 +138,8 @@
setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE );
setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE );
setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE );
+
+ return currentTreatmentParamsState;
}
/*********************************************************************//**
Index: firmware/App/Modes/ModeTreatmentParams.h
===================================================================
diff -u -rccfd15568f1e3d304320c2babb2fd4bcf0413304 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision ccfd15568f1e3d304320c2babb2fd4bcf0413304)
+++ firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -74,7 +74,7 @@
// ********** Public function prototypes **********
void initTreatParamsMode( void ); // Initialize this module
-void transitionToTreatParamsMode( void ); // Prepares for transition to treatment parameters mode
+U32 transitionToTreatParamsMode( void ); // Prepares for transition to treatment parameters mode
U32 execTreatParamsMode( void ); // Execute the treatment parameters mode state machine (call from OperationModes)
BOOL validateAndSetTreatmentParameters( TREATMENT_PARAMS_DATA_PAYLOAD_T params ); // User provided treatment params to be set and validated
Index: firmware/App/Modes/OperationModes.c
===================================================================
diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6)
+++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -49,6 +49,7 @@
static U32 broadcastModeIntervalCtr = 11; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast.
/// Interval (in task intervals) at which to publish operation mode data to CAN bus.
static OVERRIDE_U32_T opModePublishInterval = { BROADCAST_HD_OP_MODE_INTERVAL, BROADCAST_HD_OP_MODE_INTERVAL, BROADCAST_HD_OP_MODE_INTERVAL, 0 };
+static U32 priorSubMode = 0; ///< The prior submode state.
/// This matrix determines legal transitions from one mode to another
static const HD_OP_MODE_T MODE_TRANSITION_TABLE[ NUM_OF_MODES - 1 ][ NUM_OF_MODES - 1 ] = {
@@ -88,6 +89,7 @@
// Start in init mode
currentMode = MODE_INIT;
currentSubMode = 0;
+ priorSubMode = 0;
transitionToNewOperationMode( MODE_INIT );
// Call initializers for the individual modes
@@ -111,8 +113,9 @@
void execOperationModes( void )
{
HD_OP_MODE_T newMode;
- U32 priorSubMode = currentSubMode;
+ priorSubMode = currentSubMode;
+
// Any new mode requests?
newMode = arbitrateModeRequest(); // Will return current mode if no pending requests
newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ];
@@ -128,7 +131,6 @@
if ( currentMode != newMode )
{
// Handle transition to new mode
- priorSubMode = 0;
lastMode = currentMode;
transitionToNewOperationMode( newMode );
currentMode = newMode;
@@ -332,33 +334,37 @@
switch ( newMode )
{
case MODE_FAUL:
- transitionToFaultMode();
+ currentSubMode = transitionToFaultMode();
break;
case MODE_SERV:
- transitionToServiceMode();
+ currentSubMode = transitionToServiceMode();
break;
case MODE_INIT:
- transitionToInitAndPOSTMode();
+ currentSubMode = transitionToInitAndPOSTMode();
break;
case MODE_STAN:
- transitionToStandbyMode();
+ currentSubMode = transitionToStandbyMode();
break;
case MODE_TPAR:
- transitionToTreatParamsMode();
+ currentSubMode = transitionToTreatParamsMode();
break;
case MODE_PRET:
- transitionToPreTreatmentMode();
+ currentSubMode = transitionToPreTreatmentMode();
break;
case MODE_TREA:
- transitionToTreatmentMode();
+ currentSubMode = transitionToTreatmentMode();
break;
case MODE_POST:
- transitionToPostTreatmentMode();
+ currentSubMode = transitionToPostTreatmentMode();
break;
default:
SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_INVALID_MODE_TO_TRANSITION_TO, newMode )
break;
}
+
+ SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode )
+
+ priorSubMode = currentSubMode;
}
/*********************************************************************//**
Index: firmware/App/Services/SystemCommMessages.c
===================================================================
diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa
--- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6)
+++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa)
@@ -355,10 +355,10 @@
/*********************************************************************//**
* @brief
- * The sendEvent function constructs an HD event message to the UI and
+ * The sendEvent function constructs an DG event message to the UI and
* queues the msg for transmit on the appropriate CAN channel.
* @details Inputs: none
- * @details Outputs: HD event msg constructed and queued.
+ * @details Outputs: DG event msg constructed and queued.
* @param event Enumeration of event type that occurred
* @param dat1 First data associated with event
* @param dat2 Second data associated with event
@@ -370,17 +370,25 @@
MESSAGE_T msg;
U08 *payloadPtr = msg.payload;
U32 e = (U32)event;
+ // Convert the two data types enums to U32. The enums are interpreted as a U08 by the compiler
+ U32 dataType1 = (U32)dat1.dataType;
+ U32 dataType2 = (U32)dat2.dataType;
// Create a message record
blankMessage( &msg );
msg.hdr.msgID = MSG_ID_HD_EVENT;
- msg.hdr.payloadLen = sizeof( U32 ) + sizeof( EVENT_DATA_T ) * 2;
+ // The payload length is the event ID, 2 event datas and the events data types for each of the event data
+ msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( EVENT_DATAS_T ) + 2 * sizeof( U32 );
memcpy( payloadPtr, &e, sizeof( U32 ) );
payloadPtr += sizeof( U32 );
- memcpy( payloadPtr, &dat1, sizeof( EVENT_DATA_T ) );
- payloadPtr += sizeof( EVENT_DATA_T );
- memcpy( payloadPtr, &dat2, sizeof( EVENT_DATA_T ) );
+ memcpy( payloadPtr, &dataType1, sizeof( U32 ) );
+ payloadPtr += sizeof( U32 );
+ memcpy( payloadPtr, &dat1.data, sizeof( EVENT_DATAS_T ) );
+ payloadPtr += sizeof( EVENT_DATAS_T );
+ memcpy( payloadPtr, &dataType2, sizeof( U32 ) );
+ payloadPtr += sizeof( U32 );
+ memcpy( payloadPtr, &dat2.data, sizeof( EVENT_DATAS_T ) );
// Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer
result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED );