Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r876a1cdab00a28265349cec424f77709a101db5c -r5c083ca7d4ebd1ebd8e745c0fba7148e59894569 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 876a1cdab00a28265349cec424f77709a101db5c) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 5c083ca7d4ebd1ebd8e745c0fba7148e59894569) @@ -8,7 +8,7 @@ * @file ModeStandby.c * * @author (last) Sean Nash -* @date (last) 05-Feb-2023 +* @date (last) 13-Mar-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -198,7 +198,6 @@ handleDisinfectCancel( stop ); -#ifndef RUN_WITHOUT_DG // State machine to get DG to prep a reservoir so we can start a treatment switch ( currentStandbyState ) { @@ -267,33 +266,7 @@ currentStandbyState = STANDBY_START_STATE; break; } -#else - // 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; - // Temporary test code - TODO - remove later - homeBloodPump(); - homeDialInPump(); - homeDialOutPump(); - break; - case STANDBY_WAIT_FOR_TREATMENT_STATE: - if ( TRUE == treatStartReqReceived ) - { - requestNewOperationMode( MODE_TPAR ); - treatStartReqReceived = FALSE; - } - break; - - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_STANDBY_INVALID_STATE, currentStandbyState ); - currentStandbyState = STANDBY_START_STATE; - break; - } -#endif - return currentStandbyState; } Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -ra6587c2ba0a40bdf12b5fdcf2ba8dec0cd958cfa -r5c083ca7d4ebd1ebd8e745c0fba7148e59894569 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision a6587c2ba0a40bdf12b5fdcf2ba8dec0cd958cfa) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 5c083ca7d4ebd1ebd8e745c0fba7148e59894569) @@ -7,8 +7,8 @@ * * @file OperationModes.c * -* @author (last) Michael Garthwaite -* @date (last) 31-Jan-2023 +* @author (last) Sean Nash +* @date (last) 13-Mar-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -42,7 +42,7 @@ #define BROADCAST_HD_OP_MODE_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< HD operation mode broadcast interval (in task interval/sec). #define DATA_PUBLISH_COUNTER_START_COUNT 11 ///< Data publish counter start count. -#define NUM_CONFIRM_REQUESTS 4 ///< Number of available confirmation requests. +#define MAX_PENDING_CONFIRM_REQUESTS 4 ///< Maximum number of confirmation requests allowed at any given time. #define CONFIRMATION_REQUEST_TIMEOUT_MS ( SEC_PER_MIN * MS_PER_SECOND ) ///< Confirmation response timeout in ms /// Structure for confirmation request. @@ -64,7 +64,7 @@ /// 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 }; /// Local structure init for saving confirmation requests -static CONFIRMATION_REQUEST_T confirmRequests[NUM_CONFIRM_REQUESTS] = +static CONFIRMATION_REQUEST_T confirmRequests[ MAX_PENDING_CONFIRM_REQUESTS ] = { GENERIC_CONFIRM_ID_NONE, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0, CONFIRMATION_REQUEST_STATUS_UNUSED, GENERIC_CONFIRM_ID_NONE, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0, CONFIRMATION_REQUEST_STATUS_UNUSED, GENERIC_CONFIRM_ID_NONE, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0, CONFIRMATION_REQUEST_STATUS_UNUSED, @@ -434,14 +434,13 @@ * all active confirmation requests and updates the timeout. * @details Inputs: confirmRequests[] * @details Outputs: confirmRequests[] status updated if timeout. - * @param none * @return none *************************************************************************/ void updateConfirmationRequestTimeouts( void ) { U08 i; - for ( i = 0; i < NUM_CONFIRM_REQUESTS; i++ ) + for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { if ( CONFIRMATION_REQUEST_STATUS_PENDING == confirmRequests[ i ].status ) { @@ -457,9 +456,9 @@ * @brief * The getConfirmationRequestStatus function returns the status of a confirmation request * @details Inputs: confirmRequests[] - * @details Outputs: confirmRequests[] cleared if completed. - * @param request ID - * @return CONFIRMATION_REQUEST_STATUS_T + * @details Outputs: confirmRequests[] consumed/cleared if completed. + * @param request_id ID of confirmation being requested + * @return Status of given confirmation *************************************************************************/ CONFIRMATION_REQUEST_STATUS_T getConfirmationRequestStatus( GENERIC_CONFIRM_ID_T request_id ) { @@ -468,15 +467,15 @@ BOOL pending = FALSE; U08 pending_index = 0; - for ( i = 0; i < NUM_CONFIRM_REQUESTS; i++ ) + for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { if ( confirmRequests[ i ].requestID == request_id ) { status = confirmRequests[ i ].status; if ( CONFIRMATION_REQUEST_STATUS_PENDING != status ) { // Send UI clear - if ( CONFIRMATION_REQUEST_STATUS_TIMEOUT == confirmRequests[ i ].status ) + if ( CONFIRMATION_REQUEST_STATUS_TIMEOUT == status ) { sendConfirmationRequest( confirmRequests[ i ].requestID, GENERIC_CONFIRM_CMD_TIMEOUT_CLOSE, 0 ); } @@ -523,16 +522,16 @@ * @brief * The setConfirmationRequestStatus function sets the status of a confirmation request * @details Inputs: confirmRequests[] - * @details Outputs: confirmRequests[] status. - * @param request ID - * @param new status - * @return CONFIRMATION_REQUEST_STATUS_T + * @details Outputs: confirmRequests[]. + * @param request_id ID of confirmation being requested + * @param status Status to set for given confirmation (open, close, reject) + * @return none *************************************************************************/ void setConfirmationRequestStatus( GENERIC_CONFIRM_ID_T request_id, CONFIRMATION_REQUEST_STATUS_T status ) { U08 i; - for ( i = 0; i < NUM_CONFIRM_REQUESTS; i++ ) + for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { if ( confirmRequests[ i ].requestID == request_id ) { @@ -547,16 +546,17 @@ * The addConfirmationRequest function sends a confirmation request to UI * @details Inputs: confirmRequests[] * @details Outputs: confirmRequests[] new added. - * @param request_id - confirm id / type - * @param request_type - confirm command + * @param request_id ID of confirmation being requested + * @param request_type Type of confirmation being requested (open, close, reject) + * @param reject_Reason Reason for reject if type is reject * @return request ID - will be non-zero if added *************************************************************************/ GENERIC_CONFIRM_ID_T addConfirmationRequest( GENERIC_CONFIRM_ID_T request_id, GENERIC_CONFIRM_COMMAND_T request_type, U32 reject_reason ) { U08 i; GENERIC_CONFIRM_ID_T new_id = GENERIC_CONFIRM_ID_NONE; - for ( i = 0; i < NUM_CONFIRM_REQUESTS; i++ ) + for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { if ( CONFIRMATION_REQUEST_STATUS_UNUSED == confirmRequests[ i ].status ) { Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r99ec83eff4683ad69a249f935d74cb9226984d21 -r5c083ca7d4ebd1ebd8e745c0fba7148e59894569 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 99ec83eff4683ad69a249f935d74cb9226984d21) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 5c083ca7d4ebd1ebd8e745c0fba7148e59894569) @@ -851,18 +851,22 @@ memcpy( &cmd, message->payload, sizeof(U32) ); - if ( 0 == cmd ) // Command 0 = Flush + if ( DG_DISINFECT_FLUSH_STATE == cmd ) // Command 0 = Flush { result = signalUserInitiateFlushMode(); } - else if ( 1 == cmd ) // Command 1 = Heat disinfect + else if ( DG_DISINFECT_HEAT_STATE == cmd ) // Command 1 = Heat disinfect { result = signalUserInitiateHeatDisinfectMode(); } - else if ( 2 == cmd ) // Command 2 = chemical disinfect + else if ( DG_DISINFECT_CHEM_STATE == cmd ) // Command 2 = chemical disinfect { result = signalUserInitiateChemicalDisinfectMode(); } + else if ( DG_DISINFECT_CHEM_FLUSH_STATE == cmd ) // Command 3 = chemical disinfect flush + { + result = signalUserInitiateChemcialDisinfectFlushMode(); + } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); @@ -1050,7 +1054,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &reason, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, alarmList, size ); + memcpy( payloadPtr, alarmList, sizeof( U32 ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -1229,7 +1233,7 @@ * @param message a pointer to the message to handle * @return none. *************************************************************************/ -void handleInstallationConfirm( MESSAGE_T *message ) +void handleInstallationConfirm( MESSAGE_T *message ) { if ( 0 == message->hdr.payloadLen ) { @@ -1798,6 +1802,35 @@ /*********************************************************************//** * @brief + * The sendDGStartChemicalDisinfectFlushModeCommand function constructs a DG + * start/stop chemical disinfect flush mode command message and queues the msg + * for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start chemical disinfect flush mode command msg + * constructed and queued. + * @param start TRUE indicates start chemical disinfect flush mode + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartChemicalDisinfectFlushModeCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_CHEM_DISINFECT_FLUSH; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( msg.payload, &start, sizeof( BOOL ) ); + + // 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 broadcastAlarmStatus function constructs an alarm status msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -3305,7 +3338,7 @@ if ( ( CONFIRMATION_REQUEST_STATUS_REJECTED == status ) || ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == status ) ) { - setConfirmationRequestStatus( (GENERIC_CONFIRM_ID_T) request_id, (CONFIRMATION_REQUEST_STATUS_T) status ); + setConfirmationRequestStatus( (GENERIC_CONFIRM_ID_T)request_id, (CONFIRMATION_REQUEST_STATUS_T)status ); } } @@ -3345,7 +3378,33 @@ serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } +/*********************************************************************//** + * @brief + * The handleSendChemFlushPassFailToDG function sends the result of the + * chemical disinfect flush sample pass/fail to DG + * @details Inputs: none + * @details Outputs: none + * @param status which is the status of the result + * @return none + *************************************************************************/ +void handleSendChemFlushPassFailToDG( U32 status ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_CHEM_FLUSH_SAMPLE_PASS_FAIL_TO_DG; + // The payload length is U32 Request ID, U32 Type + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &status, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_NOT_REQUIRED ); +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -7939,4 +7998,73 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleDialInPumpHardStopRequest function handles a + * request to stop the dial in pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDialInPumpHardStopRequest( MESSAGE_T * message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( 0 == message->hdr.payloadLen ) + { + signalDialInPumpHardStop(); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleDialOutPumpHardStopRequest function handles a + * request to stop the dial out pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDialOutPumpHardStopRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( 0 == message->hdr.payloadLen ) + { + signalDialOutPumpHardStop(); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleBloodPumpHardStopRequest function handles a + * request to stop the blood pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBloodPumpHardStopRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( 0 == message->hdr.payloadLen ) + { + signalBloodPumpHardStop(); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/