Skip to main content

COMPAS Event Extensions: adds event-based communication infrastructure to the COMPAS framework.

Project description

COMPAS EVE

Event-based communication for the COMPAS framework.

>>> import compas_eve as eve
>>> pub = eve.Publisher("/hello_world")
>>> sub = eve.EchoSubscriber("/hello_world")
>>> sub.subscribe()
>>> for i in range(10):
...    pub.publish(dict(text=f"Hello World {i}"))

It is extremely easy to send messages around. COMPAS EVE supports different transport mechanisms to send messages between different threads, processes, computers, etc.

Installation

Install using pip:

    pip install compas_eve

Or using conda:

    conda install compas_eve

Supported features

  • Publisher/subscriber communication model (N-to-N communication)
  • In-process events
  • MQTT support
  • CPython & IronPython support

Examples

In-process events

The simplest option is to use in-process events. This works for simple applications and allows to communicate between threads.

import compas_eve as eve

pub = eve.Publisher("/hello_world")
sub = eve.EchoSubscriber("/hello_world")
sub.subscribe()

for i in range(10):
    pub.publish(dict(text=f"Hello World {i}"))

MQTT

MQTT is a protocol that allows to send messages between different systems/computers. Using MQTT is very simple as well:

import compas_eve as eve
from compas_eve.mqtt import MqttTransport

tx = MqttTransport("broker.hivemq.com")
eve.set_default_transport(tx)

pub = eve.Publisher("/hello_world")
sub = eve.EchoSubscriber("/hello_world")
sub.subscribe()

for i in range(10):
    pub.publish(dict(text=f"Hello World {i}"))

This example shows how to send and receive from a single script, but running publishers and subscribers on different scripts, different processes, or even different computers will work the exact same way.

Usage from Rhinoceros 3D

It is possible to use the same code from within Rhino/Grasshopper.

Make sure you have installed it to Rhino using the COMPAS installation mechanism:

    python -m compas_rhino.install -v 7.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compas_eve-1.0.0.tar.gz (162.5 kB view details)

Uploaded Source

Built Distribution

compas_eve-1.0.0-py2.py3-none-any.whl (167.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file compas_eve-1.0.0.tar.gz.

File metadata

  • Download URL: compas_eve-1.0.0.tar.gz
  • Upload date:
  • Size: 162.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.11

File hashes

Hashes for compas_eve-1.0.0.tar.gz
Algorithm Hash digest
SHA256 40ad0a387b0b831b97304bff0a5bfaa3e8ba9128bd4004920eea3acf90e0ac56
MD5 baf14aff9be3632b8896a138919c09b0
BLAKE2b-256 d40f26e979b1687faf6b4790df9ea4ef45d3c9c5693e384034235b63c8b28566

See more details on using hashes here.

File details

Details for the file compas_eve-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: compas_eve-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 167.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.11

File hashes

Hashes for compas_eve-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bb8122401e503e845169b986f19828982b9d9fdca8455e6d8330913d1a35a96e
MD5 e5cd69cf204615381eaade4c5380acf5
BLAKE2b-256 ff8da838cce50ad232ae1fa4fece824bbccc4296f2e1ec089e59d9cb67187aad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page