Commit dfd904d4 authored by Spencer Du's avatar Spencer Du

update

parent d68ff943
import random
import asyncio
from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference
class Cameras(Actor):
# Here we override the handle_message method to send a `DataMessage` with the data "Hello World!".
async def handle_message(self, message: Message):
class Cameras:
async def Cameras():
print("Camera")
await asyncio.sleep(2)
print("Unitialised")
......@@ -17,11 +14,5 @@ class Cameras(Actor):
await asyncio.sleep(2)
print("Configured")
await asyncio.sleep(2)
await message.sender.tell(DataMessage(data="Hello World Im a camera!" + "\n", sender=self))
async def main():
# Let's create an instance of a Greeter actor and start it.
async with Cameras() as cameras:
# Then we'll just send it an empty message and wait for a response
reply : DataMessage = await ask(cameras, Message())
print(reply.data)
asyncio.get_event_loop().run_until_complete(main())
\ No newline at end of file
print("Hello World Im a camera!" + "\n")
asyncio.run(Cameras())
\ No newline at end of file
import random
import asyncio
from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference
class FW(Actor):
async def handle_message(self, message: Message):
class FW:
async def FW():
print("Filter wheel")
await asyncio.sleep(2)
print("Unitialised")
......@@ -16,11 +14,5 @@ class FW(Actor):
await asyncio.sleep(2)
print("Configured")
await asyncio.sleep(2)
await message.sender.tell(DataMessage(data="Hello World Im a filter wheel!" + "\n", sender=self))
async def main():
# Let's create an instance of a Greeter actor and start it.
async with FW() as fw:
# Then we'll just send it an empty message and wait for a response
reply : DataMessage = await ask(fw, Message())
print(reply.data)
asyncio.get_event_loop().run_until_complete(main())
\ No newline at end of file
print("Hello World Im a filter wheel!" + "\n")
asyncio.run(FW())
\ No newline at end of file
import random
import asyncio
from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference
from mqtt2 import *
class Laser(Actor):
async def handle_message(self, message: Message):
class Laser:
async def Laser():
print("Laser")
# await asyncio.sleep(1)
await asyncio.sleep(2)
print("Unitialised")
# await asyncio.sleep(1)
await asyncio.sleep(2)
print("Initialising")
# await asyncio.sleep(1)
await asyncio.sleep(2)
print("Initialised")
# await asyncio.sleep(1)
await asyncio.sleep(2)
print("Configuring")
# await asyncio.sleep(1)
await asyncio.sleep(2)
print("Configured")
# await asyncio.sleep(1)
await message.sender.tell(DataMessage(data="Hello World Im a laser!" +"\n", sender=self))
async def main():
# Let's create an instance of a Greeter actor and start it.
async with Laser() as laser:
# 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())
await asyncio.sleep(2)
print("Hello World Im a laser!" + "\n")
asyncio.run(Laser())
def subscribe():
client = embedded()
......
......@@ -16,4 +16,4 @@ class device(mqtt.Client):
m_in = json.loads(m_decode)
def run(self):
self.connect("localhost", 1883, 60)
\ No newline at end of file
self.connect("broker.hivemq.com", 1883, 60)
\ No newline at end of file
......@@ -16,4 +16,4 @@ class embedded(mqtt.Client):
m_in = json.loads(m_decode)
def run(self):
self.connect("localhost", 1883, 60)
\ No newline at end of file
self.connect("broker.hivemq.com", 1883, 60)
\ 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