Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r766708fceb0bdf1af8c7897df29d4f5036bfd3db -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 766708fceb0bdf1af8c7897df29d4f5036bfd3db) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -27,12 +27,15 @@ #include "ModePreTreat.h" #include "ModeStandby.h" #include "ModeTreatment.h" -#include "ModeTreatmentParams.h" -#include "PresOccl.h" +#include "ModeTreatmentParams.h" +#include "OperationModes.h" +#include "PresOccl.h" #include "RTC.h" #include "SafetyShutdown.h" #include "SystemComm.h" -#include "SystemCommMessages.h" +#include "SystemCommMessages.h" +#include "TreatmentEnd.h" +#include "TreatmentRecirc.h" #include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" @@ -361,8 +364,8 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; -} - +} + /*********************************************************************//** * @brief * The sendChangeBloodDialysateRateChangeResponse function constructs a change @@ -531,6 +534,34 @@ return result; } + +/*********************************************************************//** + * @brief + * The sendDGChangeValveSettingCommand function constructs a DG change valve + * setting message for DG and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG change valve setting msg constructed and queued. + * @param valveSettingCmd valve setting ID to change to + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGChangeValveSettingCommand( U32 valveSettingCmd ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_CHANGE_VALVE_SETTING_CMD; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &valveSettingCmd, 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_2_DG, ACK_REQUIRED ); + + return result; +} /*********************************************************************//** * @brief @@ -566,9 +597,7 @@ * and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: DG drain command msg constructed and queued. - * @param drainToVolumeMl volume (in mL) to drain the inactive reservoir to - * @param tareLoadCells set to TRUE if inactive reservoir load cells should be - * tared after draining + * @param drainCmdPtr drain command data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGDrainCommand( DRAIN_RESERVOIR_CMD_PAYLOAD_T *drainCmdPtr ) @@ -625,10 +654,11 @@ * appropriate CAN channel. * @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 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 ) +BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start, F32 trimmerHtrTemp ) { BOOL result; MESSAGE_T msg; @@ -637,10 +667,12 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD; - msg.hdr.payloadLen = sizeof( BOOL ); + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( F32 ); + + memcpy( payloadPtr, &start, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &trimmerHtrTemp, sizeof( F32 ) ); - memcpy( payloadPtr, &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 ); @@ -669,10 +701,58 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); return result; -} +} + +/*********************************************************************//** + * @brief + * The handleDGCmdResp function handles a DG command response message. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param messagePtr pointer to the message to handle. + * @return none + *************************************************************************/ +void handleDGCmdResp( MESSAGE_T *messagePtr ) +{ + BOOL result = FALSE; + if ( messagePtr->hdr.payloadLen == sizeof( DG_CMD_RESPONSE_T ) ) + { + DG_CMD_RESPONSE_T dgCmdResponse; + + result = TRUE; + memcpy( &dgCmdResponse, messagePtr->payload, sizeof( DG_CMD_RESPONSE_T ) ); + handleDGCommandResponse( &dgCmdResponse ); + } + + sendAckResponseMsg( (MSG_ID_T)messagePtr->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, result ); +} + /*********************************************************************//** * @brief + * The handleDGOpMode function handles a DG broadcast of its current mode. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param message pointer to the message to handle. + * @return none + *************************************************************************/ +void handleDGOpMode( MESSAGE_T *message ) +{ + U32 payloadSize = sizeof(U32) + sizeof(U32); + + if ( message->hdr.payloadLen == payloadSize ) + { + U32 mode, subMode; + + memcpy( &mode, message->payload, sizeof(U32) ); + memcpy( &subMode, &message->payload[sizeof(U32)], sizeof(U32) ); + + setDGOpMode( mode, subMode ); + checkInFromDG(); // TODO - here until we implement DG check-in w/ HD broadcast + } +} + +/*********************************************************************//** + * @brief * The broadcastAccelData function constructs an accelerometer data msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -1040,28 +1120,19 @@ * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: treatment state msg constructed and queued - * @param subMode Current state (sub-mode) of treatment - * @param uFState Current state of ultrafiltration - * @param salineBolusState 1=saline bolus in progress, 0=not, 2=max bolus volume reached + * @param payload Record with treatment state data * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastTreatmentState( U32 subMode, U32 uFState, U32 salineBolusState ) +BOOL broadcastTreatmentState( TREATMENT_STATE_DATA_T payload ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - TREATMENT_STATE_DATA_T payload; - // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_TREATMENT_STATE; msg.hdr.payloadLen = sizeof( TREATMENT_STATE_DATA_T ); - payload.treatmentSubMode = subMode; - payload.uFState = uFState; - payload.salineBolusState = salineBolusState; - payload.heparinState = 0; // TODO - add this later - memcpy( payloadPtr, &payload, sizeof( TREATMENT_STATE_DATA_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -1100,7 +1171,8 @@ * broadcast message and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: HD operation mode msg constructed and queued - * @param mode current HD operation mode + * @param mode current HD operation mode + * @param subMode current HD operation sub-mode * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastHDOperationMode( U32 mode, U32 subMode ) @@ -1130,6 +1202,7 @@ * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: HD valves msg constructed and queued + * @param valveData valve data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastHDValves( HD_VALVE_DATA_T *valveData ) @@ -1157,6 +1230,7 @@ * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: saline bolus data msg constructed and queued + * @param data saline bolus data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastSalineBolusData( SALINE_BOLUS_DATA_PAYLOAD_T data ) @@ -1180,10 +1254,130 @@ /***********************************************************************//** * @brief + * The broadcastTreatmentStopData function constructs a treatment stop data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: treatment stop data msg constructed and queued + * @param timeout treatment stop timeout (in sec) + * @param countdown treatment stop timeout count down (in sec) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastTreatmentStopData( U32 timeout, U32 countdown ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_STOP_TIMER_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &timeout, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &countdown, 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; +} + +/***********************************************************************//** + * @brief + * The broadcastRinsebackData function constructs a rinseback data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: rinseback data msg constructed and queued + * @param data rinseback data record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastRinsebackData( RINSEBACK_DATA_PAYLOAD_T data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RINSEBACK_PROGRESS; + msg.hdr.payloadLen = sizeof( RINSEBACK_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &data, sizeof( RINSEBACK_DATA_PAYLOAD_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_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/***********************************************************************//** + * @brief + * The broadcastRecircData function constructs a treatment re-circ data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: treatment re-circ data msg constructed and queued + * @param timeout re-circulation timeout (in sec) + * @param countdown re-circulation timeout count down (in sec) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastRecircData( U32 timeout, U32 countdown ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RECIRC_PROGRESS; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &timeout, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &countdown, 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; +} + +/***********************************************************************//** + * @brief + * The broadcastBloodPrimeData function constructs a blood prime data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: blood prime data msg constructed and queued + * @param data blood prime data record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastBloodPrimeData( BLOOD_PRIME_DATA_PAYLOAD_T data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_BLOOD_PRIME_PROGRESS; + msg.hdr.payloadLen = sizeof( BLOOD_PRIME_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &data, sizeof( BLOOD_PRIME_DATA_PAYLOAD_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_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/***********************************************************************//** + * @brief * The broadcastAirTrapData function constructs an HD air trap data msg to \n * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: air trap data msg constructed and queued + * @param lowerLevel air trap lower level data + * @param upperLevel air trap upper level data * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAirTrapData( AIR_TRAP_LEVELS_T lowerLevel, AIR_TRAP_LEVELS_T upperLevel ) @@ -1209,6 +1403,34 @@ return result; } +/***********************************************************************//** + * @brief + * The broadcastAirTrapData function constructs an HD air trap data msg to \n + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: air trap data msg constructed and queued + * @param primeDataPtr prime data record pointer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastPrimeData( PRIMING_DATA_PAYLOAD_T *primeDataPtr ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_PRIMING_STATUS_DATA; + msg.hdr.payloadLen = sizeof( PRIMING_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, primeDataPtr, sizeof( PRIMING_DATA_PAYLOAD_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_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -1335,7 +1557,7 @@ memcpy( &cmd, payloadPtr, sizeof( U32 ) ); - signalAlarmSilence( cmd ); + signalAlarmSilence( (ALARM_SILENCE_CMD_T)cmd ); } else { @@ -1655,56 +1877,6 @@ /*********************************************************************//** * @brief - * The handleUIUserEndTreatmentRequest function handles a treatment end - * request message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleUIUserEndTreatmentRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == 0 ) - { - result = userRequestEndTreatment(); - } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); -} - -/*********************************************************************//** - * @brief - * The sendTreatmentEndResponseMsg function constructs a treatment end - * request response message to the UI and queues the msg for transmit on - * the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Treatment end response msg constructed and queued. - * @param accepted T/F - request accepted? - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendTreatmentEndResponseMsg( BOOL accepted ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_TREATMENT_END_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ); - - memcpy( payloadPtr, &accepted, 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_UI, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief * The handleTreatmentParametersFromUI function handles a treatment parameters * set and validate request message from the UI. * @details Inputs: none @@ -1924,7 +2096,7 @@ sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); } } - + /*********************************************************************//** * @brief * The handleChangeBloodDialysateRateChangeRequest function handles a blood @@ -2043,34 +2215,180 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; +} + +/*********************************************************************//** + * @brief + * The handlRinsebackCmd function handles a rinseback user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handlRinsebackCmd( MESSAGE_T *message ) +{ + if ( sizeof(U32) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof(U32) ); + + signalRinsebackUserAction( (REQUESTED_RINSEBACK_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendRinsebackCmdResponse function constructs a rinseback user action + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Rinseback command response msg constructed and queued. + * @param accepted T/F - was rinseback user action accepted? + * @param rejReason reason why action was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendRinsebackCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RINSEBACK_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, 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_2_UI, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleTreatmentRecircCmd function handles a treatment re-circ user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTreatmentRecircCmd( MESSAGE_T *message ) +{ + if ( sizeof(U32) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof(U32) ); + + signalTreatmentRecircUserAction( (REQUESTED_TREATMENT_RECIRC_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendTreatmentRecircCmdResponse function constructs a treatment re-circulation + * user action response to the UI and queues the msg for transmit on the appropriate + * CAN channel. + * @details Inputs: none + * @details Outputs: Treatment re-circ command response msg constructed and queued. + * @param accepted T/F - was re-circ user action accepted? + * @param rejReason reason why action was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentRecircCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RECIRC_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, 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_2_UI, ACK_REQUIRED ); + + return result; } + +/*********************************************************************//** + * @brief + * The handleTreatmentEndCmd function handles a treatment end user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTreatmentEndCmd( MESSAGE_T *message ) +{ + if ( sizeof(U32) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof(U32) ); + + signalTreatmentEndUserAction( (REQUESTED_TREATMENT_END_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendTreatmentEndCmdResponse function constructs a treatment end + * user action response to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment end command response msg constructed and queued. + * @param accepted T/F - was user action accepted? + * @param rejReason reason why action was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentEndCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TX_END_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, 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_2_UI, ACK_REQUIRED ); + + return result; +} /*********************************************************************//** * @brief - * The handleDGOpMode function handles a DG broadcast of its current mode. - * @details Inputs: none - * @details Outputs: message handled, response constructed and queued for transmit. - * @param message a pointer to the message to handle. - * @return none - *************************************************************************/ -void handleDGOpMode( MESSAGE_T *message ) -{ - U32 payloadSize = sizeof(U32) + sizeof(U32); - - if ( message->hdr.payloadLen == payloadSize ) - { - U32 mode, subMode; - - memcpy( &mode, message->payload, sizeof(U32) ); - memcpy( &subMode, &message->payload[sizeof(U32)], sizeof(U32) ); - - setDGOpMode( mode, subMode ); - checkInFromDG(); // TODO - here until we implement DG check-in w/ HD broadcast - } -} - -/*********************************************************************//** - * @brief * The handleFWVersionRequest function handles a request for HD f/w version. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for transmit. @@ -3423,6 +3741,31 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleTestTreatmentTimeRemainingOverrideRequest function handles a treatment + * time remaining override request message. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTreatmentTimeRemainingOverrideRequest( MESSAGE_T *message ) +{ + U32 payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(U32) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(U32) ); + result = testSetTreatmentTimeRemainingOverride( payload ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /*********************************************************************//** * @brief * The handleTestHDSafetyShutdownOverrideRequest function handles a @@ -3553,84 +3896,6 @@ /*********************************************************************//** * @brief - * The handleSetAccelCalibration function handles a request to set - * accelerometer calibration factors. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetAccelCalibration( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // Verify payload length - if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) - { - ACCEL_CAL_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(ACCEL_CAL_PAYLOAD_T) ); - result = setAccelCalibration( payload.xOffset, payload.yOffset, payload.zOffset ); - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleSetBloodFlowCalibration function handles a request to set - * blood flow calibration factors. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetBloodFlowCalibration( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // Verify payload length - if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) - { - LINEAR_F32_CAL_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(LINEAR_F32_CAL_PAYLOAD_T) ); - result = setBloodFlowCalibration( payload.gain, payload.offset ); - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleSetDialysateFlowCalibration function handles a request to set - * dialysate flow calibration factors. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetDialysateFlowCalibration( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // Verify payload length - if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) - { - LINEAR_F32_CAL_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(LINEAR_F32_CAL_PAYLOAD_T) ); - result = setDialInFlowCalibration( payload.gain, payload.offset ); - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/************************************************************************* - * @brief * The handleTestSetTreatmentParameter function handles a request to set * a specific treatment parameter value. * @details Inputs: none @@ -3655,7 +3920,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleHomeHDValve function handles a request to home an HD valve * @details Inputs: none @@ -3807,7 +4072,7 @@ } #endif -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetAirTrapBroadcastIntervalOverrideRequest function handles a * request to override the air trap data broadcast interval. @@ -3839,7 +4104,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetAirTrapLevelSensorOverrideRequest function handles a request to * override an air trap level sensor. @@ -3905,9 +4170,8 @@ * @brief * The handleTestBloodPumpHomeRequest function handles a request to home * the blood pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3928,9 +4192,8 @@ * @brief * The handleTestDialInPumpHomeRequest function handles a request to home * the dialysate inlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3951,9 +4214,8 @@ * @brief * The handleTestDialOutPumpHomeRequest function handles a request to home * the dialysate outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3974,9 +4236,8 @@ * @brief * The handleTestSuperClearAlarmsRequest function handles a request to clear * all active alarms. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3990,8 +4251,6 @@ memcpy( &key, message->payload, sizeof(U32) ); result = testClearAllAlarms( key ); - - result = TRUE; } // Respond to request @@ -4000,65 +4259,23 @@ /*********************************************************************//** * @brief - * The handleTestHDCalibrationDataRequest function handles a request for - * HD calibration data. - * @details - * Inputs : none - * Outputs : message handled + * The handleTestSetOpModeRequest function handles a request to set the + * HD operation mode. + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestHDCalibrationDataRequest( MESSAGE_T *message ) +void handleTestSetOpModeRequest( MESSAGE_T *message ) { BOOL result = FALSE; - if ( 0 == message->hdr.payloadLen ) - { - CALIBRATION_DATA_T cal; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Get calibration data - result = getCalibrationData( &cal ); - if ( TRUE == result ) - { - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_CALIBRATION_DATA; - msg.hdr.payloadLen = sizeof( CALIBRATION_DATA_T ); - - memcpy( payloadPtr, &cal, sizeof( CALIBRATION_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - } - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleTestEraseHDCalibrationDataRequest function handles a request for - * HD calibration data erasure. - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestEraseHDCalibrationDataRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) { - U32 key; + U32 mode; - memcpy( &key, message->payload, sizeof(U32) ); - - result = testResetCalibrationData( key ); + memcpy( &mode, message->payload, sizeof(U32) ); + result = testSetOperationMode( (HD_OP_MODE_T)mode ); } // Respond to request