Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r0c8ae7b952186d912c77d8c2cfb7dad809fa5225 -r56100135135bb715d316b5fd002a4a4951b9334a --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 0c8ae7b952186d912c77d8c2cfb7dad809fa5225) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 56100135135bb715d316b5fd002a4a4951b9334a) @@ -17,15 +17,27 @@ #include // For memcpy() +#include "AirPump.h" +#include "AirTrap.h" +#include "AlarmMgmt.h" +#include "BloodFlow.h" #include "Bubbles.h" +#include "Buttons.h" #include "Compatible.h" +#include "CpldInterface.h" +#include "LevelSensors.h" #include "Messaging.h" #include "OperationModes.h" #include "PAL.h" #include "PressureSensor.h" +#include "RotaryValve.h" +#include "Switches.h" #include "SystemCommTD.h" #include "Utilities.h" +#include "Valve2Way.h" +#include "Valves.h" #include "Voltages.h" +#include "WatchdogMgmt.h" /** * @addtogroup Messaging @@ -55,15 +67,15 @@ COMM_BUFFER_OUT_CAN_TD_ALARM, ///< Buffer for responding to incoming RO alarm messages COMM_BUFFER_OUT_CAN_TD_ALARM, ///< Buffer for responding to incoming UI alarm messages COMM_BUFFER_NOT_USED, ///< Buffer for outgoing TD to DD messages so no response buffer - COMM_BUFFER_OUT_CAN_TD_2_DD, ///< Buffer for responding to incoming DD to HD messages + COMM_BUFFER_OUT_CAN_TD_2_DD, ///< Buffer for responding to incoming DD to TD messages COMM_BUFFER_NOT_USED, ///< Buffer for outgoing TD to UI messages so no response buffer - COMM_BUFFER_OUT_CAN_TD_2_UI, ///< Buffer for responding to incoming UI to HD messages + COMM_BUFFER_OUT_CAN_TD_2_UI, ///< Buffer for responding to incoming UI to TD messages COMM_BUFFER_NOT_USED, ///< Buffer for outgoing TD broadcast messages so no response buffer COMM_BUFFER_OUT_CAN_TD_BROADCAST, ///< Buffer for responding to incoming DD broadcast messages COMM_BUFFER_OUT_CAN_TD_BROADCAST, ///< Buffer for responding to incoming RO broadcast messages COMM_BUFFER_OUT_CAN_TD_BROADCAST, ///< Buffer for responding to incoming UI broadcast messages - COMM_BUFFER_OUT_CAN_PC, ///< Buffer for responding to incoming PC to TD messages - COMM_BUFFER_NOT_USED, ///< Buffer for outgoing HD to PC messages so no response buffer + COMM_BUFFER_OUT_CAN_PC, ///< Buffer for responding to incoming PC to RO messages + COMM_BUFFER_NOT_USED, ///< Buffer for outgoing TD to PC messages so no response buffer }; typedef BOOL (*MsgFuncPtr)( MESSAGE_T* ); @@ -73,21 +85,93 @@ MSG_ID_TESTER_LOGIN_REQUEST, MSG_ID_TD_SOFTWARE_RESET_REQUEST, MSG_ID_TD_BUBBLE_OVERRIDE_REQUEST, + MSG_ID_TD_BUBBLE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, MSG_ID_TD_VOLTAGE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, MSG_ID_TD_VOLTAGE_OVERRIDE_REQUEST, - MSG_ID_TD_BUBBLE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, - MSG_ID_TD_PRESSURE_OVERRIDE_REQUEST + MSG_ID_TD_PRESSURE_OVERRIDE_REQUEST, + MSG_ID_TD_PRESSURE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, + MSG_ID_TD_AIR_PUMP_SET_STATE_REQUEST, + MSG_ID_TD_AIR_PUMP_PUBLISH_INTERVAL_OVERRIDE_REQUEST, + MSG_ID_TD_SWITCHES_PUBLISH_INTERVAL_OVERRIDE_REQUEST, + MSG_ID_TD_SWITCH_STATE_OVERRIDE_REQUEST, + MSG_ID_TD_OFF_BUTTON_OVERRIDE_REQUEST, + MSG_ID_TD_STOP_BUTTON_OVERRIDE_REQUEST, + MSG_ID_TD_ALARM_LAMP_PATTERN_OVERRIDE_REQUEST, + MSG_ID_TD_ALARM_AUDIO_LEVEL_OVERRIDE_REQUEST, + MSG_ID_TD_ALARM_AUDIO_CURRENT_HG_OVERRIDE_REQUEST, + MSG_ID_TD_ALARM_AUDIO_CURRENT_LG_OVERRIDE_REQUEST, + MSG_ID_TD_BACKUP_ALARM_AUDIO_CURRENT_OVERRIDE_REQUEST, + MSG_ID_TD_AIR_TRAP_LEVEL_OVERRIDE_REQUEST, + MSG_ID_TD_AIR_TRAP_LEVEL_RAW_OVERRIDE_REQUEST, + MSG_ID_TD_AIR_TRAP_PUBLISH_INTERVAL_OVERRIDE_REQUEST, + MSG_ID_TD_2_WAY_VALVE_SET_STATE_REQUEST, + MSG_ID_TD_ROTARY_PINCH_VALVE_SET_POS_REQUEST, + MSG_ID_TD_ROTARY_PINCH_VALVE_STATUS_OVERRIDE_REQUEST, + MSG_ID_TD_ROTARY_PINCH_VALVE_POSITION_OVERRIDE_REQUEST, + MSG_ID_TD_VALVES_PUBLISH_INTERVAL_OVERRIDE_REQUEST, + MSG_ID_TD_PINCH_VALVE_SET_POSITION_REQUEST, + MSG_ID_TD_PINCH_VALVE_HOME_REQUEST, + MSG_ID_TD_ALARM_STATUS_PUBLISH_INTERVAL_OVERRIDE_REQUEST, + MSG_ID_TD_ALARM_INFO_PUBLISH_INTERVAL_OVERRIDE_REQUEST, + MSG_ID_TD_ALARM_START_TIME_OVERRIDE_REQUEST, + MSG_ID_TD_ALARM_CLEAR_ALL_ALARMS_REQUEST, + MSG_ID_TD_WATCHDOG_OVERRIDE_REQUEST, + MSG_ID_TD_ALARM_STATE_OVERRIDE_REQUEST, + MSG_ID_TD_SAFETY_SHUTDOWN_OVERRIDE_REQUEST, + MSG_ID_TD_BLOOD_PUMP_PUBLISH_INTERVAL_OVERRIDE_REQUEST, + MSG_ID_TD_BLOOD_PUMP_SET_FLOW_RATE_REQUEST, + MSG_ID_TD_BLOOD_PUMP_SET_SPEED_REQUEST, + MSG_ID_TD_BLOOD_PUMP_MEASURED_FLOW_RATE_OVERRIDE_REQUEST, + MSG_ID_TD_BLOOD_PUMP_MEASURED_MOTOR_SPEED_OVERRIDE_REQUEST, + MSG_ID_TD_BLOOD_PUMP_MEASURED_ROTOR_SPEED_OVERRIDE_REQUEST, + MSG_ID_TD_BLOOD_PUMP_ROTOR_COUNT_OVERRIDE_REQUEST }; /// Message handling function table static const MsgFuncPtr MSG_FUNCTION_HANDLERS[] = { &handleTesterLogInRequest, - &handleTDSoftwareResetRequest, + &testTDSoftwareResetRequest, &testBubbleDetectOverride, + &testBubblesDataPublishIntervalOverride, &testVoltageDataPublishIntervalOverride, &testVoltageOverride, - &testBubblesDataPublishIntervalOverride, - &testPressureSensorOverride + &testPressureSensorOverride, + &testSwitchesDataPublishIntervalOverride, + &testSetAirPump, + &testAirPumpDataPublishIntervalOverride, + &testSwitchesDataPublishIntervalOverride, + &testSwitchOverride, + &testOffButtonOverride, + &testStopButtonOverride, + &testAlarmLampPatternOverride, + &testAlarmAudioVolumeLevelOverride, + &testPrimaryAlarmAudioCurrentHGOverride, + &testPrimaryAlarmAudioCurrentLGOverride, + &testBackupAlarmAudioCurrentOverride, + &testLevelSensorOverride, + &testRawLevelSensorOverride, + &testAirTrapDataPublishIntervalOverride, + &testSet2WayValve, + &testSetValve, + &testValveStatusOverride, + &testValveEncoderPositionOverride, + &testValvesDataPublishIntervalOverride, + &testValveSetABCCmdPosition, + &testHomeValve, + &testAlarmStatusPublishIntervalOverride, + &testAlarmInfoPublishIntervalOverride, + &testSetAlarmStartTimeOverride, + &testClearAllAlarms, + &testWatchdogTaskCheckInOverride, + &testAlarmStateOverride, + &testSafetyShutdownOverride, + &testBloodFlowDataPublishIntervalOverride, + &testSetTargetBloodFlowRateOverride, + &testSetBloodPumpSpeedOverride, + &testMeasuredBloodFlowRateOverride, + &testMeasuredBloodPumpSpeedOverride, + &testMeasuredBloodPumpRotorSpeedOverride, + &testBloodPumpRotorCountOverride }; #define NUM_OF_FUNCTION_HANDLERS (sizeof(MSG_FUNCTION_HANDLERS) / sizeof(MsgFuncPtr)) @@ -345,16 +429,51 @@ } } +// Send message helper functions +/*********************************************************************//** + * @brief + * The broadcastAlarmStatus function constructs an alarm status msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details \b Inputs: none + * @details \b Outputs: alarm status msg constructed and queued. + * @param almStatus alarm status record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ) +{ + BOOL result; + ALARM_COMP_STATUS_PAYLOAD_T payload; + payload.alarmState = (U32)almStatus.alarmsState; + payload.alarmTop = (U32)almStatus.alarmTop; + payload.silenceExpiresIn = almStatus.alarmsSilenceExpiresIn; + payload.alarmsFlags = ( almStatus.systemFault ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_SYSTEM_FAULT) : 0 ); + payload.alarmsFlags |= ( almStatus.stop ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_STOP) : 0 ); + payload.alarmsFlags |= ( almStatus.noClear ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_CLEAR) : 0 ); + payload.alarmsFlags |= ( almStatus.noResume ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_RESUME) : 0 ); + payload.alarmsFlags |= ( almStatus.noRinseback ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_RINSEBACK) : 0 ); + payload.alarmsFlags |= ( almStatus.noEndTreatment ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_END_TREATMENT) : 0 ); + payload.alarmsFlags |= ( almStatus.ok ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_OK_BUTTON_ONLY) : 0 ); + payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_SILENCED) : 0 ); + payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_LAMP_ON) : 0 ); + payload.alarmsFlags |= ( almStatus.noBloodRecirc ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_BLOOD_RECIRC) : 0 ); + payload.alarmsFlags |= ( almStatus.noDialRecirc ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_DIALYSATE_RECIRC) : 0 ); + payload.alarmsFlags |= ( almStatus.noMinimize ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_MINIMIZE) : 0 ); + payload.alarmsFlags |= ( almStatus.topAlarmConditionDetected ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_TOP_CONDITION) : 0 ); + + result = broadcastData( MSG_ID_ALARM_STATUS_DATA, COMM_BUFFER_OUT_CAN_TD_ALARM, (U08*)&payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); + + return result; +} + + // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // *********************************************************************** - - /*********************************************************************//** * @brief * The sendEvent function constructs a TD event message and queues the msg @@ -392,7 +511,38 @@ return result; } +/*********************************************************************//** + * @brief + * The sendOffButtonMsgToUI function constructs an off button msg to the UI + * and queues the msg for transmit on the appropriate CAN channel. + * @details \b Message \b Sent: MSG_ID_OFF_BUTTON_PRESS_REQUEST + * @details \b Inputs: none + * @details \b Outputs: Off button msg constructed and queued. + * @param prompt 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendOffButtonMsgToUI( U08 prompt ) +{ + BOOL result; + MESSAGE_T msg; + UI_OFF_BUTTON_RESPONSE_PAYLOAD_T cmd; + cmd.userRequest = prompt; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS_REQUEST; + msg.hdr.payloadLen = sizeof( UI_OFF_BUTTON_RESPONSE_PAYLOAD_T ); + + memcpy( &msg.payload, &cmd, sizeof( UI_OFF_BUTTON_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_TD_2_UI, ACK_REQUIRED ); + + return result; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -476,22 +626,20 @@ testerLoggedIn = FALSE; } - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); - return testerLoggedIn; } /*********************************************************************//** * @brief - * The handleTDSoftwareResetRequest function handles a request to reset the + * The testTDSoftwareResetRequest function handles a request to reset the * TD firmware processor. * @note If reset is successful, this function will not return. * @details \b Inputs: none * @details \b Outputs: TD processor soft reset if request is valid * @param message Pointer to the reset request message * @return FALSE if reset command rejected *************************************************************************/ -BOOL handleTDSoftwareResetRequest( MESSAGE_T *message ) +BOOL testTDSoftwareResetRequest( MESSAGE_T *message ) { BOOL result = FALSE;