Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rfea9457eb78e1c39fa4eb35780d2ac7c43f12ce0 -rc31c6e4340c28577df4d146165ccbfc8f0a47134 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision fea9457eb78e1c39fa4eb35780d2ac7c43f12ce0) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c31c6e4340c28577df4d146165ccbfc8f0a47134) @@ -7,17 +7,20 @@ * * @file SystemCommMessages.c * -* @author (last) Sean Nash -* @date (last) 19-Aug-2020 +* @author (last) Quang Nguyen +* @date (last) 26-Aug-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ -#include // for memcpy() +#include // for memcpy() -#include "Accel.h" +#include "reg_system.h" + +#include "Accel.h" +#include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "DrainPump.h" #include "FPGA.h" @@ -58,7 +61,7 @@ // ********** 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 ********** @@ -73,9 +76,8 @@ * bit of the sequence # is set if ACK is required per parameter. A sync byte * is inserted at the beginning of the message and an 8-bit CRC is appended to * the end of the message. The message is queued for transmission in the given buffer. - * @details - * Inputs : none - * Outputs : given data array populated with serialized message data and queued for transmit. + * @details Inputs: none + * @details Outputs: given data array populated with serialized message data and queued for transmit. * @param msg message to serialize * @param buffer outgoing buffer that message should be queued in * @param ackReq is an acknowledgement from receiver required? @@ -153,9 +155,8 @@ * @brief * The sendACKMsg function constructs and queues for transmit an ACK message * for a given received message. - * @details - * Inputs : none - * Outputs : ACK message queued for transmit on broadcast CAN channel. + * @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 *************************************************************************/ @@ -183,9 +184,8 @@ * @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 - * Outputs : response message constructed and queued for transmit. + * @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 @@ -217,9 +217,8 @@ * @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 - * Outputs : alarm triggered msg constructed and queued. + * @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 @@ -252,9 +251,8 @@ * @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 - * Outputs : alarm cleared msg constructed and queued. + * @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 *************************************************************************/ @@ -281,9 +279,8 @@ * @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 - * Outputs : accelerometer data broadcast msg constructed and queued. + * @details Inputs: none + * @details Outputs: accelerometer data broadcast msg constructed and queued. * @param x X axis vector magnitude (in g) * @param y Y axis vector magnitude (in g) * @param z Z axis vector magnitude (in g) @@ -328,9 +325,8 @@ * @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 - * Outputs : RTC time and date in epoch + * @details Inputs: none + * @details Outputs: RTC time and date in epoch * @param epoch Current time and date in epoch * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -357,9 +353,8 @@ * @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 - * Outputs : DG operation mode msg constructed and queued + * @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 @@ -388,9 +383,8 @@ /*********************************************************************//** * @brief * The broadcastLoadCellData function sends out load cell data. - * @details - * Inputs : none - * Outputs : load cell data msg constructed and queued + * @details Inputs: none + * @details Outputs: load cell data msg constructed and queued * @param loadCellA1 load cell A 1 data in grams * @param loadCellA2 load cell A 2 data in grams * @param loadCellB1 load cell B 1 data in grams @@ -425,9 +419,8 @@ /*********************************************************************//** * @brief * The broadcastValvesStates function sends out DG valves states. - * @details - * Inputs : none - * Outputs : Valves states msg constructed and queued + * @details Inputs: none + * @details Outputs: Valves states msg constructed and queued * @param valvesStates valves states * refer to setFPGAValveStates function in FPGA.c for details * @return TRUE if msg successfully queued for transmit, FALSE if not @@ -454,9 +447,8 @@ /*********************************************************************//** * @brief * The broadcastHeatersData function sends out DG heaters data - * @details - * Inputs : heaters data - * Outputs : heatears data msg constructed and queued + * @details Inputs: heaters data + * @details Outputs: heatears data msg constructed and queued * @param mainPrimaryDC main primary heater duty cycle * @param smallPrimaryDC small primary heater duty cycle * @param trimmerDC trimmer heater duty cycle @@ -486,47 +478,38 @@ return result; } -/*********************************************************************//** - * @brief - * The broadcastROPumpData function sends out RO pump data. - * @details - * Inputs : none - * 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 broadcastROPumpData function sends out RO pump data. + * @details Inputs: none + * @details Outputs: RO pump data msg constructed and queued + * @param pumpData which is the msg constructed and queued + * @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 broadcastDrainPumpData function sends out RO pump data. - * @details - * Inputs : none - * Outputs : Drain pump data msg constructed and queued + * 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 @@ -552,14 +535,42 @@ 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 + * @param cp1TgtSpeed target speed for concentrate pump CP1 + * @param measuredCP1Speed measured speed for concentrate pump CP1 using hall sense + * @param cp2TgtSpeed target speed for concentrate pump CP2 + * @param measuredCP2Speed measured speed for concentrate pump CP2 using hall sense + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastConcentratePumpData( void * concentratePumpDataPtr ) +{ + BOOL result; + MESSAGE_T msg; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_CONCENTRATE_PUMP_DATA; + msg.hdr.payloadLen = sizeof( CONCENTRATE_PUMP_DATA_T ); + + memcpy( &msg.payload, concentratePumpDataPtr, 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 - * Outputs : Pressure data msg constructed and queued + * @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 @@ -594,9 +605,8 @@ /*********************************************************************//** * @brief * The broadcastReservoirData function broadcasts the DG reservoir data. - * @details - * Inputs : none - * Outputs : Reservoir data msg constructed and queued + * @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 @@ -630,8 +640,8 @@ * @brief * The broadcastTemperatureSensorsData function sends out DG temperature * sensors data. - * Inputs : none - * Outputs : temperature sensors data message constructed and queued + * @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 @@ -658,32 +668,25 @@ /*********************************************************************//** * @brief * The broadcastConductivityData function sends out conductivity data. - * @details - * Inputs : none - * Outputs : conductivity data message constructed and queued + * @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( F32 roRejectionRatio, F32 cpi, F32 cpo ) +BOOL broadcastConductivityData( void * conductivityDataPtr ) { 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 ); - payload.roRejectionRatio = roRejectionRatio; - payload.cpi = cpi; - payload.cpo = cpo; + memcpy( &msg.payload, conductivityDataPtr, sizeof( CONDUCTIVITY_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 ); @@ -695,13 +698,13 @@ // **************** Message Handling Helper Functions ******************** // *********************************************************************** + /*********************************************************************//** * @brief * The handlePowerOffWarning function handles a power off warning message * from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -717,22 +720,21 @@ * @brief * The handleSetDialysateTemperatureCmd function handles a dialysate temperature * set points message from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @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) ) + 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) ); + memcpy( &payload, message->payload, sizeof( TARGET_TEMPS_PAYLOAD_T ) ); setPrimaryHeaterTargetTemperature( payload.targetPrimaryHeaterTemp ); setTrimmerHeaterTargetTemperature( payload.targetTrimmerHeaterTemp ); } @@ -742,9 +744,8 @@ /*********************************************************************//** * @brief * The handleFWVersionCmd function handles a FW version request message. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -777,23 +778,22 @@ * @brief * The handleSwitchReservoirCmd function handles a switch reservoirs command * from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @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) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { RESERVOIR_ID_T reservoirID; U32 resID; result = TRUE; - memcpy( &resID, message->payload, sizeof(U32) ); + memcpy( &resID, message->payload, sizeof( U32 ) ); reservoirID = (RESERVOIR_ID_T)resID; setActiveReservoirCmd( reservoirID ); } @@ -804,22 +804,21 @@ /*********************************************************************//** * @brief * The handleFillCmd function handles a fill command from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @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) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { U32 fillToVolumeMl; result = TRUE; - memcpy( &fillToVolumeMl, message->payload, sizeof(U32) ); + memcpy( &fillToVolumeMl, message->payload, sizeof( U32 ) ); startFillCmd( fillToVolumeMl ); } @@ -829,24 +828,23 @@ /*********************************************************************//** * @brief * The handleDrainCmd function handles a drain command from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @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(U32) ) + if ( message->hdr.payloadLen == sizeof( DRAIN_CMD_T ) ) { - U32 drainToVolMl; + DRAIN_CMD_T drainCmd; result = TRUE; - memcpy( &drainToVolMl, message->payload, sizeof(U32) ); + memcpy( &drainCmd, message->payload, sizeof( DRAIN_CMD_T ) ); - startDrainCmd( drainToVolMl ); + startDrainCmd( drainCmd ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); @@ -856,21 +854,20 @@ * @brief * The handleStartStopTreatmentMsg function handles a treatment start/stop * message from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @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) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { BOOL startingTreatment; - memcpy( &startingTreatment, message->payload, sizeof(U32) ); + memcpy( &startingTreatment, message->payload, sizeof( U32 ) ); if ( DG_MODE_STAN == getCurrentOperationMode() && TRUE == startingTreatment ) { @@ -889,21 +886,20 @@ * @brief * The handleStartStopTrimmerHeaterCmd function handles a trimmer heater start/stop * command message from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @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) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { BOOL startingHeater; - memcpy( &startingHeater, message->payload, sizeof(U32) ); + memcpy( &startingHeater, message->payload, sizeof( U32 ) ); if ( TRUE == startingHeater ) { @@ -921,9 +917,8 @@ /*********************************************************************//** * @brief * The handleSampleWaterCmd function handles a sample water command from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -946,9 +941,8 @@ * @brief * The handleSetRTCTimestamp function handles a request to write time and * date to RTC - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -961,7 +955,7 @@ U08 days = message->payload[3]; U08 months = message->payload[4]; U32 years; - memcpy(&years, &message->payload[5], sizeof(U32)); + memcpy(&years, &message->payload[5], sizeof( U32 )); result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); @@ -973,21 +967,20 @@ * @brief * The handleStartStopPrimaryHeater function handles a request start or * stop the primary heater - * @details - * Inputs : none - * Outputs : message handled + * @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) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { BOOL startingHeater; - memcpy( &startingHeater, message->payload, sizeof(U32) ); + memcpy( &startingHeater, message->payload, sizeof( U32 ) ); if ( TRUE == startingHeater ) { @@ -1016,8 +1009,8 @@ * @brief * The sendDebugData function sends debug data out to the PC port. * @details - * Inputs : none - * Outputs : PC serial port + * @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 @@ -1036,8 +1029,8 @@ * @brief * The sendDebugDataToUI function sends debug string to the UI for logging. * @details - * Inputs : none - * Outputs : Message constructed and queued for transmit + * @details Inputs: none + * @details Outputs: Message constructed and queued for transmit * @param str Pointer to debug string * @return none *************************************************************************/ @@ -1065,9 +1058,8 @@ * @brief * The isTestingActivated function determines whether a tester has successfully * logged in to activate testing functionality. - * @details - * Inputs : testerLoggedIn - * Outputs : none + * @details Inputs: testerLoggedIn + * @details Outputs: none * @return TRUE if a tester has logged in to activate testing, FALSE if not *************************************************************************/ BOOL isTestingActivated( void ) @@ -1079,9 +1071,8 @@ * @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 - * Outputs : response message constructed and queued for transmit. + * @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 @@ -1106,9 +1097,8 @@ /*********************************************************************//** * @brief * The handleTesterLogInRequest function handles a request to login as a tester. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1132,9 +1122,8 @@ * @brief * The handleTestWatchdogCheckInStateOverrideRequest function handles a * request to override the check-in status of a given task. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1144,9 +1133,9 @@ BOOL result = FALSE; // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetWatchdogTaskCheckInOverride( payload.index, (BOOL)(payload.state.u32) ); @@ -1165,9 +1154,8 @@ * @brief * The handleTestAlarmStateOverrideRequest function handles a request to * override the active status of a given alarm. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1177,9 +1165,9 @@ BOOL result = FALSE; // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetAlarmStateOverride( payload.index, payload.state.u32 ); @@ -1198,9 +1186,8 @@ * @brief * The handleTestLoadCellOverrideRequest function handles a request to * override the value read from the given load cell. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1210,9 +1197,9 @@ BOOL result = FALSE; // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetLoadCellOverride( payload.index, payload.state.f32 ); @@ -1231,9 +1218,8 @@ * @brief * The handleTestTemperatureSensorsOverrideRequest function handles a * request to override a temperatures sensor's value. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1243,9 +1229,9 @@ BOOL result = FALSE; // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetMeasuredTemperatureOverride( payload.index, payload.state.f32 ); @@ -1265,8 +1251,8 @@ * The handleTestTemperatureSensorsDataPublishOverrideRequest function handles * a request to override the publish interval of temperature sensors data. * @details -* Inputs : none -* Outputs : message handled +* @details Inputs: none +* @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1276,9 +1262,9 @@ 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 = testSetTemperatureSensorsPublishIntervalOverride( payload.state.u32 ); @@ -1297,9 +1283,8 @@ * @brief * The handleTestHeatersDataPublishOverrideRequest function handles * a request to override the publish interval of heaters data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1309,9 +1294,9 @@ 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 = testSetHeatersPublishIntervalOverride( payload.state.u32 ); @@ -1330,9 +1315,8 @@ * @brief * The handleTestLoadCellDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for load cell data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1342,9 +1326,9 @@ 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 = testSetLoadCellDataPublishIntervalOverride( payload.state.u32 ); @@ -1363,9 +1347,8 @@ * @brief * The handleTestPressureSensorOverrideRequest function handles a request to * override the value read from the given pressure sensor. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1375,9 +1358,9 @@ BOOL result = FALSE; // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetDGPressureSensorOverride( payload.index, payload.state.f32 ); @@ -1396,9 +1379,8 @@ * @brief * The handleTestPressureDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for load cell data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1408,9 +1390,9 @@ 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 = testSetPressuresDataPublishIntervalOverride( payload.state.u32 ); @@ -1427,44 +1409,10 @@ /*********************************************************************//** * @brief - * The handleTestROPumpSetPointOverrideRequest function handles a request to - * override the RO pump pressure set point (in PSI). - * @details - * Inputs : none - * 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 * override the RO flow rate. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1474,9 +1422,9 @@ 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 = testSetMeasuredROFlowRateOverride( payload.state.f32 ); @@ -1495,9 +1443,8 @@ * @brief * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for RO pump data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1507,9 +1454,9 @@ 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 = testSetROPumpDataPublishIntervalOverride( payload.state.u32 ); @@ -1526,44 +1473,10 @@ /*********************************************************************//** * @brief - * The handleTestDrainPumpSetPointOverrideRequest function handles a request to - * override the drain pump speed set point (in RPM). - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestDrainPumpSetPointOverrideRequest( 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 = testSetTargetDrainPumpSpeedOverride( payload.state.u32 ); - } - else - { - result = testResetTargetDrainPumpSpeedOverride(); - } - } - - // 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 - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1573,9 +1486,9 @@ 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 ); @@ -1594,9 +1507,8 @@ * @brief * The handleTestValveStateOverrideRequest function handles a request to * override the state value read from the given valve. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1606,9 +1518,9 @@ BOOL result = FALSE; // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetValveStateOverride( payload.index, payload.state.u32 ); @@ -1627,9 +1539,8 @@ * @brief * The handleTestValvesStatesPublishIntervalOverrideRequest function handles * a request to override the publish interval of valves states from the given valve. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1639,9 +1550,9 @@ 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 = testSetValvesStatesPublishIntervalOverride( payload.state.u32 ); @@ -1660,9 +1571,8 @@ * @brief * The handleTestDGSafetyShutdownOverrideRequest function handles a * request to override the safety shutdown signal. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1672,9 +1582,9 @@ 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 = testSetSafetyShutdownOverride( payload.state.u32 ); @@ -1693,9 +1603,8 @@ * @brief * The handleTestDGAccelOverrideRequest function handles a request to * override the measured accelerometer sensor readings. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1705,9 +1614,9 @@ BOOL result = FALSE; // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetAccelAxisOverride( payload.index, payload.state.f32 ); @@ -1726,9 +1635,8 @@ * @brief * The handleTestDGAccelMaxOverrideRequest function handles a request to * override the measured accelerometer sensor maximum readings. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1738,9 +1646,9 @@ BOOL result = FALSE; // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetAccelMaxOverride( payload.index, payload.state.f32 ); @@ -1759,9 +1667,8 @@ * @brief * The handleTestDGAccelBroadcastIntervalOverrideRequest function handles a * request to override the broadcast interval for accelerometer data messages. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1771,9 +1678,9 @@ 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 = testSetAccelDataPublishIntervalOverride( payload.state.u32 ); @@ -1792,21 +1699,20 @@ * @brief * The handleSetAccelCalibration function handles a request to set * accelerometer calibration factors. - * @details - * Inputs : none - * Outputs : message handled + * @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) ) + if ( message->hdr.payloadLen == sizeof( ACCEL_CAL_PAYLOAD_T ) ) { ACCEL_CAL_PAYLOAD_T payload; - memcpy( &payload, message->payload, sizeof(ACCEL_CAL_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( ACCEL_CAL_PAYLOAD_T ) ); result = setAccelCalibration( payload.xOffset, payload.yOffset, payload.zOffset ); } @@ -1818,9 +1724,8 @@ * @brief * The handleTestSetConductivityOverrideRequest function handles a * request to override a conductivity sensor's value - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1830,9 +1735,9 @@ BOOL result = FALSE; // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetConductivityOverride( payload.index, payload.state.f32 ); @@ -1852,8 +1757,8 @@ * The handleTestSetConductivityDataPublishIntervalOverrideRequest function * handles a request to override the publish interval of conductivity sensors data * @details -* Inputs : none -* Outputs : message handled +* @details Inputs: none +* @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1863,9 +1768,9 @@ 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 = testSetConductivityDataPublishIntervalOverride( payload.state.u32 ); @@ -1880,4 +1785,267 @@ 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 + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGSoftwareResetRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = TRUE; // reset will prevent this from getting transmitted + systemREG1->SYSECR = ( 0x2 << 14 ); // reset processor + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @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 + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetConcentratePumpTargetSpeed( 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 ) ); + 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 = testSetConcentratePumpDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetConcentratePumpDataPublishIntervalOverride(); + } + } + + // 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 handleTestROPumpTargetFlowOverride function handles a request to +* override the RO pump target flow rate. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*******************************************************************/ +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 handleROPumpTargetPressureOverride function handles a request to +* override the RO pump target 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 ); +} + /**@}*/