Index: dialin/common/dg_defs.py =================================================================== diff -u -r71a18fc40dc40519d50aa7888405dbcd4c4cad25 -rc2596a85ec09eaf40003833a4f68fb07cca27522 --- dialin/common/dg_defs.py (.../dg_defs.py) (revision 71a18fc40dc40519d50aa7888405dbcd4c4cad25) +++ dialin/common/dg_defs.py (.../dg_defs.py) (revision c2596a85ec09eaf40003833a4f68fb07cca27522) @@ -8,7 +8,7 @@ # @file dg_defs.py # # @author (last) Dara Navaei -# @date (last) 20-Jun-2022 +# @date (last) 15-Jul-2022 # @author (original) Peter Lucia # @date (original) 22-Jun-2021 # @@ -53,12 +53,13 @@ DG_POST_STATE_UV_REACTORS = 14 DG_POST_STATE_THERMISTORS = 15 DG_POST_STATE_FANS = 16 - DG_POST_STATE_WATCHDOG = 17 - DG_POST_STATE_SAFETY_SHUTDOWN = 18 - DG_POST_STATE_LOAD_CELL = 19 - DG_POST_STATE_COMPLETED = 20 - DG_POST_STATE_FAILED = 21 - NUM_OF_DG_POST_STATES = 22 + DG_POST_STATE_DIALYSATE_FLOW_SENSOR = 17 + DG_POST_STATE_WATCHDOG = 18 + DG_POST_STATE_SAFETY_SHUTDOWN = 19 + DG_POST_STATE_LOAD_CELL = 20 + DG_POST_STATE_COMPLETED = 21 + DG_POST_STATE_FAILED = 22 + NUM_OF_DG_POST_STATES = 23 @unique Index: dialin/dg/dialysate_generator.py =================================================================== diff -u -r1befe554b44643ad704955626720fccb6cf6dc47 -rc2596a85ec09eaf40003833a4f68fb07cca27522 --- dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision 1befe554b44643ad704955626720fccb6cf6dc47) +++ dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision c2596a85ec09eaf40003833a4f68fb07cca27522) @@ -7,8 +7,8 @@ # # @file dialysate_generator.py # -# @author (last) Dara Navaei -# @date (last) 20-Jun-2022 +# @author (last) Sean Nash +# @date (last) 08-Jul-2022 # @author (original) Peter Lucia # @date (original) 02-Apr-2020 # @@ -354,6 +354,51 @@ self.can_interface.send(message, 0) + def cmd_dg_set_operation_mode(self, new_mode: int = 0) -> int: + """ + Constructs and sends a set operation mode request command via CAN bus. + Constraints: + Must be logged into DG. + Transition from current to requested op mode must be legal. + + @param new_mode: ID of operation mode to transition to + DG_MODE_FAUL = 0 + DG_MODE_SERV = 1 + DG_MODE_INIT = 2 + DG_MODE_STAN = 3 + DG_MODE_SOLO = 4 + DG_MODE_GENE = 5 + DG_MODE_FILL = 6 + DG_MODE_DRAI = 7 + DG_MODE_FLUS = 8 + DG_MODE_HEAT = 9 + DG_MODE_CHEM = 10 + + @return: 1 if successful, zero otherwise + + """ + + payload = integer_to_bytearray(new_mode) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, + message_id=MsgIds.MSG_ID_DG_SET_OP_MODE_REQUEST.value, + payload=payload) + + self.logger.debug("Requesting DG mode change to " + str(new_mode)) + + # Send message + received_message = self.can_interface.send(message) + + if received_message is not None: + if received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] == 1: + self.logger.debug("Success: Mode change accepted") + else: + self.logger.debug("Failure: Mode change rejected.") + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("DG mode change request Timeout!!!!") + return False + def cmd_dg_safety_shutdown_override(self) -> int: """ Constructs and sends an DG safety shutdown override command via CAN bus. Index: dialin/hd/alarms.py =================================================================== diff -u -r837d2551fdf0ffbbf96870de746a0d4864f17d84 -rc2596a85ec09eaf40003833a4f68fb07cca27522 --- dialin/hd/alarms.py (.../alarms.py) (revision 837d2551fdf0ffbbf96870de746a0d4864f17d84) +++ dialin/hd/alarms.py (.../alarms.py) (revision c2596a85ec09eaf40003833a4f68fb07cca27522) @@ -7,8 +7,8 @@ # # @file alarms.py # -# @author (last) Sean Nash -# @date (last) 31-Mar-2022 +# @author (last) Dara Navaei +# @date (last) 03-Aug-2022 # @author (original) Peter Lucia # @date (original) 02-Apr-2020 # @@ -56,9 +56,6 @@ START_POS_ALARMS_FLAGS = END_POS_ALARM_SILENCE_EXPIRES_IN END_POS_ALARMS_FLAGS = START_POS_ALARMS_FLAGS + 2 - START_POS_ALARM_ID = DenaliMessage.PAYLOAD_START_INDEX - END_POS_ALARM_ID = START_POS_ALARM_ID + 2 - def __init__(self, can_interface, logger: Logger): """ @param can_interface: Denali Can Messenger object @@ -99,6 +96,12 @@ self.alarm_states = [False] * 500 # alarm condition states based on received HD alarm activation and clear condition messages self.alarm_conditions = [False] * 500 + # alarm priorities based on received HD alarm activation messages + self.alarm_priorities = [0] * 500 + # alarm ranks based on received HD alarm activation messages + self.alarm_ranks = [0] * 500 + # alarm clear top only flags based on received HD alarm activation messages + self.alarm_clear_top_only_flags = [False] * 500 # alarm information self.alarm_volume = 0 @@ -139,6 +142,34 @@ """ return self.alarm_states[alarm_id] + def get_alarm_priority(self, alarm_id): + """ + Gets alarm priority for given alarm. + 0=None + 1=Low + 2=Medium + 3=High + + @return: Alarm priority + """ + return self.alarm_priorities[alarm_id] + + def get_alarm_rank(self, alarm_id): + """ + Gets alarm rank for given alarm. + + @return: Alarm rank + """ + return self.alarm_ranks[alarm_id] + + def get_alarm_clear_top_only(self, alarm_id): + """ + Gets alarm "clear top only" property for given alarm. + + @return: T/F + """ + return self.alarm_clear_top_only_flags[alarm_id] + def get_alarms_top(self): """ Gets the top alarm @@ -363,9 +394,20 @@ """ self.logger.debug("Alarm activated!") - alarm_id = struct.unpack(' int: + """ + Constructs and sends the re-send all active alarms command. + This will allow Dialin to get caught up with HD alarms that were triggered prior to connection. + Constraints: + Must be logged into HD. + + @return: 1 if successful, zero otherwise + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_SEND_ALARMS_COMMAND.value) + + # Send message + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + self.logger.debug("Command to re-send all active HD alarms acknowledged.") + # response payload is OK or not OK + return 1 == received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + return False + def cmd_alarm_state_override(self, alarm: int, state: int, reset: int = NO_RESET) -> int: """ Constructs and sends the alarm state override command Index: dialin/hd/treatment.py =================================================================== diff -u -r2c3670be196a05ad6c34d798af26bdb798e607d4 -rc2596a85ec09eaf40003833a4f68fb07cca27522 --- dialin/hd/treatment.py (.../treatment.py) (revision 2c3670be196a05ad6c34d798af26bdb798e607d4) +++ dialin/hd/treatment.py (.../treatment.py) (revision c2596a85ec09eaf40003833a4f68fb07cca27522) @@ -57,7 +57,8 @@ DIALYZER_TYPE_BBRAUN_PRO_16H = 1 # BBraun Diacap Pro 16H DIALYZER_TYPE_BBRAUN_PRO_19H = 2 # BBraun Diacap Pro 19H DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F160NRE = 3 # Fresenius Optiflux F160NRe - DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F180NRE = 4 + DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F180NRE = 4 # Fresenius Optiflux F180NRe + DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F200NRE = 5 # Fresenius Optiflux F200NRe # Acid Concentrate IDs ACID_CONC_TYPE_FRESENIUS_08_1251_1 = 0 @@ -1001,7 +1002,9 @@ DIALYZER_TYPE_BBRAUN_PRO_19H = 2 DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F160NRE = 3 DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F180NRE = 4 + DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F200NRE = 5 + @param dialyzer: integer - set dialyzer type @return: 1 if successful, zero otherwise """