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.