Commit 98b4c49e authored by Spencer Du's avatar Spencer Du

update code

parent 8dd224f5
......@@ -3,11 +3,12 @@ from mqtt2 import *
import os
import time
import json
import configparser
def start():
try:
os.remove("list_of_device(s)_currently_active.txt")
os.remove("laserConfig.json")
os.remove("laser.ini")
print("Awaiting device(s) to be activated")
except:
print("Awaiting device(s) to be activated")
......@@ -46,4 +47,22 @@ def readFile(fname):
print(item.rstrip("\n"))
except:
print("No device(s) added yet")
readFile("list_of_device(s)_currently_active.txt")
\ No newline at end of file
readFile("list_of_device(s)_currently_active.txt")
# print("Connected to broker")
# time.sleep(1)
# client.subscribe("microscope/light_sheet_microscope/UI/laser/#")
# if os.path.exists:
# parser = configparser.ConfigParser()
# parser.read("laser.ini")
# try:
# subscriptions = dict(parser.items("Subscriptions"))
# print("Subscribing to topics", subscriptions)
# client.subscribe(subscriptions)
# except:
# pass
# else:
# pass
client.loop_forever()
\ No newline at end of file
......@@ -3,6 +3,7 @@ import asyncio
from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference
import configparser as configparser
import os
from mqtt2 import *
class Laser(Actor):
async def handle_message(self, message: Message):
......@@ -26,12 +27,12 @@ async def main():
# Then we'll just send it an empty message and wait for a response
reply : DataMessage = await ask(laser, Message())
print(reply.data)
asyncio.get_event_loop().run_until_complete(main())
asyncio.get_event_loop().run_until_complete(main())
# if os.path.exists("laser.ini"):
# parser = configparser.ConfigParser()
# parser.read("laser.ini")
def subscribe():
client = embedded()
client.run()
# subscriptions = dict(parser.items("Subscriptions"))
# print("Subscribing to topics", subscriptions)
# client.subscribe(subscriptions)
\ No newline at end of file
client.loop_start()
client.subscribe("microscope/light_sheet_microscope/UI/laser/#")
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