Index: dialin/common/msg_ids.py =================================================================== diff -u -r821d2c94ccc6542a7733a9453e59b751bfd0ef75 -re8f9ead3fe058b688c0b42c599886375e1730008 --- dialin/common/msg_ids.py (.../msg_ids.py) (revision 821d2c94ccc6542a7733a9453e59b751bfd0ef75) +++ dialin/common/msg_ids.py (.../msg_ids.py) (revision e8f9ead3fe058b688c0b42c599886375e1730008) @@ -470,6 +470,7 @@ MSD_ID_DG_RTC_CTL_REG3_STATUS_OVERRIDE = 0xA063 MSG_ID_DG_NELSON_DISINFECT_SUPPORT = 0xA064 MSG_ID_DG_SET_DIALYSATE_MIXING_RATIOS = 0xA065 + MSG_ID_DG_SET_TEST_CONFIGURATION = 0xA066 MSG_ID_HD_DEBUG_EVENT = 0xFFF1 MSG_ID_DG_DEBUG_EVENT = 0xFFF2 Index: dialin/common/test_config_defs.py =================================================================== diff -u --- dialin/common/test_config_defs.py (revision 0) +++ dialin/common/test_config_defs.py (revision e8f9ead3fe058b688c0b42c599886375e1730008) @@ -0,0 +1,18 @@ + +from enum import unique +from ..utils.base import DialinEnum + + +@unique +class DGTestConfigEnums(DialinEnum): + # NOTE: This enum has been commented out because two enums cannot have the same value but the firmware is assigned + # to the enum number. + TEST_CONFIG_ENABLE_MIXING_WITH_WATER = 0 # Test configuration enable mixing with water. + # TEST_CONFIG_FIRST = TEST_CONFIG_ENABLE_MIXING_WITH_WATER, # Test configuration first configuration. + NUM_OF_TEST_CONFIGS = 1 # Number of test configurations. + + +@unique +class HDTestConfigEnums(DialinEnum): + pass + # TODo update Index: dialin/dg/dg_test_configs.py =================================================================== diff -u --- dialin/dg/dg_test_configs.py (revision 0) +++ dialin/dg/dg_test_configs.py (revision e8f9ead3fe058b688c0b42c599886375e1730008) @@ -0,0 +1,80 @@ + +import struct +import time +from enum import unique +from logging import Logger +from time import sleep + +from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..common.test_config_defs import DGTestConfigEnums +from ..protocols.CAN import DenaliMessage, DenaliChannels +from .constants import NO_RESET, RESET +from ..utils.conversions import integer_to_bytearray +from ..utils.base import AbstractSubSystem, DialinEnum + + +class DGTestConfig(AbstractSubSystem): + """ + + Dialysate Generator (DG) Dialin API sub-class for setting and getting the test configurations. + """ + + def __init__(self, can_interface, logger: Logger): + """ + + @param can_interface: Denali CAN Messenger object + """ + super().__init__() + + self.can_interface = can_interface + self.logger = logger + self.dg_test_configs = dict() + + for config in DGTestConfigEnums.__members__: + if 'NUM_OF_TEST_CONFIGS' not in config: + self.dg_test_configs[config] = 0 + + def cmd_get_test_config_status(self, config: int): + """ + Returns the status of a test config + + @param config: (int) Test config to set + @return: the status of a test config + """ + return self.dg_test_configs[DGTestConfigEnums(config).name] + + def cmd_set_test_config(self, config: int, reset: int = NO_RESET): + """ + Constructs and sends the DG test config + Constraints: + Must be logged into DG. + + @param config: (int) Test config to set + @param reset: (int) 1 to reset a previous override, 0 to override + @return: 1 if successful, zero otherwise + """ + reset_value = integer_to_bytearray(reset) + c = integer_to_bytearray(config) + payload = reset_value + c + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, + message_id=MsgIds.MSG_ID_DG_SET_TEST_CONFIGURATION.value, + payload=payload) + + if reset == NO_RESET: + self.logger.debug("Setting {}".format(DGTestConfigEnums(config).name)) + else: + self.logger.debug("Resetting {}".format(DGTestConfigEnums(config).name)) + + # Send message + received_message = self.can_interface.send(message) + + # If there is no content... + if received_message is not None: + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + + Index: dialin/dg/sw_configs.py =================================================================== diff -u -r9bc00e997e91dab8b404aa877b02ae3d4100d417 -re8f9ead3fe058b688c0b42c599886375e1730008 --- dialin/dg/sw_configs.py (.../sw_configs.py) (revision 9bc00e997e91dab8b404aa877b02ae3d4100d417) +++ dialin/dg/sw_configs.py (.../sw_configs.py) (revision e8f9ead3fe058b688c0b42c599886375e1730008) @@ -182,7 +182,7 @@ self.dg_sw_config_record_timestamp = timestamp self._handler_received_complete_dg_sw_config_record() - @publish(["dg_sw_config_record_timestamp","dg_sw_config_record"]) + @publish(["dg_sw_config_record_timestamp", "dg_sw_config_record"]) def _handler_received_complete_dg_sw_config_record(self): """ Publishes the received software configuration record Index: tests/dg_tests.py =================================================================== diff -u -r6eb7388c7884a276c3c8b93aa8060feaab38081b -re8f9ead3fe058b688c0b42c599886375e1730008 --- tests/dg_tests.py (.../dg_tests.py) (revision 6eb7388c7884a276c3c8b93aa8060feaab38081b) +++ tests/dg_tests.py (.../dg_tests.py) (revision e8f9ead3fe058b688c0b42c599886375e1730008) @@ -522,7 +522,7 @@ f = open(address, "w") #dg.heaters.cmd_heaters_broadcast_interval_override(50) #sleep(1) - dg.hd_proxy.cmd_start_stop_dg_heat_disinfect() + #dg.hd_proxy.cmd_start_stop_dg_heat_disinfect() #dg.hd_proxy.cmd_start_stop_dg_heat_disinfect_active_cool() try: @@ -672,7 +672,7 @@ hd.cmd_log_in_to_hd() sleep(1) - #run_heat_disinfect() + run_heat_disinfect() #run_flush_mode() @@ -708,8 +708,8 @@ #hd.ui.cmd_set_ro_only_mode_status(1) - while True: - print(get_dg_voltages_info()) - sleep(1) + #while True: + # print(get_dg_voltages_info()) + # sleep(1)