Skip to main content

A Python client for RTMA/Dragonfly

Project description

pyrtma

Python package Documentation Status

RTMA/Dragonfly client written in python with no external dependencies. Based on and compatible with Dragonfly Messaging

Installation

pyrtma is available on PyPI

pip install pyrtma --upgrade

Installing for pyrtma development

This is only necessary for individuals who would like to contribute to pyrtma.

From pyrtma git repo directory:

pip install --upgrade pip setuptools
pip install -e .

Usage

Launch Manager

python -m pyrtma.manager

or

message_manager

Create a message in message.yaml

Message definitions are created in a .yaml file.

The ruamel.yaml parser library is used internally (https://yaml.readthedocs.io/en/latest/)

Notes about yaml format:

  • Whitespace sensitive. Use either 2 or 4 spaces for tab not '\t'
  • Key-values must be separated by a colon followed by a space, (Key: Value, not Key:Value)
  • Must follow the top-level headers shown below.
  • Unused sections should be marked null
  • Names must start with letter. (no _ or numeric prefixes allowed)
  • Use (.yaml) extension not (.yml)

List of supported native data types:

  • char
  • byte
  • float
  • double
  • int8
  • int16
  • int32
  • int64
  • uint8
  • uint16
  • uint32
  • uint64

Below is an example:

# message.yaml

imports: null

# Constant values and expressions
constants: 
    STR_SIZE: 32
    LONG_STRING: STR_SIZE * 2

# Constant string values
string_constants:
    default_msg: "hello_world"

host_ids: null

module_ids:
    PERSON_PUBLISHER: 212
    PERSON_SUBSCRIBER: 214

# Alias a type by another name
aliases:
    AGE_TYPE: int32

# Non-message structured data (no id field)
struct_defs:
    TEST_STRUCT:
        fields:
            value_str: char[STR_SIZE]
            value_int: int32

# Message defintions with user assigned id field
message_defs:
    PERSON_MESSAGE:
        id: 1234
        fields:
            name: char[STR_SIZE]
            age: AGE_TYPE

    ANOTHER_EXAMPLE:
        id: 5678
        fields:
            value_struct: TEST_STRUCT
            value_float: float
            value_double: double

    # Example signal definition
    USER_SIGNAL:
        id: 2468
        fields: null

    # Example using a nested message defintion 
    PERSON_LIST:
        id: 1357
        fields:
            person: PERSON_MESSAGE[32]

    # Example reusing a message definition by another name
    EMPLOYEES:
        id: 1368
        fields: PERSON_LIST

    # A block of message ids can be reserved by a file for future use
    # Ranges are inclusive on both ends
    # Note that ':' cannot be used to indicate a range, as this will cause
    # the yaml parser to throw an error
    _RESERVED_:
        id: [1000, 1002 - 1008, 1009 to 1012]

Run the following command to compile the yaml file into Python, C, Matlab, or Javascript files. This will output a message.(py|h|m|js) file.

python -m pyrtma.compile -i examples/msg_defs/message.yaml --py --c --mat --js

or

rtma_compiler -i examples/msg_defs/message.yaml --py --c --mat --js

The msg_defs directory should now have message def files created for each language.

The rtma objects are compiled into objects suitable for each language.

[!NOTE] The pyrtma message compiler requires python 3.8+. Messages compiled for python in python 3.8+ may continue to work with pyrtma clients in python 3.7, but support for 3.7 is being phased out.

Examples

See /examples/example.py for pub/sub demo app

Compile the example message defintions:

python -m pyrtma.compile -i ./examples/msg_defs/message.yaml --py

Start the demo MessageManager server

python -m pyrtma.manager

Start the publisher in one console:

python ./examples/example.py --pub

Start the subscriber in another:

python ./examples/example.py --sub

Javascript

Clients in javascript require the web_manager server to convert websocket messages to rtma messages.

Run:

python -m pyrtma.web_manager -m <MM_IP> -p <WEBSOCKET_PORT> -d <DEFS_FILE>

or

web_manager -m <MM_IP> -p <WEBSOCKET_PORT> -d <DEFS_FILE>

to launch the web_manager which will listen to websocket connects on port <WEBSOCKET_PORT> and forward to message manager at <MM_IP>, using pyrtma message definitions defined in <DEFS_FILE>.

See rtma-js for developing rtma clients in javascript.

DataLogger

See examples/data_log_example.py for an example on how to configure data collection for a DataLogger.

To start up the logging module:

python -m pyrtma.data_logger --help

or

data_logger --help

There is also an interactive command line tool to control and configure the DataLogger manually:

python -m pyrtma.data_logger.cli

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

pyrtma-3.0.1.tar.gz (94.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrtma-3.0.1-py3-none-any.whl (100.8 kB view details)

Uploaded Python 3

File details

Details for the file pyrtma-3.0.1.tar.gz.

File metadata

  • Download URL: pyrtma-3.0.1.tar.gz
  • Upload date:
  • Size: 94.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyrtma-3.0.1.tar.gz
Algorithm Hash digest
SHA256 fd832a3ca960a09d6bf2a6b069a0df464e3b15635deff82af3d807bd487a20b0
MD5 98bdb927018cd66d65902dae309771b0
BLAKE2b-256 5ef6444b39e88acdc7f32fab472a82a824b75017f865beb6b3d7773ed1675ea7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrtma-3.0.1.tar.gz:

Publisher: deploy.yml on pitt-rnel/pyrtma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrtma-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyrtma-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 100.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyrtma-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8bc9436fbd6b1ab4c29d9b1864c19df170aa7b1d3d1478d6212f568a8e96b9f1
MD5 b2e71c4b30e8d95b6c18ea9efd9bb163
BLAKE2b-256 38662625a0c18cb523277ce81a1036eaec6c0ec7e0cd83836a5a52dcbfe4220b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrtma-3.0.1-py3-none-any.whl:

Publisher: deploy.yml on pitt-rnel/pyrtma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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