-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from compas-dev/docs
Documentation: clean up and added examples
- Loading branch information
Showing
24 changed files
with
531 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ API Reference | |
:maxdepth: 1 | ||
|
||
api/compas_eve | ||
api/compas_eve.mqtt | ||
api/compas_eve.memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
.. automodule:: compas_eve.memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
.. automodule:: compas_eve.mqtt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
******************************************************************************** | ||
compas_eve | ||
******************************************************************************** | ||
|
||
.. automodule:: compas_eve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import time | ||
|
||
from compas_eve import Message | ||
from compas_eve import Publisher | ||
from compas_eve import Subscriber | ||
from compas_eve import Topic | ||
|
||
|
||
topic = Topic("/compas_eve/hello_world/", Message) | ||
|
||
publisher = Publisher(topic) | ||
subcriber = Subscriber(topic, callback=lambda msg: print(f"Received message: {msg.text}")) | ||
subcriber.subscribe() | ||
|
||
for i in range(20): | ||
msg = Message(text=f"Hello world #{i}") | ||
print(f"Publishing message: {msg.text}") | ||
publisher.publish(msg) | ||
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import time | ||
from threading import Thread | ||
|
||
from compas_eve import Message | ||
from compas_eve import Publisher | ||
from compas_eve import Subscriber | ||
from compas_eve import Topic | ||
|
||
topic = Topic("/compas_eve/hello_world/", Message) | ||
|
||
|
||
def start_publisher(): | ||
publisher = Publisher(topic) | ||
|
||
for i in range(20): | ||
msg = Message(text=f"Hello world #{i}") | ||
print(f"Publishing message: {msg.text}") | ||
publisher.publish(msg) | ||
time.sleep(1) | ||
|
||
|
||
def start_subscriber(): | ||
subcriber = Subscriber(topic, callback=lambda msg: print(f"Received message: {msg.text}")) | ||
subcriber.subscribe() | ||
|
||
|
||
# Define one thread for each | ||
t1 = Thread(target=start_subscriber) | ||
t2 = Thread(target=start_publisher) | ||
|
||
# Start both threads | ||
t1.start() | ||
t2.start() | ||
|
||
# Wait until both threads complete | ||
t1.join() | ||
t2.join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import time | ||
|
||
from compas_eve import Message | ||
from compas_eve import Publisher | ||
from compas_eve import Topic | ||
from compas_eve.mqtt import MqttTransport | ||
|
||
topic = Topic("/compas_eve/hello_world/", Message) | ||
tx = MqttTransport("broker.hivemq.com") | ||
|
||
publisher = Publisher(topic, transport=tx) | ||
|
||
for i in range(20): | ||
msg = Message(text=f"Hello world #{i}") | ||
print(f"Publishing message: {msg.text}") | ||
publisher.publish(msg) | ||
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import time | ||
|
||
from compas_eve import Message | ||
from compas_eve import Subscriber | ||
from compas_eve import Topic | ||
from compas_eve.mqtt import MqttTransport | ||
|
||
topic = Topic("/compas_eve/hello_world/", Message) | ||
tx = MqttTransport("broker.hivemq.com") | ||
|
||
subcriber = Subscriber(topic, callback=lambda msg: print(f"Received message: {msg.text}"), transport=tx) | ||
subcriber.subscribe() | ||
|
||
print("Waiting for messages, press CTRL+C to cancel") | ||
while True: | ||
time.sleep(1) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.