Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 -rab304e2ca6e3e40ed8cb12650e9855ae0b9649d8 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision ab304e2ca6e3e40ed8cb12650e9855ae0b9649d8) @@ -7,23 +7,27 @@ * * @file SystemCommMessages.c * -* @author (last) Sean Nash -* @date (last) 29-Jun-2020 +* @author (last) Quang Nguyen +* @date (last) 26-Aug-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #include // for memcpy() - + +#include "Accel.h" +#include "ConductivitySensors.h" #include "DrainPump.h" #include "FPGA.h" #include "Heaters.h" #include "LoadCell.h" -#include "MsgQueues.h" +#include "MessagePayloads.h" #include "ModeStandby.h" #include "ModeRecirculate.h" +#include "MsgQueues.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "Pressures.h" #include "Reservoirs.h" @@ -36,104 +40,24 @@ #include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" -#include "ModeHeatDisinfect.h" +#include "ModeHeatDisinfect.h" + +/** + * @addtogroup SystemCommMessages + * @{ + */ // ********** private definitions ********** -#define ACK_REQUIRED TRUE -#define ACK_NOT_REQUIRED FALSE +#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 -#pragma pack(push,1) - -typedef struct -{ - U32 alarmState; //< 0 = no alarms, 1 = low priority, 2 = medium priority, 3 = high priority - U32 alarmTop; //< ID of top active alarm - U32 escalatesIn; //< seconds - U32 silenceExpiresIn; //< seconds - U16 alarmsFlags; //< bit flags: 1 = true, 0 = false for each bit -} ALARM_COMP_STATUS_PAYLOAD_T; +#pragma pack(push,1) -/// DG version data -typedef struct -{ - U08 major; ///< Major - U08 minor; ///< Minor - U08 micro; ///< Micro - U16 build; ///< Build number - U08 fpgaId; ///< FPGA ID - U08 fpgaMajor; ///< FPGA major - U08 fpgaMinor; ///< FPGA minor - U08 fpgaLab; ///< FPGA lab -} DG_VERSIONS_T; - -typedef struct -{ - U32 treatmentTimePrescribedinSec; - U32 treatmentTimeElapsedinSec; - U32 treatmentTimeRemaininginSec; -} TREATMENT_TIME_DATA_T; - -typedef struct -{ - F32 loadCellA1inGram; - F32 loadCellA2inGram; - F32 loadCellB1inGram; - F32 loadCellB2inGram; -} LOAD_CELL_DATA_T; - -/// RO pump data -typedef struct -{ - F32 roPumpTgtPressure; ///< RO pump target pressure - F32 measROFlowRate; ///< RO pump measured flow rate - F32 roPumpPWM; ///< RO pump PWM duty cycle - U32 roPumpState; ///< RO pump current state -} RO_PUMP_DATA_T; - -/// Drain pump data -typedef struct -{ - U32 setDrainPumpSpeed; ///< Drain pump set speed - U32 dacValue; ///< Drain pump DAC value - F32 deltaPressure; ///< Drain pump delta pressure - U32 drainPState; ///< Drain pump state -} DRAIN_PUMP_DATA_T; - -typedef struct -{ - F32 roPumpInletPressure; - F32 roPumpOutletPressure; - F32 drainPumpInletPressure; - F32 drainPumpOutletPressure; -} PRESSURES_DATA_T; - -typedef struct -{ - U32 activeReservoir; - U32 fillToVolumeMl; - U32 drainToVolumeMl; -} RESERVOIR_DATA_T; - -/// Target temperature of the heaters data -typedef struct -{ - F32 targetPrimaryHeaterTemp; ///< Target primary heater temperature - F32 targetTrimmerHeaterTemp; ///< Target trimmer heater temperature -} TARGET_TEMPS_PAYLOAD_T; - -/// Heaters data -typedef struct -{ - U32 mainPrimayHeaterDC; ///< Main primary heater duty cycle - U32 smallPrimaryHeaterDC; ///< Small primary heater duty cycle - U32 trimmerHeaterDC; ///< Trimmer heater duty cycle -} HEATERS_DATA_T; - /// Heat disinfect data typedef struct { @@ -146,33 +70,33 @@ // ********** private data ********** -static BOOL testerLoggedIn = FALSE; -static volatile U16 nextSeqNo = 1; +static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether tester logged in or not. +static volatile U16 nextSeqNo = 1; ///< Next sequence number. // ********** private function prototypes ********** static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ); static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); -/************************************************************************* - * @brief serializeMessage - * The serializeMessage function serializes a given message into a given \n - * array of bytes. A sequence # is added to the message here and the ACK \n - * bit of the sequence # is set if ACK is required per parameter. A sync byte \n - * is inserted at the beginning of the message and an 8-bit CRC is appended to \n +/*********************************************************************//** + * @brief + * The serializeMessage function serializes a given message into a given + * array of bytes. A sequence # is added to the message here and the ACK + * 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. - * @param msg : message to serialize - * @param buffer : outgoing buffer that message should be queued in - * @param ackReq : is an acknowledgement from receiver required? + * @param msg message to serialize + * @param buffer outgoing buffer that message should be queued in + * @param ackReq is an acknowledgement from receiver required? * @return size (in bytes) of serialized message populated in given data array. *************************************************************************/ static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) { - BOOL result = 0; + BOOL result = FALSE; BOOL error = FALSE; U32 msgSize = 0; U32 sizeMod, sizePad; @@ -237,15 +161,15 @@ return result; } - -/************************************************************************* - * @brief sendACKMsg - * The sendACKMsg function constructs and queues for transmit an ACK message \n + +/*********************************************************************//** + * @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. - * @param message : message to send an ACK for + * @param message message to send an ACK for * @return TRUE if ACK message queued successfully, FALSE if not *************************************************************************/ BOOL sendACKMsg( MESSAGE_T *message ) @@ -267,18 +191,17 @@ return result; } - -/************************************************************************* - * @brief sendTestAckResponseMsg - * The sendTestAckResponseMsg function constructs a simple response \n - * message for a handled test message and queues it for transmit on the \n - * appropriate UART channel. + +/*********************************************************************//** + * @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. - * @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 + * @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 ) @@ -297,21 +220,22 @@ return result; } + // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // *********************************************************************** - -/************************************************************************* - * @brief broadcastAlarmTriggered - * The broadcastAlarmTriggered function constructs an alarm triggered msg to \n + +/*********************************************************************//** + * @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. - * @param alarm : ID of alarm triggered - * @param almData1 : 1st data associated with alarm - * @param almData2 : 2nd data associated with alarm + * @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 ) @@ -336,15 +260,15 @@ return result; } - -/************************************************************************* - * @brief broadcastAlarmCleared - * The broadcastAlarmCleared function constructs an alarm cleared msg to be \n + +/*********************************************************************//** + * @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. - * @param alarm : ID of alarm cleared + * @param alarm ID of alarm cleared * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAlarmCleared( U16 alarm ) @@ -365,15 +289,62 @@ return result; } - -/************************************************************************* - * @brief broadcastRTCEpoch - * The broadcastRTCEpoch function constructs an epoch msg to \n - * be broadcast and queues the msg for transmit on the appropriate CAN channel. + +/*********************************************************************//** + * @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. + * @param x X axis vector magnitude (in g) + * @param y Y axis vector magnitude (in g) + * @param z Z axis vector magnitude (in g) + * @param xm max X axis vector magnitude (in g) + * @param ym max Y axis vector magnitude (in g) + * @param zm max Z axis vector magnitude (in g) + * @param xt X axis tilt (in degrees) + * @param yt Y axis tilt (in degrees) + * @param zt Z axis tilt (in degrees) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAccelData( F32 x, F32 y, F32 z, F32 xm, F32 ym, F32 zm, F32 xt, F32 yt, F32 zt ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + ACCEL_DATA_PAYLOAD_T payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_ACCELEROMETER_DATA; + msg.hdr.payloadLen = sizeof( ACCEL_DATA_PAYLOAD_T ); + payload.x = x; + payload.y = y; + payload.z = z; + payload.xMax = xm; + payload.yMax = ym; + payload.zMax = zm; + payload.xTilt = xt; + payload.yTilt = yt; + payload.zTilt = zt; + + memcpy( payloadPtr, &payload, sizeof( ACCEL_DATA_PAYLOAD_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 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 - * @param epoch : Current time and date in epoch + * @param epoch Current time and date in epoch * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastRTCEpoch( U32 epoch ) @@ -394,16 +365,16 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief - * The broadcastDGHDOperationMode function constructs a DG operation mode \n + * 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 - * @param mode : current operation mode of the DG. - * @param subMode : current sub-mode of the current operation mode of the DG. + * @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 ) @@ -426,17 +397,17 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief * The broadcastLoadCellData function sends out load cell data. * @details * Inputs : none * 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. - * @param loadCellB2 : load cell B 2 data in grams. + * @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 + * @param loadCellB2 load cell B 2 data in grams * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastLoadCellData( F32 loadCellA1, F32 loadCellA2, F32 loadCellB1, F32 loadCellB2 ) @@ -463,14 +434,14 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief * The broadcastValvesStates function sends out DG valves states. * @details * Inputs : none * Outputs : Valves states msg constructed and queued - * @param valvesStates : valves states + * @param valvesStates valves states * refer to setFPGAValveStates function in FPGA.c for details * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -492,16 +463,16 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief * The broadcastHeatersData function sends out DG heaters data * @details * Inputs : heaters data * 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 + * @param mainPrimaryDC main primary heater duty cycle + * @param smallPrimaryDC small primary heater duty cycle + * @param trimmerDC trimmer heater duty cycle * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastHeatersData ( U32 mainPrimaryDC, U32 smallPrimaryDC, U32 trimmerDC ) @@ -527,17 +498,16 @@ 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 % - * @param pumpState: set the current pump state + * @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( F32 tgtPressure, F32 measFlow, F32 setPWM, U32 pumpState ) @@ -564,17 +534,15 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief * The broadcastDrainPumpData function sends out RO pump data. * @details * Inputs : none * Outputs : Drain pump data msg constructed and queued - * @param tgtSpeed : target speed for drain pump in RPM. - * @param dac : set DAC value. - * @param deltaP : Delta pressure for the sensors - * @param drainPumpState : The state of the drain pump + * @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, F32 deltaP, U32 drainPumpState ) @@ -601,17 +569,17 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief * The broadcastPressureSensorsData function sends out DG pressure data. * @details * Inputs : none * 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. + * @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 ) @@ -637,17 +605,17 @@ 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 * 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. + * @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 ) @@ -673,14 +641,15 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief * The broadcastTemperatureSensorsData function sends out DG temperature - * sensors data - * Inputs : heaters data - * Outputs : temperature sensors data msg constructed and queued - * @param sensorsValue : sensors value array + * sensors data. + * Inputs : none + * 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 ) @@ -736,34 +705,73 @@ return result; } + +/*********************************************************************//** + * @brief + * The broadcastConductivityData function sends out conductivity data. + * @details + * Inputs : none + * 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 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( 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; +} + // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** - -/************************************************************************* + +/*********************************************************************//** * @brief - * The handlePowerOffWarning function handles a power off warning message \n + * The handlePowerOffWarning function handles a power off warning message * from the HD. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handlePowerOffWarning( MESSAGE_T *message ) -{ - // TODO - signal modules that require a warning +{ + if ( message->hdr.payloadLen == 0 ) + { + signalPowerOffWarning(); + } } - -/************************************************************************* + +/*********************************************************************//** * @brief - * The handleSetDialysateTemperatureCmd function handles a dialysate temperature \n + * The handleSetDialysateTemperatureCmd function handles a dialysate temperature * set points message from the HD. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDialysateTemperatureCmd( MESSAGE_T *message ) @@ -781,14 +789,14 @@ } 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 * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleFWVersionCmd( MESSAGE_T *message ) @@ -815,15 +823,15 @@ // 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 \n + * The handleSwitchReservoirCmd function handles a switch reservoirs command * from the HD. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSwitchReservoirCmd( MESSAGE_T *message ) @@ -839,17 +847,18 @@ memcpy( &resID, message->payload, sizeof(U32) ); reservoirID = (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 * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleFillCmd( MESSAGE_T *message ) @@ -863,17 +872,18 @@ 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 handleDrainCmd function handles a drain command from the HD. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDrainCmd( MESSAGE_T *message ) @@ -888,18 +898,19 @@ memcpy( &drainToVolMl, message->payload, sizeof(U32) ); startDrainCmd( drainToVolMl ); - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - -/************************************************************************* + +/*********************************************************************//** * @brief - * The handleStartStopTreatmentMsg function handles a treatment start/stop \n + * The handleStartStopTreatmentMsg function handles a treatment start/stop * message from the HD. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleStartStopTreatmentMsg( MESSAGE_T *message ) @@ -920,18 +931,19 @@ { result = requestDGStop(); } - } + } + 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 \n + * The handleStartStopTrimmerHeaterCmd function handles a trimmer heater start/stop * command message from the HD. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleStartStopTrimmerHeaterCmd( MESSAGE_T *message ) @@ -952,17 +964,18 @@ { result = stopTrimmerHeaterCmd(); } - } + } + 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 * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSampleWaterCmd( MESSAGE_T *message ) @@ -975,18 +988,19 @@ { result = requestWaterSample(); } - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - -/************************************************************************* - * @brief handleSetRTCTimestamp + +/*********************************************************************//** + * @brief * The handleSetRTCTimestamp function handles a request to write time and * date to RTC * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetRTCTimestamp( MESSAGE_T *message ) @@ -1005,15 +1019,15 @@ // 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 * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return result *************************************************************************/ BOOL handleStartStopPrimaryHeater( MESSAGE_T * message ) @@ -1035,11 +1049,13 @@ stopPrimaryHeater(); result = TRUE; } - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); return result; } + /************************************************************************* * @brief @@ -1104,17 +1120,17 @@ /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ + - #ifdef DEBUG_ENABLED - /************************************************************************* - * @brief sendDebugData + /*********************************************************************//** + * @brief * The sendDebugData function sends debug data out to the PC port. * @details * Inputs : none * Outputs : PC serial port - * @param dbgData : Pointer to debug data - * @param len : # of bytes of debug data + * @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 ) @@ -1126,14 +1142,14 @@ return result; } - - /************************************************************************* + + /*********************************************************************//** * @brief * The sendDebugDataToUI function sends debug string to the UI for logging. * @details * Inputs : none * Outputs : Message constructed and queued for transmit - * @param str : Pointer to debug string + * @param str Pointer to debug string * @return none *************************************************************************/ void sendDebugDataToUI( U08 *str ) @@ -1151,36 +1167,34 @@ memcpy( payloadPtr, str, txtLen + 1 ); // 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_UI, ACK_NOT_REQUIRED ); + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_NOT_REQUIRED ); } } #endif - -/************************************************************************* - * @brief isTestingActivated - * The isTestingActivated function determines whether a tester has successfully \n + +/*********************************************************************//** + * @brief + * The isTestingActivated function determines whether a tester has successfully * logged in to activate testing functionality. * @details * Inputs : testerLoggedIn * Outputs : none - * @param none * @return TRUE if a tester has logged in to activate testing, FALSE if not *************************************************************************/ BOOL isTestingActivated( void ) { return testerLoggedIn; } - -/************************************************************************* - * @brief sendTestAckResponseMsg - * The sendTestAckResponseMsg function constructs a simple response \n - * message for a handled test message and queues it for transmit on the \n - * appropriate UART channel. + +/*********************************************************************//** + * @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. - * @param msgID : ID of handled message that we are responding to - * @param ack : TRUE if test message was handled successfully, FALSE if not + * @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 ) @@ -1199,15 +1213,14 @@ return result; } - -/************************************************************************* - * @brief handleTesterLogInRequest - * The handleTesterLogInRequest function handles a request to login as a \n - * tester. + +/*********************************************************************//** + * @brief + * The handleTesterLogInRequest function handles a request to login as a tester. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTesterLogInRequest( MESSAGE_T *message ) @@ -1225,221 +1238,535 @@ // respond to would be tester sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); } - -/************************************************************************* - * @brief handleTestWatchdogCheckInStateOverrideRequest - * The handleTestWatchdogCheckInStateOverrideRequest function handles a \n + +/*********************************************************************//** + * @brief + * The handleTestWatchdogCheckInStateOverrideRequest function handles a * request to override the check-in status of a given task. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestWatchdogCheckInStateOverrideRequest, testSetWatchdogTaskCheckInOverride, testResetWatchdogTaskCheckInOverride ) - -/************************************************************************* - * @brief handleTestAlarmStateOverrideRequest - * The handleTestAlarmStateOverrideRequest function handles a request to \n +void handleTestWatchdogCheckInStateOverrideRequest( 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 = testSetWatchdogTaskCheckInOverride( payload.index, (BOOL)(payload.state.u32) ); + } + else + { + result = testResetWatchdogTaskCheckInOverride( payload.index ); + } + } + + // respond to request + 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 * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestAlarmStateOverrideRequest, testSetAlarmStateOverride, testResetAlarmStateOverride ) - -/************************************************************************* +void handleTestAlarmStateOverrideRequest( 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 = testSetAlarmStateOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetAlarmStateOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestLoadCellOverrideRequest function handles a request to \n + * The handleTestLoadCellOverrideRequest function handles a request to * override the value read from the given load cell. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestLoadCellOverrideRequest, testSetLoadCellOverride, testResetLoadCellOverride ) - -/************************************************************************* +void handleTestLoadCellOverrideRequest( 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 = testSetLoadCellOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetLoadCellOverride( payload.index ); + } + } + + //respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief * The handleTestTemperatureSensorsOverrideRequest function handles a - * request to override a temperatures sensor's value + * request to override a temperatures sensor's value. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestTemperatureSensorsOverrideRequest, \ - testSetMeasuredTemperatureOverride, testResetMeasuredTemperatureOverride ) - -/************************************************************************* +void handleTestTemperatureSensorsOverrideRequest( 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 = testSetMeasuredTemperatureOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetMeasuredTemperatureOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief -* The handleTestTemperatureSensorsDataPublishOverrideRequest function handles \n -* a request to override the publish interval of temperature sensors data +* The handleTestTemperatureSensorsDataPublishOverrideRequest function handles +* a request to override the publish interval of temperature sensors data. * @details * Inputs : none * Outputs : message handled -* @param message : a pointer to the message to handle +* @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestTemperatureSensorsDataPublishOverrideRequest, \ - testSetTemperatureSensorsPublishIntervalOverride, testResetTemperatureSensorsPublishIntervalOverride ) +void handleTestTemperatureSensorsDataPublishOverrideRequest( 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 = testSetTemperatureSensorsPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetTemperatureSensorsPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestHeatersDataPublishOverrideRequest function handles \n - * a request to override the publish interval of heaters data + * The handleTestHeatersDataPublishOverrideRequest function handles + * a request to override the publish interval of heaters data. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestHeatersDataPublishOverrideRequest, \ - testSetHeatersPublishIntervalOverride, testResetHeatersPublishIntervalOverride ) - -/************************************************************************* +void handleTestHeatersDataPublishOverrideRequest( 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 = testSetHeatersPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetHeatersPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestLoadCellDataBroadcastIntervalOverrideRequest function handles \n + * The handleTestLoadCellDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for load cell data. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestLoadCellDataBroadcastIntervalOverrideRequest, testSetLoadCellDataPublishIntervalOverride, testResetLoadCellDataPublishIntervalOverride ) - -/************************************************************************* +void handleTestLoadCellDataBroadcastIntervalOverrideRequest( 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 = testSetLoadCellDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetLoadCellDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestPressureSensorOverrideRequest function handles a request to \n + * The handleTestPressureSensorOverrideRequest function handles a request to * override the value read from the given pressure sensor. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestPressureSensorOverrideRequest, testSetDGPressureSensorOverride, testResetDGPressureSensorOverride ) - -/************************************************************************* +void handleTestPressureSensorOverrideRequest( 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 = testSetDGPressureSensorOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetDGPressureSensorOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestPressureDataBroadcastIntervalOverrideRequest function handles \n + * The handleTestPressureDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for load cell data. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestPressureDataBroadcastIntervalOverrideRequest, \ - testSetPressuresDataPublishIntervalOverride, testResetPressuresDataPublishIntervalOverride ) - -/************************************************************************* +void handleTestPressureDataBroadcastIntervalOverrideRequest( 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 = testSetPressuresDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetPressuresDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestROPumpSetPointOverrideRequest function handles a request to \n + * 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 + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestROPumpSetPointOverrideRequest, \ - testSetTargetROPumpFlowRateOverride, testResetTargetROPumpFlowRateOverride ) - -/************************************************************************* +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 \n + * The handleTestROMeasuredFlowOverrideRequest function handles a request to * override the RO flow rate. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestROMeasuredFlowOverrideRequest, testSetMeasuredROFlowRateOverride, testResetMeasuredROFlowRateOverride ) - -/************************************************************************* +void handleTestROMeasuredFlowOverrideRequest( 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 = testSetMeasuredROFlowRateOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredROFlowRateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles \n + * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for RO pump data. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestROPumpDataBroadcastIntervalOverrideRequest, \ - testSetROPumpDataPublishIntervalOverride, testResetROPumpDataPublishIntervalOverride ) - -/************************************************************************* +void handleTestROPumpDataBroadcastIntervalOverrideRequest( 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 = testSetROPumpDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetROPumpDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestDrainPumpSetPointOverrideRequest function handles a request to \n + * 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 + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDrainPumpSetPointOverrideRequest, \ - testSetTargetDrainPumpSpeedOverride, testResetTargetDrainPumpSpeedOverride ) - -/************************************************************************* +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 \n + * The handleTestDrainPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for drain pump data. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDrainPumpDataBroadcastIntervalOverrideRequest, \ - testSetDrainPumpDataPublishIntervalOverride, testResetDrainPumpDataPublishIntervalOverride ) - -/************************************************************************* +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 ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetDrainPumpDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetDrainPumpDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestValveStateOverrideRequest function handles a request to \n + * The handleTestValveStateOverrideRequest function handles a request to * override the state value read from the given valve. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestValveStateOverrideRequest, testSetValveStateOverride, testResetValveStateOverride ) - -/************************************************************************* +void handleTestValveStateOverrideRequest( 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 = testSetValveStateOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetValveStateOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestValvesStatesPublishIntervalOverrideRequest function handles \n + * The handleTestValvesStatesPublishIntervalOverrideRequest function handles * a request to override the publish interval of valves states from the given valve. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestValvesStatesPublishIntervalOverrideRequest, \ - testSetValvesStatesPublishIntervalOverride, testResetValvesStatesPublishIntervalOverride ) - -/************************************************************************* - * @brief - * The handleTestDGSafetyShutdownOverrideRequest function handles a \n - * request to override the safety shutdown signal. - * @details - * Inputs : none - * Outputs : message handled - * @param message : a pointer to the message to handle - * @return none - *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDGSafetyShutdownOverrideRequest, \ - testSetSafetyShutdownOverride, testResetSafetyShutdownOverride ) +void handleTestValvesStatesPublishIntervalOverrideRequest( 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 = testSetValvesStatesPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetValvesStatesPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /************************************************************************* * @brief * The handleSetDrainPumpDeltaPressure function handles a \n @@ -1523,3 +1850,228 @@ DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleSetHeatDisinfectionPublishDataIntervalOverrideRequest, \ testSetHeatDisinfectDataPublishIntervalOverride, testResetHeatDisinfectDataPublishIntervalOverride ) +/*********************************************************************//** + * @brief + * The handleTestDGSafetyShutdownOverrideRequest function handles a + * request to override the safety shutdown signal. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDGSafetyShutdownOverrideRequest( 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 = testSetSafetyShutdownOverride( payload.state.u32 ); + } + else + { + result = testResetSafetyShutdownOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestDGAccelOverrideRequest function handles a request to + * override the measured accelerometer sensor readings. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDGAccelOverrideRequest( 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 = testSetAccelAxisOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetAccelAxisOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestDGAccelMaxOverrideRequest function handles a request to + * override the measured accelerometer sensor maximum readings. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDGAccelMaxOverrideRequest( 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 = testSetAccelMaxOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetAccelMaxOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestDGAccelBroadcastIntervalOverrideRequest function handles a + * request to override the broadcast interval for accelerometer data messages. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDGAccelBroadcastIntervalOverrideRequest( 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 = testSetAccelDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetAccelDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetAccelCalibration function handles a request to set + * accelerometer calibration factors. + * @details + * Inputs : none + * 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 + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSetConductivityOverrideRequest( 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 = testSetConductivityOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetConductivityOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleTestSetConductivityDataPublishIntervalOverrideRequest function +* handles a request to override the publish interval of conductivity sensors data +* @details +* Inputs : none +* Outputs : message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestSetConductivityDataPublishIntervalOverrideRequest( 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 = testSetConductivityDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetConductivityDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/**@}*/