Index: leahi_dialin/common/msg_defs.py =================================================================== diff -u -r2138d06d100fdcf23f2e9069f35ee2fdee62008f -r4c6191b3a68f1167a0e443c975c51f3cb00b8000 --- leahi_dialin/common/msg_defs.py (.../msg_defs.py) (revision 2138d06d100fdcf23f2e9069f35ee2fdee62008f) +++ leahi_dialin/common/msg_defs.py (.../msg_defs.py) (revision 4c6191b3a68f1167a0e443c975c51f3cb00b8000) @@ -134,3 +134,25 @@ END_POS_FIELD_28 = START_POS_FIELD_28 + 4 START_POS_FIELD_29 = END_POS_FIELD_28 END_POS_FIELD_29 = START_POS_FIELD_29 + 4 + + +class MsgFieldPositionsFWVersions: + # UI version message field positions + START_POS_MAJOR = 6 # Hardcoded for now to avoid cyclic import issue. See protocols.CAN.DenaliMessage class + END_POS_MAJOR = START_POS_MAJOR + 1 + START_POS_MINOR = END_POS_MAJOR + END_POS_MINOR = START_POS_MINOR + 1 + START_POS_MICRO = END_POS_MINOR + END_POS_MICRO = START_POS_MICRO + 1 + START_POS_BUILD = END_POS_MICRO + END_POS_BUILD = START_POS_BUILD + 2 + START_POS_FPGA_ID = END_POS_BUILD + END_POS_FPGA_ID = START_POS_FPGA_ID + 1 + START_POS_FPGA_MAJOR = END_POS_FPGA_ID + END_POS_FPGA_MAJOR = START_POS_FPGA_MAJOR + 1 + START_POS_FPGA_MINOR = END_POS_FPGA_MAJOR + END_POS_FPGA_MINOR = START_POS_FPGA_MINOR + 1 + START_POS_FPGA_MICRO = END_POS_FPGA_MINOR + END_POS_FPGA_MICRO = START_POS_FPGA_MICRO + 1 + START_POS_COMPATIBILITY_REV = END_POS_FPGA_MICRO + END_POS_COMPATIBILITY_REV = START_POS_COMPATIBILITY_REV + 4 \ No newline at end of file Index: leahi_dialin/common/msg_ids.py =================================================================== diff -u -rc3cb761794ec2dd44f4289b2d2441ff6bc037f6a -r4c6191b3a68f1167a0e443c975c51f3cb00b8000 --- leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision c3cb761794ec2dd44f4289b2d2441ff6bc037f6a) +++ leahi_dialin/common/msg_ids.py (.../msg_ids.py) (revision 4c6191b3a68f1167a0e443c975c51f3cb00b8000) @@ -110,6 +110,7 @@ MSG_ID_FP_CONCENTRATE_FLUSH_DATA = 0x57 MSG_ID_FP_GENP_DEF_DATA = 0x58 MSG_ID_FP_PRE_GEN_DEF_DATA = 0x59 + MSG_ID_FP_VERSION_RESPONSE = 0x5A MSG_ID_DD_PISTON_PUMP_CONTROL_DATA = 0xF0 Index: leahi_dialin/dd/dialysate_delivery.py =================================================================== diff -u -rcf5e82faaf502b2828ffb6e43c2a64b71f6e31f2 -r4c6191b3a68f1167a0e443c975c51f3cb00b8000 --- leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision cf5e82faaf502b2828ffb6e43c2a64b71f6e31f2) +++ leahi_dialin/dd/dialysate_delivery.py (.../dialysate_delivery.py) (revision 4c6191b3a68f1167a0e443c975c51f3cb00b8000) @@ -33,7 +33,7 @@ from .proxies.ro_proxy import ROProxy from .proxies.td_proxy import TDProxy -from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..common.msg_defs import MsgIds, MsgFieldPositions, MsgFieldPositionsFWVersions from ..common.dd_defs import DDOpModes from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels from ..utils.base import AbstractSubSystem, publish, LogManager @@ -54,18 +54,6 @@ # DD login password DD_LOGIN_PASSWORD = '123' - # UI version message field positions - START_POS_MAJOR = DenaliMessage.PAYLOAD_START_INDEX - END_POS_MAJOR = START_POS_MAJOR + 1 - START_POS_MINOR = END_POS_MAJOR - END_POS_MINOR = START_POS_MINOR + 1 - START_POS_MICRO = END_POS_MINOR - END_POS_MICRO = START_POS_MICRO + 1 - START_POS_BUILD = END_POS_MICRO - END_POS_BUILD = START_POS_BUILD + 2 - START_POS_COMPATIBILITY_REV = END_POS_BUILD - END_POS_COMPATIBILITY_REV = START_POS_COMPATIBILITY_REV + 4 - def __init__(self, can_interface="can0", log_level=None): """ DD object provides test/service commands for the DD sub-system. @@ -97,18 +85,21 @@ self._handler_dd_op_mode_sync) self.can_interface.register_receiving_publication_function(channel_id, + MsgIds.MSG_ID_DD_VERSION_REPONSE.value, + self._handler_dd_version_response_sync) + + self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_DD_DEBUG_EVENT.value, self._handler_dd_debug_event_sync) # create properties self.dd_op_mode_timestamp = 0.0 self.dd_debug_events_timestamp = 0.0 - self.ui_version_info_response_timestamp = 0.0 + self.dd_version_response_timestamp = 0.0 self.dd_operation_mode = DDOpModes.MODE_INIT.value self.dd_operation_sub_mode = 0 self.dd_logged_in = False self.dd_set_logged_in_status(False) - self.ui_version = None self.dd_debug_events = [''] * self._DD_DEBUG_EVENT_LIST_COUNT self.dd_debug_event_index = 0 self.dd_last_debug_event = '' @@ -182,6 +173,44 @@ self.dd_operation_sub_mode = smode[0] self.dd_op_mode_timestamp = timestamp + @publish(["dd_version, dd_fpga_version"]) + def _handler_dd_version_response_sync(self,message, timestamp = 0.0): + """ + Handler for response from DD regarding its version. + + @param message: version response message from DD.\n + + @return: None if not successful, the version string if unpacked successfully + """ + major = struct.unpack(' 0 for each in [major, minor, micro, build, compatibility]]): + self.dd_version = f"v{major[0]}.{minor[0]}.{micro[0]}-{build[0]}.{compatibility[0]}" + self.logger.debug(f"DD VERSION: {self.dd_version}") + + if all([len(each) > 0 for each in [fpga_id, fpga_major, fpga_minor, fpga_lab]]): + self.dd_fpga_version = f"v{fpga_id[0]}.{fpga_major[0]}.{fpga_minor[0]}-{fpga_lab[0]}" + self.logger.debug(f"DD FPGA VERSION: {self.dd_fpga_version}") + + self.dd_version_response_timestamp = timestamp + def cmd_log_in_to_dd(self, resend: bool = False) -> int: """ Constructs and sends a login command via CAN bus. Login required before \n Index: leahi_dialin/fp/filtration_purification.py =================================================================== diff -u -rcf5e82faaf502b2828ffb6e43c2a64b71f6e31f2 -r4c6191b3a68f1167a0e443c975c51f3cb00b8000 --- leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision cf5e82faaf502b2828ffb6e43c2a64b71f6e31f2) +++ leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision 4c6191b3a68f1167a0e443c975c51f3cb00b8000) @@ -29,7 +29,7 @@ from .proxies.dd_proxy import DDProxy -from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..common.msg_defs import MsgIds, MsgFieldPositions, MsgFieldPositionsFWVersions from ..common.fp_defs import FPOpModes from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels from ..utils.base import AbstractSubSystem, publish, LogManager @@ -50,18 +50,6 @@ # FP login password FP_LOGIN_PASSWORD = '123' - # UI version message field positions - START_POS_MAJOR = DenaliMessage.PAYLOAD_START_INDEX - END_POS_MAJOR = START_POS_MAJOR + 1 - START_POS_MINOR = END_POS_MAJOR - END_POS_MINOR = START_POS_MINOR + 1 - START_POS_MICRO = END_POS_MINOR - END_POS_MICRO = START_POS_MICRO + 1 - START_POS_BUILD = END_POS_MICRO - END_POS_BUILD = START_POS_BUILD + 2 - START_POS_COMPATIBILITY_REV = END_POS_BUILD - END_POS_COMPATIBILITY_REV = START_POS_COMPATIBILITY_REV + 4 - def __init__(self, can_interface="can0", log_level=None): """ FP object provides test/service commands for the FP sub-system. @@ -93,18 +81,23 @@ self._handler_fp_op_mode_sync) self.can_interface.register_receiving_publication_function(channel_id, + MsgIds.MSG_ID_FP_VERSION_REPONSE.value, + self._handler_fp_version_response_sync) + + self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_FP_DEBUG_EVENT.value, self._handler_fp_debug_event_sync) # create properties self.fp_op_mode_timestamp = 0.0 self.fp_debug_events_timestamp = 0.0 - self.ui_version_info_response_timestamp = 0.0 + self.fp_version_response_timestamp = 0.0 self.fp_operation_mode = FPOpModes.MODE_INIT.value self.fp_operation_sub_mode = 0 self.fp_logged_in = False self.fp_set_logged_in_status(False) - self.ui_version = None + self.fp_version = None + self.fp_fpga_version = None self.fp_debug_events = [''] * self._FP_DEBUG_EVENT_LIST_COUNT self.fp_debug_event_index = 0 self.fp_last_debug_event = '' @@ -120,7 +113,6 @@ self.ro_pump = FPROPump(self.can_interface, self.logger) self.temperatures = FPTemperatureSensors(self.can_interface, self.logger) self.valves = FPValves(self.can_interface, self.logger) - self.dd_proxy = DDProxy(self.can_interface, self.logger) @publish(["fp_debug_events_timestamp","fp_debug_events"]) @@ -159,6 +151,44 @@ """ self.fp_logged_in = logged_in + @publish(["fp_version, fp_fpga_version"]) + def _handler_fp_version_response_sync(self,message, timestamp = 0.0): + """ + Handler for response from FP regarding its version. + + @param message: version response message from FP.\n + + @return: None if not successful, the version string if unpacked successfully + """ + major = struct.unpack(' 0 for each in [major, minor, micro, build, compatibility]]): + self.fp_version = f"v{major[0]}.{minor[0]}.{micro[0]}-{build[0]}.{compatibility[0]}" + self.logger.debug(f"FP VERSION: {self.fp_version}") + + if all([len(each) > 0 for each in [fpga_id, fpga_major, fpga_minor, fpga_lab]]): + self.fp_fpga_version = f"v{fpga_id[0]}.{fpga_major[0]}.{fpga_minor[0]}-{fpga_lab[0]}" + self.logger.debug(f"FP FPGA VERSION: {self.fp_fpga_version}") + + self.fp_version_response_timestamp = timestamp + @publish(["fp_op_mode_timestamp","fp_operation_mode", "fp_operation_sub_mode"]) def _handler_fp_op_mode_sync(self, message, timestamp = 0.0): """ Index: leahi_dialin/td/proxies/ui_proxy.py =================================================================== diff -u -r72c423da1d07c40699f40b5da5bee6d992d3082c -r4c6191b3a68f1167a0e443c975c51f3cb00b8000 --- leahi_dialin/td/proxies/ui_proxy.py (.../ui_proxy.py) (revision 72c423da1d07c40699f40b5da5bee6d992d3082c) +++ leahi_dialin/td/proxies/ui_proxy.py (.../ui_proxy.py) (revision 4c6191b3a68f1167a0e443c975c51f3cb00b8000) @@ -242,4 +242,19 @@ self.logger.debug("Sending treatment parameters to TD.") - self.can_interface.send(message, 0) \ No newline at end of file + self.can_interface.send(message, 0) + + + def cmd_send_ui_version_request(self): + """ + Constructs and sends a UI version request broadcast. + Can be used to retrieve all sub system version responses. + + @return: none + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.ui_sync_broadcast_ch_id, + message_id=MsgIds.MSG_ID_FW_VERSIONS_REQUEST.value) + + self.logger.debug("Sending UI Version Request.") + self.can_interface.send(message, 0) Index: leahi_dialin/td/treatment_delivery.py =================================================================== diff -u -rb3774ad1df35c613de1c09bef40a55eb0ce4af36 -r4c6191b3a68f1167a0e443c975c51f3cb00b8000 --- leahi_dialin/td/treatment_delivery.py (.../treatment_delivery.py) (revision b3774ad1df35c613de1c09bef40a55eb0ce4af36) +++ leahi_dialin/td/treatment_delivery.py (.../treatment_delivery.py) (revision 4c6191b3a68f1167a0e443c975c51f3cb00b8000) @@ -31,7 +31,7 @@ from .proxies.dd_proxy import DDProxy -from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..common.msg_defs import MsgIds, MsgFieldPositions, MsgFieldPositionsFWVersions from ..common.td_defs import TDOpModes from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels from ..utils.base import AbstractSubSystem, publish, LogManager @@ -52,18 +52,6 @@ # TD login password TD_LOGIN_PASSWORD = '123' - # UI version message field positions - START_POS_MAJOR = DenaliMessage.PAYLOAD_START_INDEX - END_POS_MAJOR = START_POS_MAJOR + 1 - START_POS_MINOR = END_POS_MAJOR - END_POS_MINOR = START_POS_MINOR + 1 - START_POS_MICRO = END_POS_MINOR - END_POS_MICRO = START_POS_MICRO + 1 - START_POS_BUILD = END_POS_MICRO - END_POS_BUILD = START_POS_BUILD + 2 - START_POS_COMPATIBILITY_REV = END_POS_BUILD - END_POS_COMPATIBILITY_REV = START_POS_COMPATIBILITY_REV + 4 - def __init__(self, can_interface="can0", log_level=None): """ TD object provides test/service commands for the TD sub-system. @@ -98,6 +86,10 @@ MsgIds.MSG_ID_TD_DEBUG_EVENT.value, self._handler_td_debug_event_sync) + self.can_interface.register_receiving_publication_function(channel_id, + MsgIds.MSG_ID_TD_VERSION_REPONSE.value, + self._handler_td_version_response_sync) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_to_td_ch_id, MsgIds.MSG_ID_UI_VERSION_INFO_RESPONSE.value, self._handler_ui_version_response_sync) @@ -106,11 +98,14 @@ self.td_op_mode_timestamp = 0.0 self.td_debug_events_timestamp = 0.0 self.ui_version_info_response_timestamp = 0.0 + self.td_version_response_timestamp = 0.0 self.td_operation_mode = TDOpModes.MODE_INIT.value self.td_operation_sub_mode = 0 self.td_logged_in = False self.td_set_logged_in_status(False) self.ui_version = None + self.td_version = None + self.td_fpga_version = None self.td_debug_events = [''] * self._TD_DEBUG_EVENT_LIST_COUNT self.td_debug_event_index = 0 self.td_last_debug_event = '' @@ -181,7 +176,45 @@ self.td_operation_sub_mode = smode[0] self.td_op_mode_timestamp = timestamp + @publish(["td_version, td_fpga_version"]) + def _handler_td_version_response_sync(self,message, timestamp = 0.0): + """ + Handler for response from TD regarding its version. + @param message: version response message from TD.\n + + @return: None if not successful, the version string if unpacked successfully + """ + major = struct.unpack(' 0 for each in [major, minor, micro, build, compatibility]]): + self.td_version = f"v{major[0]}.{minor[0]}.{micro[0]}-{build[0]}.{compatibility[0]}" + self.logger.debug(f"TD VERSION: {self.td_version}") + + if all([len(each) > 0 for each in [fpga_id, fpga_major, fpga_minor, fpga_lab]]): + self.td_fpga_version = f"v{fpga_id[0]}.{fpga_major[0]}.{fpga_minor[0]}-{fpga_lab[0]}" + self.logger.debug(f"TD FPGA VERSION: {self.td_fpga_version}") + + self.td_version_response_timestamp = timestamp + + def _handler_ui_version_response_sync(self,message, timestamp = 0.0): """ Handler for response from TD regarding its version.