/************************************************************************** * * Copyright (c) 2019-2023 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 * * @author (last) Sean Nash * @date (last) 30-Sep-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #include // for memcpy() #include "reg_system.h" #include "Accel.h" #include "Compatible.h" #include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "CPLD.h" #include "Fans.h" #include "FlowSensors.h" #include "FPGA.h" #include "Heaters.h" #include "Integrity.h" #include "ModeChemicalDisinfect.h" #include "ModeChemicalDisinfectFlush.h" #include "ModeDrain.h" #include "ModeFill.h" #include "ModeFlush.h" #include "ModeGenIdle.h" #include "ModeHeatDisinfect.h" #include "ModeHeatDisinfectActiveCool.h" #include "ModeInitPOST.h" #include "ModeROPermeateSample.h" #include "ModeStandby.h" #include "MsgQueues.h" #include "NVDataMgmt.h" #include "OperationModes.h" #include "Pressures.h" #include "Reservoirs.h" #include "RTC.h" #include "Switches.h" #include "SystemComm.h" #include "SafetyShutdown.h" #include "SystemCommMessages.h" #include "TemperatureSensors.h" #include "Thermistors.h" #include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" #include "UVReactors.h" /** * @addtogroup SystemCommMessages * @{ */ // ********** private definitions ********** #define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. #pragma pack(push,1) /// Payload record structure for block message transmission request. typedef struct { U16 blockedMessages[ MAX_MSGS_BLOCKED_FOR_XMIT ]; ///< Blocked messages array. } BLOCKED_MSGS_DATA_T; /// Load cells override payload structure typedef struct { TEST_OVERRIDE_ARRAY_PAYLOAD_T ovRecord; ///< Test override array payload. BOOL flag; ///< Flag. } LC_OVERRIDE_PAYLOAD_T; /// Flow Sensor override payload structure typedef struct { TEST_OVERRIDE_ARRAY_PAYLOAD_T ovRecord; ///< Test override array payload. BOOL flag; ///< Flag. } FS_OVERRIDE_PAYLOAD_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 BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); static BOOL sendUIResponseMsg( MSG_ID_T msgID, BOOL accepted, U32 reason ); /*********************************************************************//** * @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 * @details Outputs: given data array populated with serialized message data and queued for transmit. * @param msg message to serialize * @param buffer outgoing buffer that message should be queued in * @param ackReq is an acknowledgement from receiver required? * @return size (in bytes) of serialized message populated in given data array. *************************************************************************/ U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) { BOOL result = FALSE; BOOL error = FALSE; U32 msgSize = 0; U32 sizeMod, sizePad; U32 i; U08 crc; U08 data[ MAX_ACK_MSG_SIZE ]; // byte array to populate with message data // prefix data with message sync byte 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_MESSAGE_THAT_REQUIRES_ACK ) { // thread protect next sequence # access & increment _disable_IRQ(); msg.hdr.seqNo = nextSeqNo; nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); _enable_IRQ(); if ( TRUE == ackReq ) { msg.hdr.seqNo *= -1; } } // calculate message CRC crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); // serialize message header data memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); msgSize += sizeof( MESSAGE_HEADER_T ); // serialize message payload (only used bytes per payloadLen field) memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); msgSize += msg.hdr.payloadLen; // add 8-bit CRC data[ msgSize++ ] = crc; // pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); for ( i = 0; i < sizePad; i++ ) { data[ msgSize++ ] = 0; } // if ACK required, add to pending ACK list if ( TRUE == ackReq ) { if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) { error = TRUE; SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) } } if ( FALSE == error ) { // add serialized message data to appropriate out-going comm buffer result = addToCommBuffer( buffer, data, msgSize ); } return result; } /*********************************************************************//** * @brief * The sendACKMsg function constructs and queues for transmit an ACK message * for a given received message. * @details Inputs: none * @details Outputs: ACK message queued for transmit on broadcast CAN channel. * @param message message to send an ACK for * @return TRUE if ACK message queued successfully, FALSE if not *************************************************************************/ BOOL sendACKMsg( MESSAGE_T *message ) { BOOL result; MESSAGE_T msg; // create a message record blankMessage( &msg ); // send ACK back with same seq. #, but w/o ACK bit msg.hdr.seqNo = message->hdr.seqNo * -1; // ACK messages always have this ID msg.hdr.msgID = MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK; // ACK messages always have no payload msg.hdr.payloadLen = 0; // serialize and queue the message for transmit on broadcast channel result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); return result; } /*********************************************************************//** * @brief * The sendTestAckResponseMsg function constructs a simple response message for * a handled test message and queues it for transmit on the appropriate UART channel. * @details Inputs: none * @details Outputs: response message constructed and queued for transmit. * @param msgID ID of handled message that we are responding to * @param buffer outgoing buffer that message should be queued in * @param ack TRUE if test message was handled successfully, FALSE if not * @return TRUE if response message successfully queued for transmit, FALSE if not *************************************************************************/ static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) { BOOL result; MESSAGE_T msg; // create a message record blankMessage( &msg ); msg.hdr.msgID = msgID; msg.hdr.payloadLen = sizeof( U08 ); msg.payload[ 0 ] = (U08)ack; // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); return result; } /*********************************************************************//** * @brief * The sendUIResponseMsg function constructs an UI response message for a * handled UI message and queues it for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: response message constructed and queued for transmit. * @param msgID ID of handled message that we are responding to * @param accepted T/F - request accepted? * @param reason reason code if rejected * @return TRUE if response message successfully queued for transmit, FALSE if not *************************************************************************/ static BOOL sendUIResponseMsg( MSG_ID_T msgID, BOOL accepted, U32 reason ) { BOOL result; MESSAGE_T msg; UI_RESPONSE_PAYLOAD_T cmd; cmd.accepted = accepted; cmd.rejectionReason = reason; // Create a message record blankMessage( &msg ); msg.hdr.msgID = msgID; msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ); memcpy( &msg.payload, &cmd, sizeof( UI_RESPONSE_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_2_UI, ACK_REQUIRED ); return result; } // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // *********************************************************************** /*********************************************************************//** * @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 * @details Outputs: alarm triggered msg constructed and queued. * @param alarm ID of alarm triggered * @param almData1 1st data associated with alarm * @param almData2 2nd data associated with alarm * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAlarmTriggered( U32 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; U32 data; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_TRIGGERED; msg.hdr.payloadLen = sizeof( U32 ) * 8; memcpy( payloadPtr, &alarm, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); 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 ) ); // Pad with space for 3 U32s - set to zero - unused for DG payloadPtr += ( sizeof( U32) * 3 ); memset( payloadPtr, 0, sizeof( U32) * 3 ); // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_ALARM, ACK_REQUIRED ); return result; } /*********************************************************************//** * @brief * The broadcastAlarmCleared function constructs an alarm cleared msg to be * broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: alarm cleared msg constructed and queued. * @param alarm ID of alarm cleared * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAlarmCleared( U32 alarm ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_CLEARED; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &alarm, sizeof( U32 ) ); // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_ALARM, ACK_REQUIRED ); return result; } /*********************************************************************//** * @brief * The broadcastAlarmConditionCleared function constructs an alarm condition * cleared msg to be broadcast and queues the msg for transmit on the * appropriate CAN channel. * @details Inputs: none * @details Outputs: alarm condition cleared msg constructed and queued. * @param alarm ID of alarm which alarm condition is cleared * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAlarmConditionCleared( U32 alarm ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_CONDITION_CLEARED; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &alarm, sizeof( U32 ) ); // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_ALARM, ACK_REQUIRED ); return result; } // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** /*********************************************************************//** * @brief * The handlePowerOffWarning function handles a power off warning message * from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handlePowerOffWarning( MESSAGE_T *message ) { if ( message->hdr.payloadLen == 0 ) { signalPowerOffWarning(); } } /*********************************************************************//** * @brief * The handleRTCSyncFromHD function handles an HD date/time broadcast message * from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleRTCSyncFromHD( MESSAGE_T *message ) { // TODO - remove the code below until the issue for the synchronization // of the DG RTC to the HD RTC is resolved. /* // Only sync RTC to HD date/time when ... if ( TRUE == syncDG2HDDateTime() ) { if ( sizeof( RTC_DATA_T ) == message->hdr.payloadLen ) { RTC_DATA_T epoch; memcpy( &epoch, message->payload, sizeof( RTC_DATA_T ) ); setRTCEpoch( epoch.epochTime ); } } */ } /*********************************************************************//** * @brief * The handleAlarmClear function handles a clear alarm message from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ 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 ); } /*********************************************************************//** * @brief * The handleSetDialysateTemperatureCmd function handles a dialysate temperature * set points message from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDialysateTemperatureCmd( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ) ) { DG_CMD_DIALYSATE_HEATING_PARAMS_T payload; result = TRUE; 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 ); } /*********************************************************************//** * @brief * The handleFWVersionCmd function handles a FW version request message. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleFWVersionCmd( MESSAGE_T *message ) { MESSAGE_T msg; DG_VERSIONS_T payload; U08 *payloadPtr = msg.payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_VERSION_REPONSE; msg.hdr.payloadLen = sizeof( DG_VERSIONS_T ); if ( message->hdr.payloadLen == sizeof( U08 ) + sizeof( U08 ) + sizeof( U08 ) + sizeof( U16 ) + sizeof( U32 ) ) { // populate payload payload.major = (U08)DG_VERSION_MAJOR; 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 ); // fill message payload memcpy( payloadPtr, &payload, sizeof( DG_VERSIONS_T ) ); } // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_REQUIRED ); } /*********************************************************************//** * @brief * The handleDGSerialNumberRequest function handles a request for DG serial * number request. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for transmit. * @return none *************************************************************************/ void handleDGSerialNumberRequest( void ) { MESSAGE_T msg; DG_SYSTEM_RECORD_T system; // 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 ); U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SERIAL_NUMBER_RESPONSE; // Add 1 byte for null terminator msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; // Fill message payload memcpy( payloadPtr, &system.topLevelSN, sizeof( U08 ) * MAX_TOP_LEVEL_SN_CHARS ); payloadPtr += MAX_TOP_LEVEL_SN_CHARS; *payloadPtr = 0; // 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 handleDGServiceScheduleRequestToUI function handles a request for DG * service information to UI. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for * transmit. * @return none *************************************************************************/ void handleDGServiceScheduleRequestToUI( MESSAGE_T *message ) { MESSAGE_T msg; DG_SERVICE_RECORD_T service; U08 *payloadPtr = msg.payload; // 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 ); // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA_TO_UI; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); if ( 0 == message->hdr.payloadLen ) { memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); service.serviceIntervalSeconds = ( 0 == service.lastServiceEpochDate ? 0 : service.serviceIntervalSeconds ); 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 serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_REQUIRED ); } /*********************************************************************//** * @brief * The handleDGSendConcentrateMixingRatios function handles a request for DG * mixing ratios. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for * transmit. * @return none *************************************************************************/ void handleDGSendConcentrateMixingRatios( MESSAGE_T *message ) { MESSAGE_T msg; DG_ACID_CONCENTRATES_RECORD_T acid; DG_BICARB_CONCENTRATES_RECORD_T bicarb; // 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; getAcidConcentrateCalRecord( &acid ); getBicarbConcentrateCalRecord( &bicarb ); // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_CONCENTRATE_MIXING_RATIOS_DATA; msg.hdr.payloadLen = sizeof( F32 ) + sizeof( F32 ) + 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, &fillPrepTimeMS, sizeof( U32 ) ); // 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 ); } /*********************************************************************//** * @brief * The sendDGCalibrationRecord function sends out the DG calibration * record. * @details Inputs: none * @details Outputs: DG calibration record msg constructed and queued * @param msgCurrNum: current payload number * @param msgTotalNum: total number of payloads * @param length: buffer length to be written * @param calRcrdAddress: start address of the calibration record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGCalibrationRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* calRcrdAddress ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SEND_CALIBRATION_RECORD; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &length, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, calRcrdAddress, length ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); return result; } /*********************************************************************//** * @brief * The sendDGSystemRecord function sends out the DG system record. * @details Inputs: none * @details Outputs: DG system record msg constructed and queued * @param msgCurrNum: current payload number * @param msgTotalNum: total number of payloads * @param length: buffer length to be written * @param sysRcrdAddress: start address of the system record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGSystemRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* sysRcrdAddress ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SEND_SYSTEM_RECORD; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &length, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, sysRcrdAddress, length ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); return result; } /*********************************************************************//** * @brief * The sendDGServiceRecord function sends out the DG service record. * @details Inputs: none * @details Outputs: DG system record msg constructed and queued * @param msgCurrNum: current payload number * @param msgTotalNum: total number of payloads * @param length: buffer length to be written * @param srvcRcrdAddress: start address of the service record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGServiceRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* srvcRcrdAddress ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SEND_SERVICE_RECORD; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &length, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, srvcRcrdAddress, length ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); return result; } /*********************************************************************//** * @brief * The sendPOSTTestResult function constructs an DG POST test result message * and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: DG POST test result msg constructed and queued. * @param test ID of DG POST test * @param passed TRUE if POST test passed, FALSE if not * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendPOSTTestResult( DG_POST_STATE_T test, BOOL passed ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; U32 testID = (U32)test; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_POST_SINGLE_TEST_RESULT; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); memcpy( payloadPtr, &passed, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); memcpy( payloadPtr, &testID, 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 sendPOSTFinalResult function constructs an DG POST final result message * and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: DG POST final result msg constructed and queued. * @param passed TRUE if DG POST passed, FALSE if not * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendPOSTFinalResult( BOOL passed ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_POST_FINAL_TEST_RESULT; msg.hdr.payloadLen = sizeof( BOOL ); memcpy( payloadPtr, &passed, sizeof( BOOL ) ); // 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 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 ); // 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 handleStartStopDGFlush function handles a request to start or stop * DG flush mode. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ BOOL handleStartStopDGFlush( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { BOOL startingDGFlush; memcpy( &startingDGFlush, message->payload, sizeof(U32) ); if ( TRUE == startingDGFlush ) { result = startDGFlush(); } else { result = stopDGFlush(); } } // Respond to request sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); return result; } /*********************************************************************//** * @brief * The sendCommandResponseMsg function constructs a command response to HD * and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: Command response msg constructed and queued. * @param cmdResponsePtr pointer to command response data record * @return none *************************************************************************/ void sendCommandResponseMsg( DG_CMD_RESPONSE_T *cmdResponsePtr ) { MESSAGE_T msg; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_COMMAND_RESPONSE; msg.hdr.payloadLen = sizeof( DG_CMD_RESPONSE_T ); memcpy( msg.payload, cmdResponsePtr, sizeof( DG_CMD_RESPONSE_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); } /*********************************************************************//** * @brief * The handleSwitchReservoirCmd function handles a switch reservoirs command * from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSwitchReservoirCmd( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( DG_SWITCH_RSRVRS_CMD_T ) ) { DG_SWITCH_RSRVRS_CMD_T cmd; memcpy( &cmd, message->payload, sizeof( DG_SWITCH_RSRVRS_CMD_T ) ); setActiveReservoirCmd( (DG_RESERVOIR_ID_T)cmd.reservoirID ); setTrimmerHeaterUseLastDutyCycleStatus( cmd.useLastTrimmerHeaterDC ); result = TRUE; } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } /*********************************************************************//** * @brief * The handleChangeValveSettingCmd function handles a switch reservoirs command * from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleChangeValveSettingCmd( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( U32 ) ) { U32 valveSettingID; result = TRUE; memcpy( &valveSettingID, message->payload, sizeof( U32 ) ); changeValveSettingCmd( (DG_VALVE_SETTING_ID_T)valveSettingID ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } /*********************************************************************//** * @brief * The handleFillCmd function handles a fill command from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleFillCmd( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( FILL_CMD_T ) ) { FILL_CMD_T fillCmd; result = TRUE; memcpy( &fillCmd, message->payload, sizeof( FILL_CMD_T ) ); if ( DG_CMD_START == fillCmd.cmd ) { startFillCmd( fillCmd.fillToVolumeMl, fillCmd.targetFlowLPM ); } else { stopFillCmd(); } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } /*********************************************************************//** * @brief * The handleDrainCmd function handles a drain command from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDrainCmd( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( DRAIN_CMD_T ) ) { DRAIN_CMD_T drainCmd; result = TRUE; memcpy( &drainCmd, message->payload, sizeof( DRAIN_CMD_T ) ); 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 ); } /*********************************************************************//** * @brief * The handleStartStopTreatmentMsg function handles a treatment start/stop * message from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleStartStopTreatmentMsg( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( DG_START_STOP_TX_CMD_REQUEST_T ) ) { DG_START_STOP_TX_CMD_REQUEST_T startingTreatment; DG_OP_MODE_T dgMode = getCurrentOperationMode(); memcpy( &startingTreatment, message->payload, sizeof( DG_START_STOP_TX_CMD_REQUEST_T ) ); if ( ( DG_MODE_STAN == dgMode ) && ( TRUE == startingTreatment.start ) ) { // If the command is start DG, set the acid and bicarb types to be used, otherwise in the stop command it does not matter setAcidAndBicarbType( startingTreatment.acidType, startingTreatment.bicarbType ); result = requestDGStart(); } else if ( ( dgMode >= DG_MODE_GENE ) && ( dgMode <= DG_MODE_DRAI ) && ( FALSE == startingTreatment.start ) ) { result = requestDGStop(); } else if ( ( DG_MODE_STAN == dgMode ) && ( FALSE == startingTreatment.start ) ) { result = signalAbortWaterSampling(); } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } /*********************************************************************//** * @brief * The handleParkConecentratePumpsCmd function handles a DG concentrate pumps park * command message from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleParkConecentratePumpsCmd( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == 0 ) { result = handleConcentratePumpParkRequest(); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } /*********************************************************************//** * @brief * The handleStartStopTrimmerHeaterCmd function handles a trimmer heater start/stop * command message from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleHDStartStopTrimmerHeaterCmd( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( TRIMMER_HEATER_CMD_T ) ) { TRIMMER_HEATER_CMD_T heaterCmd; DG_CMD_RESPONSE_T cmdResponse; cmdResponse.commandID = DG_CMD_START_TRIMMER_HEATER; cmdResponse.rejected = FALSE; cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; result = TRUE; memcpy( &heaterCmd, message->payload, sizeof( TRIMMER_HEATER_CMD_T ) ); if ( TRUE == heaterCmd.startHeater ) { BOOL isSet = setHeaterTargetTemperature( DG_TRIMMER_HEATER, getTrimmerHeaterTargetTemperature() ); if ( TRUE == isSet ) { startHeater( DG_TRIMMER_HEATER ); } else { cmdResponse.rejected = TRUE; cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_INVALID_PARAMETER; } } else { stopHeater( DG_TRIMMER_HEATER ); } sendCommandResponseMsg( &cmdResponse ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } /*********************************************************************//** * @brief * The handleSampleWaterCmd function handles a sample water command from the HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSampleWaterCmd( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( U32 ) ) { SAMPLE_WATER_CMD_T sampleWaterCmd; result = TRUE; memcpy( &sampleWaterCmd, message->payload, sizeof( U32 ) ); waterSampleCommandHandler( sampleWaterCmd ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } /*********************************************************************//** * @brief * The handleSetRTCTimestamp function handles a request to write time and * date to RTC * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetRTCTimestamp( MESSAGE_T *message ) { BOOL result; U08 seconds = message->payload[0]; U08 minutes = message->payload[1]; U08 hours = message->payload[2]; U08 days = message->payload[3]; U08 months = message->payload[4]; U32 years; memcpy(&years, &message->payload[5], sizeof( U32 )); result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleStartStopDGHeatDisinfect function handles a request start or * stop DG heat disifect mode. * @details Inputs: none * @details Outputs: message handled * @param message: a pointer to the message to handle * @return result *************************************************************************/ BOOL handleStartStopDGHeatDisinfect( MESSAGE_T *message ) { BOOL status = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { BOOL startingDGHeatDisinfect; memcpy( &startingDGHeatDisinfect, message->payload, sizeof(U32) ); if ( TRUE == startingDGHeatDisinfect ) { status = startDGHeatDisinfect(); } else { status = stopDGHeatDisinfect(); } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); return status; } /*********************************************************************//** * @brief * The handleUIClockSyncRequest function handles a UI clock sync message. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for transmit. * @param messagePtr pointer to the message to handle. * @return none *************************************************************************/ void handleUIClockSyncRequest( MESSAGE_T *message ) { BOOL result = FALSE; U32 rejReason = REQUEST_REJECT_REASON_NONE; MESSAGE_T msg; U08 *payloadPtr = msg.payload; if ( message->hdr.payloadLen == sizeof( U32 ) ) { U32 epoch; memcpy( &epoch, message->payload, sizeof( U32 ) ); result = setRTCEpoch( epoch ); if ( FALSE == result ) { rejReason = REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME; } } else { rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } // Create a response message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_UI_SET_RTC_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); memcpy( payloadPtr, &result, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); memcpy( payloadPtr, &rejReason, 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_2_UI, ACK_REQUIRED ); sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_UI, result ); } /*********************************************************************//** * @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 handleStartStopPrimaryHeater function handles a request start or * stop the primary heater * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return result *************************************************************************/ BOOL handleStartStopPrimaryHeater( MESSAGE_T * message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( U32 ) ) { BOOL startingHeater; memcpy( &startingHeater, message->payload, sizeof( U32 ) ); if ( TRUE == startingHeater ) { result = startHeater( DG_PRIMARY_HEATER ); } else { stopHeater( DG_PRIMARY_HEATER ); result = TRUE; } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); return result; } /*********************************************************************//** * @brief * The handleDGStartStopTrimmerHeater function handles a request start or * stop the trimmer heater * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return result *************************************************************************/ BOOL handleDGStartStopTrimmerHeater( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof( BOOL ) ) { BOOL startingHeater; memcpy( &startingHeater, message->payload, sizeof( BOOL ) ); if ( TRUE == startingHeater ) { result = startHeater( DG_TRIMMER_HEATER ); } else { stopHeater( DG_TRIMMER_HEATER ); result = TRUE; } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); return result; } /*********************************************************************//** * @brief * The handleStartStopDGChemicalDisinfect function handles a request to start * or stop DG chemical disinfect mode. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ BOOL handleStartStopDGChemicalDisinfect( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { BOOL startingDGChemicalDisinfect; memcpy( &startingDGChemicalDisinfect, message->payload, sizeof(U32) ); if ( TRUE == startingDGChemicalDisinfect ) { result = startDGChemicalDisinfect(); } else { result = stopChemicalDisinfect(); } } // Respond to request sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); return result; } /*********************************************************************//** * @brief * The handleStartStopDGChemicalDisinfectFlush function handles a request to start * or stop DG chemical disinfect flush mode. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ BOOL handleStartStopDGChemicalDisinfectFlush( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof(BOOL) ) { BOOL startingDGChemicalDisinfectFlush; memcpy( &startingDGChemicalDisinfectFlush, message->payload, sizeof(BOOL) ); if ( TRUE == startingDGChemicalDisinfectFlush ) { result = startDGChemicalDisinfectFlush(); } else { result = stopChemicalDisinfectFlush(); } } // Respond to request sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); return result; } /*********************************************************************//** * @brief * The handleTestSetOpModeRequest function handles a request to set the * DG operation mode. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestSetOpModeRequest( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { U32 mode; memcpy( &mode, message->payload, sizeof(U32) ); result = testSetOperationMode( (DG_OP_MODE_T)mode ); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestTareReservoirRequest function handles a request to tare a * given reservoir's weight. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestTareReservoirRequest( MESSAGE_T *message ) { BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { U32 res; memcpy( &res, message->payload, sizeof(U32) ); result = testTareReservoir( res ); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleSetHDOperationMode function receives the HD operation modes data * publish message. * @details Inputs: none * @details Outputs: none * @param message a pointer to the message to handle * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL handleSetHDOperationMode( MESSAGE_T *message ) { BOOL status = FALSE; U08* payloadPtr = message->payload; // HD mode broadcast is operations mode and submode so 8 bytes if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) { U32 mode = 0; U32 subMode = 0; memcpy( &mode, payloadPtr, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( &subMode, payloadPtr, sizeof( U32 ) ); setHDOperationMode( mode, subMode ); status = TRUE; } return status; } /*********************************************************************//** * @brief * The handleServiceModeRequest function handles a request to enter service * mode. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleServiceModeRequest( MESSAGE_T *message ) { BOOL status = FALSE; DG_OP_MODE_T currentMode = getCurrentOperationMode(); REQUEST_REJECT_REASON_CODE_T reject; if ( 0 == message->hdr.payloadLen ) { if ( ( DG_MODE_STAN == currentMode ) || ( DG_MODE_FAUL == currentMode ) ) { status = TRUE; requestNewOperationMode( DG_MODE_SERV ); reject = REQUEST_REJECT_REASON_NONE; } else { reject = REQUEST_REJECT_REASON_DG_NOT_IN_STANDBY_IDLE_STATE; } } else { reject = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); sendServiceModeResponse( status, (U32)reject ); } /*********************************************************************//** * @brief * The handleHDRequestDGUsageInfo function handles a request for DG * usage information. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for * transmit. * @return none *************************************************************************/ void handleHDRequestDGUsageInfo( MESSAGE_T * message ) { MESSAGE_T msg; DG_USAGE_INFO_RECORD_T usageInfo; U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_USAGE_DATA; msg.hdr.payloadLen = sizeof( DG_USAGE_INFO_RECORD_T ); // 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_USAGE_RECORD, (U08*)&usageInfo, sizeof( DG_USAGE_INFO_RECORD_T ), 0, ALARM_ID_NO_ALARM ); if ( 0 == message->hdr.payloadLen ) { // Fill message payload memcpy( payloadPtr, &usageInfo, sizeof( DG_USAGE_INFO_RECORD_T ) ); } // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_REQUIRED ); } /*********************************************************************//** * @brief * The sendServiceModeResponse function sends out the DG response to a * UI request to go to service mode. * @details Inputs: none * @details Outputs: Service mode request response msg constructed and queued * @param accepted TRUE if request was accepted, FALSE if not * @param rejCode Reject reason code explaining why request was rejected * @return none *************************************************************************/ BOOL sendServiceModeResponse( BOOL accepted, U32 rejCode ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_RESPONSE_SERVICE_MODE_REQUEST; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); memcpy( payloadPtr, &rejCode, 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_2_HD, ACK_REQUIRED ); return result; } /*********************************************************************//** * @brief * The handleSetDGServiceTime function sets the DG service time once the * command is received from UI * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDGServiceTime( MESSAGE_T *message ) { BOOL result = FALSE; if ( 0 == message->hdr.payloadLen ) { result = setServiceTime(); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_UI, result ); } /*********************************************************************//** * @brief * The handleStartStopDGHeatDisinfectActiveCool function handles a request * start or stop DG heat disinfect active cool mode. * @details Inputs: none * @details Outputs: message handled * @param message: a pointer to the message to handle * @return result *************************************************************************/ void handleStartStopDGHeatDisinfectActiveCool( MESSAGE_T* message ) { BOOL status = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { BOOL startingDGHeatDisinfectActiveCool; memcpy( &startingDGHeatDisinfectActiveCool, message->payload, sizeof(U32) ); if ( TRUE == startingDGHeatDisinfectActiveCool ) { status = startDGHeatDisinfectActiveCool(); } else { status = stopDGHeatDisinfectActiveCool(); } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); } /*********************************************************************//** * @brief * The handleReceiveChemFlushSampleResultsFromHD function handles receiving * the chemical disinfect sample flush results from HD. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleReceiveChemFlushSampleResultsFromHD( MESSAGE_T *message ) { BOOL status = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { U32 result; memcpy( &result, message->payload, sizeof(U32) ); setChemicalDisinfectFlushSampleResult( result ); status = TRUE; } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); } /*********************************************************************//** * @brief * The handleSetROOnlyMode function handles the setting of the RO mode only. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetROOnlyMode( MESSAGE_T* message ) { REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_DG_RO_ONLY_MODE_INVALID_PAYLOAD_LENGTH; BOOL accepted = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { BOOL result; rejReason = REQUEST_REJECT_REASON_NONE; memcpy( &result, message->payload, sizeof(BOOL) ); if ( ( FALSE == result ) || ( TRUE == result ) ) { switch ( getCurrentOperationMode() ) { case DG_MODE_FAUL: case DG_MODE_SERV: case DG_MODE_INIT: case DG_MODE_STAN: case DG_MODE_SOLO: setROMode( result ); accepted = TRUE; break; default: rejReason = REQUEST_REJECT_REASON_DG_RO_ONLY_MODE_DG_BUSY; break; } } else { rejReason = REQUEST_REJECT_REASON_DG_RO_ONLY_MODE_INVALID_PARAMETER; } } sendUIResponseMsg( MSG_ID_DG_RO_ONLY_MODE_STATUS_RESPONSE, accepted, rejReason ); } /*********************************************************************//** * @brief * The requestROOnlyModeStatusFromUI function handles the request * the RO only mode status from UI. * @details Inputs: none * @details Outputs: message handled * @return none *************************************************************************/ void requestROOnlyModeStatusFromUI( void ) { MESSAGE_T msg; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_RO_ONLY_MODE_STATUS_REQUEST; msg.hdr.payloadLen = 0; // 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 handleStartStopDGROPermeateSample function handles a request to * start or stop DG RO permeate sample mode. * @details Inputs: none * @details Outputs: message handled * @param message: a pointer to the message to handle * @return result *************************************************************************/ void handleStartStopDGROPermeateSample( MESSAGE_T* message ) { BOOL status = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { BOOL startingDGROPermeateSample; memcpy( &startingDGROPermeateSample, message->payload, sizeof(U32) ); if ( TRUE == startingDGROPermeateSample ) { status = startDGROPermeateSample(); } else { status = stopDGROPermeateSample(); } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); } /*********************************************************************//** * @brief * The handleReceiveROPermeatSampleDispenseRequest function handles receiving * the RO permeate sample dispense request * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleReceiveROPermeatSampleDispenseRequest( MESSAGE_T* message ) { BOOL status = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { U32 result; memcpy( &result, message->payload, sizeof(U32) ); setROPermeateSampleDispenseRequest( result ); status = TRUE; } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); } /*********************************************************************//** * @brief * The sendROPermeateSampleDispenseReadyToHD function handles sending * RO permeate sample dispense ready to HD * @details Inputs: none * @details Outputs: none * @return none *************************************************************************/ void sendROPermeateSampleDispenseReadyToHD( void ) { MESSAGE_T msg; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SEND_RO_PERMEATE_SAMPLE_DISPENSE_READY_TO_HD; msg.hdr.payloadLen = 0; // 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 ); } /*********************************************************************//** * @brief * The handleSendDGServiceRecordToHD function handles sending DG service * record to HD upon request from HD * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSendDGServiceRecordToHD( MESSAGE_T* message ) { MESSAGE_T msg; DG_SERVICE_RECORD_T service; U08 *payloadPtr = msg.payload; // 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 ); // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SEND_SERVICE_SCHEDULE_DATA_TO_HD; msg.hdr.payloadLen = sizeof( DG_SERVICE_RECORD_T ); if ( 0 == message->hdr.payloadLen ) { memcpy( payloadPtr, &service, sizeof( DG_SERVICE_RECORD_T ) ); } // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); } // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ /*********************************************************************//** * @brief * The isTestingActivated function determines whether a tester has successfully * logged in to activate testing functionality. * @details Inputs: testerLoggedIn * @details Outputs: none * @return TRUE if a tester has logged in to activate testing, FALSE if not *************************************************************************/ BOOL isTestingActivated( void ) { return testerLoggedIn; } /*********************************************************************//** * @brief * The setTesterStatusToLoggedOut function sets the status of the tester to * logged out. * @details Inputs: none * @details Outputs: testerLoggedIn * @return none *************************************************************************/ void setTesterStatusToLoggedOut( void ) { testerLoggedIn = FALSE; } /*********************************************************************//** * @brief * The sendTestAckResponseMsg function constructs a simple response message for * a handled test message and queues it for transmit on the appropriate UART channel. * @details Inputs: none * @details Outputs: response message constructed and queued for transmit. * @param msgID ID of handled message that we are responding to * @param ack TRUE if test message was handled successfully, FALSE if not * @return TRUE if response message successfully queued for transmit, FALSE if not *************************************************************************/ static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) { BOOL result; MESSAGE_T msg; // create a message record blankMessage( &msg ); msg.hdr.msgID = msgID; msg.hdr.payloadLen = sizeof( U08 ); msg.payload[ 0 ] = (U08)ack; // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); return result; } /*********************************************************************//** * @brief * The handleTesterLogInRequest function handles a request to login as a tester. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTesterLogInRequest( MESSAGE_T *message ) { // verify pass code // TODO - placeholder - how do we want to authenticate tester? if ( ( 3 == message->hdr.payloadLen ) && ( 0x31 == message->payload[ 0 ] ) && ( 0x32 == message->payload[ 1 ] ) && ( 0x33 == message->payload[ 2 ] ) ) { testerLoggedIn = TRUE; } else { testerLoggedIn = FALSE; } // respond to would be tester sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); } /*********************************************************************//** * @brief * The handleTestWatchdogCheckInStateOverrideRequest function handles a * request to override the check-in status of a given task. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestWatchdogCheckInStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; 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 * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestAlarmStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; 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 * override the value read from the given load cell. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestLoadCellOverrideRequest( MESSAGE_T *message ) { LC_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof( LC_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( LC_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.ovRecord.reset ) { result = testSetLoadCellOverride( payload.ovRecord.index, payload.ovRecord.state.f32, payload.flag ); } else { result = testResetLoadCellOverride( payload.ovRecord.index, payload.flag ); } } //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. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestTemperatureSensorsOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; 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 * a request to override the publish interval of temperature sensors data. * @details * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestTemperatureSensorsDataPublishOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; 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 * a request to override the publish interval of heaters data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestHeatersDataPublishOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; 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 * a request to override the broadcast interval for load cell data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestLoadCellDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; 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 * override the value read from the given pressure sensor. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestPressureSensorOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; 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 * a request to override the broadcast interval for load cell data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestPressureDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; 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 handleTestMeasuredFlowOverrideRequest function handles a request to * override the measured flow sensor rate. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestMeasuredFlowOverrideRequest( MESSAGE_T *message ) { FS_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof( FS_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( FS_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.ovRecord.reset ) { result = testSetMeasuredFlowRateOverride( payload.ovRecord.index, payload.ovRecord.state.f32, payload.flag ); } else { result = testResetMeasuredFlowRateOverride( payload.ovRecord.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for RO pump data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ 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 handleTestFlowSensorsDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for the flow sensors data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestFlowSensorsDataBroadcastIntervalOverrideRequest( 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 = testSetFlowDataPublishIntervalOverride( payload.state.u32 ); } else { result = testResetFlowDataPublishIntervalOverride(); } } // 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; memcpy( &payLoad, message->payload, sizeof( U32 ) ); result = testSetTargetDrainPumpRPM( payLoad ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDrainPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for drain pump data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ 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 * override the state value read from the given valve. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestValveStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; 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 * a request to override the publish interval of valves states from the given valve. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestValvesStatesPublishIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; 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 handleTestDGSafetyShutdownOverrideRequest function handles a * request to override the safety shutdown signal. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGSafetyShutdownOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; 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 ) { U32 command = 1; result = testSetSafetyShutdownOverride( command ); } else { result = testResetSafetyShutdownOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleSetDrainPumpTargetOutletFlowLPM function handles a * request to set the drain pump outlet flow in L/min. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDrainPumpTargetOutletFlowLPM( MESSAGE_T *message ) { BOOL result = 0; /* verify payload length */ if ( sizeof( F32 ) == message->hdr.payloadLen ) { F32 payLoad; memcpy( &payLoad, message->payload, sizeof( F32 ) ); result = testSetTargetDrainPumpOutletFlowLPM( payLoad ); } /* respond to request */ 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 * override the measured accelerometer sensor readings. * @details Inputs: none * @details 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 * @details 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 * @details 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 handleTestMonitoredVoltagesSendIntervalOverrideRequest function handles a * request to override the monitored DG voltages data publication interval. * @details Inputs: none * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ void handleTestMonitoredVoltagesSendIntervalOverrideRequest( 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 = testSetVoltagesDataPublishIntervalOverride( payload.state.u32 ); } else { result = testResetVoltagesDataPublishIntervalOverride(); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestMonitoredVoltageOverrideRequest function handles a * request to override the monitored DG voltage override. * @details Inputs: none * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ void handleTestMonitoredVoltageOverrideRequest( 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 = testSetLineLevelOverride( payload.index, payload.state.f32 ); } else { result = testResetLineLevelOverride( payload.index ); } } // 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 * @details 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 * @details Inputs: none * @details 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 ); } /*********************************************************************//** * @brief * The handleStartStopUVReactors function handles a request to turn on/off * the UV reactors. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleStartStopUVReactors( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); // Set turn on/off command switch ( payload.state.u32 ) { case TURN_OFF: result = turnOffUVReactor( (UV_REACTORS_T)payload.index ); break; case TURN_ON: result = turnOnUVReactor( (UV_REACTORS_T)payload.index ); break; } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestUVReactorsDataPublishIntervalOverride function handles a * request to override the publish interval of the UV reactors data * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestUVReactorsDataPublishIntervalOverride( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); if ( FALSE == payload.reset ) { result = testSetReactorsDataPublishInterval( payload.state.u32 ); } else { result = testResetReactorsDataPublishInterval(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleUVReactorsHealthOverride function handles UV reactors health * status override. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestUVReactorsHealthOverride( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); if ( FALSE == payload.reset ) { result = testSetUVReactorHealthOverride( payload.index, payload.state.u32 ); } else { result = testResetUVReactorHealthOverride( payload.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleSetFluidLeakBroadcastIntervalOverrideRequest function handles a * request to override the fluid leak state broadcast interval. * @details Inputs: none * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ void handleSetFluidLeakBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // Verify payload length if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetFluidLeakStatePublishIntervalOverride( (U32)( payload.state.u32 ) ); } else { result = testResetFluidLeakStatePublishIntervalOverride(); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleSetFluidLeakStateDetectorOverrideRequest function handles a request to * override the fluid leak detector state. * @details Inputs: none * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ void handleSetFluidLeakStateDetectorOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_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 = testSetFluidLeakStateOverride( ( FLUID_LEAK_STATES_T)( payload.state.u32 ) ); } else { result = testResetFluidLeakStateOverride(); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleDGSoftwareResetRequest function handles a request to * perform a software reset on DG. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDGSoftwareResetRequest( MESSAGE_T *message ) { BOOL result = FALSE; // verify payload length if ( 0 == message->hdr.payloadLen ) { // tester must be logged in if ( TRUE == isTestingActivated() ) { result = TRUE; // reset will prevent this from getting transmitted systemREG1->SYSECR = ( 0x2 << 14 ); // reset processor } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleConcentratePumpMeasuredSpeedOverride function handles a request * to override a concentrate pump measured speed value. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleConcentratePumpMeasuredSpeedOverride( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetConcentratePumpMeasuredSpeedOverride( payload.index, payload.state.f32 ); } else { result = testResetConcentratePumpMeasuredSpeedOverride( payload.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleSetConcentratePumpTargetSpeed function handles a request to * override a concentrate pump's target speed value. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetConcentratePumpTargetSpeed( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); result = testSetConcentratePumpTargetSpeedOverride( payload.index, payload.state.f32 ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleConcentratePumpStateChangeRequest function handles a request to * change the concentrate pumps' state. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleConcentratePumpStateChangeRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) && ( TRUE == isTestingActivated() ) ) { result = TRUE; memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( TRUE == ( BOOL )payload.state.u32 ) { requestConcentratePumpOn( ( CONCENTRATE_PUMPS_T )payload.index ); } else { requestConcentratePumpOff( ( CONCENTRATE_PUMPS_T )payload.index, NO_PARK_CONC_PUMPS ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleConcentratePumpPublishIntervalOverride function handles a request * to override a concentrate pump's publish interval value. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleConcentratePumpPublishIntervalOverride( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetConcentratePumpDataPublishIntervalOverride( payload.state.u32 ); } else { result = testResetConcentratePumpDataPublishIntervalOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestThermistorsDataPublishIntervalOverride function handles a * request to override the publish interval of the thermistors data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestThermistorsDataPublishIntervalOverride( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetThermistorPublishIntervalOverride( payload.state.u32 ); } else { result = testResetThermistorPublishIntervalOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestROPumpDutyCycleOverride function handles a request to override * the RO pumps duty cycle. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestROPumpDutyCycleOverride( MESSAGE_T *message ) { BOOL result = FALSE; // verify payload length if ( sizeof( F32 ) == message->hdr.payloadLen ) { F32 payLoad; memcpy( &payLoad, message->payload, sizeof( F32 ) ); result = testSetTargetDutyCycle( payLoad ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestThermistorsValueOverride function handles a request to * override a thermistor's value. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestThermistorsValueOverride( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); if ( FALSE == payload.reset ) { result = testSetMeasuredThermistorOverride( payload.index, payload.state.f32 ); } else { result = testResetMeasuredThermistorOverride( payload.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @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; // verify payload length if ( sizeof( F32 ) == message->hdr.payloadLen ) { F32 payload; memcpy( &payload, message->payload, sizeof( F32 ) ); result = testSetTargetROPumpFlow( payload ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestFansDataPublishIntervalOverride function handles a request * to override the publish interval of the fans data * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestFansDataPublishIntervalOverride( MESSAGE_T * message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetFanPublishIntervalOverride( payload.state.u32 ); } else { result = testResetFanPublishIntervalOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The 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 * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleROPumpTargetPressureOverride( MESSAGE_T *message ) { BOOL result = FALSE; // verify payload length if ( sizeof( U32 ) == message->hdr.payloadLen ) { U32 payload; memcpy( &payload, message->payload, sizeof( U32 ) ); result = testSetTargetROPumpPressure( payload ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleSetDGCalibrationRecord function handles a request to set the DG * calibration data record. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDGCalibrationRecord( MESSAGE_T *message ) { BOOL status = FALSE; U08* payloadPtr = message->payload; U32 currentMessage; U32 totalMessages; U32 payloadLength; 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_CALIBRATION_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * @brief * The handleGetDGCalibrationRecord function handles a request to get the DG * calibration data record. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleGetDGCalibrationRecord( MESSAGE_T *message ) { BOOL result = FALSE; // verify payload length if ( 0 == message->hdr.payloadLen ) { // Tester must be logged in if ( TRUE == isTestingActivated() ) { result = sendRecordToDialin( NVDATAMGMT_CALIBRATION_RECORD ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleSetDGSystemRecord function handles a request to set the DG * system data record. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDGSystemRecord( MESSAGE_T *message ) { BOOL status = FALSE; U08* payloadPtr = message->payload; U32 currentMessage; U32 totalMessages; U32 payloadLength; 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_SYSTEM_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * @brief * The handleGetDGSystemRecord function handles a request to get the DG * system data record. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleGetDGSystemRecord( MESSAGE_T *message ) { BOOL result = FALSE; // verify payload length if ( 0 == message->hdr.payloadLen ) { // Tester must be logged in if ( TRUE == isTestingActivated() ) { result = sendRecordToDialin( NVDATAMGMT_SYSTEM_RECORD ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleGetDGServiceRecord function handles a request to get the DG * service data record. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleGetDGServiceRecord( MESSAGE_T *message ) { BOOL result = FALSE; // verify payload length if ( 0 == message->hdr.payloadLen ) { // Tester must be logged in if ( TRUE == isTestingActivated() ) { result = sendRecordToDialin( NVDATAMGMT_SERVICE_RECORD ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleSetDGServiceRecord function handles a request to set the DG * service data record. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDGServiceRecord( MESSAGE_T *message ) { BOOL status = FALSE; U08* payloadPtr = message->payload; U32 currentMessage; U32 totalMessages; U32 payloadLength; 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_SERVICE_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_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 = testSetDrainPumpMeasuredRPMOverride( payload.index, payload.state.u32 ); } else { result = testResetDrainPumpMeasuredRPMOverride( payload.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, 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 handleTestFansRPMAlarmStartTimeOffsetRequest function handles a * request to set the fans RPM alarm start time offset. * @details Inputs: none * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ void handleTestFansRPMAlarmStartTimeOffsetRequest( MESSAGE_T *message ) { U32 rpmTimeOffset; BOOL result = FALSE; // Verify payload length if ( sizeof(U32) == message->hdr.payloadLen ) { memcpy( &rpmTimeOffset, message->payload, sizeof(U32) ); result = testSetFanRPMAlarmStartTimestamp( rpmTimeOffset ); } // 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 ); } #ifndef _RELEASE_ /*********************************************************************//** * @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 ); } #endif /*********************************************************************//** * @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 ); } /*********************************************************************//** * @brief * The handleSetPrimaryAndTrimmerHeatersTargetTemperature function handles * setting primary and trimmer heaters target temperature. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetPrimaryAndTrimmerHeatersTargetTemperature( MESSAGE_T *message ) { BOOL status = FALSE; U08* payloadPtr = message->payload; if ( message->hdr.payloadLen >= ( sizeof( F32 ) + sizeof( F32 ) ) ) { F32 primaryTargetTemp = 0.0F; F32 trimmerTargetTemp = 0.0F; status = TRUE; memcpy( &primaryTargetTemp, payloadPtr, sizeof( F32 ) ); payloadPtr += sizeof( F32 ); memcpy( &trimmerTargetTemp, payloadPtr, sizeof( F32 ) ); setHeaterTargetTemperature( DG_PRIMARY_HEATER, primaryTargetTemp ); setHeaterTargetTemperature( DG_TRIMMER_HEATER, trimmerTargetTemp ); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * The handleTestDGDrainPumpDirectionOverrideRequest function handles a * request to override the drain pump measured direction. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGDrainPumpDirectionOverrideRequest( 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 = testSetDrainPumpMeasuredDirectionOverride( payload.state.u32 ); } else { result = testResetDrainPumpMeasuredDirectionOverride(); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * The handleTestDGValvesSensedStateOverrideRequest function handles a * request to override the valves sensed state. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGValvesSensedStateOverrideRequest( 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 = testSetValveSensedStateOverride( payload.index, payload.state.u32 ); } else { result = testResetValveSensedStateOverride( payload.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleGetDGUsageInfoRecord function handles a request to get the DG * usage information record. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleGetDGUsageInfoRecord( 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_USAGE_INFO_RECORD ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleSetDGUsageInfoRecord function handles a request to set the DG * information record. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDGUsageInfoRecord( 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_USAGE_INFO_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * @brief * The sendDGUsageInfoRecord function sends out the DG usage information record. * @details Inputs: none * @details Outputs: DG usage information record msg constructed and queued * @param msgCurrNum: current payload number * @param msgTotalNum: total number of payloads * @param length: buffer length to be written * @param usageInfoAddress: start address of the susage information record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGUsageInfoRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* usageInfoAddress ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SEND_USAGE_INFO_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, usageInfoAddress, 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 handleResendAllAlarmsCommand function handles a request to re-send * all active DG alarms. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleResendAllAlarmsCommand( MESSAGE_T *message ) { BOOL result = FALSE; // verify payload length if ( 0 == message->hdr.payloadLen ) { handleResendActiveAlarmsRequest(); result = TRUE; } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDGNVRecordCRCOverride function handles a request to override * the selected NV record's CRC. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGNVRecordCRCOverride( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); result = testSetNVRecordCRCOverride( payload.index, (U16)payload.state.u32 ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * The handleTestDGConcPumpParkStatusOverrideRequest function handles a * request to override the parked status of a given concentrate pump. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGConcPumpParkStatusOverrideRequest( 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 = testSetConcentratePumpParkedOverride( payload.index, (U16)payload.state.u32 ); } else { result = testResetConcentratePumpParkedOverride( payload.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * The handleTestDGConcPumpParkFaultStatusOverrideRequest function handles a * request to override the park faulted status of a given concentrate pump. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGConcPumpParkFaultStatusOverrideRequest( 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 = testSetConcentratePumpParkCmdFaultedOverride( payload.index, (U16)payload.state.u32 ); } else { result = testResetConcentratePumpParkCmdFaultedOverride( payload.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * The handleTestDGConcPumpParkCommandRequest function handles a command * to park a given concentrate pump. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGConcPumpParkCommandRequest( MESSAGE_T *message ) { U32 pumpIdx; BOOL result = FALSE; // verify payload length if ( sizeof( U32 ) == message->hdr.payloadLen ) { memcpy( &pumpIdx, message->payload, sizeof( U32 ) ); result = testSetConcentratePumpParkCommand( pumpIdx ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDrainPumpMeasuredCurrentOverride function handles a request * to override the drain pump measured current * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDrainPumpMeasuredCurrentOverride( 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 = testSetDrainPumpMeasuredCurrentOverride( payload.state.f32 ); } else { result = testResetDrainPumpMeasuredCurrentOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestGenIdlePublishIntervalOverride function handles a request * to override the gen idle state publish interval * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestGenIdlePublishIntervalOverride( 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 = testSetGenIdleSubstatesPublishIntervalOverride( payload.state.u32 ); } else { result = testResetGenIdleSubstatesPublishIntervalOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDGROPumpFeedbackVoltageOverrideRequest function handles a request * to override the gen idle state publish interval * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGROPumpFeedbackVoltageOverrideRequest( 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 = testSetROPumpMeasuredFeedbackDutyCycleOverride( payload.state.f32 ); } else { result = testResetROPumpMeasuredFeedbackDutyCycleOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDGFillModeBroadcastOverrideRequest function handles a request * to override the gen idle state publish interval * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGFillModeBroadcastOverrideRequest( 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 = testSetFillModeDataPublishIntervalOverride( payload.state.u32 ); } else { result = testResetFillModeDataPublishIntervalOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDGFillIntegratedVolumeOverrideRequest function handles a request * to override the gen idle state publish interval * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGFillIntegratedVolumeOverrideRequest( 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 = testSetIntegratedVolumeOverride( payload.state.f32 ); } else { result = testResetIntegratedVolumeOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDGHeatersDutyCycleOverrideRequest function handles a request * to override the heaters duty cycle * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGHeatersDutyCycleOverrideRequest( 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 = testSetHeaterDutyCycleOverride( payload.index, payload.state.f32 ); } else { result = testResetHeaterDutyCycleOverride( payload.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleDGRTCControlReg1StatusOverrideRequest function handles a * request to override RTC control register 1. * @details Inputs: none * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ void handleDGRTCControlReg1StatusOverrideRequest( 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 = testSetRTCCtlReg1Status( payload.state.u32 ); } else { result = testResetRTCCtlReg1Status(); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleDGRTCControlReg1StatusOverrideRequest function handles a * request to override RTC control register 3. * @details Inputs: none * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ void handleDGRTCControlReg3StatusOverrideRequest( 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 = testSetRTCCtlReg3Status( payload.state.u32 ); } else { result = testResetRTCCtlReg3Status(); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } #ifndef _RELEASE_ /*********************************************************************//** * @brief * The handleTestDGNelsonDisinfectSupport function handles a request * to set the Nelson disinfect support mode. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGNelsonDisinfectSupport( MESSAGE_T *message ) { U32 payload; BOOL result = FALSE; // verify payload length if ( ( sizeof( U32 ) == message->hdr.payloadLen ) && ( ( DG_MODE_STAN == getCurrentOperationMode() ) || ( DG_MODE_SOLO == getCurrentOperationMode() ) ) ) { NELSON_SUPPORT_T nelson; memcpy( &payload, message->payload, sizeof( U32 ) ); nelson = (NELSON_SUPPORT_T)payload; result = TRUE; switch( nelson ) { case NELSON_INOCULATE: setHeatNelsonSupportMode( nelson ); requestNewOperationMode( DG_MODE_HEAT ); break; case NELSON_HEAT_DISINFECT: setHeatNelsonSupportMode( nelson ); requestNewOperationMode( DG_MODE_HEAT ); break; case NELSON_POS_CONTROL_HEAT_DISINFECT: setHeatNelsonSupportMode( nelson ); requestNewOperationMode( DG_MODE_HEAT ); break; case NELSON_CHEM_DISINFECT: setChemNelsonSupportMode( nelson ); requestNewOperationMode( DG_MODE_CHEM ); break; case NELSON_DRAIN_SAMPLES: setHeatNelsonSupportMode( nelson ); requestNewOperationMode( DG_MODE_HEAT ); break; } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } #endif /*********************************************************************//** * @brief * The handleTestDGSetDialysateMixingRatios function handles a request * to set the dialysate mixing ratios. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGSetDialysateMixingRatios( MESSAGE_T *message ) { BOOL status = FALSE; U08* payloadPtr = message->payload; if ( message->hdr.payloadLen >= ( 2 * sizeof(F32) ) ) { F32 acidMixingRatio = 0.0F; F32 bicarbMixingRatio = 0.0F; memcpy(&acidMixingRatio, payloadPtr, sizeof(F32)); payloadPtr += sizeof(F32); memcpy(&bicarbMixingRatio, payloadPtr, sizeof(F32)); status = testSetDialysateMixingRatios( acidMixingRatio, bicarbMixingRatio ); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * @brief * The handleTestDGSetTestConfig function handles a request to set the * test configuration. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGSetTestConfig( MESSAGE_T *message ) { BOOL status = FALSE; if ( message->hdr.payloadLen == sizeof( TEST_CONFIG_PAYLOAD_T ) ) { TEST_CONFIG_PAYLOAD_T payload; memcpy( &payload, message->payload, sizeof( TEST_CONFIG_PAYLOAD_T ) ); if ( TRUE == payload.reset ) { status = resetTestConfig( (TEST_CONFIG_T)payload.config ); } else { status = setTestConfig( (TEST_CONFIG_T)payload.config ); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * @brief * The handleTestDGGetTestConfig function handles a request to get the * test configuration per request. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGGetTestConfig( MESSAGE_T* message ) { BOOL result = FALSE; // verify payload length if ( 0 == message->hdr.payloadLen ) { result = sendTestConfigStatusToDialin(); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDGResetAllTestConfigs function handles a request to reset * all of the test configurations. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGResetAllTestConfigs( MESSAGE_T* message ) { BOOL result = FALSE; // verify payload length if ( 0 == message->hdr.payloadLen ) { result = resetAllTestConfigs(); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDGDialinCheckIn function handles check in from Dialin. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGDialinCheckIn( MESSAGE_T* message ) { if ( 0 == message->hdr.payloadLen ) { setDialinCheckInTimeStamp(); } } /*********************************************************************//** * @brief * The handleTestDGGetLoadCellsTareValues function handles a request to * get the load cells tare values. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGGetLoadCellsTareValues( MESSAGE_T* message ) { BOOL status = FALSE; if ( 0 == message->hdr.payloadLen ) { MESSAGE_T msg; U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SEND_LOAD_CELLS_TARE_VALUES; msg.hdr.payloadLen = sizeof( F32 ) * NUM_OF_LOAD_CELLS; getLoadCellsTareValues( payloadPtr ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer status = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * @brief * The handleTestDGSetLoadCellsTareValues function handles a request to * set the load cells tare values. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGSetLoadCellsTareValues( MESSAGE_T* message ) { BOOL status = FALSE; if ( ( sizeof( F32 ) * NUM_OF_LOAD_CELLS ) == message->hdr.payloadLen ) { F32 payload[ NUM_OF_LOAD_CELLS ]; status = TRUE; memcpy( &payload, message->payload, sizeof( F32 ) * NUM_OF_LOAD_CELLS ); setLoadCellsTareValues( (U08*)&payload ); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * @brief * The handleTestDGSetConductivitySensorCalTable function handles a request to * set the conductivity sensor's calibration table. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGSetConductivitySensorCalTable( MESSAGE_T* message ) { BOOL status = FALSE; if ( sizeof( CONDUCTIVITY_SENSOR_CAL_TABLE_T ) == message->hdr.payloadLen ) { CONDUCTIVITY_SENSOR_CAL_TABLE_T payload; memcpy( &payload, message->payload, sizeof( CONDUCTIVITY_SENSOR_CAL_TABLE_T ) ); testSetConductivitySensorCalibrationTable( &payload ); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * @brief * The handleTestDGSetRecoverFromFaultModeSignal function handles a request to * set the signal to recover from the fault mode. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGSetRecoverFromFaultModeSignal( MESSAGE_T* message ) { BOOL status = FALSE; if ( 0 == message->hdr.payloadLen ) { status = TRUE; setRecoverFromFaultModeSignal(); } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } /*********************************************************************//** * @brief * The handleTestDGDrainModeBroadcastOverrideRequest function handles a request * to override the drain mode state publish interval * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGDrainModeBroadcastOverrideRequest( 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 = testSetDrainModeDataPublishIntervalOverride( payload.state.u32 ); } else { result = testResetDrainModeDataPublishIntervalOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleDGROStatusRequest function handles a request * to get the RO only mode * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDGROStatusRequest( MESSAGE_T* message ) { REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NONE; BOOL roMode = FALSE; if ( 0 == message->hdr.payloadLen ) { roMode = isROOnlyModeEnabled(); } else { rejReason = REQUEST_REJECT_REASON_DG_RO_ONLY_MODE_INVALID_PAYLOAD_LENGTH; } sendUIResponseMsg( MSG_ID_DG_RO_ONLY_MODE_STATUS_RESPONSE, roMode, rejReason ); } /*********************************************************************//** * @brief * The handleTestHDRAMStatusOverrideRequest function handles a request to * override the RAM status register. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGRAMStatusOverrideRequest( 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 = testSetRAMStatusOverride( payload.index, payload.state.u32 ); } else { result = testResetRAMStatusOverride( payload.index ); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDGPendingACKOverrideRequest function handles a * request to override pending ACKs. * @details Inputs: none * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGPendingACKOverrideRequest( 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 = testSetPendingACKOverride( payload.state.u32 ); } else { result = testResetPendingACKOverride(); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDGReservoirOverrideRequest function handles a request * to override the reservoir publish interval * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDGReservoirOverrideRequest( 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 = testSetReservoirDataPublishIntervalOverride( payload.state.u32 ); } else { result = testResetReservoirDataPublishIntervalOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDG77CStateTimerOverride function handles a request * to override the heat disinfection timer at 77 C * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDG77CStateTimerOverride( 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 = testSetDG77CStateTimerOverride( payload.state.u32 ); } else { result = testResetDG77CStateTimerOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDG82CStateTimerOverride function handles a request * to override the heat disinfection timer at 82 C * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestDG82CStateTimerOverride( 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 = testSetDG82CStateTimerOverride( payload.state.u32 ); } else { result = testResetDG82CStateTimerOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestChemDisinfectAcidOverride function handles a request * to override the CD2 moving average in Chem disinfection. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestChemDisinfectAcidOverride( 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 = testSetChemDisinfectionCD2AvgOverride( payload.state.f32 ); } else { result = testResetChemDisinfectionCD2AvgOverride(); } } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /**@}*/