Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r3d131237935eb36e56e0d057a713430e31dc6405 -r604d8aaceeb8e0b650ac2054644333fc7717bb51 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 3d131237935eb36e56e0d057a713430e31dc6405) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 604d8aaceeb8e0b650ac2054644333fc7717bb51) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2022 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * -* @file SystemCommMessages.c +* @file SystemCommMessages.c * -* @author (last) Quang Nguyen -* @date (last) 26-Aug-2020 +* @author (last) Dara Navaei +* @date (last) 31-Mar-2022 * -* @author (original) Dara Navaei -* @date (original) 05-Nov-2019 +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 * ***************************************************************************/ @@ -20,22 +20,25 @@ #include "reg_system.h" #include "Accel.h" +#include "Compatible.h" #include "ConcentratePumps.h" #include "ConductivitySensors.h" -#include "DrainPump.h" +#include "Fans.h" #include "FPGA.h" #include "Heaters.h" -#include "LoadCell.h" +#include "ModeFill.h" #include "ModeFlush.h" +#include "ModeGenIdle.h" +#include "ModeInitPOST.h" #include "ModeStandby.h" -#include "ModeRecirculate.h" #include "MsgQueues.h" #include "NVDataMgmt.h" #include "OperationModes.h" +#include "DialysateFlow.h" #include "Pressures.h" #include "Reservoirs.h" -#include "ROPump.h" #include "RTC.h" +#include "Switches.h" #include "SystemComm.h" #include "SafetyShutdown.h" #include "SystemCommMessages.h" @@ -53,21 +56,25 @@ // ********** private definitions ********** -#define ACK_REQUIRED TRUE ///< Require an ACK. -#define ACK_NOT_REQUIRED FALSE ///< Not require an ACK. +#define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. -#ifdef DEBUG_ENABLED - #define DEBUG_EVENT_MAX_TEXT_LEN 40 -#endif - -// ********** private data ********** - -static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether tester logged in or not. +#pragma pack(push,1) +/// Payload record structure for block message transmission request. +typedef struct +{ + U16 blockedMessages[ MAX_MSGS_BLOCKED_FOR_XMIT ]; +} BLOCKED_MSGS_DATA_T; +#pragma pack(pop) + +// ********** private data ********** + +static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether tester logged in or not. static volatile U16 nextSeqNo = 1; ///< Next sequence number. +/// List of message IDs that are requested not to be transmitted. +static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; // ********** 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 ); @@ -85,7 +92,7 @@ * @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 ) +U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) { BOOL result = FALSE; BOOL error = FALSE; @@ -99,7 +106,7 @@ data[ msgSize++ ] = MESSAGE_SYNC_BYTE; // set sequence # and ACK bit (unless this is an ACK to a received message) - if ( msg.hdr.msgID != MSG_ID_ACK ) + if ( msg.hdr.msgID != MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK ) { // thread protect next sequence # access & increment _disable_IRQ(); @@ -172,7 +179,7 @@ // send ACK back with same seq. #, but w/o ACK bit msg.hdr.seqNo = message->hdr.seqNo * -1; // ACK messages always have this ID - msg.hdr.msgID = MSG_ID_ACK; + msg.hdr.msgID = MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK; // ACK messages always have no payload msg.hdr.payloadLen = 0; @@ -217,6 +224,49 @@ /*********************************************************************//** * @brief + * The sendEvent function constructs an DG event message to the UI and + * queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG event msg constructed and queued. + * @param event Enumeration of event type that occurred + * @param dat1 First data associated with event + * @param dat2 Second data associated with event + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendEvent( DG_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 e = (U32)event; + // Convert the two data types enums to U32. The enums are interpreted as a U08 by the compiler + U32 dataType1 = (U32)dat1.dataType; + U32 dataType2 = (U32)dat2.dataType; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_EVENT; + // The payload length is the event ID, 2 event datas and the events data types for each of the event data + msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( EVENT_DATAS_T ) + 2 * sizeof( U32 ); + + memcpy( payloadPtr, &e, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dataType1, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dat1.data, sizeof( EVENT_DATAS_T ) ); + payloadPtr += sizeof( EVENT_DATAS_T ); + memcpy( payloadPtr, &dataType2, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dat2.data, sizeof( EVENT_DATAS_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_2_UI, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @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 @@ -231,17 +281,26 @@ BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; + U32 data; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_TRIGGERED; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( ALARM_DATA_T ) + sizeof( ALARM_DATA_T ); + msg.hdr.payloadLen = sizeof( U32 ) * 5; memcpy( payloadPtr, &alarm, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData1, sizeof( ALARM_DATA_T ) ); - payloadPtr += sizeof( ALARM_DATA_T ); - memcpy( payloadPtr, &almData2, sizeof( ALARM_DATA_T ) ); + data = (U32)almData1.dataType; + memcpy( payloadPtr, &data, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + data = almData1.data.uInt.data; + memcpy( payloadPtr, &data, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + data = (U32)almData2.dataType; + memcpy( payloadPtr, &data, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + data = almData2.data.uInt.data; + memcpy( payloadPtr, &data, sizeof( U32 ) ); // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_ALARM, ACK_REQUIRED ); @@ -306,440 +365,7 @@ return result; } -/*********************************************************************//** - * @brief - * The broadcastAccelData function constructs an accelerometer data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @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) - * @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 - * @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 - *************************************************************************/ -BOOL broadcastRTCEpoch( U32 epoch ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_RTC_EPOCH; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &epoch, sizeof( U32 ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastLoadCellData function sends out load cell data. - * @details Inputs: none - * @details Outputs: load cell data msg constructed and queued - * @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 ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - LOAD_CELL_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_LOAD_CELL_READINGS; - msg.hdr.payloadLen = sizeof( LOAD_CELL_DATA_T ); - - payload.loadCellA1inGram = loadCellA1; - payload.loadCellA2inGram = loadCellA2; - payload.loadCellB1inGram = loadCellB1; - payload.loadCellB2inGram = loadCellB2; - - memcpy( payloadPtr, &payload, sizeof( LOAD_CELL_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 broadcastValvesStates function sends out DG valves states. - * @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 - *************************************************************************/ -BOOL broadcastValvesStates( U16 valvesStates ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_VALVES_STATES; - msg.hdr.payloadLen = sizeof( U16 ); - - memcpy( payloadPtr, &valvesStates, sizeof( U16 ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastHeatersData function sends out DG heaters data - * @details Inputs: none - * @details Outputs: heaters data msg constructed and queued - * @param heatersData which is the heaters data structure pointer - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastHeatersData ( HEATERS_DATA_T *heatersData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_HEATERS_DATA; - msg.hdr.payloadLen = sizeof( HEATERS_DATA_T ); - - memcpy( payloadPtr, heatersData, sizeof( HEATERS_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastDrainPumpData function sends out the drain pump data. - * @details Inputs: none - * @details Outputs: Drain pump data msg constructed and queued - * @param drainPumpData which is the drain pump data structure pointer - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDrainPumpData( DRAIN_PUMP_DATA_T *drainPumpData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DRAIN_PUMP_DATA; - msg.hdr.payloadLen = sizeof( DRAIN_PUMP_DATA_T ); - - memcpy( payloadPtr, drainPumpData, sizeof( DRAIN_PUMP_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastDGHDOperationMode function constructs a DG operation mode - * broadcast message and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG operation mode msg constructed and queued - * @param mode current operation mode of the DG. - * @param subMode current sub-mode of the current operation mode of the DG. - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDGOperationMode( U32 mode, U32 subMode ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_OP_MODE; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &mode, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &subMode, sizeof( U32 ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastROPumpData function sends out RO pump data. - * @details Inputs: none - * @details Outputs: RO pump data msg constructed and queued - * @param tgtPressure target pressure for RO pump in PSI - * @param measFlow measure RO flow rate in LPM - * @param setPWM set PWM duty cycle in % - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastROPumpData( RO_PUMP_DATA_T *pumpData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_RO_PUMP_DATA; - msg.hdr.payloadLen = sizeof( RO_PUMP_DATA_T ); - - memcpy( payloadPtr, pumpData, sizeof( RO_PUMP_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastConcentratePumpData function sends out concentrate pumps' data. - * @details Inputs: none - * @details Outputs: concentrate pump data msg constructed and queued - * @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 - * @details Outputs: Pressure data msg constructed and queued - * @param measROIn measured RO pump inlet pressure in PSI - * @param measROOut measured RO pump outlet pressure in PSI - * @param measDrainIn measured Drain pump inlet pressure in PSI - * @param measDrainOut measured Drain pump outlet pressure in PSI - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPressureSensorsData( F32 measROIn, F32 measROOut, F32 measDrainIn, F32 measDrainOut ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - PRESSURES_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_PRESSURES_DATA; - msg.hdr.payloadLen = sizeof( PRESSURES_DATA_T ); - - payload.roPumpInletPressure = measROIn; - payload.roPumpOutletPressure = measROOut; - payload.drainPumpInletPressure = measDrainIn; - payload.drainPumpOutletPressure = measDrainOut; - - memcpy( payloadPtr, &payload, sizeof( PRESSURES_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastReservoirData function broadcasts the DG reservoir data. - * @details Inputs: none - * @details Outputs: Reservoir data msg constructed and queued - * @param resID ID of currently active reservoir - * @param fillToVol Current target fill to volume for inactive reservoir - * @param drainToVol Current target drain to volume for inactive reservoir - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastReservoirData( U32 resID, U32 fillToVol, U32 drainToVol ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - RESERVOIR_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_RESERVOIR_DATA; - msg.hdr.payloadLen = sizeof( RESERVOIR_DATA_T ); - - payload.activeReservoir = resID; - payload.fillToVolumeMl = fillToVol; - payload.drainToVolumeMl = drainToVol; - - memcpy( payloadPtr, &payload, sizeof( RESERVOIR_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastTemperatureSensorsData function sends out DG temperature - * sensors data. - * @details Inputs: none - * @details Outputs: temperature sensors data message constructed and queued - * @param tempSensorsData which is constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTemperatureSensorsData ( TEMPERATURE_SENSORS_DATA_T* tempSensorsData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_TEMPERATURE_DATA; - msg.hdr.payloadLen = sizeof( TEMPERATURE_SENSORS_DATA_T ); - - memcpy( payloadPtr, tempSensorsData, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastThermistorsData function sends out the thermistors data. - * @details - * @details Inputs: none - * @details Outputs: thermistors data msg constructed and queued - * @param thermistorsData which is constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastThermistorsData( THERMISTORS_DATA_T *thermistorsData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_THERMISTORS_DATA; - msg.hdr.payloadLen = sizeof( THERMISTORS_DATA_T ); - - memcpy( payloadPtr, thermistorsData, sizeof( THERMISTORS_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastFansData function sends out the fans data. - * @details Inputs: none - * @details Outputs: fans data msg constructed and queued - * @param fansData which is constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastFansData( FANS_DATA_T *fansData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_FANS_DATA; - msg.hdr.payloadLen = sizeof( FANS_DATA_T ); - - memcpy( payloadPtr, fansData, sizeof( FANS_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -772,13 +398,17 @@ *************************************************************************/ void handleAlarmClear( MESSAGE_T *message ) { + BOOL result = FALSE; + if ( message->hdr.payloadLen == sizeof( U32 ) ) { U32 alarmId; + result = TRUE; memcpy(&alarmId, message->payload, sizeof( U32 ) ); clearAlarm( (ALARM_ID_T)alarmId ); } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } /*********************************************************************//** @@ -794,15 +424,15 @@ { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof( TARGET_TEMPS_PAYLOAD_T ) ) + if ( message->hdr.payloadLen == sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ) ) { - TARGET_TEMPS_PAYLOAD_T payload; + DG_CMD_DIALYSATE_HEATING_PARAMS_T payload; result = TRUE; - memcpy( &payload, message->payload, sizeof( TARGET_TEMPS_PAYLOAD_T ) ); - setPrimaryHeaterTargetTemperature( payload.targetPrimaryHeaterTemp ); - setTrimmerHeaterTargetTemperature( payload.targetTrimmerHeaterTemp ); + memcpy( &payload, message->payload, sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ) ); + setDialysateHeatingParameters( payload ); } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } @@ -825,6 +455,7 @@ payload.minor = (U08)DG_VERSION_MINOR; payload.micro = (U08)DG_VERSION_MICRO; payload.build = (U16)DG_VERSION_BUILD; + payload.compatibilityRev = (U32)SW_COMPATIBILITY_REV; getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); // create a message record @@ -841,113 +472,108 @@ /*********************************************************************//** * @brief - * The broadcastConductivityData function sends out conductivity data. + * The handleDGSerialNumberRequest function handles a request for DG serial + * number request. * @details Inputs: none - * @details Outputs: conductivity data message constructed and queued - * @param conductivityDataPtr which is the data msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not + * @details Outputs: message handled, response constructed and queued for transmit. + * @return none *************************************************************************/ -BOOL broadcastConductivityData( void * conductivityDataPtr ) +void handleDGSerialNumberRequest( void ) { - BOOL result; MESSAGE_T msg; + DG_SYSTEM_RECORD_T system; - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_CONDUCTIVITY_DATA; - msg.hdr.payloadLen = sizeof( CONDUCTIVITY_DATA_T ); + // Get the system's record. There are no arrays of system to check and also, raise no alarm since the system record + // has been already checked in POST + getNVRecord2Driver( GET_SYS_RECORD, (U08*)&system, sizeof( DG_SYSTEM_RECORD_T ), 0, ALARM_ID_NO_ALARM ); - memcpy( &msg.payload, conductivityDataPtr, sizeof( CONDUCTIVITY_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastUVReactorsData function sends out the UV reactors data. - * @details Inputs: none - * @details Outputs: UV reactors data msg constructed and queued - * @param uvReactorsData which is UV reactors msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastUVReactorsData( UV_REACTORS_DATA_T *uvReactorsData ) -{ - BOOL result; - MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_UV_REACTORS_DATA; - msg.hdr.payloadLen = sizeof( UV_REACTORS_DATA_T ); + msg.hdr.msgID = MSG_ID_DG_SERIAL_NUMBER; - memcpy( payloadPtr, uvReactorsData, sizeof( UV_REACTORS_DATA_T ) ); + // Add 1 byte for null terminator + msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; - // 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 ); + // Fill message payload + memcpy( payloadPtr, &system.topLevelSN, MAX_TOP_LEVEL_SN_CHARS ); + payloadPtr += MAX_TOP_LEVEL_SN_CHARS; + *payloadPtr = 0; - return result; + // 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_REQUIRED ); } /*********************************************************************//** * @brief - * The broadcastHeatDisinfectData function sends out the heat disinfect - * mode data. + * The handleDGServiceScheduleRequest function handles a request for DG + * service information. * @details Inputs: none - * @details Outputs: heat disinfect data msg constructed and queued - * @param heatDisinfectData which is heat disinfect msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not + * @details Outputs: message handled, response constructed and queued for + * transmit. + * @return none *************************************************************************/ -BOOL broadcastHeatDisinfectData( MODE_HEAT_DISINFECT_DATA_T *heatDisinfectData ) +void handleDGServiceScheduleRequest( MESSAGE_T *message ) { - BOOL result; MESSAGE_T msg; + DG_SERVICE_RECORD_T service; + + // Get the service record. There are no arrays of service to check and also, raise no alarm since the service record + // has been already checked in POST + getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( DG_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_HEAT_DISINFECT_DATA; - msg.hdr.payloadLen = sizeof( MODE_HEAT_DISINFECT_DATA_T ); + msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - memcpy( payloadPtr, heatDisinfectData, sizeof( MODE_HEAT_DISINFECT_DATA_T ) ); + // Fill message payload + memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; + // 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_REQUIRED ); } /*********************************************************************//** * @brief - * The broadcastFilterFlushData function sends out the filter flush progress data. + * The handleDGSendConcentrateMixingRatios function handles a request for DG + * mixing ratios. * @details Inputs: none - * @details Outputs: filter flush data msg constructed and queued - * @param timeout flush filter timeout (in sec) - * @param countdown flush filter timeout count down (in sec) - * @return TRUE if msg successfully queued for transmit, FALSE if not + * @details Outputs: message handled, response constructed and queued for + * transmit. + * @return none *************************************************************************/ -BOOL broadcastFilterFlushData( U32 timeout, U32 countdown ) +void handleDGSendConcentrateMixingRatios( MESSAGE_T *message ) { - BOOL result; MESSAGE_T msg; + + DG_ACID_CONCENTRATES_RECORD_T acid = getAcidConcentrateCalRecord(); + DG_BICARB_CONCENTRATES_RECORD_T bicarb = getBicarbConcentrateCalRecord(); + // By the time these are requested, the prepare time is no longer needed since the concentrate lines are + // primed before the actual treatment starts + U32 fillPrepTimeMS = 0; + U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_FILTER_FLUSH_PROGRESS; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + msg.hdr.msgID = MSG_ID_DG_CONCENTRATE_MIXING_RATIOS_DATA; + msg.hdr.payloadLen = sizeof( F32 ) + sizeof( F32 ) + sizeof( U32 ); - memcpy( payloadPtr, &timeout, sizeof( U32 ) ); + // Fill message payload + memcpy( payloadPtr, &acid.acidConcentrate[ CAL_DATA_ACID_CONCENTRATE_1 ].acidConcMixRatio, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &bicarb.bicarbConcentrate[ CAL_DATA_BICARB_CONCENTRATE_1 ].bicarbConcMixRatio, sizeof( F32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &countdown, sizeof( U32 ) ); + memcpy( payloadPtr, &fillPrepTimeMS, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); } /*********************************************************************//** @@ -990,176 +616,8 @@ return result; } -/***********************************************************************//** - * @brief - * The broadcastFluidLeakState function constructs a DG fluid leak state msg to \n - * be broadcasted and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: fluid leak state msg constructed and queued - * @param state fluid leak state - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastFluidLeakState( FLUID_LEAK_STATES_T state ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U32 leakState = (U32)state; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_FLUID_LEAK_STATE; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &leakState, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - /*********************************************************************//** * @brief - * The broadcastVoltagesData function constructs a monitored voltages data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: monitored voltages data msg constructed and queued. - * @param data Latest monitored voltage values. - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastVoltagesData( VOLTAGES_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_VOLTAGES_DATA; - msg.hdr.payloadLen = sizeof( VOLTAGES_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( VOLTAGES_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 broadcastFlushData function sends out the flush mode data. - * @details Inputs: none - * @details Outputs: flush data msg constructed and queued - * @param flushData which is flush msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastFlushData( MODE_FLUSH_DATA_T *flushData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_FLUSH_DATA; - msg.hdr.payloadLen = sizeof( MODE_FLUSH_DATA_T ); - - memcpy( payloadPtr, flushData, sizeof( MODE_FLUSH_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 broadcastChemicalDisinfectData function sends out the chemical - * disinfect mode data. - * @details Inputs: none - * @details Outputs: chemical disinfect data msg constructed and queued - * @param chemDisinfectData which is flush msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastChemicalDisinfectData( MODE_CHEMICAL_DISINFECT_DATA_T *chemDisinfectData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_CHEM_DISINFECT_DATA; - msg.hdr.payloadLen = sizeof( MODE_CHEMICAL_DISINFECT_DATA_T ); - - memcpy( payloadPtr, chemDisinfectData, sizeof( MODE_CHEMICAL_DISINFECT_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 broadcastChemicalDisinfectData2UI function sends out the chemical - * disinfect mode data to the UI. - * @details Inputs: none - * @details Outputs: chemical disinfect UI data msg constructed and queued - * @param chemDisinfectUIData which is flush msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastChemicalDisinfectData2UI( MODE_CHEMICAL_DISINFECT_UI_DATA_T *chemDisinfectUIData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_CHEM_DISINFECT_TIME_DATA; - msg.hdr.payloadLen = sizeof( MODE_CHEMICAL_DISINFECT_UI_DATA_T ); - - memcpy( payloadPtr, chemDisinfectUIData, sizeof( MODE_CHEMICAL_DISINFECT_UI_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_2_UI, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastChemicalDisinfectData2UI function sends out the heat - * disinfect mode data to the UI. - * @details Inputs: none - * @details Outputs: heat disinfect UI data msg constructed and queued - * @param heatDisinfectUIData which is flush msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastHeatDisinfectData2UI( MODE_HEAT_DISINFECT_UI_DATA_T *heatDisinfectUIData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_HEAT_DISINFECT_TIME_DATA; - msg.hdr.payloadLen = sizeof( MODE_HEAT_DISINFECT_UI_DATA_T ); - - memcpy( payloadPtr, heatDisinfectUIData, sizeof( MODE_HEAT_DISINFECT_UI_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_2_UI, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief * The sendDGSystemRecord function sends out the DG system record. * @details Inputs: none * @details Outputs: DG system record msg constructed and queued @@ -1338,6 +796,76 @@ /*********************************************************************//** * @brief + * The sendDGSWConfigRecord function sends out the DG software configuration record. + * @details Inputs: none + * @details Outputs: DG software configuration record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param swRcrdAddress: start address of the software configuration record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGSWConfigRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* swRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SEND_SW_CONFIG_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, swRcrdAddress, length ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDGScheduledRunsRequest function handles a request for DG + * scheduled runs information. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for + * transmit. + * @return none + *************************************************************************/ +void handleDGScheduledRunsRequest( MESSAGE_T *message ) +{ + MESSAGE_T msg; + DG_SCHEDULED_RUN_RECORD_T scheduledService; + + // Get the service record. There are no arrays of service to check and also, raise no alarm since the service record + // has been already checked in POST + getNVRecord2Driver( GET_SRR_RECORD, (U08*)&scheduledService, sizeof( DG_SCHEDULED_RUN_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SCHEDULED_RUNS_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + // TODO this message is for Phase 1B. + + // 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_REQUIRED ); +} + +/*********************************************************************//** + * @brief * The sendCommandResponseMsg function constructs a command response to HD * and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -1391,7 +919,6 @@ sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - /*********************************************************************//** * @brief * The handleChangeValveSettingCmd function handles a switch reservoirs command @@ -1438,7 +965,7 @@ if ( DG_CMD_START == fillCmd.cmd ) { - startFillCmd( fillCmd.fillToVolumeMl ); + startFillCmd( fillCmd.fillToVolumeMl, fillCmd.targetFlowLPM ); } else { @@ -1468,7 +995,14 @@ result = TRUE; memcpy( &drainCmd, message->payload, sizeof( DRAIN_CMD_T ) ); - startDrainCmd( drainCmd ); + if ( DG_CMD_START == drainCmd.cmd ) + { + startDrainCmd( drainCmd ); + } + else + { + stopDrainCmd(); + } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); @@ -1487,17 +1021,18 @@ { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof( U32 ) ) + if ( message->hdr.payloadLen == sizeof( BOOL ) ) { BOOL startingTreatment; + DG_OP_MODE_T dgMode = getCurrentOperationMode(); - memcpy( &startingTreatment, message->payload, sizeof( U32 ) ); + memcpy( &startingTreatment, message->payload, sizeof( BOOL ) ); - if ( DG_MODE_STAN == getCurrentOperationMode() && TRUE == startingTreatment ) + if ( ( DG_MODE_STAN == dgMode ) && ( TRUE == startingTreatment ) ) { result = requestDGStart(); } - else if ( DG_MODE_CIRC == getCurrentOperationMode() && FALSE == startingTreatment ) + else if ( ( dgMode >= DG_MODE_GENE ) && ( dgMode <= DG_MODE_DRAI ) && ( FALSE == startingTreatment ) ) { result = requestDGStop(); } @@ -1602,11 +1137,11 @@ if ( TRUE == startingHeater ) { - result = startPrimaryHeater(); + result = startHeater( DG_PRIMARY_HEATER ); } else { - stopPrimaryHeater(); + stopHeater( DG_PRIMARY_HEATER ); result = TRUE; } } @@ -1621,56 +1156,6 @@ * TEST SUPPORT FUNCTIONS *************************************************************************/ -#ifdef DEBUG_ENABLED - /*********************************************************************//** - * @brief - * The sendDebugData function sends debug data out to the PC port. - * @details - * @details Inputs: none - * @details Outputs: PC serial port - * @param dbgData Pointer to debug data - * @param len number of bytes of debug data - * @return TRUE if debug data was successfully queued for transmit, FALSE if not - *************************************************************************/ - BOOL sendDebugData( U08 *dbgData, U32 len ) - { - BOOL result; - - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); - - return result; - } - - /*********************************************************************//** - * @brief - * The sendDebugDataToUI function sends debug string to the UI for logging. - * @details - * @details Inputs: none - * @details Outputs: Message constructed and queued for transmit - * @param str Pointer to debug string - * @return none - *************************************************************************/ - void sendDebugDataToUI( U08 *str ) - { - MESSAGE_T msg; - U32 txtLen = strlen( (char*)str ); - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_DEBUG_EVENT; - msg.hdr.payloadLen = DEBUG_EVENT_MAX_TEXT_LEN + 1; // add 1 byte for null terminator - if ( txtLen <= DEBUG_EVENT_MAX_TEXT_LEN ) - { - 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 ); - } - } -#endif - /*********************************************************************//** * @brief * The isTestingActivated function determines whether a tester has successfully @@ -2025,15 +1510,15 @@ } -/*********************************************************************//** - * @brief - * The handleTestROMeasuredFlowOverrideRequest 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 - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestROMeasuredFlowOverrideRequest 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 handleTestROMeasuredFlowOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -2059,6 +1544,38 @@ /*********************************************************************//** * @brief + * The handleTestDialysateMeasuredFlowOverrideRequest function handles a request to + * override the Dialysate flow rate. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialysateMeasuredFlowOverrideRequest( 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 = testSetMeasuredDialysateFlowRateOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialysateFlowRateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for RO pump data. * @details Inputs: none @@ -2091,18 +1608,50 @@ /*********************************************************************//** * @brief - * The handleTestDrainPumpRPMOverrideRequest function handles a request to - * override the drain pump speed set point (in RPM). + * The handleTestDialysateFlowDataBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for dialysate flow data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestDrainPumpRPMOverrideRequest( MESSAGE_T *message ) +void handleTestDialysateFlowDataBroadcastIntervalOverrideRequest( 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 = testSetDialysateFlowDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetDialysateFlowDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSetDrainPumpRPM function handles a request to set the drain + * pump speed set point (in RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSetDrainPumpRPM( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length if ( sizeof( U32 ) == message->hdr.payloadLen ) { U32 payLoad; @@ -2227,12 +1776,14 @@ BOOL result = FALSE; // verify payload length - if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + if ( 0 == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetSafetyShutdownOverride( payload.state.u32 ); + U32 command = 1; + + result = testSetSafetyShutdownOverride( command ); } else { @@ -2246,14 +1797,14 @@ /************************************************************************* * @brief - * The handleSetDrainPumpDeltaPressureOverrideRequest function handles a - * request to override the delta pressure for the drain pump. + * The handleSetDrainPumpTargetOutletPressure function handles a + * request to set the drain pump outlet pressure. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleSetDrainPumpDeltaPressureOverrideRequest( MESSAGE_T *message ) +void handleSetDrainPumpTargetOutletPressure( MESSAGE_T *message ) { BOOL result = 0; @@ -2270,6 +1821,70 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/************************************************************************* + * @brief + * The handleSetSwitchesStatusOverrideRequest function handles a + * request to override the status of a switch in DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetSwitchesStatusOverrideRequest( 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 = testSetSwitchesStatusOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetSwitchesStatusOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/************************************************************************* + * @brief + * The handleTestSwitchesPublishIntervalOverrideRequest function handles a + * request to override the the switches data publish interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSwitchesPublishIntervalOverrideRequest( 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 = testSetSwitchesDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetSwitchesDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /*********************************************************************//** * @brief * The handleTestDGAccelOverrideRequest function handles a request to @@ -2766,11 +2381,11 @@ memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( ( BOOL )payload.state.u32 ) { - requestConcentratePumpsOn( ( CONCENTRATE_PUMPS_T )payload.index ); + requestConcentratePumpOn( ( CONCENTRATE_PUMPS_T )payload.index ); } else { - requestConcentratePumpsOff( ( CONCENTRATE_PUMPS_T )payload.index ); + requestConcentratePumpOff( ( CONCENTRATE_PUMPS_T )payload.index ); } } @@ -2871,38 +2486,6 @@ /*********************************************************************//** * @brief -* The handleTestROFlowRateOverride function handles a request to override -* the RO flow rate. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*******************************************************************/ -void handleTestMeasuredROFlowRateOverride( MESSAGE_T *message ) -{ - TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; - BOOL result = FALSE; - - // verify payload length - if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) - { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); - if ( FALSE == payload.reset ) - { - result = testSetMeasuredROFlowRateOverride( payload.state.f32 ); - } - else - { - result = testResetMeasuredROFlowRateOverride(); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** -* @brief * The handleTestThermistorsValueOverride function handles a request to * override a thermistor's value. * @details Inputs: none @@ -2933,7 +2516,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -//*******************************************************************/ +/*********************************************************************//** +* @brief +* The handleTestROPumpTargetFlowOverride function handles a request to +* set the RO pump target flow. +* @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; @@ -2985,6 +2576,38 @@ /*********************************************************************//** * @brief +* The handleSetDGOpModeBroadcastIntervalOverrideRequest function handles a request +* to override the publish interval of the DG operation mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDGOpModeBroadcastIntervalOverrideRequest( 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 = testSetDGOpModePublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetDGOpModePublishIntervalOverride(); + } + } + + // 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 @@ -3092,6 +2715,39 @@ /*********************************************************************//** * @brief +* The handleDGPOSTResultRequest function handles a request to report DG +* POST results. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleDGPOSTResultRequest( MESSAGE_T *message ) +{ + BOOL status = FALSE; + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + if ( TRUE == isPOSTCompleted() ) + { + status = TRUE; + if ( TRUE == isPOSTPassed() ) + { + result = TRUE; + } + sendPOSTFinalResult( result ); + } + } + // If can't respond to request, NAK the message + if ( status != TRUE ) + { + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); + } +} + +/*********************************************************************//** +* @brief * The handleSetDGCalibrationRecord function handles a request to set the DG * calibration data record. * @details Inputs: none @@ -3116,7 +2772,7 @@ memcpy(&payloadLength, payloadPtr, sizeof(U32)); payloadPtr += sizeof(U32); - status = setCalibrationRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + status = receiveRecordFromDialin( NVDATAMGMT_CALIBRATION_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); @@ -3176,7 +2832,7 @@ // Tester must be logged in if ( TRUE == isTestingActivated() ) { - result = getCalibrationRecord(); + result = sendRecordToDialin( NVDATAMGMT_CALIBRATION_RECORD ); } } @@ -3210,7 +2866,7 @@ memcpy(&payloadLength, payloadPtr, sizeof(U32)); payloadPtr += sizeof(U32); - status = setSystemRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + status = receiveRecordFromDialin( NVDATAMGMT_SYSTEM_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); @@ -3235,7 +2891,7 @@ // Tester must be logged in if ( TRUE == isTestingActivated() ) { - result = getSystemRecord(); + result = sendRecordToDialin( NVDATAMGMT_SYSTEM_RECORD ); } } @@ -3262,7 +2918,7 @@ // Tester must be logged in if ( TRUE == isTestingActivated() ) { - result = getServiceRecord(); + result = sendRecordToDialin( NVDATAMGMT_SERVICE_RECORD ); } } @@ -3296,7 +2952,7 @@ memcpy(&payloadLength, payloadPtr, sizeof(U32)); payloadPtr += sizeof(U32); - status = setServiceRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + status = receiveRecordFromDialin( NVDATAMGMT_SERVICE_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); @@ -3321,7 +2977,7 @@ // Tester must be logged in if ( TRUE == isTestingActivated() ) { - result = getScheduledRunsRecord(); + result = sendRecordToDialin( NVDATAMGMT_SCHEDULED_RUNS_RECORD ); } } @@ -3355,14 +3011,130 @@ memcpy(&payloadLength, payloadPtr, sizeof(U32)); payloadPtr += sizeof(U32); - status = setScheduledRunsRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + status = receiveRecordFromDialin( NVDATAMGMT_SCHEDULED_RUNS_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** + * @brief + * The handleFilterFlushTimePeriodOverride function handles a request + * to override the filter flush time period value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFilterFlushTimePeriodOverride( 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 = testSetFilterFlushTimePeriodOverride( payload.state.u32 ); + } + else + { + result = testResetFilterFlushTimePeriodOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleFansRPMOverride function handles a request to override a fans RPM value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFansRPMOverride( 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 = testSetFanRPMOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetFanRPMOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief +* The handleStopDGRTCClock function handles a request to stop the RTC clock. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleStopDGRTCClock( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + testSetStopRTC(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetDrainPumpMeasuredRPMOverrideRequest function handles a request +* to override the drain pump measured RPM. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDrainPumpMeasuredRPMOverrideRequest( 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 = testSetDrainPumpMeasuredRPMOverride( payload.state.u32 ); + } + else + { + result = testResetDrainPumpMeasuredRPMOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief * The handleStartStopDGChemicalDisinfect function handles a request to start * or stop DG chemical disinfect mode. * @details Inputs: none @@ -3396,4 +3168,311 @@ return result; } +/*********************************************************************//** + * @brief + * The handleTestBlockMessagesRequest function handles a request to + * block transmission of specific message(s). + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBlockMessagesRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(BLOCKED_MSGS_DATA_T) == message->hdr.payloadLen ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + memcpy( &blockedMessagesForXmit.blockedMessages[0], message->payload, sizeof(BLOCKED_MSGS_DATA_T) ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmInfoSendIntervalOverrideRequest function handles a + * request to override the HD alarm information broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmInfoSendIntervalOverrideRequest( 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 = testSetAlarmInfoPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetAlarmInfoPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSuperClearAlarmsRequest function handles a request to clear + * all active alarms on DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSuperClearAlarmsRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 key; + + memcpy( &key, message->payload, sizeof(U32) ); + result = testClearAllAlarms( key ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestFansRPMAlarmStartTimeOverrideRequest function handles a + * request to override the fan RPM alarm start time. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestFansRPMAlarmStartTimeOffsetOverrideRequest( 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 = testSetFanRPMAlarmStartTimeOffsetOverride( payload.state.u32 ); + } + else + { + result = testResetFanRPMAlarmStartTimeOffsetOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestUsedAcidVolumeMLOverrideRequest function handles a + * request to override the acid volume. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestUsedAcidVolumeMLOverrideRequest( 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 = testSetUsedAcidVolumeMLOverride( payload.state.f32 ); + } + else + { + result = testResetUsedAcidVolumeMLOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} +/*********************************************************************//** +* The handleSetFansDutyCycleOverrideRequest function handles a +* request to override the fans duty cycle. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetFansDutyCycleOverrideRequest( 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 = testSetFansDutyCycleOverride( payload.state.f32 ); + } + else + { + result = testResetFansDutyCycleOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestUsedBicarbVolumeMLOverrideRequest function handles a + * request to override the used bicarb volume. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestUsedBicarbVolumeMLOverrideRequest( 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 = testSetUsedBicarbVolumeMLOverride( payload.state.f32 ); + } + else + { + result = testResetUsedBicarbVolumeMLOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleGetDGSoftwareConfigRecord function handles a request to get the DG +* software configuration record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetDGSoftwareConfigRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_SW_CONFIG_RECORD ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetDGSoftwareConfigRecord function handles a request to set the DG +* software configuration record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDGSoftwareConfigRecord( MESSAGE_T *message ) +{ + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + if ( message->hdr.payloadLen >= ( sizeof(currentMessage) + sizeof(totalMessages) + sizeof(payloadLength) ) ) + { + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_SW_CONFIG_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** + * @brief + * The handleTestHDCommunicationStatusOverrideRequest function handles a request + * request to override the HD Communication Status. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestHDCommunicationStatusOverrideRequest(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 = testSetHDCommunicationStatus(payload.state.u32); + } + else + { + result = testResetHDCommuncationStatus(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/