Commit 08e05402 authored by Spencer Du's avatar Spencer Du

pub/sub added for laser wavelength

parent 22393bfa
......@@ -53,6 +53,6 @@ client.run()
client.loop_start()
print("Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/states")
client.subscribe("microscope/light_sheet_microscope/UI/states")
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/445nm")
client.subscribe("microscope/light_sheet_microscope/UI/445nm")
client.loop_forever()
\ No newline at end of file
......@@ -8,6 +8,9 @@
from PyQt5 import QtCore, QtGui, QtWidgets
import paho.mqtt.client as mqtt
from mqtt import *
import time
class Ui_Laser(object):
def setupUi(self, Laser):
......@@ -131,6 +134,7 @@ class Ui_Laser(object):
self.pushButton_9 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_9.setGeometry(QtCore.QRect(0, 260, 41, 19))
self.pushButton_9.setObjectName("pushButton_9")
self.pushButton_9.clicked.connect(self.printValue)
self.pushButton_10 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_10.setGeometry(QtCore.QRect(50, 260, 41, 19))
self.pushButton_10.setObjectName("pushButton_10")
......@@ -239,14 +243,37 @@ class Ui_Laser(object):
self.label_20.setText(_translate("Laser", "0"))
self.label_21.setText(_translate("Laser", "100l"))
def printValue(self):
textboxValue = self.lineEdit.text()
print("hi")
print(textboxValue)
if self.lineEdit.text() == "":
self.verticalSlider.setValue(0)
else:
self.verticalSlider.setValue(int(textboxValue))
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()
......
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