Index: dialin/common/msg_ids.py =================================================================== diff -u -r3b58405e25515e1cf391d513a5b6551ab3468369 -rd1e3f50dceb4c11cff5af632b39c64b4407aad68 --- dialin/common/msg_ids.py (.../msg_ids.py) (revision 3b58405e25515e1cf391d513a5b6551ab3468369) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision d1e3f50dceb4c11cff5af632b39c64b4407aad68) @@ -185,6 +185,7 @@ MSG_ID_HD_SWITCHES_DATA = 0XA2 MSG_ID_HD_FANS_DATA = 0XA3 MSG_ID_DG_DIALYSATE_FLOW_METER_DATA = 0xA6 + MSG_ID_DG_ALARM_INFO = 0xA7 MSG_ID_CAN_ERROR_COUNT = 0X999 MSG_ID_TESTER_LOGIN_REQUEST = 0X8000 MSG_ID_DIAL_OUT_FLOW_SET_PT_OVERRIDE = 0X8001 @@ -375,6 +376,7 @@ MSG_ID_DG_STOP_RTC_CLOCK = 0XA045 MSG_ID_DG_DRAIN_PUMP_MEASURED_RPM_OVERRIDE = 0XA046 MSG_ID_DG_SUPER_CLEAR_ALARMS_CMD = 0XA047 + MSG_ID_DG_ALARM_INFO_SEND_INTERVAL_OVERRIDE = 0xA048 MSG_ID_HD_DEBUG_EVENT = 0XFFF1 MSG_ID_DG_DEBUG_EVENT = 0XFFF2 Index: dialin/dg/alarms.py =================================================================== diff -u -r3b58405e25515e1cf391d513a5b6551ab3468369 -rd1e3f50dceb4c11cff5af632b39c64b4407aad68 --- dialin/dg/alarms.py (.../alarms.py) (revision 3b58405e25515e1cf391d513a5b6551ab3468369) +++ dialin/dg/alarms.py (.../alarms.py) (revision d1e3f50dceb4c11cff5af632b39c64b4407aad68) @@ -17,7 +17,8 @@ from logging import Logger from .constants import RESET, NO_RESET -from ..common.msg_defs import MsgIds +from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..utils.checks import check_broadcast_interval_override_ms from ..protocols.CAN import DenaliMessage, DenaliChannels from ..utils.base import AbstractSubSystem, publish from ..utils.conversions import integer_to_bytearray @@ -50,10 +51,14 @@ msg_id = MsgIds.MSG_ID_ALARM_CONDITION_CLEARED.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_alarm_condition_clear) + msg_id = MsgIds.MSG_ID_DG_ALARM_INFO.value + self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_alarm_information_sync) + # alarm states based on received DG alarm activation and alarm clear messages self.alarm_states = [False] * 500 # alarm condition states based on received DG alarm activation and clear condition messages self.alarm_conditions = [False] * 500 + self.safety_shutdown_active = False def get_alarm_states(self): """ @@ -79,6 +84,14 @@ """ return self.alarm_states[alarm_id] + def get_safety_shutdown_activated(self): + """ + Gets the state of the DG safety shutdown signal. + + @return: (bool) safety shutdown line is activated (T/F) + """ + return self.safety_shutdown_active + @publish(["alarm_states"]) def _handler_alarm_activate(self, message): """ @@ -117,6 +130,19 @@ alarm_id = struct.unpack(' int: """ Constructs and sends the alarm state override command @@ -182,3 +208,45 @@ # response payload is OK or not OK return 1 == received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] return False + + def cmd_alarm_info_broadcast_interval_override(self, ms: int = 1000, reset: int = NO_RESET): + """ + Constructs and sends the alarm information broadcast interval override command + Constraints: + Must be logged into DG. + Given interval must be non-zero and a multiple of the DG general task interval (50 ms). + + @param ms: integer - interval (in ms) to override with + @param reset: integer - 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + + if not check_broadcast_interval_override_ms(ms): + return False + + rst = integer_to_bytearray(reset) + mis = integer_to_bytearray(ms) + payload = rst + mis + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, + message_id=MsgIds.MSG_ID_DG_ALARM_INFO_SEND_INTERVAL_OVERRIDE.value, + payload=payload) + + self.logger.debug("override DG alarm information broadcast interval") + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + if reset == RESET: + str_res = "reset back to normal: " + else: + str_res = str(ms) + " ms: " + self.logger.debug("DG alarm information broadcast interval overridden to " + str_res + + str(received_message['message'][DenaliMessage.PAYLOAD_START_INDEX])) + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False Index: dialin/hd/alarms.py =================================================================== diff -u -r3b58405e25515e1cf391d513a5b6551ab3468369 -rd1e3f50dceb4c11cff5af632b39c64b4407aad68 --- dialin/hd/alarms.py (.../alarms.py) (revision 3b58405e25515e1cf391d513a5b6551ab3468369) +++ dialin/hd/alarms.py (.../alarms.py) (revision d1e3f50dceb4c11cff5af632b39c64b4407aad68) @@ -383,7 +383,7 @@ alarm_id = struct.unpack('