Commit 335bc31d authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Fixes bug due to a remainig self.run in ohmpi

Showing with 7 additions and 4 deletions
+7 -4
......@@ -6,6 +6,7 @@ import zmq
ctrl_queue = Queue()
def on_message(client, userdata, message):
global socket
......@@ -17,6 +18,7 @@ def on_message(client, userdata, message):
reply = socket.recv()
print(f'Received reply {message.payload.decode("utf-8")}: {reply}')
mqtt_client = mqtt.Client(f'ohmpi_{OHMPI_CONFIG["id"]}_listener', clean_session=False) # create new instance
print('connecting command listener to broker')
trials = 0
......@@ -24,14 +26,15 @@ trials_max = 10
broker_connected = False
while trials < trials_max:
try:
mqtt_client.username_pw_set(MQTT_CONTROL_CONFIG['auth'].get('username'),MQTT_CONTROL_CONFIG['auth']['password'])
mqtt_client.username_pw_set(MQTT_CONTROL_CONFIG['auth'].get('username'),
MQTT_CONTROL_CONFIG['auth']['password'])
mqtt_client.connect(MQTT_CONTROL_CONFIG['hostname'])
trials = trials_max
broker_connected = True
except:
print('trying again...')
time.sleep(2)
trials+=1
trials += 1
if broker_connected:
print('Subscribing to topic', MQTT_CONTROL_CONFIG['ctrl_topic'])
mqtt_client.subscribe(MQTT_CONTROL_CONFIG['ctrl_topic'], MQTT_CONTROL_CONFIG['qos'])
......@@ -45,7 +48,7 @@ if broker_connected:
socket.connect(f'tcp://localhost:{CONTROL_CONFIG["tcp_port"]}')
while True:
time.sleep(.1)
time.sleep(.1)
else:
print("Unable to connect to broker")
exit(1)
......@@ -745,7 +745,7 @@ class OhmPi(object):
# measure all quadrupole of the sequence
for i in range(0, self.sequence.shape[0]):
quad = self.sequence[i, :] # quadrupole
if self.run is False:
if self.status == 'stopping':
break
# call the switch_mux function to switch to the right electrodes
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment