Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r349fea3fcdcc561afda3d8c3d7c8bc62eec29664 -r85c052e0c8340e4a26a072e8aba70c2e17ce00e2 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 349fea3fcdcc561afda3d8c3d7c8bc62eec29664) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 85c052e0c8340e4a26a072e8aba70c2e17ce00e2) @@ -30,13 +30,13 @@ #include "ModeTreatment.h" #include "ModeTreatmentParams.h" #include "OperationModes.h" +#include "Switches.h" +#include "SyringePump.h" #include "SystemComm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Timers.h" -#ifdef EMC_TEST_BUILD // TODO - test code -#include "FPGA.h" -#endif +#include "Valves.h" /** * @addtogroup HDStandbyMode @@ -64,6 +64,7 @@ // ********** private function prototypes ********** +static HD_STANDBY_STATE_T handleStandbyModeStartState( void ); static HD_STANDBY_STATE_T handleStandbyModeWaitForTreatmentState( void ); static HD_STANDBY_STATE_T handleStandbyModeWaitForDisinfectState( void ); @@ -157,18 +158,14 @@ *************************************************************************/ U32 execStandbyMode( void ) { -#ifdef EMC_TEST_BUILD - static U32 toggle = 0; - static BOOL button_state = FALSE; -#endif BOOL stop = isStopButtonPressed(); #ifndef RUN_WITHOUT_DG // State machine to get DG to prep a reservoir so we can start a treatment switch ( currentStandbyState ) { case STANDBY_START_STATE: - currentStandbyState = STANDBY_WAIT_FOR_TREATMENT_STATE; + currentStandbyState = handleStandbyModeStartState();; break; case STANDBY_WAIT_FOR_TREATMENT_STATE: @@ -230,13 +227,6 @@ homeBloodPump(); homeDialInPump(); homeDialOutPump(); -#ifdef EMC_TEST_BUILD - setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); - setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); - startAirTrapControl(); -#endif break; case STANDBY_WAIT_FOR_TREATMENT_STATE: @@ -245,63 +235,6 @@ requestNewOperationMode( MODE_TPAR ); treatStartReqReceived = FALSE; } - // TODO - test code - if ( TRUE == stop ) - { -#ifndef EMC_TEST_BUILD - treatStartReqReceived = FALSE; - setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); - setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); - requestNewOperationMode( MODE_TPAR ); -#else - if ( stop != button_state ) - { - toggle = INC_WRAP( toggle, 0, 3 ); - switch ( toggle ) - { - case 0: // Pumps and valves off - setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); - setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); - break; - - case 1: // Pumps off, valves in pos A - setValvePosition( VDI, VALVE_POSITION_A_INSERT_EJECT ); - setValvePosition( VDO, VALVE_POSITION_A_INSERT_EJECT ); - setValvePosition( VBA, VALVE_POSITION_A_INSERT_EJECT ); - setValvePosition( VBV, VALVE_POSITION_A_INSERT_EJECT ); - break; - - case 2: // Pumps on, valves in pos A - setBloodPumpTargetFlowRate( 500, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setDialInPumpTargetFlowRate( 500, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setDialOutPumpTargetRate( 500, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - break; - - - default: // Should not get here, reset if we do - toggle = 0; - setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); - setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); - setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); - break; - } - } -#endif - } -#ifdef EMC_TEST_BUILD - button_state = stop; -#endif break; default: @@ -342,12 +275,10 @@ rejReason = REQUEST_REJECT_REASON_DG_NOT_IN_STANDBY_IDLE_STATE; } -#ifndef DISABLE_BATT_COMM if ( FALSE == isBatteryCharged() ) { rejReason = REQUEST_REJECT_REASON_BATTERY_IS_NOT_CHARGED; } -#endif if ( REQUEST_REJECT_REASON_NONE == rejReason ) { @@ -539,6 +470,57 @@ /*********************************************************************//** * @brief + * The handleStandbyModeStartState function handles the standby start state. + * This state waits for the door to be closed and then initiates homing of + * pumps and valves and transitions to the wait for treatment state. + * @details Inputs: + * @details Outputs: + * @return next state of the standby mode state machine + *************************************************************************/ +static HD_STANDBY_STATE_T handleStandbyModeStartState( void ) +{ + static BOOL homingInitiated = FALSE; + HD_STANDBY_STATE_T state = STANDBY_START_STATE; + + // Wait for door to be closed so we can home actuators + if ( ( homingInitiated != TRUE ) && ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) ) + { + VALVE_T valve; + + // Home pumps and valves + for ( valve = VDI; valve < NUM_OF_VALVES; ++valve ) + { + homeValve( valve ); + } + homeBloodPump(); + homeDialInPump(); + homeDialOutPump(); + retractSyringePump(); + + homingInitiated = TRUE; + } + else + { + // Trigger door open alarm to prompt user to close the door + activateAlarmNoData( ALARM_ID_CARTRIDGE_DOOR_OPENED ); + homingInitiated = FALSE; + } + + // If homing has been initiated, wait for syringe pump to home and the verify force sensor calibration + if ( ( TRUE == homingInitiated ) && ( TRUE == isSyringePumpHome() ) ) + { + syringePumpVerifyForceSensorDACCalibration(); + homingInitiated = FALSE; // reset for next time + state = STANDBY_WAIT_FOR_TREATMENT_STATE; // Go to wait for treatment state after above check + } + + return state; +} +// Verify calibration + + +/*********************************************************************//** + * @brief * The handleStandbyModeWaitForTreatmentState function handles wait for * treatment state. * @details Inputs: treatStartReqReceived @@ -550,16 +532,19 @@ HD_STANDBY_STATE_T state = STANDBY_WAIT_FOR_TREATMENT_STATE; DG_OP_MODE_T dgOperationMode = getDGOpMode(); + // If DG is filling while we are in standby mode, abort the fill if ( DG_MODE_FILL == dgOperationMode ) { cmdStopDGFill(); } + // If DG is in idle generation state while we are in standby mode, transition DG to standby too if ( DG_MODE_GENE == dgOperationMode ) { cmdStopDG(); } + // If treatment start is requested by user, initiate treatment workflow (transition to treatment params mode). TODO - check required conditions before allowing treatment start, reject if necessary. if ( TRUE == treatStartReqReceived ) { // Initialize treatment modes before starting a new treatment Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -rd6255708e8305bf5509485a860eb3469a42ec9ad -r85c052e0c8340e4a26a072e8aba70c2e17ce00e2 --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision d6255708e8305bf5509485a860eb3469a42ec9ad) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 85c052e0c8340e4a26a072e8aba70c2e17ce00e2) @@ -51,7 +51,7 @@ BOOL signalUserInitiateFlushMode( void ); // User has requested to start flush BOOL signalUserInitiateHeatDisinfectMode( void ); // User has requested to start heat disinfection BOOL signalUserInitiateChemicalDisinfectMode( void ); // User has requested to start chem disinfection -BOOL signalInitiateStandbyDisinfectSubmode( void ); // UI has signaled user will be selecting a clearning operation to perform +BOOL signalInitiateStandbyDisinfectSubmode( U32 cmd ); // UI has signaled user will be selecting a cleaning operation to perform BOOL testSetStandbyModePublishIntervalOverride( U32 ms ); BOOL testResetStandbyModePublishIntervalOverride( void ); Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -rc20c77ef196a760a7642d2426e509995e4a98e01 -r85c052e0c8340e4a26a072e8aba70c2e17ce00e2 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision c20c77ef196a760a7642d2426e509995e4a98e01) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 85c052e0c8340e4a26a072e8aba70c2e17ce00e2) @@ -140,7 +140,7 @@ transitionToNewOperationMode( newMode ); currentMode = newMode; - if ( MODE_TREA == currentMode ) + if ( MODE_TREA == lastMode ) { // If the current mode is treatment but transitioning to another mode has been requested (including transitioning to fault mode) // it means the treatment is done. Get the elapsed time since the beginning of the treatment and convert it to hours to be written Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r65586d515b6824115a90d81595915be02213f679 -r85c052e0c8340e4a26a072e8aba70c2e17ce00e2 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 65586d515b6824115a90d81595915be02213f679) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 85c052e0c8340e4a26a072e8aba70c2e17ce00e2) @@ -7,8 +7,8 @@ * * @file SystemCommMessages.c * -* @author (last) Dara Navaei -* @date (last) 03-Aug-2022 +* @author (last) Michael Garthwaite +* @date (last) 07-Sep-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -28,6 +28,7 @@ #include "Fans.h" #include "FPGA.h" #include "ModeStandby.h" +#include "ModeInitPOST.h" #include "OperationModes.h" #include "RTC.h" #include "SampleWater.h" @@ -41,8 +42,11 @@ #include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" -#include "HDDefs.h" +#include "HDDefs.h" +#include "TaskPriority.h" +#include "TaskPriority.h" + /** * @addtogroup SystemCommMessages * @{ @@ -61,9 +65,9 @@ #pragma pack(pop) // ********** private data ********** - static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether an external tester (connected PC) has sent a valid login message. static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted message. + /// List of message IDs that are requested not to be transmitted. static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -1570,10 +1574,9 @@ * @details Inputs: none * @details Outputs: DG start/stop trimmer heater command msg constructed and queued. * @param start TRUE indicates start heater, FALSE indicates stop heater - * @param trimmerHtrTemp target temperature for trimmer heater * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start, F32 trimmerHtrTemp ) +BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start ) { BOOL result; MESSAGE_T msg; @@ -1582,11 +1585,9 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( F32 ); + msg.hdr.payloadLen = sizeof( BOOL ); memcpy( payloadPtr, &start, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &trimmerHtrTemp, sizeof( F32 ) ); // 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_DG, ACK_REQUIRED ); @@ -2004,35 +2005,6 @@ } -#ifdef EMC_TEST_BUILD -/*********************************************************************//** - * @brief - * The broadcastCANErrorCount function handles the CAN error count - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -BOOL broadcastCANErrorCount( U32 count ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_CAN_ERROR_COUNT; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &count, sizeof( U32 ) ); - - // 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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} -#endif - // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -2271,7 +2243,6 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); @@ -2340,17 +2311,36 @@ *************************************************************************/ void handleLoadCellReadingsFromDG( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ) + if ( message->hdr.payloadLen == sizeof( LOAD_CELL_DATA_T ) ) { - LOAD_CELL_READINGS_PAYLOAD_T payload; + LOAD_CELL_DATA_T payload; - memcpy( &payload, message->payload, sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ); - setNewLoadCellReadings( payload.res1PrimaryLoadCell, payload.res1BackupLoadCell, payload.res2PrimaryLoadCell, payload.res2BackupLoadCell ); + memcpy( &payload, message->payload, sizeof( LOAD_CELL_DATA_T ) ); + setNewLoadCellReadings( payload.loadCellA1inGram, payload.loadCellA2inGram, payload.loadCellB1inGram, payload.loadCellB2inGram ); } } /*********************************************************************//** * @brief + * The handleDGHeatersData function handles the heaters data reading from DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGHeatersData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( HEATERS_DATA_T ) ) + { + HEATERS_DATA_T payload; + + memcpy( &payload, message->payload, sizeof( HEATERS_DATA_T ) ); + setDGHeatersData( &payload ); + } +} + +/*********************************************************************//** + * @brief * The handleDGTemperatureData function handles a temperature readings * broadcast message from the DG. * @details Inputs: none @@ -2364,13 +2354,13 @@ { TEMPERATURE_SENSORS_DATA_T payload; - memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); - setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); - } - // TODO - what to do if invalid payload length? - // TODO - how to know if DG stops sending these? -} - + memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); + setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); + } + // TODO - what to do if invalid payload length? + // TODO - how to know if DG stops sending these? +} + /*********************************************************************//** * @brief * The handleDialysateFlowData function handles dialysate flow data broadcast @@ -2673,111 +2663,111 @@ return result; } -/*********************************************************************//** - * @brief - * The handleChangeUFSettingsRequest function handles a ultrafiltration - * change settings request message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleChangeUFSettingsRequest( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(F32) ) - { - F32 uFVolume; - - memcpy( &uFVolume, message->payload, sizeof(F32) ); - - verifyUFSettingsChange( uFVolume ); - } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); - } -} - -/*********************************************************************//** - * @brief - * The handleChangeUFSettingsConfirmation function handles a ultrafiltration - * change setting confirmation message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleChangeUFSettingsConfirmation( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T) ) - { - UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T) ); - - verifyUFSettingsConfirmation( payload.volume_mL, payload.adjustType ); - } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); - } -} - -/*********************************************************************//** - * @brief - * The handleChangeTreatmentDurationRequest function handles a treatment - * duration setting change message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleChangeTreatmentDurationRequest( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(U32) ) - { +/*********************************************************************//** + * @brief + * The handleChangeUFSettingsRequest function handles a ultrafiltration + * change settings request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeUFSettingsRequest( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(F32) ) + { + F32 uFVolume; + + memcpy( &uFVolume, message->payload, sizeof(F32) ); + + verifyUFSettingsChange( uFVolume ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleChangeUFSettingsConfirmation function handles a ultrafiltration + * change setting confirmation message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeUFSettingsConfirmation( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T) ) + { + UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T) ); + + verifyUFSettingsConfirmation( payload.volume_mL, payload.adjustType ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleChangeTreatmentDurationRequest function handles a treatment + * duration setting change message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeTreatmentDurationRequest( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(U32) ) + { U32 timeInMin; - - memcpy( &timeInMin, message->payload, sizeof(U32) ); - verifyTreatmentDurationSettingChange( timeInMin ); - } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); - } -} -/*********************************************************************//** - * @brief - * The handleChangeBloodDialysateRateChangeRequest function handles a blood - * and dialysate rate settings change message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleChangeBloodDialysateRateChangeRequest( MESSAGE_T *message ) -{ - U32 expPayloadSize = sizeof(U32) + sizeof(U32); - - if ( expPayloadSize == message->hdr.payloadLen ) - { - U32 bloodRate; - U32 dialRate; - - memcpy( &bloodRate, &message->payload[0], sizeof(U32) ); - memcpy( &dialRate, &message->payload[sizeof(U32)], sizeof(U32) ); - - verifyBloodAndDialysateRateSettingsChange( bloodRate, dialRate ); - } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); - } + memcpy( &timeInMin, message->payload, sizeof(U32) ); + verifyTreatmentDurationSettingChange( timeInMin ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** * @brief + * The handleChangeBloodDialysateRateChangeRequest function handles a blood + * and dialysate rate settings change message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeBloodDialysateRateChangeRequest( MESSAGE_T *message ) +{ + U32 expPayloadSize = sizeof(U32) + sizeof(U32); + + if ( expPayloadSize == message->hdr.payloadLen ) + { + U32 bloodRate; + U32 dialRate; + + memcpy( &bloodRate, &message->payload[0], sizeof(U32) ); + memcpy( &dialRate, &message->payload[sizeof(U32)], sizeof(U32) ); + + verifyBloodAndDialysateRateSettingsChange( bloodRate, dialRate ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief * The handleChangePressureLimitsRequest function handles a pressure limits * change message from the UI. * @details Inputs: none @@ -5160,6 +5150,7 @@ if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) { result = testSetBatteryRemainingPercentOverride( payload.state.u32 ); @@ -7035,15 +7026,26 @@ { BOOL status = FALSE; HD_OP_MODE_T currentMode = getCurrentOperationMode(); + DG_OP_MODE_T currentDGMode = getDGOpMode(); REQUEST_REJECT_REASON_CODE_T reject; if ( 0 == message->hdr.payloadLen ) { if ( ( MODE_STAN == currentMode ) || ( MODE_FAUL == currentMode ) ) { - status = TRUE; + requestNewOperationMode( MODE_SERV ); - reject = REQUEST_REJECT_REASON_NONE; + + if ( (DG_MODE_STAN == currentDGMode) || (DG_MODE_FAUL == currentDGMode) ) + { + status = TRUE; + cmdSetDGToServiceMode(); + reject = REQUEST_REJECT_REASON_NONE; + } + else + { + reject = REQUEST_REJECT_REASON_DG_NOT_IN_STANDBY_IDLE_STATE; + } } else { @@ -7089,6 +7091,30 @@ } /*********************************************************************//** + * @brief + * The sendRequestForDGResendAlarms function sends out the HD request for + * DG re-send all active alarms. + * @details Inputs: none + * @details Outputs: DG alarms re-send request msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendRequestForDGResendAlarms( void ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_ALARMS; + msg.hdr.payloadLen = 0; + + // 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** * @brief * The handleGetHDUsageInfoRecord function handles a request to get the HD * usage information record. @@ -7244,15 +7270,15 @@ /*********************************************************************//** * @brief - * The handleSendBloodLeakEmbeddedModeCommandResponse function sends out + * The sendBloodLeakEmbeddedModeCommandResponse function sends out * the blood leak embedded mode command response. * @details Inputs: none * @details Outputs: blood leak embedded mode command response msg constructed and queued * @param responseLen: the length of the buffer * @param response: pointer to the response buffer * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL handleSendBloodLeakEmbeddedModeCommandResponse( U32 responseLen, U08* response ) +BOOL sendBloodLeakEmbeddedModeCommandResponse( U32 responseLen, U08* response ) { BOOL result; MESSAGE_T msg; @@ -7273,4 +7299,52 @@ return result; } +/*********************************************************************//** +* @brief +* The handleResendAllAlarmsCommand function handles a request to re-send +* all active HD alarms. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleResendAllAlarmsCommand( MESSAGE_T* message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + handleResendActiveAlarmsRequest(); + result = TRUE; + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The sendDGServiceModeRequest function constructs a service mode request msg + * to the DG and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG Service mode request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGServiceModeRequest() +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_SERVICE_MODE; + msg.hdr.payloadLen = 0; + + // 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_DG, ACK_REQUIRED ); + + return result; +} + /**@}*/