Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Spencer Du
control software
Commits
dfd904d4
Commit
dfd904d4
authored
Oct 25, 2019
by
Spencer Du
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
d68ff943
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
20 additions
and
46 deletions
+20
-46
__pycache__/cameras2.cpython-38.pyc
__pycache__/cameras2.cpython-38.pyc
+0
-0
__pycache__/laser2.cpython-38.pyc
__pycache__/laser2.cpython-38.pyc
+0
-0
__pycache__/mqtt.cpython-38.pyc
__pycache__/mqtt.cpython-38.pyc
+0
-0
__pycache__/mqtt2.cpython-38.pyc
__pycache__/mqtt2.cpython-38.pyc
+0
-0
camerasEmbedded.py
camerasEmbedded.py
+4
-13
filterwheelEmbedded.py
filterwheelEmbedded.py
+4
-12
laserEmbedded.py
laserEmbedded.py
+10
-19
mqtt.py
mqtt.py
+1
-1
mqtt2.py
mqtt2.py
+1
-1
No files found.
__pycache__/cameras2.cpython-38.pyc
0 → 100644
View file @
dfd904d4
File added
__pycache__/laser2.cpython-38.pyc
0 → 100644
View file @
dfd904d4
File added
__pycache__/mqtt.cpython-38.pyc
0 → 100644
View file @
dfd904d4
File added
__pycache__/mqtt2.cpython-38.pyc
0 → 100644
View file @
dfd904d4
File added
camerasEmbedded.py
View file @
dfd904d4
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
filterwheelEmbedded.py
View file @
dfd904d4
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
laserEmbedded.py
View file @
dfd904d4
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
()
...
...
mqtt.py
View file @
dfd904d4
...
...
@@ -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
mqtt2.py
View file @
dfd904d4
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment