filter_wheel_embedded.py 970 Bytes
Newer Older
Spencer Du's avatar
update  
Spencer Du committed
1
import random
Spencer Du's avatar
Spencer Du committed
2
import asyncio
Spencer Du's avatar
update  
Spencer Du committed
3
from actorio import Actor, Message, DataMessage, ask, EndMainLoop, Reference
Spencer Du's avatar
Spencer Du committed
4

Spencer Du's avatar
update  
Spencer Du committed
5 6
class FW(Actor):
    async def handle_message(self, message: Message):
Spencer Du's avatar
Spencer Du committed
7
        print("Filter wheel")
8
        # await asyncio.sleep(2)
Spencer Du's avatar
Spencer Du committed
9
        print("Unitialised")
10
        # await asyncio.sleep(2)
Spencer Du's avatar
Spencer Du committed
11
        print("Initialising")
12
        # await asyncio.sleep(2)
Spencer Du's avatar
Spencer Du committed
13
        print("Initialised")
14
        # await asyncio.sleep(2)
Spencer Du's avatar
Spencer Du committed
15
        print("Configuring")
16
        # await asyncio.sleep(2)
Spencer Du's avatar
Spencer Du committed
17
        print("Configured")
18
        # await asyncio.sleep(2)
Spencer Du's avatar
update  
Spencer Du committed
19 20 21 22 23 24 25 26
        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())