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
......@@ -197,6 +197,25 @@ class Ui_Laser(object):
self.pushButton_8 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_8.setCheckable(True)
self.pushButton_8.setChecked(True)
# try:
if not os.path.exists("laser.ini"):
print("Laser turned on")
print("LED 0 turning on")
try:
base = BaseOverlay("base.bit")
led0 = base.leds[0]
led0.on()
except Exception as e:
pass
config = configparser.RawConfigParser()
f = open("laser.ini", "w")
config.add_section("laser")
config.set("laser", "status", "on")
config.write(f)
else:
pass
self.pushButton_8.clicked.connect(self.on)
self.pushButton_8.setObjectName("pushButton_8")
self.gridLayout.addWidget(self.pushButton_8, 1, 0, 1, 2)
......@@ -219,7 +238,7 @@ class Ui_Laser(object):
QtCore.QMetaObject.connectSlotsByName(Laser)
def btnstate(self):
if not os.path.exists("laser.ini"):
if os.path.exists("laser.ini"):
if self.pushButton.isChecked():
client = device()
client.run()
......@@ -235,6 +254,14 @@ class Ui_Laser(object):
client.loop_stop()
print("445nm laser turned on")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("445nm")
config.set("445nm", "status", "on")
config.write(f)
self.pushButton_9.clicked.connect(self.printValue)
else:
self.pushButton_9.clicked.connect(self.printValue)
......@@ -253,55 +280,24 @@ class Ui_Laser(object):
client.publish("microscope/light_sheet_microscope/UI/laser/445nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "445nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("445nm laser turned off")
else:
if self.pushButton.isChecked():
client = device()
client.run()
print("445nm laser turned off")
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/laser/445nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/445nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/445nm")
client.publish("microscope/light_sheet_microscope/UI/laser/445nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "445nm", "cmd": "turning on laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("445nm laser turned on")
self.pushButton_9.clicked.connect(self.printValue)
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
try:
self.verticalSlider.setValue(config.getint("445nm", "intensity"))
self.lineEdit.setText(str(config.getint("445nm", "intensity")))
config.add_section("445nm")
except Exception as e:
pass
else:
try:
self.pushButton_9.clicked.disconnect(self.printValue)
config.set("445nm", "status", "off")
except Exception as e:
pass
self.verticalSlider.setValue(0)
self.lineEdit.clear()
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/445nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/445nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/445nm")
client.publish("microscope/light_sheet_microscope/UI/laser/445nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "445nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("445nm laser turned off")
config.write(f)
def btnstate2(self):
if not os.path.exists("laser.ini"):
if os.path.exists("laser.ini"):
if self.pushButton_2.isChecked():
client = device()
client.run()
......@@ -317,12 +313,20 @@ class Ui_Laser(object):
client.loop_stop()
print("488nm laser turned on")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("488nm")
config.set("488nm", "status", "on")
config.write(f)
self.pushButton_10.clicked.connect(self.printValue2)
else:
self.pushButton_10.clicked.connect(self.printValue2)
self.pushButton_10.clicked.disconnect(self.printValue2)
self.verticalSlider_2.setValue(0)
self.lineEdit_3.clear()
self.lineEdit_2.clear()
client = device()
client.run()
......@@ -335,56 +339,24 @@ class Ui_Laser(object):
client.publish("microscope/light_sheet_microscope/UI/laser/488nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "488nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("488nm laser turned off")
else:
if self.pushButton_2.isChecked():
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/488nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/488nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/488nm")
client.publish("microscope/light_sheet_microscope/UI/laser/488nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "488nm", "cmd": "turning on laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("488nm laser turned on")
self.pushButton_10.clicked.connect(self.printValue2)
print("488nm laser turned off")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
try:
self.verticalSlider_2.setValue(config.getint("488nm", "intensity"))
self.lineEdit_2.setText(str(config.getint("488nm", "intensity")))
config.add_section("488nm")
except Exception as e:
pass
else:
self.pushButton_10.clicked.connect(self.printValue2)
self.pushButton_10.clicked.disconnect(self.printValue2)
self.verticalSlider_2.setValue(0)
self.lineEdit_2.clear()
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/488nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/488nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/488nm")
client.publish("microscope/light_sheet_microscope/UI/laser/488nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "488nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("488nm laser turned off")
try:
config.set("488nm", "status", "off")
except Exception as e:
pass
config.write(f)
def btnstate3(self):
if not os.path.exists("laser.ini"):
if os.path.exists("laser.ini"):
if self.pushButton_3.isChecked():
client = device()
client.run()
......@@ -400,6 +372,14 @@ class Ui_Laser(object):
client.loop_stop()
print("515nm laser turned on")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("515nm")
config.set("515nm", "status", "on")
config.write(f)
self.pushButton_11.clicked.connect(self.printValue3)
else:
self.pushButton_11.clicked.connect(self.printValue3)
......@@ -418,55 +398,24 @@ class Ui_Laser(object):
client.publish("microscope/light_sheet_microscope/UI/laser/515nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "515nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("515nm laser turned off")
else:
if self.pushButton_3.isChecked():
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/515nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/515nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/515nm")
client.publish("microscope/light_sheet_microscope/UI/laser/515nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "515nm", "cmd": "turning on laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("515nm laser turned on")
self.pushButton_11.clicked.connect(self.printValue3)
print("515nm laser turned off")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
try:
self.verticalSlider_3.setValue(config.getint("515nm", "intensity"))
self.lineEdit_3.setText(str(config.getint("515nm", "intensity")))
config.add_section("515nm")
except Exception as e:
pass
else:
self.pushButton_11.clicked.disconnect(self.printValue3)
self.verticalSlider_3.setValue(0)
self.lineEdit_3.clear()
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/515nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/515nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/515nm")
client.publish("microscope/light_sheet_microscope/UI/laser/515nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "515nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("515nm laser turned off")
pass
try:
config.set("515nm", "status", "off")
except Exception as e:
pass
config.write(f)
def btnstate4(self):
if not os.path.exists("laser.ini"):
if os.path.exists("laser.ini"):
if self.pushButton_4.isChecked():
client = device()
client.run()
......@@ -482,6 +431,14 @@ class Ui_Laser(object):
client.loop_stop()
print("561nm laser turned on")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("561nm")
config.set("561nm", "status", "on")
config.write(f)
self.pushButton_12.clicked.connect(self.printValue4)
else:
self.pushButton_12.clicked.connect(self.printValue4)
......@@ -500,55 +457,24 @@ class Ui_Laser(object):
client.publish("microscope/light_sheet_microscope/UI/laser/561nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "561nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("561nm laser turned off")
else:
if self.pushButton_4.isChecked():
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/561nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/561nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/561nm")
client.publish("microscope/light_sheet_microscope/UI/laser/561nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "561nm", "cmd": "turning on laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("561nm laser turned on")
self.pushButton_12.clicked.connect(self.printValue4)
print("561nm laser turned off")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
try:
self.verticalSlider_4.setValue(config.getint("561nm", "intensity"))
self.lineEdit_4.setText(str(config.getint("561nm", "intensity")))
config.add_section("561nm")
except Exception as e:
pass
else:
self.pushButton_12.clicked.disconnect(self.printValue4)
self.verticalSlider_4.setValue(0)
self.lineEdit_4.clear()
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/561nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/561nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/561nm")
client.publish("microscope/light_sheet_microscope/UI/laser/561nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "561nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("515nm laser turned off")
try:
config.set("561nm", "status", "off")
except Exception as e:
pass
config.write(f)
def btnstate5(self):
if not os.path.exists("laser.ini"):
if os.path.exists("laser.ini"):
if self.pushButton_5.isChecked():
client = device()
client.run()
......@@ -564,12 +490,20 @@ class Ui_Laser(object):
client.loop_stop()
print("594nm laser turned on")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("594nm")
config.set("594nm", "status", "on")
config.write(f)
self.pushButton_13.clicked.connect(self.printValue5)
else:
self.pushButton_13.clicked.connect(self.printValue5)
self.pushButton_13.clicked.disconnect(self.printValue5)
self.verticalSlider_3.setValue(0)
self.lineEdit_3.clear()
self.verticalSlider_5.setValue(0)
self.lineEdit_5.clear()
client = device()
client.run()
......@@ -582,55 +516,24 @@ class Ui_Laser(object):
client.publish("microscope/light_sheet_microscope/UI/laser/594nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "594nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("594nm laser turned off")
else:
if self.pushButton_5.isChecked():
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/594nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/594nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/594nm")
client.publish("microscope/light_sheet_microscope/UI/laser/594nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "594nm", "cmd": "turning on laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("594nm laser turned on")
self.pushButton_13.clicked.connect(self.printValue5)
print("594nm laser turned off")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
try:
self.verticalSlider_5.setValue(config.getint("594nm", "intensity"))
self.lineEdit_5.setText(str(config.getint("594nm", "intensity")))
config.add_section("594nm")
except Exception as e:
pass
else:
self.pushButton_13.clicked.disconnect(self.printValue5)
self.verticalSlider_5.setValue(0)
self.lineEdit_5.clear()
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/594nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/594nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/594nm")
client.publish("microscope/light_sheet_microscope/UI/laser/594nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "594nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("594nm laser turned off")
try:
config.set("594nm", "status", "off")
except Exception as e:
pass
config.write(f)
def btnstate6(self):
if not os.path.exists("laser.ini"):
if os.path.exists("laser.ini"):
if self.pushButton_6.isChecked():
client = device()
client.run()
......@@ -646,6 +549,14 @@ class Ui_Laser(object):
client.loop_stop()
print("638nm laser turned on")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("638nm")
config.set("638nm", "status", "on")
config.write(f)
self.pushButton_14.clicked.connect(self.printValue6)
else:
self.pushButton_14.clicked.connect(self.printValue6)
......@@ -664,55 +575,24 @@ class Ui_Laser(object):
client.publish("microscope/light_sheet_microscope/UI/laser/638nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "638nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("638nm laser turned off")
else:
if self.pushButton_6.isChecked():
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/638nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/638nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/638nm")
client.publish("microscope/light_sheet_microscope/UI/laser/638nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "638nm", "cmd": "turning on laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("638nm laser turned on")
self.pushButton_14.clicked.connect(self.printValue6)
print("638nm laser turned off")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
try:
self.verticalSlider_6.setValue(config.getint("638nm", "intensity"))
self.lineEdit_6.setText(str(config.getint("638nm", "intensity")))
config.add_section("638nm")
except Exception as e:
pass
else:
self.pushButton_14.clicked.disconnect(self.printValue6)
self.verticalSlider_6.setValue(0)
self.lineEdit_6.clear()
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/638nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/638nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/638nm")
client.publish("microscope/light_sheet_microscope/UI/laser/638nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "638nm", "cmd": "turning off laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("638nm laser turned off")
pass
try:
config.set("638nm", "status", "off")
except Exception as e:
pass
config.write(f)
def printValue(self):
if not os.path.exists("laser.ini"):
if os.path.exists("laser.ini"):
textboxValue = self.lineEdit.text()
if self.lineEdit.text() == "":
self.verticalSlider.setValue(0)
......@@ -736,41 +616,6 @@ class Ui_Laser(object):
print("Intensity: " + textboxValue + "%")
print("Voltage: " + str(voltage) + "V")
config = configparser.RawConfigParser()
f = open("laser.ini", "w")
config.add_section("445nm")
config.set("445nm", "intensity", textboxValue + "%")
config.set("445nm", "voltage", str(voltage) + "V")
config.add_section("Subscriptions")
config.set("Subscriptions", "445nm", "microscope/light_sheet_microscope/UI/laser/445nm")
config.write(f)
else:
textboxValue = self.lineEdit.text()
if self.lineEdit.text() == "":
self.verticalSlider.setValue(0)
else:
self.verticalSlider.setValue(int(textboxValue))
voltage = (float(textboxValue) / float(100)) * float(2.5)
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/445nm")
client.subscribe("microscope/light_sheet_microscope/UI/laser/445nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/laser/445nm")
client.publish("microscope/light_sheet_microscope/UI/laser/445nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "445nm", "intensity": textboxValue + "%", "voltage": str(voltage) + "V", "cmd": "set intensity of laser"}}, indent=2))
time.sleep(1)
client.loop_stop()