Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rfb4b4a4f9d16742bfb76f62970a43c97e1ac14f0 -r968f9908941a8f8ceeacdb6aa40655abf54c1ef4 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision fb4b4a4f9d16742bfb76f62970a43c97e1ac14f0) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 968f9908941a8f8ceeacdb6aa40655abf54c1ef4) @@ -21,6 +21,7 @@ #include "AlarmLamp.h" #include "BloodFlow.h" #include "Buttons.h" +#include "DGInterface.h" #include "DialInFlow.h" #include "Dialysis.h" #include "MsgQueues.h" @@ -97,6 +98,34 @@ typedef struct { + U32 setPtPSI; + F32 measFlowRateMlMin; + F32 setPWM; +} DG_RO_PUMP_DATA_PAYLOAD_T; + +typedef struct +{ + U32 setPtRPM; + F32 setPWM; +} DG_DRAIN_PUMP_DATA_PAYLOAD_T; + +typedef struct +{ + F32 roInPSI; + F32 roOutPSI; + F32 drainInPSI; + F32 drainOutPSI; +} DG_PRESSURES_DATA_PAYLOAD_T; + +typedef struct +{ + U32 resID; + U32 setFillToVolumeMl; + U32 setDrainToVolumeMl; +} DG_RESERVOIRS_DATA_PAYLOAD_T; + +typedef struct +{ F32 volume_mL; UF_ADJ_T adjustType; } UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T; @@ -341,7 +370,7 @@ /************************************************************************* * @brief * The handleLoadCellReadingsFromDG function handles a load cell readings \n - * message from the DG. + * broadcast message from the DG. * @details * Inputs : none * Outputs : message handled @@ -364,6 +393,94 @@ /************************************************************************* * @brief + * The handleROPumpData function handles an RO pump data broadcast \n + * message from the DG. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleROPumpData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(DG_RO_PUMP_DATA_PAYLOAD_T) ) + { + DG_RO_PUMP_DATA_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(DG_RO_PUMP_DATA_PAYLOAD_T) ); + setDGROPumpData( payload.setPtPSI, payload.measFlowRateMlMin ); + } + // TODO - what to do if invalid payload length? +} + +/************************************************************************* + * @brief + * The handleDrainPumpData function handles a drain pump broadcast \n + * message from the DG. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDrainPumpData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(DG_DRAIN_PUMP_DATA_PAYLOAD_T) ) + { + DG_DRAIN_PUMP_DATA_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(DG_DRAIN_PUMP_DATA_PAYLOAD_T) ); + setDGDrainPumpData( payload.setPtRPM ); + } + // TODO - what to do if invalid payload length? +} + +/************************************************************************* + * @brief + * The handleDGPressuresData function handles a DG pressure sensor readings \n + * broadcast message from the DG. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGPressuresData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(DG_PRESSURES_DATA_PAYLOAD_T) ) + { + DG_PRESSURES_DATA_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(DG_PRESSURES_DATA_PAYLOAD_T) ); + setDGPressures( payload.roInPSI, payload.roOutPSI, payload.drainInPSI, payload.drainOutPSI ); + } + // TODO - what to do if invalid payload length? +} + +/************************************************************************* + * @brief + * The handleDGReservoirData function handles a reservoir data broadcast \n + * message from the DG. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGReservoirData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(DG_RESERVOIRS_DATA_PAYLOAD_T) ) + { + DG_RESERVOIRS_DATA_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(DG_RESERVOIRS_DATA_PAYLOAD_T) ); + setDGReservoirsData( payload.resID, payload.setFillToVolumeMl, payload.setDrainToVolumeMl ); + } + // TODO - what to do if invalid payload length? +} + +/************************************************************************* + * @brief * The handleUFPauseResumeRequest function handles a ultrafiltration pause \n * or resume request message from the UI. * @details @@ -675,6 +792,31 @@ /************************************************************************* * @brief + * The handleDGOpMode function handles a DG broadcast of it's current mode. + * @details + * Inputs : none + * 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 ) +{ + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 mode; + + memcpy( &mode, message->payload, sizeof(U32) ); + + setDGOpMode( mode ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, FALSE ); + } +} + +/************************************************************************* + * @brief * The handleFWVersionRequest function handles a request for HD f/w version. * @details * Inputs : none