Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r32d22b41c0297166bf2c89e59c968d69828d5025 -rbbd5ac2589c8093f681f2284367975ddd220b553 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 32d22b41c0297166bf2c89e59c968d69828d5025) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision bbd5ac2589c8093f681f2284367975ddd220b553) @@ -14,54 +14,57 @@ * @date (original) 05-Nov-2019 * ***************************************************************************/ - + #include // for memcpy() -#include "reg_system.h" +#include "reg_system.h" #include "Accel.h" -#include "ConcentratePumps.h" +#include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "DrainPump.h" -#include "FPGA.h" -#include "Heaters.h" -#include "LoadCell.h" +#include "FPGA.h" +#include "Heaters.h" +#include "LoadCell.h" #include "MessagePayloads.h" -#include "ModeStandby.h" -#include "ModeRecirculate.h" +#include "ModeStandby.h" +#include "ModeRecirculate.h" #include "MsgQueues.h" #include "NVDataMgmt.h" -#include "OperationModes.h" -#include "Pressures.h" -#include "Reservoirs.h" -#include "ROPump.h" -#include "RTC.h" -#include "SystemComm.h" -#include "SafetyShutdown.h" -#include "SystemCommMessages.h" -#include "TemperatureSensors.h" -#include "Utilities.h" -#include "Valves.h" -#include "WatchdogMgmt.h" +#include "OperationModes.h" +#include "Pressures.h" +#include "Reservoirs.h" +#include "ROPump.h" +#include "RTC.h" +#include "SystemComm.h" +#include "SafetyShutdown.h" +#include "SystemCommMessages.h" +#include "TemperatureSensors.h" +#include "Thermistors.h" +#include "Utilities.h" +#include "Utilities.h" +#include "Valves.h" +#include "WatchdogMgmt.h" +#include "UVReactors.h" /** * @addtogroup SystemCommMessages * @{ */ - -// ********** private definitions ********** - -#define ACK_REQUIRED TRUE ///< Require an ACK. -#define ACK_NOT_REQUIRED FALSE ///< Not require an ACK. - + +// ********** private definitions ********** + +#define ACK_REQUIRED TRUE ///< Require an ACK. +#define ACK_NOT_REQUIRED FALSE ///< Not require an ACK. + #ifdef DEBUG_ENABLED #define DEBUG_EVENT_MAX_TEXT_LEN 40 #endif // ********** private data ********** static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether tester logged in or not. -static volatile U16 nextSeqNo = 1; ///< Next sequence number. +static volatile U16 nextSeqNo = 1; ///< Next sequence number. // ********** private function prototypes ********** @@ -151,132 +154,161 @@ return result; } -/*********************************************************************//** - * @brief - * The sendACKMsg function constructs and queues for transmit an ACK message - * for a given received message. - * @details Inputs: none - * @details Outputs: ACK message queued for transmit on broadcast CAN channel. - * @param message message to send an ACK for - * @return TRUE if ACK message queued successfully, FALSE if not - *************************************************************************/ -BOOL sendACKMsg( MESSAGE_T *message ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - // send ACK back with same seq. #, but w/o ACK bit - msg.hdr.seqNo = message->hdr.seqNo * -1; - // ACK messages always have this ID - msg.hdr.msgID = MSG_ID_ACK; - // ACK messages always have no payload - msg.hdr.payloadLen = 0; - - // serialize and queue the message for transmit on broadcast channel - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} +/*********************************************************************//** + * @brief + * The sendACKMsg function constructs and queues for transmit an ACK message + * for a given received message. + * @details Inputs: none + * @details Outputs: ACK message queued for transmit on broadcast CAN channel. + * @param message message to send an ACK for + * @return TRUE if ACK message queued successfully, FALSE if not + *************************************************************************/ +BOOL sendACKMsg( MESSAGE_T *message ) +{ + BOOL result; + MESSAGE_T msg; -/*********************************************************************//** - * @brief + // create a message record + blankMessage( &msg ); + // send ACK back with same seq. #, but w/o ACK bit + msg.hdr.seqNo = message->hdr.seqNo * -1; + // ACK messages always have this ID + msg.hdr.msgID = MSG_ID_ACK; + // ACK messages always have no payload + msg.hdr.payloadLen = 0; + + // serialize and queue the message for transmit on broadcast channel + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The sendTestAckResponseMsg function constructs a simple response message for - * a handled test message and queues it for transmit on the appropriate UART channel. - * @details Inputs: none - * @details Outputs: response message constructed and queued for transmit. - * @param msgID ID of handled message that we are responding to - * @param buffer outgoing buffer that message should be queued in - * @param ack TRUE if test message was handled successfully, FALSE if not - * @return TRUE if response message successfully queued for transmit, FALSE if not - *************************************************************************/ -static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = (U08)ack; - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); - - return result; -} + * a handled test message and queues it for transmit on the appropriate UART channel. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. + * @param msgID ID of handled message that we are responding to + * @param buffer outgoing buffer that message should be queued in + * @param ack TRUE if test message was handled successfully, FALSE if not + * @return TRUE if response message successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) +{ + BOOL result; + MESSAGE_T msg; - -// *********************************************************************** -// ***************** Message Sending Helper Functions ******************** -// *********************************************************************** + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + msg.hdr.payloadLen = sizeof( U08 ); + msg.payload[ 0 ] = (U08)ack; -/*********************************************************************//** - * @brief - * The broadcastAlarmTriggered function constructs an alarm triggered msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm triggered msg constructed and queued. - * @param alarm ID of alarm triggered - * @param almData1 1st data associated with alarm - * @param almData2 2nd data associated with alarm - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmTriggered( U16 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_TRIGGERED; - msg.hdr.payloadLen = sizeof( U16 ) + sizeof( ALARM_DATA_T ) + sizeof( ALARM_DATA_T ); - - memcpy( payloadPtr, &alarm, sizeof( U16 ) ); - payloadPtr += sizeof( U16 ); - memcpy( payloadPtr, &almData1, sizeof( ALARM_DATA_T ) ); - payloadPtr += sizeof( ALARM_DATA_T ); - memcpy( payloadPtr, &almData2, sizeof( ALARM_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_DG_ALARM, ACK_REQUIRED ); - - return result; -} + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); -/*********************************************************************//** - * @brief - * The broadcastAlarmCleared function constructs an alarm cleared msg to be - * broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm cleared msg constructed and queued. - * @param alarm ID of alarm cleared - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmCleared( U16 alarm ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_CLEARED; - msg.hdr.payloadLen = sizeof( U16 ); - - memcpy( payloadPtr, &alarm, sizeof( U16 ) ); - - // 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_DG_ALARM, ACK_REQUIRED ); - - return result; -} + return result; +} + +// *********************************************************************** +// ***************** Message Sending Helper Functions ******************** +// *********************************************************************** + /*********************************************************************//** * @brief + * The broadcastAlarmTriggered function constructs an alarm triggered msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: alarm triggered msg constructed and queued. + * @param alarm ID of alarm triggered + * @param almData1 1st data associated with alarm + * @param almData2 2nd data associated with alarm + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAlarmTriggered( U32 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_ALARM_TRIGGERED; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( ALARM_DATA_T ) + sizeof( ALARM_DATA_T ); + + memcpy( payloadPtr, &alarm, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &almData1, sizeof( ALARM_DATA_T ) ); + payloadPtr += sizeof( ALARM_DATA_T ); + memcpy( payloadPtr, &almData2, sizeof( ALARM_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_DG_ALARM, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The broadcastAlarmCleared function constructs an alarm cleared msg to be + * broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: alarm cleared msg constructed and queued. + * @param alarm ID of alarm cleared + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAlarmCleared( U32 alarm ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_ALARM_CLEARED; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &alarm, 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_DG_ALARM, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The broadcastAlarmConditionCleared function constructs an alarm condition + * cleared msg to be broadcast and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: alarm condition cleared msg constructed and queued. + * @param alarm ID of alarm which alarm condition is cleared + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAlarmConditionCleared( U32 alarm ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_ALARM_CONDITION_CLEARED; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &alarm, 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_DG_ALARM, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @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 @@ -321,8 +353,8 @@ return result; } -/*********************************************************************//** - * @brief +/*********************************************************************//** + * @brief * The broadcastRTCEpoch function constructs an epoch msg to be broadcast * and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -347,41 +379,10 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); return result; -} +} /*********************************************************************//** * @brief - * The broadcastDGHDOperationMode function constructs a DG operation mode - * broadcast message and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG operation mode msg constructed and queued - * @param mode current operation mode of the DG. - * @param subMode current sub-mode of the current operation mode of the DG. - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDGOperationMode( U32 mode, U32 subMode ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_OP_MODE; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &mode, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &subMode, 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_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief * The broadcastLoadCellData function sends out load cell data. * @details Inputs: none * @details Outputs: load cell data msg constructed and queued @@ -478,74 +479,95 @@ return result; } -/*********************************************************************//** - * @brief - * The broadcastROPumpData function sends out RO pump data. - * @details Inputs: none - * @details Outputs: RO pump data msg constructed and queued - * @param tgtPressure target pressure for RO pump in PSI - * @param measFlow measure RO flow rate in LPM - * @param setPWM set PWM duty cycle in % - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastROPumpData( U32 tgtPressure, F32 measFlow, F32 setPWM ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - RO_PUMP_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_RO_PUMP_DATA; - msg.hdr.payloadLen = sizeof( RO_PUMP_DATA_T ); - - payload.setROPumpPressure = tgtPressure; - payload.measROFlowRate = measFlow; - payload.roPumpPWM = setPWM; - - memcpy( payloadPtr, &payload, sizeof( RO_PUMP_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_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} +/*********************************************************************//** + * @brief + * The broadcastDrainPumpData function sends out the drain pump data. + * @details Inputs: none + * @details Outputs: Drain pump data msg constructed and queued + * @param drainPumpData which is the drain pump data structure pointer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastDrainPumpData( DRAIN_PUMP_DATA_T *drainPumpData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; -/*********************************************************************//** - * @brief - * The broadcastDrainPumpData function sends out drain pump data. - * @details Inputs: none - * @details Outputs: Drain pump data msg constructed and queued - * @param tgtSpeed target speed for drain pump in RPM - * @param dac set DAC value - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDrainPumpData( U32 tgtSpeed, U32 dac ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - DRAIN_PUMP_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DRAIN_PUMP_DATA; - msg.hdr.payloadLen = sizeof( DRAIN_PUMP_DATA_T ); - - payload.setDrainPumpSpeed = tgtSpeed; - payload.dacValue = dac; - - memcpy( payloadPtr, &payload, sizeof( DRAIN_PUMP_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_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DRAIN_PUMP_DATA; + msg.hdr.payloadLen = sizeof( DRAIN_PUMP_DATA_T ); + + memcpy( payloadPtr, drainPumpData, sizeof( DRAIN_PUMP_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; } /*********************************************************************//** * @brief + * The broadcastDGHDOperationMode function constructs a DG operation mode + * broadcast message and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG operation mode msg constructed and queued + * @param mode current operation mode of the DG. + * @param subMode current sub-mode of the current operation mode of the DG. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastDGOperationMode( U32 mode, U32 subMode ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_OP_MODE; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &mode, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &subMode, 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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The broadcastROPumpData function sends out RO pump data. + * @details Inputs: none + * @details Outputs: RO pump data msg constructed and queued + * @param tgtPressure target pressure for RO pump in PSI + * @param measFlow measure RO flow rate in LPM + * @param setPWM set PWM duty cycle in % + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastROPumpData( RO_PUMP_DATA_T *pumpData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_RO_PUMP_DATA; + msg.hdr.payloadLen = sizeof( RO_PUMP_DATA_T ); + + memcpy( payloadPtr, pumpData, sizeof( RO_PUMP_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The broadcastConcentratePumpData function sends out concentrate pumps' data. * @details Inputs: none * @details Outputs: concentrate pump data msg constructed and queued @@ -555,224 +577,236 @@ * @param measuredCP2Speed measured speed for concentrate pump CP2 using hall sense * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastConcentratePumpData( F32 cp1TgtSpeed, F32 cp1MeasuredSpeed, F32 cp2TgtSpeed, F32 cp2MeasuredSpeed ) +BOOL broadcastConcentratePumpData( void * concentratePumpDataPtr ) { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - CONCENTRATE_PUMP_DATA_T payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_CONCENTRATE_PUMP_DATA; msg.hdr.payloadLen = sizeof( CONCENTRATE_PUMP_DATA_T ); - payload.cp1TargetSpeed = cp1TgtSpeed; - payload.cp1MeasuredSpeed = cp1MeasuredSpeed; - payload.cp2TargetSpeed = cp2TgtSpeed; - payload.cp2MeasuredSpeed = cp2MeasuredSpeed; + memcpy( &msg.payload, concentratePumpDataPtr, sizeof( CONCENTRATE_PUMP_DATA_T ) ); - memcpy( payloadPtr, &payload, sizeof( CONCENTRATE_PUMP_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_DG_BROADCAST, ACK_NOT_REQUIRED ); return result; } -/*********************************************************************//** - * @brief - * The broadcastPressureSensorsData function sends out DG pressure data. - * @details Inputs: none - * @details Outputs: Pressure data msg constructed and queued - * @param measROIn measured RO pump inlet pressure in PSI - * @param measROOut measured RO pump outlet pressure in PSI - * @param measDrainIn measured Drain pump inlet pressure in PSI - * @param measDrainOut measured Drain pump outlet pressure in PSI - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPressureSensorsData( F32 measROIn, F32 measROOut, F32 measDrainIn, F32 measDrainOut ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - PRESSURES_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_PRESSURES_DATA; - msg.hdr.payloadLen = sizeof( PRESSURES_DATA_T ); - - payload.roPumpInletPressure = measROIn; - payload.roPumpOutletPressure = measROOut; - payload.drainPumpInletPressure = measDrainIn; - payload.drainPumpOutletPressure = measDrainOut; - - memcpy( payloadPtr, &payload, sizeof( PRESSURES_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_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; +/*********************************************************************//** + * @brief + * The broadcastPressureSensorsData function sends out DG pressure data. + * @details Inputs: none + * @details Outputs: Pressure data msg constructed and queued + * @param measROIn measured RO pump inlet pressure in PSI + * @param measROOut measured RO pump outlet pressure in PSI + * @param measDrainIn measured Drain pump inlet pressure in PSI + * @param measDrainOut measured Drain pump outlet pressure in PSI + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastPressureSensorsData( F32 measROIn, F32 measROOut, F32 measDrainIn, F32 measDrainOut ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + PRESSURES_DATA_T payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_PRESSURES_DATA; + msg.hdr.payloadLen = sizeof( PRESSURES_DATA_T ); + + payload.roPumpInletPressure = measROIn; + payload.roPumpOutletPressure = measROOut; + payload.drainPumpInletPressure = measDrainIn; + payload.drainPumpOutletPressure = measDrainOut; + + memcpy( payloadPtr, &payload, sizeof( PRESSURES_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; } -/*********************************************************************//** - * @brief - * The broadcastReservoirData function broadcasts the DG reservoir data. - * @details Inputs: none - * @details Outputs: Reservoir data msg constructed and queued - * @param resID ID of currently active reservoir - * @param fillToVol Current target fill to volume for inactive reservoir - * @param drainToVol Current target drain to volume for inactive reservoir - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastReservoirData( U32 resID, U32 fillToVol, U32 drainToVol ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - RESERVOIR_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_RESERVOIR_DATA; - msg.hdr.payloadLen = sizeof( RESERVOIR_DATA_T ); - - payload.activeReservoir = resID; - payload.fillToVolumeMl = fillToVol; - payload.drainToVolumeMl = drainToVol; - - memcpy( payloadPtr, &payload, sizeof( RESERVOIR_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_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} +/*********************************************************************//** + * @brief + * The broadcastReservoirData function broadcasts the DG reservoir data. + * @details Inputs: none + * @details Outputs: Reservoir data msg constructed and queued + * @param resID ID of currently active reservoir + * @param fillToVol Current target fill to volume for inactive reservoir + * @param drainToVol Current target drain to volume for inactive reservoir + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastReservoirData( U32 resID, U32 fillToVol, U32 drainToVol ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + RESERVOIR_DATA_T payload; -/*********************************************************************//** - * @brief - * The broadcastTemperatureSensorsData function sends out DG temperature - * sensors data. - * @details Inputs: none - * @details Outputs: temperature sensors data message constructed and queued + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_RESERVOIR_DATA; + msg.hdr.payloadLen = sizeof( RESERVOIR_DATA_T ); + + payload.activeReservoir = resID; + payload.fillToVolumeMl = fillToVol; + payload.drainToVolumeMl = drainToVol; + + memcpy( payloadPtr, &payload, sizeof( RESERVOIR_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The broadcastTemperatureSensorsData function sends out DG temperature + * sensors data. + * @details Inputs: none + * @details Outputs: temperature sensors data message constructed and queued * @param sensorsValue sensors value array - * @param byteLength payload length in bytes - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTemperatureSensorsData ( U08 *sensorsValue, U32 byteLength ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_TEMPERATURE_DATA; - msg.hdr.payloadLen = byteLength; - - memcpy( payloadPtr, sensorsValue, byteLength ); - - // 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_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} + * @param byteLength payload length in bytes + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastTemperatureSensorsData ( U08 *sensorsValue, U32 byteLength ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_TEMPERATURE_DATA; + msg.hdr.payloadLen = byteLength; + + memcpy( payloadPtr, sensorsValue, byteLength ); + + // 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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + /*********************************************************************//** * @brief - * The broadcastConductivityData function sends out conductivity data. + * The broadcastThermistorsData function sends out the thermistors data. + * @details * @details Inputs: none - * @details Outputs: conductivity data message constructed and queued - * @param roRejectionRatio RO rejection ratio - * @param cpi water inlet conductivity data - * @param cpo water outlet conductivity data + * @details Outputs: thermistors data msg constructed and queued + * @param thermistorsData which is constructed and queued * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastConductivityData( F32 roRejectionRatio, F32 cpi, F32 cpo, F32 cd1, F32 cd2 ) +BOOL broadcastThermistorsData( THERMISTORS_DATA_T *thermistorsData ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - CONDUCTIVITY_DATA_T payload; // create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_CONDUCTIVITY_DATA; - msg.hdr.payloadLen = sizeof( CONDUCTIVITY_DATA_T ); + msg.hdr.msgID = MSG_ID_DG_THERMISTORS_DATA; + msg.hdr.payloadLen = sizeof( THERMISTORS_DATA_T ); - payload.roRejectionRatio = roRejectionRatio; - payload.cpi = cpi; - payload.cpo = cpo; - payload.cd1 = cd1; - payload.cd2 = cd2; + memcpy( payloadPtr, thermistorsData, sizeof( THERMISTORS_DATA_T ) ); - memcpy( payloadPtr, &payload, sizeof( CONDUCTIVITY_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + return result; +} + +/*********************************************************************//** + * @brief + * The broadcastFansData function sends out the fans data. + * @details Inputs: none + * @details Outputs: fans data msg constructed and queued + * @param fansData which is constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastFansData( FANS_DATA_T *fansData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_FANS_DATA; + msg.hdr.payloadLen = sizeof( FANS_DATA_T ); + + memcpy( payloadPtr, fansData, sizeof( FANS_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_DG_BROADCAST, ACK_NOT_REQUIRED ); return result; } - -// *********************************************************************** -// **************** Message Handling Helper Functions ******************** -// *********************************************************************** +// *********************************************************************** +// **************** Message Handling Helper Functions ******************** +// *********************************************************************** -/*********************************************************************//** - * @brief - * The handlePowerOffWarning function handles a power off warning message - * from the HD. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handlePowerOffWarning( MESSAGE_T *message ) + +/*********************************************************************//** + * @brief + * The handlePowerOffWarning function handles a power off warning message + * from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handlePowerOffWarning( MESSAGE_T *message ) { if ( message->hdr.payloadLen == 0 ) { signalPowerOffWarning(); - } -} + } +} -/*********************************************************************//** - * @brief - * The handleSetDialysateTemperatureCmd function handles a dialysate temperature - * set points message from the HD. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetDialysateTemperatureCmd( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof( TARGET_TEMPS_PAYLOAD_T ) ) - { - TARGET_TEMPS_PAYLOAD_T payload; - - result = TRUE; - memcpy( &payload, message->payload, sizeof( TARGET_TEMPS_PAYLOAD_T ) ); - setPrimaryHeaterTargetTemperature( payload.targetPrimaryHeaterTemp ); - setTrimmerHeaterTargetTemperature( payload.targetTrimmerHeaterTemp ); - } - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); -} +/*********************************************************************//** + * @brief + * The handleSetDialysateTemperatureCmd function handles a dialysate temperature + * set points message from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetDialysateTemperatureCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; -/*********************************************************************//** - * @brief - * The handleFWVersionCmd function handles a FW version request message. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleFWVersionCmd( MESSAGE_T *message ) -{ - MESSAGE_T msg; + if ( message->hdr.payloadLen == sizeof( TARGET_TEMPS_PAYLOAD_T ) ) + { + TARGET_TEMPS_PAYLOAD_T payload; + + result = TRUE; + memcpy( &payload, message->payload, sizeof( TARGET_TEMPS_PAYLOAD_T ) ); + setPrimaryHeaterTargetTemperature( payload.targetPrimaryHeaterTemp ); + setTrimmerHeaterTargetTemperature( payload.targetTrimmerHeaterTemp ); + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} + +/*********************************************************************//** + * @brief + * The handleFWVersionCmd function handles a FW version request message. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFWVersionCmd( MESSAGE_T *message ) +{ + MESSAGE_T msg; DG_VERSIONS_T payload; U08 *payloadPtr = msg.payload; @@ -791,259 +825,544 @@ // fill message payload memcpy( payloadPtr, &payload, sizeof( DG_VERSIONS_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); -} + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); +} -/*********************************************************************//** - * @brief - * The handleSwitchReservoirCmd function handles a switch reservoirs command - * from the HD. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSwitchReservoirCmd( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof( U32 ) ) - { - RESERVOIR_ID_T reservoirID; - U32 resID; - - result = TRUE; - memcpy( &resID, message->payload, sizeof( U32 ) ); - reservoirID = (RESERVOIR_ID_T)resID; - setActiveReservoirCmd( reservoirID ); +/*********************************************************************//** + * @brief + * The broadcastConductivityData function sends out conductivity data. + * @details Inputs: none + * @details Outputs: conductivity data message constructed and queued + * @param conductivityDataPtr which is the data msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastConductivityData( void * conductivityDataPtr ) +{ + BOOL result; + MESSAGE_T msg; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_CONDUCTIVITY_DATA; + msg.hdr.payloadLen = sizeof( CONDUCTIVITY_DATA_T ); + + memcpy( &msg.payload, conductivityDataPtr, sizeof( CONDUCTIVITY_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The broadcastUVReactorsData function sends out the UV reactors data. + * @details Inputs: none + * @details Outputs: UV reactors data msg constructed and queued + * @param uvReactorsData which is UV reactors msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastUVReactorsData( UV_REACTORS_DATA_T *uvReactorsData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_UV_REACTORS_DATA; + msg.hdr.payloadLen = sizeof( UV_REACTORS_DATA_T ); + + memcpy( payloadPtr, uvReactorsData, sizeof( UV_REACTORS_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGCalibrationRecord function sends out the DG calibration + * record. + * @details Inputs: none + * @details Outputs: DG calibration record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param calRcrdAddress: start address of the calibration record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGCalibrationRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* calRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SEND_CALIBRATION_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, calRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/***********************************************************************//** + * @brief + * The broadcastFluidLeakState function constructs a DG fluid leak state msg to \n + * be broadcasted and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: fluid leak state msg constructed and queued + * @param state fluid leak state + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastFluidLeakState( FLUID_LEAK_STATES_T state ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 leakState = (U32)state; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_FLUID_LEAK_STATE; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &leakState, 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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGSystemRecord function sends out the DG system record. + * @details Inputs: none + * @details Outputs: DG system record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param sysRcrdAddress: start address of the system record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGSystemRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* sysRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SEND_SYSTEM_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, sysRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGServiceRecord function sends out the DG service record. + * @details Inputs: none + * @details Outputs: DG system record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param srvcRcrdAddress: start address of the service record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGServiceRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* srvcRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SEND_SERVICE_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, srvcRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGServiceRecord function sends out the DG service record. + * @details Inputs: none + * @details Outputs: DG system record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param scheduledRcrdAddress: start address of the scheduled runs record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGScheduledRunsRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* scheduledRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SEND_SCHEDULED_RUNS_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, scheduledRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendCommandResponseMsg function constructs a command response to HD + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Command response msg constructed and queued. + * @param cmdResponsePtr pointer to command response data record + * @return none + *************************************************************************/ +void sendCommandResponseMsg( DG_CMD_RESPONSE_T *cmdResponsePtr ) +{ + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_COMMAND_RESPONSE; + msg.hdr.payloadLen = sizeof( DG_CMD_RESPONSE_T ); + + memcpy( msg.payload, cmdResponsePtr, sizeof( DG_CMD_RESPONSE_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); +} + +// *********************************************************************** +// **************** Message Handling Helper Functions ******************** +// *********************************************************************** + +/*********************************************************************//** + * @brief + * The handleSwitchReservoirCmd function handles a switch reservoirs command + * from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSwitchReservoirCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + DG_RESERVOIR_ID_T reservoirID; + U32 resID; + + result = TRUE; + memcpy( &resID, message->payload, sizeof( U32 ) ); + reservoirID = (DG_RESERVOIR_ID_T)resID; + setActiveReservoirCmd( reservoirID ); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); -} -/*********************************************************************//** - * @brief - * The handleFillCmd function handles a fill command from the HD. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleFillCmd( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof( U32 ) ) - { - U32 fillToVolumeMl; - - result = TRUE; - memcpy( &fillToVolumeMl, message->payload, sizeof( U32 ) ); - startFillCmd( fillToVolumeMl ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} + + +/*********************************************************************//** + * @brief + * The handleChangeValveSettingCmd function handles a switch reservoirs command + * from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeValveSettingCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + DG_VALVE_SETTING_ID_T valveSettingID; + + result = TRUE; + memcpy( &valveSettingID, message->payload, sizeof( U32 ) ); + changeValveSettingCmd( valveSettingID ); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); -} -/*********************************************************************//** - * @brief - * The handleDrainCmd function handles a drain command from the HD. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDrainCmd( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof( DRAIN_CMD_T ) ) - { - DRAIN_CMD_T drainCmd; - - result = TRUE; - memcpy( &drainCmd, message->payload, sizeof( DRAIN_CMD_T ) ); - - startDrainCmd( drainCmd ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} + +/*********************************************************************//** + * @brief + * The handleFillCmd function handles a fill command from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFillCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U32 fillToVolumeMl; + + result = TRUE; + memcpy( &fillToVolumeMl, message->payload, sizeof( U32 ) ); + startFillCmd( fillToVolumeMl ); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); -} -/*********************************************************************//** - * @brief - * The handleStartStopTreatmentMsg function handles a treatment start/stop - * message from the HD. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleStartStopTreatmentMsg( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof( U32 ) ) - { - BOOL startingTreatment; - - memcpy( &startingTreatment, message->payload, sizeof( U32 ) ); - - if ( DG_MODE_STAN == getCurrentOperationMode() && TRUE == startingTreatment ) - { - result = requestDGStart(); - } - else if ( DG_MODE_CIRC == getCurrentOperationMode() && FALSE == startingTreatment ) - { - result = requestDGStop(); - } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} + +/*********************************************************************//** + * @brief + * The handleDrainCmd function handles a drain command from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDrainCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( DRAIN_CMD_T ) ) + { + DRAIN_CMD_T drainCmd; + + result = TRUE; + memcpy( &drainCmd, message->payload, sizeof( DRAIN_CMD_T ) ); + + startDrainCmd( drainCmd ); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); -} -/*********************************************************************//** - * @brief - * The handleStartStopTrimmerHeaterCmd function handles a trimmer heater start/stop - * command message from the HD. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleStartStopTrimmerHeaterCmd( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof( U32 ) ) - { - BOOL startingHeater; - - memcpy( &startingHeater, message->payload, sizeof( U32 ) ); - - if ( TRUE == startingHeater ) - { - result = startTrimmerHeaterCmd(); - } - else - { - result = stopTrimmerHeaterCmd(); - } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} + +/*********************************************************************//** + * @brief + * The handleStartStopTreatmentMsg function handles a treatment start/stop + * message from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleStartStopTreatmentMsg( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + BOOL startingTreatment; + + memcpy( &startingTreatment, message->payload, sizeof( U32 ) ); + + if ( DG_MODE_STAN == getCurrentOperationMode() && TRUE == startingTreatment ) + { + result = requestDGStart(); + } + else if ( DG_MODE_CIRC == getCurrentOperationMode() && FALSE == startingTreatment ) + { + result = requestDGStop(); + } } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); -} -/*********************************************************************//** - * @brief - * The handleSampleWaterCmd function handles a sample water command from the HD. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSampleWaterCmd( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == 0 ) - { - if ( DG_MODE_STAN == getCurrentOperationMode() ) - { - result = requestWaterSample(); - } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} + +/*********************************************************************//** + * @brief + * The handleStartStopTrimmerHeaterCmd function handles a trimmer heater start/stop + * command message from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleStartStopTrimmerHeaterCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( TRIMMER_HEATER_CMD_T ) ) + { + TRIMMER_HEATER_CMD_T heaterCmd; + + result = TRUE; + memcpy( &heaterCmd, message->payload, sizeof( TRIMMER_HEATER_CMD_T ) ); + handleTrimmerHeaterCmd( &heaterCmd ); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); -} -/*********************************************************************//** - * @brief - * The handleSetRTCTimestamp function handles a request to write time and - * date to RTC - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetRTCTimestamp( MESSAGE_T *message ) -{ - BOOL result; - U08 seconds = message->payload[0]; - U08 minutes = message->payload[1]; - U08 hours = message->payload[2]; - U08 days = message->payload[3]; - U08 months = message->payload[4]; - U32 years; - memcpy(&years, &message->payload[5], sizeof( U32 )); - - result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} -/*********************************************************************//** - * @brief - * The handleStartStopPrimaryHeater function handles a request start or - * stop the primary heater - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return result - *************************************************************************/ -BOOL handleStartStopPrimaryHeater( MESSAGE_T * message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof( U32 ) ) - { - BOOL startingHeater; - - memcpy( &startingHeater, message->payload, sizeof( U32 ) ); - - if ( TRUE == startingHeater ) - { - result = startPrimaryHeater(); - } - else - { - stopPrimaryHeater(); - result = TRUE; - } +/*********************************************************************//** + * @brief + * The handleSampleWaterCmd function handles a sample water command from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSampleWaterCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == 0 ) + { + if ( DG_MODE_STAN == getCurrentOperationMode() ) + { + result = requestWaterSample(); + } } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); - - return result; -} - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); +} - +/*********************************************************************//** + * @brief + * The handleSetRTCTimestamp function handles a request to write time and + * date to RTC + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetRTCTimestamp( MESSAGE_T *message ) +{ + BOOL result; + U08 seconds = message->payload[0]; + U08 minutes = message->payload[1]; + U08 hours = message->payload[2]; + U08 days = message->payload[3]; + U08 months = message->payload[4]; + U32 years; + memcpy(&years, &message->payload[5], sizeof( U32 )); + + result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleStartStopPrimaryHeater function handles a request start or + * stop the primary heater + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return result + *************************************************************************/ +BOOL handleStartStopPrimaryHeater( MESSAGE_T * message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + BOOL startingHeater; + + memcpy( &startingHeater, message->payload, sizeof( U32 ) ); + + if ( TRUE == startingHeater ) + { + result = startPrimaryHeater(); + } + else + { + stopPrimaryHeater(); + result = TRUE; + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); + + return result; +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + #ifdef DEBUG_ENABLED - /*********************************************************************//** - * @brief - * The sendDebugData function sends debug data out to the PC port. - * @details - * @details Inputs: none - * @details Outputs: PC serial port - * @param dbgData Pointer to debug data - * @param len number of bytes of debug data - * @return TRUE if debug data was successfully queued for transmit, FALSE if not - *************************************************************************/ - BOOL sendDebugData( U08 *dbgData, U32 len ) - { - BOOL result; - - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); - - return result; + /*********************************************************************//** + * @brief + * The sendDebugData function sends debug data out to the PC port. + * @details + * @details Inputs: none + * @details Outputs: PC serial port + * @param dbgData Pointer to debug data + * @param len number of bytes of debug data + * @return TRUE if debug data was successfully queued for transmit, FALSE if not + *************************************************************************/ + BOOL sendDebugData( U08 *dbgData, U32 len ) + { + BOOL result; + + // add serialized message data to appropriate comm buffer + result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); + + return result; } /*********************************************************************//** @@ -1073,81 +1392,81 @@ serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_NOT_REQUIRED ); } } -#endif +#endif -/*********************************************************************//** - * @brief - * The isTestingActivated function determines whether a tester has successfully - * logged in to activate testing functionality. - * @details Inputs: testerLoggedIn - * @details Outputs: none - * @return TRUE if a tester has logged in to activate testing, FALSE if not - *************************************************************************/ -BOOL isTestingActivated( void ) -{ - return testerLoggedIn; -} +/*********************************************************************//** + * @brief + * The isTestingActivated function determines whether a tester has successfully + * logged in to activate testing functionality. + * @details Inputs: testerLoggedIn + * @details Outputs: none + * @return TRUE if a tester has logged in to activate testing, FALSE if not + *************************************************************************/ +BOOL isTestingActivated( void ) +{ + return testerLoggedIn; +} -/*********************************************************************//** - * @brief +/*********************************************************************//** + * @brief * The sendTestAckResponseMsg function constructs a simple response message for - * a handled test message and queues it for transmit on the appropriate UART channel. - * @details Inputs: none - * @details Outputs: response message constructed and queued for transmit. - * @param msgID ID of handled message that we are responding to - * @param ack TRUE if test message was handled successfully, FALSE if not - * @return TRUE if response message successfully queued for transmit, FALSE if not - *************************************************************************/ -static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = (U08)ack; - - // 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_PC, ACK_NOT_REQUIRED ); - - return result; -} + * a handled test message and queues it for transmit on the appropriate UART channel. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. + * @param msgID ID of handled message that we are responding to + * @param ack TRUE if test message was handled successfully, FALSE if not + * @return TRUE if response message successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) +{ + BOOL result; + MESSAGE_T msg; -/*********************************************************************//** - * @brief - * The handleTesterLogInRequest function handles a request to login as a tester. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTesterLogInRequest( MESSAGE_T *message ) -{ - // verify pass code - // TODO - placeholder - how do we want to authenticate tester? - if ( ( 3 == message->hdr.payloadLen ) && ( 0x31 == message->payload[ 0 ] ) && ( 0x32 == message->payload[ 1 ] ) && ( 0x33 == message->payload[ 2 ] ) ) - { - testerLoggedIn = TRUE; - } - else - { - testerLoggedIn = FALSE; - } - // respond to would be tester - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); -} + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + msg.hdr.payloadLen = sizeof( U08 ); + msg.payload[ 0 ] = (U08)ack; -/*********************************************************************//** - * @brief - * The handleTestWatchdogCheckInStateOverrideRequest function handles a - * request to override the check-in status of a given task. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleTesterLogInRequest function handles a request to login as a tester. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTesterLogInRequest( MESSAGE_T *message ) +{ + // verify pass code + // TODO - placeholder - how do we want to authenticate tester? + if ( ( 3 == message->hdr.payloadLen ) && ( 0x31 == message->payload[ 0 ] ) && ( 0x32 == message->payload[ 1 ] ) && ( 0x33 == message->payload[ 2 ] ) ) + { + testerLoggedIn = TRUE; + } + else + { + testerLoggedIn = FALSE; + } + // respond to would be tester + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); +} + +/*********************************************************************//** + * @brief + * The handleTestWatchdogCheckInStateOverrideRequest function handles a + * request to override the check-in status of a given task. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestWatchdogCheckInStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -1171,15 +1490,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestAlarmStateOverrideRequest function handles a request to - * override the active status of a given alarm. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestAlarmStateOverrideRequest function handles a request to + * override the active status of a given alarm. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestAlarmStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -1203,15 +1522,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestLoadCellOverrideRequest function handles a request to - * override the value read from the given load cell. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestLoadCellOverrideRequest function handles a request to + * override the value read from the given load cell. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestLoadCellOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -1235,15 +1554,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestTemperatureSensorsOverrideRequest function handles a - * request to override a temperatures sensor's value. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestTemperatureSensorsOverrideRequest function handles a + * request to override a temperatures sensor's value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestTemperatureSensorsOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -1267,16 +1586,16 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** -* @brief -* The handleTestTemperatureSensorsDataPublishOverrideRequest function handles -* a request to override the publish interval of temperature sensors data. -* @details -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ +/*********************************************************************//** +* @brief +* The handleTestTemperatureSensorsDataPublishOverrideRequest function handles +* a request to override the publish interval of temperature sensors data. +* @details +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ void handleTestTemperatureSensorsDataPublishOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -1299,16 +1618,16 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestHeatersDataPublishOverrideRequest function handles - * a request to override the publish interval of heaters data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestHeatersDataPublishOverrideRequest function handles + * a request to override the publish interval of heaters data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestHeatersDataPublishOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -1332,15 +1651,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestLoadCellDataBroadcastIntervalOverrideRequest function handles - * a request to override the broadcast interval for load cell data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestLoadCellDataBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for load cell data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestLoadCellDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -1364,15 +1683,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestPressureSensorOverrideRequest function handles a request to - * override the value read from the given pressure sensor. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestPressureSensorOverrideRequest function handles a request to + * override the value read from the given pressure sensor. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestPressureSensorOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -1396,15 +1715,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestPressureDataBroadcastIntervalOverrideRequest function handles - * a request to override the broadcast interval for load cell data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestPressureDataBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for load cell data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestPressureDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -1428,38 +1747,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestROPumpSetPointOverrideRequest function handles a request to - * override the RO pump pressure set point (in PSI). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestROPumpSetPointOverrideRequest( 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 = testSetTargetROPumpPressureOverride( payload.state.u32 ); - } - else - { - result = testResetTargetROPumpPressureOverride(); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - /*********************************************************************//** * @brief * The handleTestROMeasuredFlowOverrideRequest function handles a request to @@ -1490,17 +1778,17 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} +} -/*********************************************************************//** - * @brief - * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles - * a request to override the broadcast interval for RO pump data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for RO pump data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestROPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -1524,56 +1812,51 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestDrainPumpSetPointOverrideRequest function handles a request to - * override the drain pump speed set point (in RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestDrainPumpSetPointOverrideRequest( MESSAGE_T *message ) +/*********************************************************************//** + * @brief + * The handleTestDrainPumpRPMOverrideRequest function handles a request to + * override the drain pump speed set point (in RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDrainPumpRPMOverrideRequest( MESSAGE_T *message ) { - TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length - if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + if ( sizeof( U32 ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); - if ( FALSE == payload.reset ) - { - result = testSetTargetDrainPumpSpeedOverride( payload.state.u32 ); - } - else - { - result = testResetTargetDrainPumpSpeedOverride(); - } + U32 payLoad; + + memcpy( &payLoad, message->payload, sizeof( U32 ) ); + + result = testSetTargetDrainPumpRPM( payLoad ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestDrainPumpDataBroadcastIntervalOverrideRequest function handles - * a request to override the broadcast interval for drain pump data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestDrainPumpDataBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for drain pump data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDrainPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length - if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); if ( FALSE == payload.reset ) { result = testSetDrainPumpDataPublishIntervalOverride( payload.state.u32 ); @@ -1588,15 +1871,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestValveStateOverrideRequest function handles a request to - * override the state value read from the given valve. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestValveStateOverrideRequest function handles a request to + * override the state value read from the given valve. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestValveStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -1620,15 +1903,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestValvesStatesPublishIntervalOverrideRequest function handles - * a request to override the publish interval of valves states from the given valve. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestValvesStatesPublishIntervalOverrideRequest function handles + * a request to override the publish interval of valves states from the given valve. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestValvesStatesPublishIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -1652,15 +1935,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestDGSafetyShutdownOverrideRequest function handles a - * request to override the safety shutdown signal. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestDGSafetyShutdownOverrideRequest function handles a + * request to override the safety shutdown signal. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDGSafetyShutdownOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -1684,6 +1967,32 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/************************************************************************* + * @brief + * The handleSetDrainPumpDeltaPressureOverrideRequest function handles a + * request to override the delta pressure for the drain pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetDrainPumpDeltaPressureOverrideRequest( MESSAGE_T *message ) +{ + BOOL result = 0; + + /* verify payload length */ + if ( sizeof( F32 ) == message->hdr.payloadLen ) + { + F32 payLoad; + + memcpy( &payLoad, message->payload, sizeof( F32 ) ); + + result = testSetTargetDrainPumpOutletPressure( payLoad ); + } + /* respond to request */ + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /*********************************************************************//** * @brief * The handleTestDGAccelOverrideRequest function handles a request to @@ -1782,31 +2091,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; - - 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 handleTestSetConductivityOverrideRequest function handles a * request to override a conductivity sensor's value * @details Inputs: none @@ -1871,7 +2155,171 @@ } /*********************************************************************//** +* @brief +* The handleStartStopUVReactors function handles a request to turn on/off +* the UV reactors. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleStartStopUVReactors( 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 ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + + // Set turn on/off command + switch ( payload.state.u32 ) + { + case TURN_OFF: + result = turnOffUVReactor( (UV_REACTORS_T)payload.index ); + break; + + case TURN_ON: + result = turnOnUVReactor( (UV_REACTORS_T)payload.index ); + break; + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleTestUVReactorsDataPublishIntervalOverride function handles a +* request to override the publish interval of the UV reactors data +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestUVReactorsDataPublishIntervalOverride( 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 = testSetReactorsDataPublishInterval( payload.state.u32 ); + } + else + { + result = testResetReactorsDataPublishInterval(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleUVReactorsHealthOverride function handles UV reactors health +* status override. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestUVReactorsHealthOverride( 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 ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetUVReactorHealthOverride( payload.index, (BOOL)payload.state.u32 ); + } + else + { + result = testResetUVReactorHealthOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief + * The handleSetFluidLeakBroadcastIntervalOverrideRequest function handles a + * request to override the fluid leak state broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetFluidLeakBroadcastIntervalOverrideRequest( 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 = testSetFluidLeakStatePublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetFluidLeakStatePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetFluidLeakStateDetectorOverrideRequest function handles a request to + * override the fluid leak detector state. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetFluidLeakStateDetectorOverrideRequest( 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 ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetFluidLeakStateOverride( ( FLUID_LEAK_STATES_T)( payload.state.u32 ) ); + } + else + { + result = testResetFluidLeakStateOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleDGSoftwareResetRequest function handles a request to * perform a software reset on DG. * @details Inputs: none @@ -1900,6 +2348,38 @@ /*********************************************************************//** * @brief + * The handleConcentratePumpMeasuredSpeedOverride function handles a request + * to override a concentrate pump measured speed value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleConcentratePumpMeasuredSpeedOverride( 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 ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetConcentratePumpMeasuredSpeedOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetConcentratePumpMeasuredSpeedOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleSetConcentratePumpTargetSpeed function handles a request to * override a concentrate pump's target speed value. * @details Inputs: none @@ -1916,18 +2396,514 @@ if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + result = testSetConcentratePumpTargetSpeedOverride( payload.index, payload.state.f32 ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleConcentratePumpStateChangeRequest function handles a request to + * change the concentrate pumps' state. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleConcentratePumpStateChangeRequest( 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 ) && ( TRUE == isTestingActivated() ) ) + { + result = TRUE; + + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( ( BOOL )payload.state.u32 ) + { + requestConcentratePumpsOn( ( CONCENTRATE_PUMPS_T )payload.index ); + } + else + { + requestConcentratePumpsOff( ( CONCENTRATE_PUMPS_T )payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleConcentratePumpPublishIntervalOverride function handles a request + * to override a concentrate pump's publish interval value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleConcentratePumpPublishIntervalOverride( 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 = testSetConcentratePumpTargetSpeedOverride( payload.index, payload.state.f32 ); + result = testSetConcentratePumpDataPublishIntervalOverride( payload.state.u32 ); } else { - result = testResetConcentratePumpTargetSpeedOverride( payload.index ); + result = testResetConcentratePumpDataPublishIntervalOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** +* @brief +* The handleTestThermistorsDataPublishIntervalOverride function handles a +* request to override the publish interval of the thermistors data. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestThermistorsDataPublishIntervalOverride( 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 = testSetThermistorPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetThermistorPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleTestROPumpDutyCycleOverride function handles a request to override +* the RO pumps duty cycle. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestROPumpDutyCycleOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( sizeof( F32 ) == message->hdr.payloadLen ) + { + F32 payLoad; + + memcpy( &payLoad, message->payload, sizeof( F32 ) ); + + result = testSetTargetDutyCycle( payLoad ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleTestROFlowRateOverride function handles a request to override +* the RO flow rate. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*******************************************************************/ +void handleTestMeasuredROFlowRateOverride( 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 ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredROFlowRateOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredROFlowRateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleTestThermistorsValueOverride function handles a request to +* override a thermistor's value. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestThermistorsValueOverride( 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 ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredThermistorOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetMeasuredThermistorOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +//*******************************************************************/ +void handleTestROPumpTargetFlowOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( sizeof( F32 ) == message->hdr.payloadLen ) + { + F32 payload; + + memcpy( &payload, message->payload, sizeof( F32 ) ); + result = testSetTargetROPumpFlow( payload ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleTestFansDataPublishIntervalOverride function handles a request +* to override the publish interval of the fans data +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestFansDataPublishIntervalOverride( 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 = testSetFanPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetFanPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleROPumpTargetPressureOverride function handles a request +* to override the target RO pump pressure. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleROPumpTargetPressureOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 payload; + + memcpy( &payload, message->payload, sizeof( U32 ) ); + + result = testSetTargetROPumpPressure( payload ); + + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetDGCalibrationRecord function handles a request to set the DG +* calibration data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDGCalibrationRecord( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = setCalibrationRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** +* @brief +* The handleGetDGCalibrationRecord function handles a request to get the DG +* calibration data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetDGCalibrationRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = getCalibrationRecord(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetDGSystemRecord function handles a request to set the DG +* system data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDGSystemRecord( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = setSystemRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** +* @brief +* The handleGetDGSystemRecord function handles a request to get the DG +* system data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetDGSystemRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = getSystemRecord(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleGetDGServiceRecord function handles a request to get the DG +* service data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetDGServiceRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = getServiceRecord(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetDGServiceRecord function handles a request to set the DG +* service data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDGServiceRecord( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = setServiceRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** +* @brief +* The handleGetDGServiceRecord function handles a request to get the DG +* scheduled runs data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetDGScheduledRunsRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = getScheduledRunsRecord(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetDGScheduledRunsRecord function handles a request to set the DG +* scheduled runs data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDGScheduledRunsRecord( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = setScheduledRunsRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + /**@}*/