Index: leahi_dialin/common/fp_defs.py =================================================================== diff -u -r77b01031a83baf68d337744afbaccb1015ef4550 -rfd6f015b1ff68a2ee15187722ec21b8898fce10c --- leahi_dialin/common/fp_defs.py (.../fp_defs.py) (revision 77b01031a83baf68d337744afbaccb1015ef4550) +++ leahi_dialin/common/fp_defs.py (.../fp_defs.py) (revision fd6f015b1ff68a2ee15187722ec21b8898fce10c) @@ -445,18 +445,18 @@ # ================================================== Enum Creators: Support ================================================== @unique class FPBoostPumpStates(DialinEnum): - PUMP_OFF_STATE = 0, # Pump Offline State - PUMP_CONTROL_TO_TARGET_FLOW_STATE = 1, # Boost pump control to target flow state - PUMP_CONTROL_TO_TARGET_PRESSURE_STATE = 2, # Boost pump control to max pressure state. - PUMP_OPEN_LOOP_STATE = 3, # Boost pump open loop state. + PUMP_OFF_STATE = 0 # Pump Offline State + PUMP_CONTROL_TO_TARGET_FLOW_STATE = 1 # Boost pump control to target flow state + PUMP_CONTROL_TO_TARGET_PRESSURE_STATE = 2 # Boost pump control to max pressure state. + PUMP_OPEN_LOOP_STATE = 3 # Boost pump open loop state. NUM_OF_BOOST_PUMP_STATES = 4 # Number of Boost pump states FPBoostPumpStates._str_list = { # Official Name : Accepted strings 'PUMP_OFF_STATE': ['closed', 'off', 'inactive', 'offline'], 'PUMP_CONTROL_TO_TARGET_FLOW_STATE': ['flow', 'target to flow', 'to flow'], 'PUMP_CONTROL_TO_TARGET_PRESSURE_STATE': ['pressure', 'target to pressure', 'to pressure', 'pres'], - 'PUMP_OPEN_LOOP_STATE': ['open', 'open loop'], + 'PUMP_OPEN_LOOP_STATE': ['open', 'open loop', 'on'], 'NUM_OF_BOOST_PUMP_STATES': [], } @@ -529,18 +529,18 @@ @unique class FPROPumpStates(DialinEnum): - PUMP_OFF_STATE = 0, # Pump Offline State - PUMP_CONTROL_TO_TARGET_FLOW_STATE = 1, # RO pump control to target flow state - PUMP_CONTROL_TO_TARGET_PRESSURE_STATE = 2, # RO pump control to max pressure state. - PUMP_OPEN_LOOP_STATE = 3, # RO pump open loop state. + PUMP_OFF_STATE = 0 # Pump Offline State + PUMP_CONTROL_TO_TARGET_FLOW_STATE = 1 # RO pump control to target flow state + PUMP_CONTROL_TO_TARGET_PRESSURE_STATE = 2 # RO pump control to max pressure state. + PUMP_OPEN_LOOP_STATE = 3 # RO pump open loop state. NUM_OF_RO_PUMP_STATES = 4 # Number of RO pump states FPROPumpStates._str_list = { # Official Name : Accepted strings 'PUMP_OFF_STATE': ['closed', 'off', 'inactive', 'offline'], 'PUMP_CONTROL_TO_TARGET_FLOW_STATE': ['flow', 'target to flow', 'to flow'], 'PUMP_CONTROL_TO_TARGET_PRESSURE_STATE': ['pressure', 'target to pressure', 'to pressure', 'pres'], - 'PUMP_OPEN_LOOP_STATE': ['open', 'open loop'], + 'PUMP_OPEN_LOOP_STATE': ['open', 'open loop', 'on'], 'NUM_OF_RO_PUMP_STATES': [], } Index: leahi_dialin/fp/filtration_purification.py =================================================================== diff -u -r99611eb808f4c73f50f70d68cc8331642a436d05 -rfd6f015b1ff68a2ee15187722ec21b8898fce10c --- leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision 99611eb808f4c73f50f70d68cc8331642a436d05) +++ leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision fd6f015b1ff68a2ee15187722ec21b8898fce10c) @@ -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 @@ -267,7 +277,32 @@ return False + 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 @@ -309,7 +344,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()