Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r497e910ca4972a1a993cb0ae1edf30d225283b34 -r88f28230d288947ba84840b967e95b32e3deffaa --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 497e910ca4972a1a993cb0ae1edf30d225283b34) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 88f28230d288947ba84840b967e95b32e3deffaa) @@ -42,8 +42,10 @@ #include "TemperatureSensors.h" #include "Thermistors.h" #include "Utilities.h" +#include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" +#include "UVReactors.h" /** * @addtogroup SystemCommMessages @@ -665,34 +667,6 @@ /*********************************************************************//** * @brief - * The broadcastConductivityData function sends out conductivity data. - * @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 - * @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 broadcastThermistorsData function sends out the thermistors data. * @details * @details Inputs: none @@ -828,6 +802,65 @@ /*********************************************************************//** * @brief + * The broadcastConductivityData function sends out conductivity data. + * @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 + * @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 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; +} + +// *********************************************************************** +// **************** Message Handling Helper Functions ******************** +// *********************************************************************** + +/*********************************************************************//** + * @brief * The handleSwitchReservoirCmd function handles a switch reservoirs command * from the HD. * @details Inputs: none @@ -1055,6 +1088,9 @@ * TEST SUPPORT FUNCTIONS *************************************************************************/ +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ #ifdef DEBUG_ENABLED /*********************************************************************//** @@ -1459,6 +1495,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } + /*********************************************************************//** * @brief * The handleTestROMeasuredFlowOverrideRequest function handles a request to @@ -1525,7 +1562,7 @@ /*********************************************************************//** * @brief - * The handleTestDrainPumpRPMOverrideRequest function handles a request to + * The handleTestDrainPumpSetPointOverrideRequest function handles a request to * override the drain pump speed set point (in RPM). * @details Inputs: none * @details Outputs: message handled @@ -1891,6 +1928,106 @@ } /*********************************************************************//** +* @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 handleUVReactorsDataPunlishIntervalOverride 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 handleDGSoftwareResetRequest function handles a request to * perform a software reset on DG.