Commit 93785362 authored by Spencer Du's avatar Spencer Du

update

parent c403ff41
......@@ -57,43 +57,62 @@ class MainWindow(QtWidgets.QMainWindow):
deviceImport.triggered.connect(self.importbutton)
except:
print("No devices active")
readFile("list_of_device(s)_currently_active.txt")
readFile("list_of_device(s)_currently_active.txt")
def importbutton(self):
if not os.path.exists("laser.ini"):
client = device()
client.run()
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/add device")
client.subscribe("microscope/light_sheet_microscope/UI/add device")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/add device")
client.publish("microscope/light_sheet_microscope/UI/add device", json.dumps({"type": "system", "payload":{"cmd": "init device panel"}}, indent=2))
time.sleep(1)
client.loop_stop()
sender = self.sender()
self.fileName_UI = sender.text()
self.loadGUI()
print("Device panel initialised" + "\n")
else:
if os.path.exists("laser.ini"):
client = device()
client.run()
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/laser")
client.subscribe("microscope/light_sheet_microscope/UI/laser")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser")
client.publish("microscope/light_sheet_microscope/UI/laser", json.dumps({"type": "device", "payload":{"name": "laser", "cmd": "set config"}}, indent=2))
time.sleep(1)
client.loop_stop()
sender = self.sender()
self.fileName_UI = sender.text()
self.loadGUI()
client = device()
client.run()
client.loop_start()
print("Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/add device")
client.subscribe("microscope/light_sheet_microscope/UI/add device")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/add device")
client.publish("microscope/light_sheet_microscope/UI/add device", json.dumps({"type": "system", "payload":{"cmd": "init device panel"}}, indent=2))
time.sleep(1)
client.loop_stop()
sender = self.sender()
self.fileName_UI = sender.text()
self.loadGUI()
print("Device panel initialised" + "\n")
# def importbutton(self):
# if not os.path.exists("laser.ini"):
# client = device()
# client.run()
# client.loop_start()
# print("\n" + "Connected to broker")
# time.sleep(1)
# print("Subscribing to topic", "microscope/light_sheet_microscope/UI/add device")
# client.subscribe("microscope/light_sheet_microscope/UI/add device")
# print("Publishing message to topic", "microscope/light_sheet_microscope/UI/add device")
# client.publish("microscope/light_sheet_microscope/UI/add device", json.dumps({"type": "system", "payload":{"cmd": "init device panel"}}, indent=2))
# time.sleep(1)
# client.loop_stop()
# sender = self.sender()
# self.fileName_UI = sender.text()
# self.loadGUI()
# print("Device panel initialised" + "\n")
# else:
# if os.path.exists("laser.ini"):
# client = device()
# client.run()
# client.loop_start()
# print("\n" + "Connected to broker")
# time.sleep(1)
# print("Subscribing to topic", "microscope/light_sheet_microscope/UI/laser")
# client.subscribe("microscope/light_sheet_microscope/UI/laser")
# print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser")
# client.publish("microscope/light_sheet_microscope/UI/laser", json.dumps({"type": "device", "payload":{"name": "laser", "cmd": "set config"}}, indent=2))
# time.sleep(1)
# client.loop_stop()
# sender = self.sender()
# self.fileName_UI = sender.text()
# self.loadGUI()
def loadGUI(self):
module = __import__(self.fileName_UI.rstrip("\n"))
......@@ -116,10 +135,10 @@ class MainWindow(QtWidgets.QMainWindow):
print("Subscribing to topic", "microscope/light_sheet_microscope")
client.subscribe("microscope/light_sheet_microscope")
print("Publishing message to topic", "microscope/light_sheet_microscope")
client.publish("microscope/light_sheet_microscope", json.dumps({"cmd": "Microscope shutting down"}, indent=2))
client.publish("microscope/light_sheet_microscope", json.dumps({"cmd": "microscope shutting down"}, indent=2))
time.sleep(1)
client.loop_stop()
print("Microscope shut down")
print("microscope shut down")
if __name__ == "__main__":
app = QApplication(sys.argv)
......
[Filter wheels]
left filter wheel = 2
right filter wheel = 2
left magnification changer = 22.2x
right magnification changer = 22.2x
......@@ -91,7 +91,6 @@ class Ui_FilterWheel(object):
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.comboBox_2.setItemText(6, "")
self.gridLayout.addWidget(self.comboBox_2, 2, 2, 2, 1)
FilterWheel.setCentralWidget(self.centralwidget)
......
[laser]
status = off
This diff is collapsed.
laser
cameras
webcam
stage
filter_wheel
......@@ -122,5 +122,9 @@ class embedded(mqtt.Client):
dac = Pmod_DAC(base.PMODA)
dac.write(m_in["payload"]["voltage"])
if message.topic == "microscope/light_sheet_microscope" and m_in["cmd"] == "microscope shutting down":
client.loop_stop()
client.disconnect()
def run(self):
self.connect("broker.hivemq.com", 1883, 60)
self.connect("broker.hivemq.com", 1883, 60)
\ No newline at end of file
Markdown is supported
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