Commit 6fa43452 authored by Spencer Du's avatar Spencer Du

update

parent bd8e2da4
......@@ -205,10 +205,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "exposure time": textboxValue, "cmd": "set exposure time of cameras"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "exposure time": textboxValue, "cmd": "set exposure time of cameras"}}, indent=2))
time.sleep(1)
client.loop_stop()
......@@ -238,10 +238,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "delay": textboxValue2, "cmd": "set delay of cameras"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "delay": textboxValue2, "cmd": "set delay of cameras"}}, indent=2))
time.sleep(1)
client.loop_stop()
......@@ -272,10 +272,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "left camera mode": leftMode, "left camera lines": textboxValue3 + "px", "cmd": "set left camera mode and left camera lines"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "left camera mode": leftMode, "left camera lines": textboxValue3 + "px", "cmd": "set left camera mode and left camera lines"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Left camera mode: " + leftMode)
......@@ -310,10 +310,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "right camera mode": rightMode, "right camera lines": textboxValue4 + "px", "cmd": "set right camera mode and right camera lines"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "right camera mode": rightMode, "right camera lines": textboxValue4 + "px", "cmd": "set right camera mode and right camera lines"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Right camera mode: " + rightMode)
......@@ -347,10 +347,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "top ROI": textboxValue5 + "px", "cmd": "set top ROI"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "top ROI": textboxValue5 + "px", "cmd": "set top ROI"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Top ROI: " + textboxValue5 + "px")
......@@ -379,10 +379,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "left ROI": textboxValue6 + "px", "cmd": "set left ROI"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "left ROI": textboxValue6 + "px", "cmd": "set left ROI"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Left ROI: " + textboxValue6 + "px")
......@@ -411,10 +411,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "width ROI": textboxValue7 + "px", "cmd": "set width ROI"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "width ROI": textboxValue7 + "px", "cmd": "set width ROI"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Width ROI: " + textboxValue7 + "px")
......@@ -443,10 +443,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "height ROI": textboxValue8 + "px", "cmd": "set height ROI"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "height ROI": textboxValue8 + "px", "cmd": "set height ROI"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Height ROI: " + textboxValue8 + "px")
......@@ -477,10 +477,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "cmd": "cameras turning on"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "cmd": "cameras turning on"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Cameras turned on")
......@@ -570,10 +570,10 @@ class Ui_Cameras(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/cameras")
client.subscribe("microscope/light_sheet_microscope/UI/cameras")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/cameras")
client.publish("microscope/light_sheet_microscope/UI/cameras", json.dumps({"type": "device", "payload":{"name": "cameras", "cmd": "device turning off"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/cameras/UI")
client.subscribe("microscope/light_sheet_microscope/cameras/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/cameras/UI")
client.publish("microscope/light_sheet_microscope/cameras/UI", json.dumps({"type": "device", "payload":{"name": "cameras", "cmd": "device turning off"}}, indent=2))
time.sleep(1)
client.loop_stop()
......
import random
import asyncio
from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference
from mqtt2 import *
class Cameras(Actor):
async def handle_message(self, message: Message):
......@@ -25,10 +26,10 @@ async def main():
print(reply.data)
asyncio.get_event_loop().run_until_complete(main())
def subscribe():
def subscribe():
client = embedded()
client.run()
client.loop_start()
client.subscribe("microscope/light_sheet_microscope/UI/cameras/#")
client.subscribe("microscope/light_sheet_microscope/cameras/#")
subscribe()
\ No newline at end of file
......@@ -8,9 +8,31 @@ import configparser
class embedded:
def start():
try:
os.remove("list_of_device(s)_currently_active.txt")
os.remove("laser.ini")
print("Activating device(s)")
try:
os.remove("list_of_device(s)_currently_active.txt")
except Exception as e:
pass
try:
os.remove("laser.ini")
except Exception as e:
pass
try:
os.remove("cameras.ini")
except Exception as e:
pass
try:
os.remove("motorized galvo wheel.ini")
except Exception as e:
pass
try:
os.remove("stage.ini")
except Exception as e:
pass
try:
os.remove("webcam.ini")
except Exception as e:
pass
print("Activating devices(s)")
except:
print("Activating devices(s)")
......
......@@ -130,10 +130,10 @@ class Ui_FilterWheel(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.subscribe("microscope/light_sheet_microscope/UI/filter wheel")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.publish("microscope/light_sheet_microscope/UI/filter wheel", json.dumps({"type": "device", "payload":{"name": "filter wheel", "left filter wheel": leftFilterWheel, "right filter wheel": rightFilterWheel, "link": "true", "cmd": "set filter wheels"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.subscribe("microscope/light_sheet_microscope/filter wheel/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.publish("microscope/light_sheet_microscope/filter wheel/UI", json.dumps({"type": "device", "payload":{"name": "filter wheel", "left filter wheel": leftFilterWheel, "right filter wheel": rightFilterWheel, "link": "true", "cmd": "set filter wheels"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Left filter wheel set")
......@@ -167,10 +167,10 @@ class Ui_FilterWheel(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.subscribe("microscope/light_sheet_microscope/UI/filter wheel")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.publish("microscope/light_sheet_microscope/UI/filter wheel", json.dumps({"type": "device", "payload":{"name": "filter wheel", "link": "true", "cmd": "left and right filter wheels unlinked"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.subscribe("microscope/light_sheet_microscope/filter wheel/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.publish("microscope/light_sheet_microscope/filter wheel/UI", json.dumps({"type": "device", "payload":{"name": "filter wheel", "link": "true", "cmd": "left and right filter wheels unlinked"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Left and right filter wheels unlinked")
......@@ -197,10 +197,10 @@ class Ui_FilterWheel(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.subscribe("microscope/light_sheet_microscope/UI/filter wheel")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.publish("microscope/light_sheet_microscope/UI/filter wheel", json.dumps({"type": "device", "payload":{"name": "filter wheel", "left filter wheel magnification changer": leftMagnificationChanger, "right filter wheel magnification changer": rightMagnificationChanger, "cmd": "set magnification of left and right filter wheels"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.subscribe("microscope/light_sheet_microscope/filter wheel/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.publish("microscope/light_sheet_microscope/filter wheel/UI", json.dumps({"type": "device", "payload":{"name": "filter wheel", "left filter wheel magnification changer": leftMagnificationChanger, "right filter wheel magnification changer": rightMagnificationChanger, "cmd": "set magnification of left and right filter wheels"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Left filter wheel magnification set")
......@@ -234,10 +234,10 @@ class Ui_FilterWheel(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.subscribe("microscope/light_sheet_microscope/UI/filter wheel")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.publish("microscope/light_sheet_microscope/UI/filter wheel", json.dumps({"type": "device", "payload":{"name": "filter wheel", "cmd": "left and right filter wheels unlinked"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.subscribe("microscope/light_sheet_microscope/filter wheel/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.publish("microscope/light_sheet_microscope/filter wheel/UI", json.dumps({"type": "device", "payload":{"name": "filter wheel", "cmd": "left and right filter wheels unlinked"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Left and right filter wheels magnification changer unlinked")
......@@ -268,10 +268,10 @@ class Ui_FilterWheel(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.subscribe("microscope/light_sheet_microscope/UI/filter wheel")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.publish("microscope/light_sheet_microscope/UI/filter wheel", json.dumps({"type": "device", "payload":{"name": "filter wheel", "cmd": "filter wheel turning on"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.subscribe("microscope/light_sheet_microscope/filter wheel/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.publish("microscope/light_sheet_microscope/filter wheel/UI", json.dumps({"type": "device", "payload":{"name": "filter wheel", "cmd": "filter wheel turning on"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Filter wheel turning on")
......@@ -319,10 +319,10 @@ class Ui_FilterWheel(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.subscribe("microscope/light_sheet_microscope/UI/filter wheel")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/filter wheel")
client.publish("microscope/light_sheet_microscope/UI/filter wheel", json.dumps({"type": "device", "payload":{"name": "filter wheel", "cmd": "device turning off"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.subscribe("microscope/light_sheet_microscope/filter wheel/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/filter wheel/UI")
client.publish("microscope/light_sheet_microscope/filter wheel/UI", json.dumps({"type": "device", "payload":{"name": "filter wheel", "cmd": "device turning off"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Filter wheel turning off")
......
import random
import asyncio
from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference
from mqtt2 import *
class FW(Actor):
async def handle_message(self, message: Message):
......@@ -30,5 +31,5 @@ def subscribe():
client.run()
client.loop_start()
client.subscribe("microscope/light_sheet_microscope/UI/filter wheel/#")
client.subscribe("microscope/light_sheet_microscope/filter wheel/#")
subscribe()
\ No newline at end of file
This diff is collapsed.
......@@ -32,4 +32,4 @@ def subscribe():
client.loop_start()
client.subscribe("microscope/light_sheet_microscope/UI/laser/#")
subscribe()
\ No newline at end of file
subscribe()
\ No newline at end of file
class Hi:
print("hi")
hi = Hi()
class Bye:
print("Bye")
bye = Bye()
\ No newline at end of file
from no import *
peggy = Penguin()
peggy.whoisThis()
peggy.swim()
peggy.run()
class Bird:
def __init__(self):
print("Bird is ready")
def whoisThis(self):
print("Bird")
def swim(self):
print("Swim faster")
# child class
class Penguin(Bird):
def __init__(self):
# call super() function
super().__init__()
print("Penguin is ready")
def whoisThis(self):
print("Penguin")
def run(self):
print("Run faster")
# peggy = Penguin()
# peggy.whoisThis()
# peggy.swim()
# peggy.run()
\ No newline at end of file
......@@ -167,10 +167,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "x position": textboxValue + "um", "cmd": "set x position"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "x position": textboxValue + "um", "cmd": "set x position"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("X position: " + textboxValue + "um")
......@@ -203,10 +203,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "y position": textboxValue2 + "um", "cmd": "set y position"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "y position": textboxValue2 + "um", "cmd": "set y position"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Y position: " + textboxValue2 + "um")
......@@ -239,10 +239,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "z position": textboxValue3 + "um", "cmd": "set z position"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "z position": textboxValue3 + "um", "cmd": "set z position"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Z position: " + textboxValue3 + "um")
......@@ -275,10 +275,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "r": textboxValue4, "cmd": "set r"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "r": textboxValue4, "cmd": "set r"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("R: " + textboxValue4 + "deg")
......@@ -304,10 +304,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "90 degrees counter-clockwise"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "90 degrees counter-clockwise"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("90 degrees counterclockwise")
......@@ -319,10 +319,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "45 degrees counter-clockwise"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "45 degrees counter-clockwise"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("45 degrees counterclockwise")
......@@ -334,10 +334,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "15 degrees counter-clockwise"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "15 degrees counter-clockwise"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("15 degrees counterclockwise")
......@@ -349,10 +349,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "15 degrees clockwise"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "15 degrees clockwise"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("15 degrees clockwise")
......@@ -364,10 +364,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "45 degrees clockwise"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "45 degrees clockwise"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("45 degrees clockwise")
......@@ -379,10 +379,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "90 degrees clockwise"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "90 degrees clockwise"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("90 degrees clockwise")
......@@ -399,10 +399,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "stage turning on"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "stage turning on"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Stage turned on")
......@@ -471,10 +471,10 @@ class Ui_Stage(object):
client.loop_start()
print("\n" + "Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/stage")
client.subscribe("microscope/light_sheet_microscope/UI/stage")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI/stage")
client.publish("microscope/light_sheet_microscope/UI/stage", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "stage turning off"}}, indent=2))
print("Subscribing to topic", "microscope/light_sheet_microscope/stage/UI")
client.subscribe("microscope/light_sheet_microscope/stage/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/stage/UI")
client.publish("microscope/light_sheet_microscope/stage/UI", json.dumps({"type": "device", "payload":{"name": "stage", "cmd": "stage turning off"}}, indent=2))
time.sleep(1)
client.loop_stop()
print("Stage turned off")
......
import random
import asyncio
from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference
from mqtt2 import *
class Stages(Actor):
async def handle_message(self, message: Message):
......@@ -30,5 +31,5 @@ def subscribe():
client.run()
client.loop_start()
client.subscribe("microscope/light_sheet_microscope/UI/stage/#")
client.subscribe("microscope/light_sheet_microscope/stage/#")
subscribe()
\ 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