Index: leahi_dialin/dd/modules/balancing_chamber.py =================================================================== diff -u -ra01dcb7ce7e9f929e5e5f41414ace01ce69ad051 -r9466b5c6b5867f392104a42608aa9542a7ff0358 --- leahi_dialin/dd/modules/balancing_chamber.py (.../balancing_chamber.py) (revision a01dcb7ce7e9f929e5e5f41414ace01ce69ad051) +++ leahi_dialin/dd/modules/balancing_chamber.py (.../balancing_chamber.py) (revision 9466b5c6b5867f392104a42608aa9542a7ff0358) @@ -54,14 +54,15 @@ self.bal_chamber_fill_in_progress = 0 self.current_bal_chamber_switching_counter = 0 self.is_pressure_stabilized_during_fill = 0 + self.bal_chamber_switch_only_state = 0 self.dd_bal_chamber_timestamp = 0 @publish(["dd_bal_chamber_timestamp", "execution_state", "switching_state", "switching_frequency", "switching_period", "bal_chamber_fill_in_progress", "current_bal_chamber_switching_counter", - "is_pressure_stabilized_during_fill"]) + "is_pressure_stabilized_during_fill", "bal_chamber_switch_only_state"]) def _handler_balancing_chamber_sync(self, message, timestamp=0.0): """ Handles published balancing chamber data messages. @@ -84,6 +85,8 @@ message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] self.is_pressure_stabilized_during_fill = struct.unpack('I', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] + self.bal_chamber_switch_only_state = struct.unpack('I', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] self.dd_bal_chamber_timestamp = timestamp @@ -126,6 +129,8 @@ def cmd_switch_frequency_override(self, frequency: float, reset: int = NO_RESET) -> int: """ Constructs and sends the balancing chamber switch frequency override command + Constraints: + Must be logged into DD. @param frequency: float - frequency value to override switch frequency with @param reset: integer - 1 to reset a previous override, 0 to override @@ -156,4 +161,35 @@ return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] else: self.logger.error("Timeout!!!!") + return False + + def cmd_switch_only_start_stop_override(self, start_stop: int, flow: float) -> int: + """ + Constructs and sends the balancing chamber switch only start stop override command + Constraints: + Must be logged into DD. + + @param start_stop: int - value to start or stop switch ( start = 1, stop = 0 + @param flow: float - flow rate in ml/min + @return: 1 if successful, zero otherwise + + """ + + sts = integer_to_bytearray(start_stop) + freq = float_to_bytearray(flow) + payload = sts + freq + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dd_ch_id, + message_id=MsgIds.MSG_ID_DD_BC_SWITCH_ONLY_START_STOP_OVERRIDE_REQUEST.value, + payload=payload) + + # Send message + received_message = self.can_interface.send(message) + + # If there is 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.error("Timeout!!!!") return False \ No newline at end of file