Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -rbd738c0705e8640d2c532ecece876aaa3496ee32 -ra19a676d1e67bb3e1aca9e9bba49727f9d5f8b38 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision bd738c0705e8640d2c532ecece876aaa3496ee32) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision a19a676d1e67bb3e1aca9e9bba49727f9d5f8b38) @@ -26,11 +26,17 @@ // ********** private definitions ********** +#define START_DG_CMD TRUE +#define STOP_DG_CMD FALSE // ********** private data ********** -// DG mode +// DG status static DG_OP_MODE_T dgCurrentOpMode = DG_MODE_INIT; +static BOOL dgStarted = FALSE; +static BOOL dgStartetSet = FALSE; +static BOOL dgWaterSampled = FALSE; +static BOOL dgWaterSampledSet = FALSE; // DG sensor data static F32 dgPressures[ NUM_OF_DG_PRESSURE_SENSORS ]; @@ -204,7 +210,7 @@ * @param drainVol : Reservoir drain to volume reported by DG. * @return none *************************************************************************/ -void setDGReservoirsData( U32 resID, U32 fillVol, U32 drainVol ) +void setDGReservoirsData( DG_RESERVOIR_ID_T resID, U32 fillVol, U32 drainVol ) { if ( resID < NUM_OF_DG_RESERVOIRS ) { @@ -275,11 +281,11 @@ * @param trimmerHtrTemp : commanded target dialysate temperature for the trimmer heater. * @return none *************************************************************************/ -void cmdSetDGDialysateTargetTemps( U32 primaryHtrTemp, U32 trimmerHtrTemp ) +void cmdSetDGDialysateTargetTemps( F32 primaryHtrTemp, F32 trimmerHtrTemp ) { dgPrimaryTempSet = primaryHtrTemp; dgTrimmerTempSet = trimmerHtrTemp; - // TODO - send command to DG + sendDialysateTempTargetsToDG( primaryHtrTemp, trimmerHtrTemp ); } /*********************************************************************//** @@ -293,7 +299,8 @@ *************************************************************************/ void cmdStartDG( void ) { - // TODO - send command to DG + dgStarted = TRUE; + sendDGStartStopCommand( START_DG_CMD ); } /*********************************************************************//** @@ -307,7 +314,8 @@ *************************************************************************/ void cmdStopDG( void ) { - // TODO - send command to DG + dgStarted = FALSE; + sendDGStartStopCommand( STOP_DG_CMD ); } /*********************************************************************//** @@ -325,7 +333,7 @@ if ( resID < NUM_OF_DG_RESERVOIRS ) { dgActiveReservoirSet = resID; - // TODO - send command to DG + sendDGSwitchReservoirCommand( resID ); } else { @@ -345,7 +353,7 @@ void cmdStartDGFill( U32 fillToVolMl ) { dgReservoirFillVolumeTargetSet = fillToVolMl; - // TODO - send command to DG + sendDGFillCommand( fillToVolMl ); } /*********************************************************************//** @@ -360,7 +368,21 @@ void cmdStartDGDrain( U32 drainToVolMl ) { dgReservoirDrainVolumeTargetSet = drainToVolMl; - // TODO - send command to DG + sendDGDrainCommand( drainToVolMl ); } +/*********************************************************************//** + * @brief + * The cmdDGSampleWater function sends a sample water command message to the DG. + * @details + * Inputs : none + * Outputs : sample water command sent to DG. + * @return none + *************************************************************************/ +void cmdDGSampleWater( void ) +{ + dgWaterSampled = TRUE; + sendDGSampleWaterCommand(); +} + /**@}*/ Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -rbd738c0705e8640d2c532ecece876aaa3496ee32 -ra19a676d1e67bb3e1aca9e9bba49727f9d5f8b38 --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision bd738c0705e8640d2c532ecece876aaa3496ee32) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision a19a676d1e67bb3e1aca9e9bba49727f9d5f8b38) @@ -79,17 +79,18 @@ void setDGOpMode( U32 opMode ); void setDGDialysateTemperatures( F32 primaryHtrTemp, F32 trimmerHtrTemp ); -void setDGReservoirsData( U32 resID, U32 fillVol, U32 drainVol ); +void setDGReservoirsData( DG_RESERVOIR_ID_T resID, U32 fillVol, U32 drainVol ); void setDGPressures( F32 roIn, F32 roOut, F32 drainIn, F32 drainOut ); void setDGROPumpData( U32 presSetPt, F32 flowRate ); void setDGDrainPumpData( U32 rpmSetPt ); -void cmdSetDGDialysateTargetTemps( U32 primaryHtrTemp, U32 trimmerHtrTemp ); +void cmdSetDGDialysateTargetTemps( F32 primaryHtrTemp, F32 trimmerHtrTemp ); void cmdStartDG( void ); void cmdStopDG( void ); void cmdSetDGActiveReservoir( DG_RESERVOIR_ID_T resID ); void cmdStartDGFill( U32 fillToVolMl ); void cmdStartDGDrain( U32 drainToVolMl ); +void cmdDGSampleWater( void ); /**@}*/ Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r9b262ba08e3180f121c3cf19d8d25e565183f87d -ra19a676d1e67bb3e1aca9e9bba49727f9d5f8b38 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 9b262ba08e3180f121c3cf19d8d25e565183f87d) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision a19a676d1e67bb3e1aca9e9bba49727f9d5f8b38) @@ -81,6 +81,7 @@ if ( TRUE == stop ) { + cmdStartDG(); requestNewOperationMode( MODE_PRES ); } #ifdef RM46_EVAL_BOARD_TARGET Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rbbea4a2a607ed759bc283c75623c0e3f9a8c066c -ra19a676d1e67bb3e1aca9e9bba49727f9d5f8b38 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision bbea4a2a607ed759bc283c75623c0e3f9a8c066c) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a19a676d1e67bb3e1aca9e9bba49727f9d5f8b38) @@ -118,7 +118,7 @@ typedef struct { - U32 resID; + DG_RESERVOIR_ID_T resID; U32 setFillToVolumeMl; U32 setDrainToVolumeMl; } DG_RESERVOIRS_DATA_PAYLOAD_T; @@ -522,6 +522,147 @@ } /************************************************************************* + * @brief + * The sendDGSwitchReservoirCommand function constructs a DG set active \n + * reservoir message for DG and queues the msg for transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : DG set active reservoir msg constructed and queued. + * @param activeReservoir : reservoir ID to set as active. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGSwitchReservoirCommand( DG_RESERVOIR_ID_T activeReservoir ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SWITCH_RESERVOIR_CMD; + msg.hdr.payloadLen = sizeof( DG_RESERVOIR_ID_T ); + + memcpy( payloadPtr, &activeReservoir, sizeof( DG_RESERVOIR_ID_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_2_DG, ACK_REQUIRED ); + + return result; +} + +/************************************************************************* + * @brief + * The sendDGFillCommand function constructs a DG fill command message \n + * and queues the msg for transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : DG fill command msg constructed and queued. + * @param fillToVolumeMl : volume (in mL) to fill inactive reservoir to. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGFillCommand( U32 fillToVolumeMl ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_FILL_CMD; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &fillToVolumeMl, 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 + * The sendDGDrainCommand function constructs a DG drain command message \n + * and queues the msg for transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : DG drain command msg constructed and queued. + * @param drainToVolumeMl : volume (in mL) to drain the inactive reservoir to. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGDrainCommand( U32 drainToVolumeMl ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_DRAIN_CMD; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &drainToVolumeMl, 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 + * The sendDGStartStopCommand function constructs a DG start/stop command \n + * message and queues the msg for transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : DG start/stop command msg constructed and queued. + * @param start : TRUE indicates start DG, FALSE indicates stop DG. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartStopCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_STARTING_STOPPING_TREATMENT_CMD; + msg.hdr.payloadLen = sizeof( BOOL ); + + 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 ); + + return result; +} + +/************************************************************************* + * @brief + * The sendDGSampleWaterCommand function constructs a DG sample water command \n + * message and queues the msg for transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : DG sample water command msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGSampleWaterCommand( void ) +{ + BOOL result; + MESSAGE_T msg; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SAMPLE_WATER_CMD; + 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 broadcastAlarmStatus * The broadcastAlarmStatus function constructs an alarm status msg to \n * be broadcast and queues the msg for transmit on the appropriate CAN channel. Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -ra4c13a58e281ff7a626a58317bc8a280df7e516e -ra19a676d1e67bb3e1aca9e9bba49727f9d5f8b38 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision a4c13a58e281ff7a626a58317bc8a280df7e516e) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision a19a676d1e67bb3e1aca9e9bba49727f9d5f8b38) @@ -20,6 +20,7 @@ #include "HDCommon.h" #include "MsgQueues.h" #include "DialOutFlow.h" +#include "DGInterface.h" // ********** public definitions ********** @@ -80,6 +81,21 @@ // MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS BOOL sendDialysateTempTargetsToDG( F32 primary, F32 trimmer ); +// MSG_ID_DG_SWITCH_RESERVOIR_CMD +BOOL sendDGSwitchReservoirCommand( DG_RESERVOIR_ID_T activeReservoir ); + +// MSG_ID_DG_FILL_CMD +BOOL sendDGFillCommand( U32 fillToVolumeMl ); + +// MSG_ID_DG_DRAIN_CMD +BOOL sendDGDrainCommand( U32 drainToVolumeMl ); + +// MSG_ID_STARTING_STOPPING_TREATMENT_CMD +BOOL sendDGStartStopCommand( BOOL start ); + +// MSG_ID_DG_SAMPLE_WATER_CMD +BOOL sendDGSampleWaterCommand( void ); + // MSG_ID_DG_OP_MODE: void handleDGOpMode( MESSAGE_T *message );