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

update

parent bd8e2da4
This diff is collapsed.
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
This diff is collapsed.
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