Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r39bff5f9647203d9eb86e18048728057dc68b4eb -r5a04a1445b684aedd199e0294311db468635c152 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 39bff5f9647203d9eb86e18048728057dc68b4eb) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 5a04a1445b684aedd199e0294311db468635c152) @@ -19,24 +19,21 @@ #include "Accel.h" #include "AlarmLamp.h" -#include "BloodFlow.h" #include "Buttons.h" #include "DGInterface.h" -#include "DialInFlow.h" -#include "Dialysis.h" #include "FPGA.h" #include "MessagePayloads.h" #include "ModeStandby.h" #include "ModeTreatment.h" #include "ModeTreatmentParams.h" #include "PresOccl.h" +#include "RTC.h" #include "SafetyShutdown.h" #include "SystemComm.h" #include "SystemCommMessages.h" #include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" -#include "RTC.h" /** * @addtogroup SystemCommMessages @@ -288,8 +285,8 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; -} - +} + /*********************************************************************//** * @brief * The sendChangeUFSettingsResponse function constructs a UF change settings @@ -823,37 +820,22 @@ * @details * Inputs : none * Outputs : blood flow data msg constructed and queued. - * @param flowStPt Current set point for blood flow - * @param measFlow Latest measured blood flow - * @param measRotorSpd Latest measured blood pump rotoro speed - * @param measSpd Latest measured blood pump speed - * @param measMCspd Latest measured blood pump motor controller speed - * @param measSpd Latest measured blood pump motor controller current - * @param pwmDC Latest PWM duty cycle % + * @param bloodData blood pump and flow data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastBloodFlowData( U32 flowStPt, F32 measFlow, F32 measRotorSpd, F32 measSpd, F32 measMCSpd, F32 measMCCurr, F32 pwmDC ) +BOOL broadcastBloodFlowData( BLOOD_PUMP_STATUS_PAYLOAD_T bloodData ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - PERISTALTIC_PUMP_STATUS_PAYLOAD_T payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_BLOOD_FLOW_DATA; - msg.hdr.payloadLen = sizeof( PERISTALTIC_PUMP_STATUS_PAYLOAD_T ); + msg.hdr.payloadLen = sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ); - payload.setPoint = flowStPt; - payload.measFlow = measFlow; - payload.measRotorSpd = measRotorSpd; - payload.measPumpSpd = measSpd; - payload.measMCSpd = measMCSpd; - payload.measMCCurr = measMCCurr; - payload.pwmDC = pwmDC; + memcpy( payloadPtr, &bloodData, sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ) ); - memcpy( payloadPtr, &payload, sizeof( PERISTALTIC_PUMP_STATUS_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 ); @@ -867,37 +849,22 @@ * @details * Inputs : none * Outputs : dialysate flow data msg constructed and queued. - * @param flowStPt Current set point for dialysate flow - * @param measFlow Latest measured dialysate flow - * @param measRotorSpd Latest measured dialysate pump rotor speed - * @param measSpd Latest measured dialysate pump speed - * @param measMCspd Latest measured dialysate pump motor controller speed - * @param measSpd Latest measured dialysate pump motor controller current - * @param pwmDC Latest PWM duty cycle % + * @param dialInData Dialysate inlet pump and flow data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastDialInFlowData( U32 flowStPt, F32 measFlow, F32 measRotorSpd, F32 measSpd, F32 measMCSpd, F32 measMCCurr, F32 pwmDC ) +BOOL broadcastDialInFlowData( DIALIN_PUMP_STATUS_PAYLOAD_T dialInData ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - PERISTALTIC_PUMP_STATUS_PAYLOAD_T payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DIALYSATE_FLOW_DATA; - msg.hdr.payloadLen = sizeof( PERISTALTIC_PUMP_STATUS_PAYLOAD_T ); + msg.hdr.payloadLen = sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ); - payload.setPoint = flowStPt; - payload.measFlow = measFlow; - payload.measRotorSpd = measRotorSpd; - payload.measPumpSpd = measSpd; - payload.measMCSpd = measMCSpd; - payload.measMCCurr = measMCCurr; - payload.pwmDC = pwmDC; + memcpy( payloadPtr, &dialInData, sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ) ); - memcpy( payloadPtr, &payload, sizeof( PERISTALTIC_PUMP_STATUS_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 ); @@ -1158,6 +1125,33 @@ return result; } +/***********************************************************************//** + * @brief + * The broadcastSalineBolusData function constructs a saline bolus data msg to + * 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 + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastSalineBolusData( SALINE_BOLUS_DATA_PAYLOAD_T data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_SALINE_BOLUS_DATA; + msg.hdr.payloadLen = sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &data, sizeof( SALINE_BOLUS_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 ) { @@ -1461,6 +1455,38 @@ /*********************************************************************//** * @brief + * The sendUFPauseResumeResponse function constructs a UF pause/resume + * response to the UI and queues the msg for transmit on the appropriate CAN + * channel. + * @details Inputs: none + * @details Outputs: UF pause/resume response msg constructed and queued. + * @param accepted was pause/resume request accepted + * @param reason reason rejected (if not accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendUFPauseResumeResponse( BOOL accepted, U32 reason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, 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 handleUIStartTreatmentMsg function handles a treatment start/cancel * message from the UI. * @details @@ -1636,12 +1662,12 @@ * @details * Inputs : none * Outputs : Treatment parameters response msg constructed and queued. - * @param accepted T/F - are settings ok? + * @param rejected T/F - are settings rejected? * @param rejectReasons reasons each parameter was rejected (if not accepted) * @param byteLength number of bytes that array of reject reasons takes * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendTreatmentParametersResponseMsg( BOOL accepted, U08 *rejectReasons, U32 byteLength ) +BOOL sendTreatmentParametersResponseMsg( BOOL rejected, U08 *rejectReasons, U32 byteLength ) { BOOL result; MESSAGE_T msg; @@ -1652,7 +1678,7 @@ msg.hdr.msgID = MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + byteLength; - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + memcpy( payloadPtr, &rejected, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); memcpy( payloadPtr, rejectReasons, byteLength ); @@ -1768,6 +1794,72 @@ { sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); } +} + +/*********************************************************************//** + * @brief + * The handleSalineBolusRequest function handles a saline bolus request + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSalineBolusRequest( MESSAGE_T *message ) +{ + if ( sizeof(BOOL) == message->hdr.payloadLen ) + { + BOOL start; + + memcpy( &start, &message->payload[0], sizeof(BOOL) ); + + if ( TRUE == start ) + { + signalStartSalineBolus(); + } + else + { + signalAbortSalineBolus(); + } + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendSalineBolusResponse function constructs a saline bolus start/abort + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment parameters response msg constructed and queued. + * @param accepted T/F - was saline bolus request accepted? + * @param rejReason reason why request was rejected (or zero if accepted) + * @param bolusVol volume (in mL) currently set for saline bolus + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendSalineBolusResponse( BOOL accepted, U32 rejReason, U32 bolusVol ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_SALINE_BOLUS_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &bolusVol, 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; } /*********************************************************************//** @@ -1781,7 +1873,7 @@ *************************************************************************/ void handleDGOpMode( MESSAGE_T *message ) { - U32 payloadSize = sizeof(U32) + sizeof(U32); + U32 payloadSize = sizeof(U32) + sizeof(U32); if ( message->hdr.payloadLen == payloadSize ) { @@ -2256,6 +2348,38 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } + +/*********************************************************************//** + * @brief + * The handleTestBloodFlowSignalStrengthOverrideRequest function handles a + * request to override the measured blood flow signal strength (%). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBloodFlowSignalStrengthOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredBloodFlowSignalStrengthOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredBloodFlowSignalStrengthOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} /*********************************************************************//** * @brief @@ -2520,6 +2644,38 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } + +/*********************************************************************//** + * @brief + * The handleTestDialInFlowSignalStrengthOverrideRequest function handles a + * request to override the measured dialysate inlet flow signal strength (%). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialInFlowSignalStrengthOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredDialInFlowSignalStrengthOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialInFlowSignalStrengthOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} /*********************************************************************//** * @brief @@ -3393,13 +3549,13 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleHomeHDValve function handles a request to home an HD valve * @details * Inputs: none * Outputs: message handled - * @param message: a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleHomeHDValve( MESSAGE_T *message ) @@ -3415,6 +3571,7 @@ result = TRUE; } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3426,14 +3583,14 @@ * @details * Inputs: none * Outputs: message handled - * @param message: a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestHDValvesBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; - BOOL result = FALSE; + // verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { @@ -3474,25 +3631,26 @@ result = TRUE; } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetHDValvePositionOverrideRequest function handles a request to * override the position of a valve * @details * Inputs: none * Outputs: message handled - * @param message: a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetHDValvePositionOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; - BOOL result = FALSE; + // verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { @@ -3506,26 +3664,27 @@ result = testResetValvesPositionOverride( payload.index ); } } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } #ifdef DEBUG_ENABLED -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetHDValvePWMOverrideRequest function handles a request to * override the PWM of a valve * @details * Inputs: none * Outputs: message handled - * @param message: a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetHDValvePWMOverrideRequest( MESSAGE_T *message ) { OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T payload; - BOOL result = FALSE; + // verify payload length if ( sizeof(OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T) == message->hdr.payloadLen ) { @@ -3539,6 +3698,7 @@ result = testResetValvePWMOverride( payload.valve ); } } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3570,4 +3730,73 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleTestBloodPumpHomeRequest function handles a request to home + * the blood pump. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBloodPumpHomeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = homeBloodPump(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestDialInPumpHomeRequest function handles a request to home + * the dialysate inlet pump. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialInPumpHomeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = homeDialInPump(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpHomeRequest function handles a request to home + * the dialysate outlet pump. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialOutPumpHomeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = homeDialOutPump(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/