Commit 07df5a64 authored by Spencer Du's avatar Spencer Du

code fixing

parent 28377abd
[445nm]
intensity = 2
[Subscriptions]
445nm = {"type": "device", "payload": {"name": "laser", "wavelength": "445nm", "intensity": "2", "cmd": "set intensity of laser"}}
488nm = {"type": "device", "payload": {"name": "laser", "wavelength": "488nm", "intensity": "2", "cmd": "set intensity of laser"}}
515nm = {"type": "device", "payload": {"name": "laser", "wavelength": "515nm", "intensity": "2", "cmd": "set intensity of laser"}}
561nm = {"type": "device", "payload": {"name": "laser", "wavelength": "561nm", "intensity": "2", "cmd": "set intensity of laser"}}
594nm = {"type": "device", "payload": {"name": "laser", "wavelength": "594nm", "intensity": "2", "cmd": "set intensity of laser"}}
638nm = {"type": "device", "payload": {"name": "laser", "wavelength": "638nm", "intensity": "2", "cmd": "set intensity of laser"}}
[488nm]
intensity = 2
[515nm]
intensity = 2
[561nm]
intensity = 2
[594nm]
intensity = 2
[638nm]
intensity = 2
......@@ -341,13 +341,15 @@ class Ui_Laser(object):
print("Intensity: " + textboxValue)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
f = open("laser.ini", "w")
config.add_section("445nm")
config.set("445nm", "intensity", textboxValue)
config.add_section("Subscriptions")
config.set("Subscriptions", "445nm", "{'type': 'device', 'payload':{'name': 'laser', 'wavelength': '445nm', 'intensity': textboxValue, 'cmd': 'set intensity of laser'}}")
config.set("Subscriptions", "445nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "445nm", "intensity": textboxValue, "cmd": "set intensity of laser"}}))
config.write(f)
else:
textboxValue = self.lineEdit.text()
if self.lineEdit.text() == "":
......@@ -369,14 +371,17 @@ class Ui_Laser(object):
print("Intensity: " + textboxValue)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("445nm")
config.set("445nm", "intensity", textboxValue)
config.set("Subscriptions", "445nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "445nm", "intensity": textboxValue, "cmd": "set intensity of laser"}}))
config.write(f)
def printValue2(self):
if not os.path.exists("laserConfig.json"):
if not os.path.exists("laser.ini"):
textboxValue2 = self.lineEdit.text()
if self.lineEdit_2.text() == "":
self.verticalSlider_2.setValue(0)
......@@ -398,12 +403,15 @@ class Ui_Laser(object):
print("Intensity: " + textboxValue2)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
f = open("laser.ini", "w")
config.add_section("488nm")
config.set("488nm", "intensity", textboxValue2)
config.add_section("Subscriptions")
config.set("Subscriptions", "488nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "488nm", "intensity": textboxValue2, "cmd": "set intensity of laser"}}))
config.write(f)
else:
textboxValue2 = self.lineEdit_2.text()
if self.lineEdit_2.text() == "":
......@@ -425,14 +433,18 @@ class Ui_Laser(object):
print("Intensity: " + textboxValue2)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("488nm")
config.set("488nm", "intensity", textboxValue2)
config.set("Subscriptions", "488nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "488nm", "intensity": textboxValue2, "cmd": "set intensity of laser"}}))
config.write(f)
def printValue3(self):
if not os.path.exists("laserConfig.json"):
if not os.path.exists("laser.ini"):
textboxValue3 = self.lineEdit_3.text()
if self.lineEdit_3.text() == "":
self.verticalSlider_3.setValue(0)
......@@ -453,11 +465,14 @@ class Ui_Laser(object):
client.loop_stop()
print("Intensity: " + textboxValue3)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
f = open("laser.ini", "w")
config.add_section("515nm")
config.set("515nm", "intensity", textboxValue3)
config.add_section("Subscriptions")
config.set("Subscriptions", "515nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "515nm", "intensity": textboxValue3, "cmd": "set intensity of laser"}}))
config.write(f)
else:
......@@ -480,15 +495,18 @@ class Ui_Laser(object):
client.loop_stop()
print("Intensity: " + textboxValue3)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("515nm")
config.set("515nm", "intensity", textboxValue3)
config.set("Subscriptions", "515nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "515nm", "intensity": textboxValue3, "cmd": "set intensity of laser"}}))
config.write(f)
def printValue4(self):
if not os.path.exists("laserConfig.json"):
if not os.path.exists("laser.ini"):
textboxValue4 = self.lineEdit_4.text()
if self.lineEdit_4.text() == "":
self.verticalSlider_4.setValue(0)
......@@ -509,11 +527,14 @@ class Ui_Laser(object):
client.loop_stop()
print("Intensity: " + textboxValue4)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
f = open("laser.ini", "w")
config.add_section("561nm")
config.set("561nm", "intensity", textboxValue4)
config.add_section("Subscriptions")
config.set("Subscriptions", "561nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "561nm", "intensity": textboxValue4, "cmd": "set intensity of laser"}}))
config.write(f)
else:
......@@ -536,15 +557,18 @@ class Ui_Laser(object):
client.loop_stop()
print("Intensity: " + textboxValue4)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("561nm")
config.set("561nm", "intensity", textboxValue4)
config.set("Subscriptions", "561nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "561nm", "intensity": textboxValue4, "cmd": "set intensity of laser"}}))
config.write(f)
def printValue5(self):
if not os.path.exists("laserConfig.json"):
if not os.path.exists("laser.ini"):
textboxValue5 = self.lineEdit_5.text()
if self.lineEdit_5.text() == "":
self.verticalSlider_5.setValue(0)
......@@ -565,11 +589,14 @@ class Ui_Laser(object):
client.loop_stop()
print("Intensity: " + textboxValue5)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
f = open("laser.ini", "w")
config.add_section("594nm")
config.set("594nm", "intensity", textboxValue5)
config.add_section("Subscriptions")
config.set("Subscriptions", "594nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "594nm", "intensity": textboxValue5, "cmd": "set intensity of laser"}}))
config.write(f)
else:
......@@ -592,15 +619,18 @@ class Ui_Laser(object):
client.loop_stop()
print("Intensity: " + textboxValue5)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("594nm")
config.set("594nm", "intensity", textboxValue5)
config.set("Subscriptions", "594nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "594nm", "intensity": textboxValue5, "cmd": "set intensity of laser"}}))
config.write(f)
def printValue6(self):
if not os.path.exists("laserConfig.json"):
if not os.path.exists("laser.ini"):
textboxValue6 = self.lineEdit_6.text()
if self.lineEdit_6.text() == "":
self.verticalSlider_6.setValue(0)
......@@ -621,11 +651,14 @@ class Ui_Laser(object):
client.loop_stop()
print("Intensity: " + textboxValue6)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("638nm")
config.set("638nm", "intensity", textboxValue6)
config.set("Subscriptions", "638nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "638nm", "intensity": textboxValue6, "cmd": "set intensity of laser"}}))
config.write(f)
else:
......@@ -649,26 +682,15 @@ class Ui_Laser(object):
print("Intensity: " + textboxValue6)
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
config.read("laser.ini")
f = open("laser.ini", "w")
config.add_section("638nm")
config.set("638nm", "intensity", textboxValue6)
config.set("Subscriptions", "638nm", json.dumps({"type": "device", "payload":{"name": "laser", "wavelength": "638nm", "intensity": textboxValue6, "cmd": "set intensity of laser"}}))
config.write(f)
def configSubscriptions():
if os.path.exists("laser.ini"):
f = open("laser.ini", "a+")
config = configparser.RawConfigParser()
config.add_section("Subscriptions")
config.set("Subscriptions", "445nm", "{'type': 'device', 'payload':{'name': 'laser', 'wavelength': '445nm', 'intensity': textboxValue, 'cmd': 'set intensity of laser'}}")
config.set("Subscriptions", "488nm", "{'type': 'device', 'payload':{'name': 'laser', 'wavelength': '488nm', 'intensity': textboxValue2, 'cmd': 'set intensity of laser'}}")
config.set("Subscriptions", "515nm", "{'type': 'device', 'payload':{'name': 'laser', 'wavelength': '515nm', 'intensity': textboxValue3, 'cmd': 'set intensity of laser'}}")
config.set("Subscriptions", "561nm", "{'type': 'device', 'payload':{'name': 'laser', 'wavelength': '561nm', 'intensity': textboxValue4, 'cmd': 'set intensity of laser'}}")
config.set("Subscriptions", "594nm", "{'type': 'device', 'payload':{'name': 'laser', 'wavelength': '594nm', 'intensity': textboxValue5, 'cmd': 'set intensity of laser'}}")
config.set("Subscriptions", "638nm", "{'type': 'device', 'payload':{'name': 'laser', 'wavelength': '638nm', 'intensity': textboxValue6, 'cmd': 'set intensity of laser'}}")
config.write(f)
configSubscriptions()
# def printValue7(self):
# textboxValue7 = self.lineEdit_7.text()
# print("hi")
......
{
"laser": [
{
"type": "device",
"payload": {
"name": "laser",
"wavelength": "445nm",
"intensity": "2",
"cmd": "set intensity of laser"
}
}
]
}
\ No newline at end of file
from PyQt5 import QtWidgets
from laser2 import Ui_Laser
import sys
def printValue(self):
textboxValue = self.lineEdit.text()
# client = device()
# client.run()
class ApplicationWindow(QtWidgets.QMainWindow):
def __init__(self):
super(ApplicationWindow, self).__init__()
# client.loop_start()
# print("Connected to broker")
# time.sleep(1)
# print("Subscribing to topic", "microscope/light_sheet_microscope/UI/445nm")
# client.subscribe("microscope/light_sheet_microscope/UI/445nm")
# print("Publishing message to topic", "microscope/light_sheet_microscope/UI/445nm")
# client.publish("microscope/light_sheet_microscope/UI/44nm", json.dumps({"type": "device", "payload":{"wavelength": "445nm", "intensity": textboxValue, "cmd": "set intensity of laser"}}, indent=2))
# time.sleep(1)
# client.loop_stop()
if self.lineEdit.text() == "":
self.verticalSlider.setValue(0)
else:
self.verticalSlider.setValue(int(textboxValue))
self.ui = Ui_Laser()
self.ui.setupUi(self)
client = device()
client.run()
def main():
app = QtWidgets.QApplication(sys.argv)
application = ApplicationWindow()
application.show()
sys.exit(app.exec_())
client.loop_start()
print("Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/445nm")
client.subscribe("microscope/light_sheet_microscope/UI/445nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/445nm")
client.publish("microscope/light_sheet_microscope/UI/445nm", json.dumps({"type": "device", "payload":{"wavelength": "445nm", "intensity": "gu", "cmd": "set intensity of laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
def printValue2(self):
textboxValue2 = self.lineEdit_2.text()
print("hi")
print(textboxValue2)
if self.lineEdit_2.text() == "":
self.verticalSlider_2.setValue(0)
else:
self.verticalSlider_2.setValue(int(textboxValue2))
def printValue3(self):
textboxValue3 = self.lineEdit_3.text()
print("hi")
print(textboxValue3)
if self.lineEdit_3.text() == "":
self.verticalSlider_3.setValue(0)
else:
self.verticalSlider_3.setValue(int(textboxValue3))
def printValue4(self):
textboxValue4 = self.lineEdit_4.text()
print("hi")
print(textboxValue4)
if self.lineEdit_4.text() == "":
self.verticalSlider_4.setValue(0)
else:
self.verticalSlider_4.setValue(int(textboxValue4))
def printValue5(self):
textboxValue5 = self.lineEdit_5.text()
print("hi")
print(textboxValue5)
if self.lineEdit_5.text() == "":
self.verticalSlider_5.setValue(0)
else:
self.verticalSlider_5.setValue(int(textboxValue5))
def printValue6(self):
textboxValue6 = self.lineEdit_6.text()
print("hi")
print(textboxValue6)
if self.lineEdit_6.text() == "":
self.verticalSlider_6.setValue(0)
else:
self.verticalSlider_6.setValue(int(textboxValue6))
def printValue7(self):
textboxValue7 = self.lineEdit_7.text()
print("hi")
print(textboxValue7)
if self.lineEdit_7.text() == "":
self.verticalSlider_7.setValue(0)
else:
self.verticalSlider_7.setValue(int(textboxValue7))
if __name__ == "__main__":
main()
\ No newline at end of file
import sys
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
app = QtWidgets.QApplication(sys.argv)
Laser = QtWidgets.QMainWindow()
ui = Ui_Laser()
ui.setupUi(Laser)
Laser.show()
sys.exit(app.exec_())
\ No newline at end of file
def printValue(self):
textboxValue = self.lineEdit.text()
# client = device()
# client.run()
# client.loop_start()
# print("Connected to broker")
# time.sleep(1)
# print("Subscribing to topic", "microscope/light_sheet_microscope/UI/445nm")
# client.subscribe("microscope/light_sheet_microscope/UI/445nm")
# print("Publishing message to topic", "microscope/light_sheet_microscope/UI/445nm")
# client.publish("microscope/light_sheet_microscope/UI/44nm", json.dumps({"type": "device", "payload":{"wavelength": "445nm", "intensity": textboxValue, "cmd": "set intensity of laser"}}, indent=2))
# time.sleep(1)
# client.loop_stop()
if self.lineEdit.text() == "":
self.verticalSlider.setValue(0)
else:
self.verticalSlider.setValue(int(textboxValue))
client = device()
client.run()
client.loop_start()
print("Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/445nm")
client.subscribe("microscope/light_sheet_microscope/UI/445nm")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/445nm")
client.publish("microscope/light_sheet_microscope/UI/445nm", json.dumps({"type": "device", "payload":{"wavelength": "445nm", "intensity": "gu", "cmd": "set intensity of laser"}}, indent=2))
time.sleep(1)
client.loop_stop()
def printValue2(self):
textboxValue2 = self.lineEdit_2.text()
print("hi")
print(textboxValue2)
if self.lineEdit_2.text() == "":
self.verticalSlider_2.setValue(0)
else:
self.verticalSlider_2.setValue(int(textboxValue2))
def printValue3(self):
textboxValue3 = self.lineEdit_3.text()
print("hi")
print(textboxValue3)
if self.lineEdit_3.text() == "":
self.verticalSlider_3.setValue(0)
else:
self.verticalSlider_3.setValue(int(textboxValue3))
def printValue4(self):
textboxValue4 = self.lineEdit_4.text()
print("hi")
print(textboxValue4)
if self.lineEdit_4.text() == "":
self.verticalSlider_4.setValue(0)
else:
self.verticalSlider_4.setValue(int(textboxValue4))
def printValue5(self):
textboxValue5 = self.lineEdit_5.text()
print("hi")
print(textboxValue5)
if self.lineEdit_5.text() == "":
self.verticalSlider_5.setValue(0)
else:
self.verticalSlider_5.setValue(int(textboxValue5))
def printValue6(self):
textboxValue6 = self.lineEdit_6.text()
print("hi")
print(textboxValue6)
if self.lineEdit_6.text() == "":
self.verticalSlider_6.setValue(0)
else:
self.verticalSlider_6.setValue(int(textboxValue6))
def printValue7(self):
textboxValue7 = self.lineEdit_7.text()
print("hi")
print(textboxValue7)
if self.lineEdit_7.text() == "":
self.verticalSlider_7.setValue(0)
else:
self.verticalSlider_7.setValue(int(textboxValue7))
if __name__ == "__main__":
import sys
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
app = QtWidgets.QApplication(sys.argv)
Laser = QtWidgets.QMainWindow()
ui = Ui_Laser()
ui.setupUi(Laser)
Laser.show()
sys.exit(app.exec_())
\ 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