Index: firmware/.cproject
===================================================================
diff -u -r24ad3dc9366ef694d84b778fc3beb15c1b8b1fe9 -r3f53d4aaf8840366306a6143eda9abf1a763bb73
--- firmware/.cproject (.../.cproject) (revision 24ad3dc9366ef694d84b778fc3beb15c1b8b1fe9)
+++ firmware/.cproject (.../.cproject) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73)
@@ -45,6 +45,7 @@
+
Index: firmware/App/Modes/ModePostTreat.c
===================================================================
diff -u -rb74d08ff24839ebbea51582772ed2b9588558ea0 -r3f53d4aaf8840366306a6143eda9abf1a763bb73
--- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision b74d08ff24839ebbea51582772ed2b9588558ea0)
+++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73)
@@ -18,7 +18,7 @@
#include "Buttons.h"
#include "ModePostTreat.h"
#include "OperationModes.h"
-#include "StateServices/TubeSetAutoEject.h"
+#include "TubeSetAutoEject.h"
/**
* @addtogroup TDPostTreatmentMode
Index: firmware/App/Modes/ModePreTreat.c
===================================================================
diff -u -rb74d08ff24839ebbea51582772ed2b9588558ea0 -r3f53d4aaf8840366306a6143eda9abf1a763bb73
--- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision b74d08ff24839ebbea51582772ed2b9588558ea0)
+++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73)
@@ -18,7 +18,7 @@
#include "Buttons.h"
#include "ModePreTreat.h"
#include "OperationModes.h"
-#include "StateServices/TubeSetInstall.h"
+#include "TubeSetInstall.h"
#include "Timers.h"
#include "TxParams.h"
@@ -30,6 +30,7 @@
// ********** private definitions **********
static TD_PRE_TREATMENT_MODE_STATE_T currentPreTreatmentState; ///< Current Pre-Treatment sub-state
+static BOOL goToInstallStateRequested; ///< Flag indicating a request to transition to Install state.
// ********** private function prototypes **********
@@ -55,7 +56,8 @@
{
// Start a fresh Treatment Parameters session for this run.
resetTreatmentParameters();
- currentPreTreatmentState = TD_PRE_TREATMENT_TUBING_SET_INSTALL_STATE;
+ currentPreTreatmentState = TD_PRE_TREATMENT_TUBING_SET_INSTALL_STATE;
+ goToInstallStateRequested = FALSE;
}
/*********************************************************************//**
@@ -231,6 +233,13 @@
{
TD_PRE_TREATMENT_MODE_STATE_T state = TD_PRE_TREATMENT_SELF_TEST_DRY_STATE;
+ if ( TRUE == goToInstallStateRequested )
+ {
+ goToInstallStateRequested = FALSE;
+ initTubeSetInstall();
+ state = TD_PRE_TREATMENT_TUBING_SET_INSTALL_STATE;
+ }
+
// TODO: Transition to Prime state on completion when implemented
// state = TD_PRE_TREATMENT_PRIME_STATE;
@@ -317,16 +326,15 @@
/*********************************************************************//**
* @brief
- * The signalGoToInstallState function resets the Tube Set Install Service
- * and set the current state of pre-treatment to install state.
+ * The signalGoToInstallState function signals a request to transition
+ * the Pre-Treatment mode state machine to Install state.
* @details Inputs: none
- * @details Outputs: currentPreTreatmentState, initTubeSetInstall()
+ * @details Outputs: goToInstallStateRequested
* @return none
*************************************************************************/
void signalGoToInstallState( void )
{
- initTubeSetInstall();
- currentPreTreatmentState = TD_PRE_TREATMENT_TUBING_SET_INSTALL_STATE;
+ goToInstallStateRequested = TRUE;
}
/**@}*/
Index: firmware/App/Services/Messaging.c
===================================================================
diff -u -rb74d08ff24839ebbea51582772ed2b9588558ea0 -r3f53d4aaf8840366306a6143eda9abf1a763bb73
--- firmware/App/Services/Messaging.c (.../Messaging.c) (revision b74d08ff24839ebbea51582772ed2b9588558ea0)
+++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73)
@@ -41,8 +41,8 @@
#include "Switches.h"
#include "SystemCommTD.h"
#include "Temperatures.h"
-#include "StateServices/TubeSetAutoEject.h"
-#include "StateServices/TubeSetInstall.h"
+#include "TubeSetAutoEject.h"
+#include "TubeSetInstall.h"
#include "TxParams.h"
#include "Utilities.h"
#include "Valve3Way.h"
Index: firmware/App/Services/StateServices/TubeSetAutoEject.c
===================================================================
diff -u -rb74d08ff24839ebbea51582772ed2b9588558ea0 -r3f53d4aaf8840366306a6143eda9abf1a763bb73
--- firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision b74d08ff24839ebbea51582772ed2b9588558ea0)
+++ firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73)
@@ -79,36 +79,34 @@
*************************************************************************/
void execTubeSetAutoEject( void )
{
- if( TRUE == ejectComplete )
+ if( FALSE == ejectComplete )
{
- return;
- }
+ switch ( currentAutoEjectState )
+ {
+ case TUBE_SET_AUTO_EJECT_STATE_AWAIT_CONFIRMATION:
+ currentAutoEjectState = handleAutoEjectAwaitConfirmState();
+ break;
- switch ( currentAutoEjectState )
- {
- case TUBE_SET_AUTO_EJECT_STATE_AWAIT_CONFIRMATION:
- currentAutoEjectState = handleAutoEjectAwaitConfirmState();
- break;
+ case TUBE_SET_AUTO_EJECT_STATE_HOMING:
+ currentAutoEjectState = handleAutoEjectHomingState();
+ break;
- case TUBE_SET_AUTO_EJECT_STATE_HOMING:
- currentAutoEjectState = handleAutoEjectHomingState();
- break;
+ case TUBE_SET_AUTO_EJECT_STATE_EXTENDING_EJECTOR:
+ currentAutoEjectState = handleAutoEjectExtendingEjectorState();
+ break;
- case TUBE_SET_AUTO_EJECT_STATE_EXTENDING_EJECTOR:
- currentAutoEjectState = handleAutoEjectExtendingEjectorState();
- break;
+ case TUBE_SET_AUTO_EJECT_STATE_EJECTING:
+ currentAutoEjectState = handleAutoEjectEjectingState();
+ break;
- case TUBE_SET_AUTO_EJECT_STATE_EJECTING:
- currentAutoEjectState = handleAutoEjectEjectingState();
- break;
+ case TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR:
+ currentAutoEjectState = handleAutoEjectRetractingEjectorState();
+ break;
- case TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR:
- currentAutoEjectState = handleAutoEjectRetractingEjectorState();
- break;
-
- default:
- SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_POST_TX_AUTO_EJECT_INVALID_STATE, (U32)currentAutoEjectState );
- break;
+ default:
+ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_POST_TX_AUTO_EJECT_INVALID_STATE, (U32)currentAutoEjectState );
+ break;
+ }
}
}
@@ -158,7 +156,7 @@
{
extendEjector();
autoEjectTimerCounter = 0;
- state = TUBE_SET_AUTO_EJECT_STATE_EXTENDING_EJECTOR;
+ state = TUBE_SET_AUTO_EJECT_STATE_EXTENDING_EJECTOR;
}
return state;
@@ -185,7 +183,7 @@
{
setBloodPumpTargetFlowRate( AUTO_EJECT_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP );
autoEjectTimerCounter = 0;
- state = TUBE_SET_AUTO_EJECT_STATE_EJECTING;
+ state = TUBE_SET_AUTO_EJECT_STATE_EJECTING;
}
return state;
@@ -215,7 +213,7 @@
signalBloodPumpHardStop();
retractEjector();
autoEjectTimerCounter = 0;
- state = TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR;
+ state = TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR;
}
return state;
@@ -242,7 +240,7 @@
{
autoEjectTimerCounter = 0;
ejectComplete = TRUE;
- state = NUM_OF_TUBE_SET_AUTO_EJECT_SUB_STATES;
+ state = NUM_OF_TUBE_SET_AUTO_EJECT_SUB_STATES;
}
return state;
@@ -291,8 +289,8 @@
}
else
{
- autoEjectReqReceived = TRUE;
- result = TRUE;
+ autoEjectReqReceived = TRUE;
+ result = TRUE;
}
}
else
Index: firmware/App/Services/StateServices/TubeSetAutoEject.h
===================================================================
diff -u -rb74d08ff24839ebbea51582772ed2b9588558ea0 -r3f53d4aaf8840366306a6143eda9abf1a763bb73
--- firmware/App/Services/StateServices/TubeSetAutoEject.h (.../TubeSetAutoEject.h) (revision b74d08ff24839ebbea51582772ed2b9588558ea0)
+++ firmware/App/Services/StateServices/TubeSetAutoEject.h (.../TubeSetAutoEject.h) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73)
@@ -23,8 +23,8 @@
/**
* @defgroup TubeSetAutoEject TubeSetAutoEject
- * @brief TubeSetAutoEject provide services to
- * Treatment and Post-Treatment modes..
+ * @brief TubeSetAutoEject provide tube set eject
+ * service to Treatment and Post-Treatment modes..
*
* @addtogroup TubeSetAutoEject
* @{
Index: firmware/App/Services/StateServices/TubeSetInstall.c
===================================================================
diff -u -rb74d08ff24839ebbea51582772ed2b9588558ea0 -r3f53d4aaf8840366306a6143eda9abf1a763bb73
--- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision b74d08ff24839ebbea51582772ed2b9588558ea0)
+++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73)
@@ -15,7 +15,7 @@
*
***************************************************************************/
-#include "AlarmMgmt.h"
+#include "AlarmMgmtTD.h"
#include "BloodFlow.h"
#include "Messaging.h"
#include "OperationModes.h"
@@ -24,7 +24,7 @@
#include "TaskGeneral.h"
#include "TDDefs.h"
#include "Timers.h"
-#include "StateServices/TubeSetInstall.h"
+#include "TubeSetInstall.h"
/**
* @addtogroup TubeSetInstall
@@ -53,6 +53,7 @@
// ********** private function prototypes **********
static TUBE_SET_INSTALL_STATE_T handleAwaitTubesetConfirmationState( void ); ///< Handle Await Tubset Install Confirmation sub-state
+static TUBE_SET_INSTALL_STATE_T handleAwaitBPDoorCloseState( void ); ///< Handle Await Blood Pump Door Close sub-state.
static TUBE_SET_INSTALL_STATE_T handleAutoLoadState( void ); ///< Handle Auto-Load sub-state
static TUBE_SET_INSTALL_STATE_T handleAutoLoadBackOffState( void ); ///< Handle Auto-Load Back-off sub-state
@@ -83,40 +84,41 @@
*************************************************************************/
void execTubeSetInstall( void )
{
- if( TRUE == installComplete )
+ if ( FALSE == installComplete )
{
- return;
- }
+ switch( currentInstallState )
+ {
+ case TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION:
+ currentInstallState = handleAwaitTubesetConfirmationState();
+ break;
- switch( currentInstallState )
- {
- case TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION:
- currentInstallState = handleAwaitTubesetConfirmationState();
- break;
+ case TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE:
+ currentInstallState = handleAwaitBPDoorCloseState();
+ break;
- case TUBE_SET_INSTALL_STATE_AUTO_LOAD:
- currentInstallState = handleAutoLoadState();
- break;
+ case TUBE_SET_INSTALL_STATE_AUTO_LOAD:
+ currentInstallState = handleAutoLoadState();
+ break;
- case TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF:
- currentInstallState = handleAutoLoadBackOffState();
- break;
+ case TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF:
+ currentInstallState = handleAutoLoadBackOffState();
+ break;
- default:
- SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_PRE_TX_INSTALL_INVALID_STATE, (U32)currentInstallState );
- break;
+ default:
+ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_PRE_TX_INSTALL_INVALID_STATE, (U32)currentInstallState );
+ break;
+ }
}
}
/*********************************************************************//**
* @brief
* The handleAwaitTubesetConfirmationState function handles the Await
* tubeset confirmation state of Tubing Set install state machine.
- * Should wait for the user to confirm the tubeset is placed, and
- * verifies that the blood pump door (H9) is closed.
- * @details Inputs: confirmTubsetPlaced, H9_SWCH state
+ * Should wait for the user to confirm the tubeset is placed
+ * @details Inputs: confirmTubsetPlaced
* @details Outputs: confirmTubesetPlaced
- * return next Pre-Treatment Install sub-state
+ * return next Install sub-state
*************************************************************************/
static TUBE_SET_INSTALL_STATE_T handleAwaitTubesetConfirmationState( void )
{
@@ -126,13 +128,30 @@
{
// Door closed required from Auto-loading onwards, set to false if not required in subsequent states
doorClosedRequired( TRUE );
+ confirmTubesetPlaced = FALSE;
+ state = TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE;
+ }
- if ( STATE_CLOSED == getSwitchState( H9_SWCH ) )
- {
- confirmTubesetPlaced = FALSE;
- setBloodPumpTargetFlowRate( AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP );
- state = TUBE_SET_INSTALL_STATE_AUTO_LOAD;
- }
+ return state;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The handleAwaitBPDoorCloseState function handles the Await Blood Pump
+ * Door Close state of Tubing Set install state machine.
+ * Should wait until blood pump door (H9) is closed.
+ * @details Inputs: H9_SWCH state
+ * @details Outputs: none
+ * return next Install sub-state
+ *************************************************************************/
+static TUBE_SET_INSTALL_STATE_T handleAwaitBPDoorCloseState( void )
+{
+ TUBE_SET_INSTALL_STATE_T state = TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE;
+
+ if ( STATE_CLOSED == getSwitchState( H9_SWCH ) )
+ {
+ setBloodPumpTargetFlowRate( AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP );
+ state = TUBE_SET_INSTALL_STATE_AUTO_LOAD;
}
return state;
@@ -145,7 +164,7 @@
* @details Inputs: bloodPumpTimerCounter, getMeasuredBloodPumpTorque()
* isPeristalticPumpHome()
* @details Outputs: bloodPumpTimerCounter, installComplete
- * return next Pre-Treatment Install sub-state
+ * return next Install sub-state
*************************************************************************/
static TUBE_SET_INSTALL_STATE_T handleAutoLoadState( void )
{
@@ -170,8 +189,8 @@
{
signalBloodPumpHardStop();
bloodPumpTimerCounter = 0;
- installComplete = TRUE;
- state = NUM_OF_TUBE_SET_INSTALL_SUB_STATES;
+ installComplete = TRUE;
+ state = NUM_OF_TUBE_SET_INSTALL_SUB_STATES;
}
return state;
@@ -183,7 +202,7 @@
* state of Tube Set install state.
* @details Inputs: bloodPumpTimerCounter, isPeristalticPumpHome()
* @details Outputs: bloodPumpTimerCounter
- * return next install sub-state
+ * return next Install sub-state
*************************************************************************/
static TUBE_SET_INSTALL_STATE_T handleAutoLoadBackOffState( void )
{
@@ -251,8 +270,8 @@
}
else
{
- confirmTubesetPlaced = TRUE;
- result = TRUE;
+ confirmTubesetPlaced = TRUE;
+ result = TRUE;
}
}
else
Index: firmware/App/Services/StateServices/TubeSetInstall.h
===================================================================
diff -u -rb74d08ff24839ebbea51582772ed2b9588558ea0 -r3f53d4aaf8840366306a6143eda9abf1a763bb73
--- firmware/App/Services/StateServices/TubeSetInstall.h (.../TubeSetInstall.h) (revision b74d08ff24839ebbea51582772ed2b9588558ea0)
+++ firmware/App/Services/StateServices/TubeSetInstall.h (.../TubeSetInstall.h) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73)
@@ -23,8 +23,8 @@
/**
* @defgroup TubeSetInstall TubeSetInstall
- * @brief The TubeSetInstall provide services to
- * Pre-Treatment and Treatment modes.
+ * @brief The TubeSetInstall provide tube set install (load)
+ * service to Pre-Treatment and Treatment modes.
*
* @addtogroup TubeSetInstall
* @{
@@ -36,6 +36,7 @@
enum Tube_Set_Install_States
{
TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION = 0, // Awaiting user confirmation that tubeset is placed.
+ TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE, // Waiting for blood pump door to be closed.
TUBE_SET_INSTALL_STATE_AUTO_LOAD, // Auto-Load the tubeset state
TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF, // Auto-Load Back-off state
NUM_OF_TUBE_SET_INSTALL_SUB_STATES, // Num of install sub-states