Index: leahi_dialin/dd/modules/gen_dialysate.py =================================================================== diff -u -rfc671af6d1a18c900812e68c42ca14da3280e4f1 -r39190f5b592ef515e19ae1b5455a32b84f853cf5 --- leahi_dialin/dd/modules/gen_dialysate.py (.../gen_dialysate.py) (revision fc671af6d1a18c900812e68c42ca14da3280e4f1) +++ leahi_dialin/dd/modules/gen_dialysate.py (.../gen_dialysate.py) (revision 39190f5b592ef515e19ae1b5455a32b84f853cf5) @@ -51,15 +51,13 @@ self.execution_state = 0 #: The Execution state self.dialysate_delivery_in_progress = 0 #: Is Dialysate delivery in progress or not self.dialysate_good_to_deliver = 0 #: The Dialysate is good to delover or not - self.targetQd = 0.0 #: The Target Qd - self.isBalancingChamberSwitchingActive = 0 #: Is the balancing chamber switching or not + self.target_qd = 0.0 #: The Target Qd @publish(["msg_id_dd_gen_dialysate_mode_data", "execution_state", "dialysate_delivery_in_progress", "dialysate_good_to_deliver", - "targetQd", - "isBalancingChamberSwitchingActive", + "target_qd", "dd_gen_dialysate_timestamp"]) def _handler_gen_dialysate_sync(self, message, timestamp=0.0): """ @@ -68,28 +66,26 @@ @param message: published gen dialysate data message @return: None """ - self.execution_state = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] - self.dialysate_delivery_in_progress = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] - self.d6_level = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] - self.d63_level = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] - self.d46_level = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] - self.d9_pressure = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] - self.d18_pressure = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] - self.d51_pressure = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] - self.dialysate_good_to_deliver = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_9:MsgFieldPositions.END_POS_FIELD_9]))[0] - self.targetQd = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_10:MsgFieldPositions.END_POS_FIELD_10]))[0] - self.isBalancingChamberSwitchingActive = struct.unpack('I', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_11:MsgFieldPositions.END_POS_FIELD_11]))[0] + sensor_list =[] + sensor_list.append(['self.execution_state', 'I']) + sensor_list.append(['self.dialysate_delivery_in_progress', 'I']) + # sensor_list.append(['self.d6_level', 'I']) + # sensor_list.append(['self.d63_level', 'f']) + # sensor_list.append(['self.d46_level', 'I']) + # sensor_list.append(['self.d9_pressure', 'f']) + # sensor_list.append(['self.d18_pressure', 'f']) + # sensor_list.append(['self.d51_pressure', 'f']) + sensor_list.append(['self.dialysate_good_to_deliver', 'I']) + sensor_list.append(['self.target_qd', 'f']) + + i = 1 + for sensor in sensor_list: + start_pos = eval(f'MsgFieldPositions.START_POS_FIELD_{i}') + end_pos = eval(f'MsgFieldPositions.END_POS_FIELD_{i}') + value = struct.unpack(sensor[1],bytearray(message['message'][start_pos:end_pos]))[0] + exec(f'{sensor[0]} = {value}') + i += 1 + self.dd_gen_dialysate_timestamp = timestamp Index: leahi_dialin/fp/filtration_purification.py =================================================================== diff -u -r5da31bc941a76297a8285323af9ff5d497ebe230 -r39190f5b592ef515e19ae1b5455a32b84f853cf5 --- leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision 5da31bc941a76297a8285323af9ff5d497ebe230) +++ leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision 39190f5b592ef515e19ae1b5455a32b84f853cf5) @@ -94,20 +94,26 @@ self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_FP_DEF_STATUS_RESPONSE.value, self._handler_fp_defeatured_response) + # self.can_interface.register_receiving_publication_function(channel_id, + # MsgIds.MSG_ID_FP_DEF_STATUS_RESPONSE.value, + # self._handler_fp_boost_pump_installed_response) # Dialin will send a login message during construction. This is for the leahi subsystems to start # publishing CAN data when there is no UI connected as the UI typically does this job. self.cmd_log_in_to_fp() - # create properties + # configuration records self.fp_defeatured = False #: The FP is defeaturized or not self.fp_defeatured_timestamp = 0.0 #: The timestamp of the latest defeatured message + self.fp_p40_installed = False #: The P40 Boost Pump is installed or not + self.fp_p40_installed_timestamp = 0.0 #: The timestamp of the latest P40 Boost Pump is installed message + + # create properties self.fp_op_mode_timestamp = 0.0 #: The timestamp of the latest operation mode message self.fp_debug_events_timestamp = 0.0 #: The timestamp of the latest events message self.fp_version_response_timestamp = 0.0 #: The timestamp of the latest FP version info message self.fp_operation_mode = fp_enum_repository.FPOpModes.MODE_INIT.value #: The Operation Mode's value self.fp_operation_sub_mode = 0 #: The Operation Sub-Mode's value self.fp_logged_in = False #: The value showing if the user is logged in or not - self.fp_set_logged_in_status(False) self.fp_version = None #: The FP's version value self.fp_fpga_version = None #: The FP's FPGA version value self.fp_debug_events = [''] * self._FP_DEBUG_EVENT_LIST_COUNT #: The Debug Event's list @@ -132,16 +138,6 @@ self.dd_proxy = DDProxy(self.can_interface, self.logger, fp = self) #: The DD Proxy module (imitates commands sent by DD) - def fp_set_logged_in_status(self, logged_in: bool = False): - """ - Callback for fp logged in status change. - - @param logged_in: Logged in status for FP - @return: None - """ - self.fp_logged_in = logged_in - - @publish(["msg_id_fp_debug_event", "fp_debug_events_timestamp","fp_debug_events"]) def _handler_fp_debug_event_sync(self, message, timestamp = 0.0): """ @@ -242,6 +238,20 @@ self.fp_defeatured_timestamp = timestamp + @publish(["msg_id_fp_def_status_response", "fp_defeatured"]) + def _handler_fp_boost_pump_installed_response(self, message, timestamp = 0.0): + """ + Handler for response from FP regarding its boost pump installation status. + + @param message: defeatured respnse from FP + @return: None + """ + self.fp_p40_installed = struct.unpack('?', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) + + self.fp_defeatured_timestamp = timestamp + + def cmd_request_defeatured_status(self) -> int: """ Constructs and sends the FP defeatured status request @@ -260,7 +270,32 @@ logger = self.logger, can_interface = self.can_interface) + def cmd_request_boost_pump_install_status(self) -> int: + """ + Constructs and sends the FP defeatured status request + Constraints: + Must be logged into FP. + @return: 1 if successful, zero otherwise + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_fp_ch_id, + message_id=MsgIds.MSG_ID_FP_DEF_STATUS_REQUEST.value) + + self.logger.debug('Getting FP P40 Boost Pump installed status') + received_message = self.can_interface.send(message) + + # If there is content... + if received_message is not None: + self.logger.debug("Received FW ACK after requesting FP P40 Boost Pump installed configuration record.") + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + + + def cmd_op_mode_broadcast_interval_override(self, ms: int, reset: int = NO_RESET) -> int: """ Constructs and sends the measured op mode broadcast interval override command @@ -302,7 +337,7 @@ if received_message is not None: if received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] == 1: self.logger.debug("Success: Logged In") - self.fp_set_logged_in_status(True) + self.fp_logged_in = True self.cmd_request_defeatured_status() #self._send_ro_checkin_message() # Timer starts interval first #self.can_interface.transmit_interval_dictionary[self.callback_id].start()