sttpapi


Namesttpapi JSON
Version 0.6.4 PyPI version JSON
download
home_pagehttps://github.com/sttp/pyapi
SummaryStreaming Telemetry Transport Protocol API
upload_time2024-10-16 05:22:33
maintainerNone
docs_urlNone
authorJ. Ritchie Carroll
requires_python>=3.9
licenseNone
keywords sttp ieee 2664 streaming telemetry time-series protocol synchrophasor
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## Python STTP ([IEEE 2664](https://standards.ieee.org/project/2664.html)) Implementation
### Streaming Telemetry Transport Protocol

<!--- Do not make this image location relative, README.md in root is a symbolic reference to one in docs. See CreateReadMeSymLink.cmd for more information. --->
<img align="right" src="https://raw.githubusercontent.com/sttp/pyapi/main/docs/img/sttp.png">

[![CodeQL](https://github.com/sttp/pyapi/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/sttp/pyapi/actions/workflows/codeql-analysis.yml) [![docs](https://raw.githubusercontent.com/sttp/pyapi/main/docs/img/py-ref.svg)]( https://sttp.github.io/pyapi) [![Release](https://img.shields.io/github/release/sttp/pyapi.svg?style=flat-square)](https://github.com/sttp/pyapi/releases/latest)

The Streaming Telemetry Transport Protocol (STTP) is optimized for the demands of transporting high volume streaming data. The protocol allows for the transmission of any information that can be represented longitudinally, e.g., time-series data.

STTP is an officially approved IEEE standard (2664), see: https://standards.ieee.org/ieee/2664/7397/

## Example Usage
```python
from sttp.subscriber import Subscriber
from time import time
from threading import Thread

def main():
    subscriber = Subscriber()

    try:
        # Start new data read at each connection
        subscriber.set_connectionestablished_receiver(
            lambda: Thread(target=read_data, args=(subscriber,)).start())

        subscriber.subscribe("FILTER TOP 20 ActiveMeasurements WHERE True")
        subscriber.connect("localhost:7175")

        # Exit when enter key is pressed
        input()
    finally:
        subscriber.dispose()


def read_data(subscriber: Subscriber):
    subscriber.default_connectionestablished_receiver()
    reader = subscriber.read_measurements()
    lastmessage = 0.0

    while subscriber.connected:
        measurement, success = reader.next_measurement()

        if not success:
            break

        if time() - lastmessage < 5.0:
            continue
        elif lastmessage == 0.0:
            subscriber.statusmessage("Receiving measurements...")
            lastmessage = time()
            continue

        message = [
            f"{subscriber.total_measurementsreceived:,}",
            " measurements received so far. Current measurement:\n    ",
            str(measurement)
        ]

        subscriber.statusmessage("".join(message))
        lastmessage = time()
```

Example Output:
```cmd
Connection to 127.0.0.1:7175 established.
Received 10,742 bytes of metadata in 0.045 seconds. Decompressing...
Decompressed 89,963 bytes of metadata in 0.004 seconds. Parsing...
Parsed 179 metadata records in 0.215 seconds
    Discovered:
        1 DeviceDetail records
        172 MeasurementDetail records
        5 PhasorDetail records
        1 SchemaVersion records
Metadata schema version: 14
Received success code in response to server command: Subscribe
Client subscribed as compact with 20 signals.
Receiving measurements...
1,470 measurements received so far. Current measurement:
    28bbb1fc-3434-48d3-87a8-bf5024c089d5 @ 19:43:53.600 = 516.545 (Normal)
2,970 measurements received so far. Current measurement:
    ed6def67-54c4-4e74-af95-c95fa6915fbc @ 19:43:58.600 = 218.070 (Normal)
4,460 measurements received so far. Current measurement:
    7aaf0a8f-3a4f-4c43-ab43-ed9d1e64a255 @ 19:44:03.633 = -0.230 (Normal)
5,930 measurements received so far. Current measurement:
    7aaf0a8f-3a4f-4c43-ab43-ed9d1e64a255 @ 19:44:08.633 = 8228.000 (Normal)

Connection to 127.0.0.1:7175 terminated.
```

## Examples
> [https://github.com/sttp/pyapi/tree/main/examples](https://github.com/sttp/pyapi/tree/main/examples)


## Support
For discussion and support, join our [discussions channel](https://github.com/sttp/pyapi/discussions) or [open an issue](https://github.com/sttp/pyapi/issues) on GitHub.

## Links

* [STTP PyPi Package: sttpapi](https://pypi.org/project/sttpapi/)
* [STTP Python Documentation](https://sttp.github.io/pyapi/)
* [STTP General Documentation](https://sttp.github.io/documentation/)
* [STTP (IEEE 2664) Standard](https://standards.ieee.org/project/2664.html)

[![Lock](https://raw.githubusercontent.com/sttp/pyapi/main/docs/img/LockPython_64High.png)](https://github.com/sttp/pyapi)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sttp/pyapi",
    "name": "sttpapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "STTP, IEEE 2664, streaming, telemetry, time-series, protocol, synchrophasor",
    "author": "J. Ritchie Carroll",
    "author_email": "rcarroll@gridprotectionalliance.org",
    "download_url": "https://files.pythonhosted.org/packages/76/97/4898e7e81fa700f33d336b723784a93957b81cb9ac4623e16ab3e442151e/sttpapi-0.6.4.tar.gz",
    "platform": null,
    "description": "## Python STTP ([IEEE 2664](https://standards.ieee.org/project/2664.html)) Implementation\r\n### Streaming Telemetry Transport Protocol\r\n\r\n<!--- Do not make this image location relative, README.md in root is a symbolic reference to one in docs. See CreateReadMeSymLink.cmd for more information. --->\r\n<img align=\"right\" src=\"https://raw.githubusercontent.com/sttp/pyapi/main/docs/img/sttp.png\">\r\n\r\n[![CodeQL](https://github.com/sttp/pyapi/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/sttp/pyapi/actions/workflows/codeql-analysis.yml) [![docs](https://raw.githubusercontent.com/sttp/pyapi/main/docs/img/py-ref.svg)]( https://sttp.github.io/pyapi) [![Release](https://img.shields.io/github/release/sttp/pyapi.svg?style=flat-square)](https://github.com/sttp/pyapi/releases/latest)\r\n\r\nThe Streaming Telemetry Transport Protocol (STTP) is optimized for the demands of transporting high volume streaming data. The protocol allows for the transmission of any information that can be represented longitudinally, e.g., time-series data.\r\n\r\nSTTP is an officially approved IEEE standard (2664), see: https://standards.ieee.org/ieee/2664/7397/\r\n\r\n## Example Usage\r\n```python\r\nfrom sttp.subscriber import Subscriber\r\nfrom time import time\r\nfrom threading import Thread\r\n\r\ndef main():\r\n    subscriber = Subscriber()\r\n\r\n    try:\r\n        # Start new data read at each connection\r\n        subscriber.set_connectionestablished_receiver(\r\n            lambda: Thread(target=read_data, args=(subscriber,)).start())\r\n\r\n        subscriber.subscribe(\"FILTER TOP 20 ActiveMeasurements WHERE True\")\r\n        subscriber.connect(\"localhost:7175\")\r\n\r\n        # Exit when enter key is pressed\r\n        input()\r\n    finally:\r\n        subscriber.dispose()\r\n\r\n\r\ndef read_data(subscriber: Subscriber):\r\n    subscriber.default_connectionestablished_receiver()\r\n    reader = subscriber.read_measurements()\r\n    lastmessage = 0.0\r\n\r\n    while subscriber.connected:\r\n        measurement, success = reader.next_measurement()\r\n\r\n        if not success:\r\n            break\r\n\r\n        if time() - lastmessage < 5.0:\r\n            continue\r\n        elif lastmessage == 0.0:\r\n            subscriber.statusmessage(\"Receiving measurements...\")\r\n            lastmessage = time()\r\n            continue\r\n\r\n        message = [\r\n            f\"{subscriber.total_measurementsreceived:,}\",\r\n            \" measurements received so far. Current measurement:\\n    \",\r\n            str(measurement)\r\n        ]\r\n\r\n        subscriber.statusmessage(\"\".join(message))\r\n        lastmessage = time()\r\n```\r\n\r\nExample Output:\r\n```cmd\r\nConnection to 127.0.0.1:7175 established.\r\nReceived 10,742 bytes of metadata in 0.045 seconds. Decompressing...\r\nDecompressed 89,963 bytes of metadata in 0.004 seconds. Parsing...\r\nParsed 179 metadata records in 0.215 seconds\r\n    Discovered:\r\n        1 DeviceDetail records\r\n        172 MeasurementDetail records\r\n        5 PhasorDetail records\r\n        1 SchemaVersion records\r\nMetadata schema version: 14\r\nReceived success code in response to server command: Subscribe\r\nClient subscribed as compact with 20 signals.\r\nReceiving measurements...\r\n1,470 measurements received so far. Current measurement:\r\n    28bbb1fc-3434-48d3-87a8-bf5024c089d5 @ 19:43:53.600 = 516.545 (Normal)\r\n2,970 measurements received so far. Current measurement:\r\n    ed6def67-54c4-4e74-af95-c95fa6915fbc @ 19:43:58.600 = 218.070 (Normal)\r\n4,460 measurements received so far. Current measurement:\r\n    7aaf0a8f-3a4f-4c43-ab43-ed9d1e64a255 @ 19:44:03.633 = -0.230 (Normal)\r\n5,930 measurements received so far. Current measurement:\r\n    7aaf0a8f-3a4f-4c43-ab43-ed9d1e64a255 @ 19:44:08.633 = 8228.000 (Normal)\r\n\r\nConnection to 127.0.0.1:7175 terminated.\r\n```\r\n\r\n## Examples\r\n> [https://github.com/sttp/pyapi/tree/main/examples](https://github.com/sttp/pyapi/tree/main/examples)\r\n\r\n\r\n## Support\r\nFor discussion and support, join our [discussions channel](https://github.com/sttp/pyapi/discussions) or [open an issue](https://github.com/sttp/pyapi/issues) on GitHub.\r\n\r\n## Links\r\n\r\n* [STTP PyPi Package: sttpapi](https://pypi.org/project/sttpapi/)\r\n* [STTP Python Documentation](https://sttp.github.io/pyapi/)\r\n* [STTP General Documentation](https://sttp.github.io/documentation/)\r\n* [STTP (IEEE 2664) Standard](https://standards.ieee.org/project/2664.html)\r\n\r\n[![Lock](https://raw.githubusercontent.com/sttp/pyapi/main/docs/img/LockPython_64High.png)](https://github.com/sttp/pyapi)\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Streaming Telemetry Transport Protocol API",
    "version": "0.6.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/sttp/pyapi/issues",
        "Documentation": "https://sttp.github.io/pyapi/",
        "Download": "https://pypi.org/project/sttpapi/",
        "Homepage": "https://github.com/sttp/pyapi",
        "Source Code": "https://github.com/sttp/pyapi"
    },
    "split_keywords": [
        "sttp",
        " ieee 2664",
        " streaming",
        " telemetry",
        " time-series",
        " protocol",
        " synchrophasor"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90b63552d8d870f062c5f1d9b486bd03d0eddd8b360dd63116d239855d85c0e6",
                "md5": "367661646a4aa676033e8a24388e86ce",
                "sha256": "99eeb477926710a7ec6d04698ca999b1c60b9a6d218ba22add398e7422cdd5b1"
            },
            "downloads": -1,
            "filename": "sttpapi-0.6.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "367661646a4aa676033e8a24388e86ce",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 137503,
            "upload_time": "2024-10-16T05:22:31",
            "upload_time_iso_8601": "2024-10-16T05:22:31.287828Z",
            "url": "https://files.pythonhosted.org/packages/90/b6/3552d8d870f062c5f1d9b486bd03d0eddd8b360dd63116d239855d85c0e6/sttpapi-0.6.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "76974898e7e81fa700f33d336b723784a93957b81cb9ac4623e16ab3e442151e",
                "md5": "9e8cd7784cd57de18afcc45f2a367236",
                "sha256": "2fd6074e4265d929cc492f282c9f61be50cb33721f25429ab40235bbded75da7"
            },
            "downloads": -1,
            "filename": "sttpapi-0.6.4.tar.gz",
            "has_sig": false,
            "md5_digest": "9e8cd7784cd57de18afcc45f2a367236",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 99890,
            "upload_time": "2024-10-16T05:22:33",
            "upload_time_iso_8601": "2024-10-16T05:22:33.856150Z",
            "url": "https://files.pythonhosted.org/packages/76/97/4898e7e81fa700f33d336b723784a93957b81cb9ac4623e16ab3e442151e/sttpapi-0.6.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-16 05:22:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sttp",
    "github_project": "pyapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "sttpapi"
}
        
Elapsed time: 0.44282s