Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r7da76d7131d824ab15f58857eeeedcf128e57391 -recbd3443e0fbf2c84da7a66761765e74eb41407e --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 7da76d7131d824ab15f58857eeeedcf128e57391) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision ecbd3443e0fbf2c84da7a66761765e74eb41407e) @@ -21,18 +21,20 @@ #include "Accel.h" #include "AlarmLamp.h" +#include "Battery.h" #include "Buttons.h" #include "ConsumableSelfTest.h" +#include "Fans.h" #include "FPGA.h" #include "ModeStandby.h" #include "ModeTreatmentParams.h" -#include "NVDataMgmt.h" #include "OperationModes.h" #include "RTC.h" #include "SampleWater.h" #include "SafetyShutdown.h" #include "SystemComm.h" #include "SystemCommMessages.h" +#include "Temperatures.h" #include "TreatmentEnd.h" #include "TreatmentRecirc.h" #include "Utilities.h" @@ -668,7 +670,7 @@ { if ( 0 == message->hdr.payloadLen ) { - handleTreatmentLogDataRequest(); + sendTreatmentLogDataToUI(); } else { @@ -927,9 +929,75 @@ // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); } - + /*********************************************************************//** * @brief + * The sendTreatmentLogAlarmEventData function constructs a treatment log + * alarm event data message for UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment log alarm event data msg constructed and queued. + * @param alarmID ID of the occurred alarm + * @param almData1 data associates with the alarm + * @param almData1 data associates with the alarm + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentLogAlarmEventData( ALARM_ID_T alarmID, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 id = (U32)alarmID; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_ALARM_EVENT; + msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( F32 ); + + memcpy( payloadPtr, &id, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &almData1.data, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &almData2.data, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The sendTreatmentLogEventData function constructs a treatment log parameter + * change event data message for UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment log event data msg constructed and queued. + * @param event ID of parameter change event + * @param oldValue parameter change event old data value + * @param newValue parameter change event new data value + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentLogEventData( EVENT_ID_T event, F32 oldValue, F32 newValue ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 eventID = (U32)event; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_EVENT; + msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( F32 ); + + memcpy( payloadPtr, &eventID, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &oldValue, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &newValue, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief * The handleSampleWaterCmd function handles a sample water user action command * message from the UI. * @details Inputs: none @@ -2761,6 +2829,60 @@ return result; } +/*********************************************************************//** + * @brief + * The broadcastTemperaturesData function sends out the temperatures data. + * @details Inputs: none + * @details Outputs: temperatures data msg constructed and queued + * @param temperaturesData which is the temperatures msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastTemperaturesData( TEMPERATURES_DATA_T *temperaturesData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TEMPERATURES_DATA; + msg.hdr.payloadLen = sizeof( TEMPERATURES_DATA_T ); + + memcpy( payloadPtr, temperaturesData, sizeof( TEMPERATURES_DATA_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The broadcastFansData function sends out the fans data. + * @details Inputs: none + * @details Outputs: fans data msg constructed and queued + * @param fansData which is the fans msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastFansData( FANS_DATA_T *fansData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_FANS_DATA; + msg.hdr.payloadLen = sizeof( FANS_DATA_T ); + + memcpy( payloadPtr, fansData, sizeof( FANS_DATA_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -3095,12 +3217,12 @@ *************************************************************************/ void handleDGTemperatureData( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof(DG_TEMPERATURES_T) ) + if ( message->hdr.payloadLen == sizeof( TEMPERATURE_SENSORS_DATA_T ) ) { - DG_TEMPERATURES_T payload; - - memcpy( &payload, message->payload, sizeof(DG_TEMPERATURES_T) ); - setDialysateTemperatureReadings( payload.TDi, payload.TRo ); + TEMPERATURE_SENSORS_DATA_T payload; + + memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); + setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); } // TODO - what to do if invalid payload length? // TODO - how to know if DG stops sending these? @@ -3865,11 +3987,9 @@ /*********************************************************************//** * @brief - * The handleFWVersionRequest function handles a request for HD f/w - * version. + * The handleFWVersionRequest function handles a request for HD f/w version. * @details Inputs: none - * @details Outputs: message handled, response constructed and queued - * for transmit. + * @details Outputs: message handled, response constructed and queued for transmit. * @param message a pointer to the message to handle. * @return none *************************************************************************/ @@ -6010,6 +6130,38 @@ /*********************************************************************//** * @brief + * The handleBatteryRemainingPercentOverrideRequest function handles a + * request to override battery remaining percent. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBatteryRemainingPercentOverrideRequest( 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 = testSetBatteryRemainingPercentOverride( payload.state.u32 ); + } + else + { + result = testResetSetBatteryRemainingPercentOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleHDSoftwareResetRequest function handles a request to reset the * HD firmware processor. * @details Inputs: none @@ -6997,4 +7149,131 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleTestTemperaturesValueOverrideRequest 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 handleTestTemperaturesValueOverrideRequest( 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 handleTestTemperaturesBroadcastIntervalOverrideRequest function handles a + * request to override the temperatures data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTemperaturesBroadcastIntervalOverrideRequest( 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 = testSetTemperaturesPublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetTemperaturesPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestTemperaturesBroadcastIntervalOverrideRequest function handles a + * request to override the temperatures data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestFansBroadcastIntervalOverrideRequest( 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( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetFanPublishIntervalOverride(); + } + } + + // 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 ); +} + /**@}*/