Skip to main content

A modern Python Framework for microboard automation and control applications development

Project description

Rackio Framework

A modern Python Framework for microboard automation and control applications development. Github-Rackio Framework

Requirements

  • Python 3.6+
  • falcon
  • pyBigParser

Installation

pip install Rackio

Examples

Basic Setup

from rackio import Rackio, TagEngine

app = Rackio()
tag_engine = TagEngine()

# Tags definitions

tag_engine.set_tag("RAND1", "float")
tag_engine.set_tag("RAND2", "float")
tag_engine.set_tag("T1", "float")
tag_engine.set_tag("T2", "float")
tag_engine.set_tag("T3", "float")

if __name__ == "__main__":

    app.run()

Rackio comes with some built-in features that let you start creating rapid and fast coding prototypes.

Adding controls

Controls are objects that interact with the tags, changing their values accordingly to a condition

Value Actions

These actions only change tags values with a defined constant value.

from rackio.controls import Condition, ValueAction, Control

# Conditions definitions

cond1 = Condition("T1",">=", "T2")
cond2 = Condition("T1","<", "T2")

# Actions definitions

act1 = ValueAction("T3", 40)
act2 = ValueAction("T3", 80)

# Controls Definitions

control1 = Control("C1", cond1, act1)
control2 = Control("C2", cond2, act2)

app.append_control(control1)
app.append_control(control2)

Math Actions

These actions change tags values with a defined mathematical expression, and defined tags can be used inside these expressions.

from rackio.controls import MathAction

# Conditions definitions

cond1 = Condition("T1",">=", "T2")
cond2 = Condition("T1","<", "T2")

# Actions definitions

act1 = MathAction("T3", "T1 + T2")
act2 = MathAction("T3", "T2 - T1")

# Controls Definitions

control1 = Control("C1", cond1, act1)
control2 = Control("C2", cond2, act2)

app.append_control(control1)
app.append_control(control2)

Once Rackio is up and running, will trigger some actions if the associated condtions are met, by observing continously all the tags values for changes.

Supported functions within expressions

You can define your mathematical expression following the same arithmetic rules that python can handle, but only a set of math functions and constants are supported.

  • cos
  • sin
  • abs
  • log10
  • log
  • exp
  • tan
  • pi
  • e

Adding continous tasks

Rackio can be extended to add custom continous tasks and operations

@app.rackit(1)
def writer1():

    tag_engine.write_tag("T1", 15)
    tag_engine.write_tag("T2", 40)

    direction = 1

    while True:

        time.sleep(0.5)

        value = 24 + 2 * random()
        tag_engine.write_tag("RAND1", value)

        T1 = tag_engine.read_tag("T1")
        T1 += direction

        tag_engine.write_tag("T1", T1)

        if T1 >= 60:
            direction *= -1

        if T1 <= 5:
            direction *= -1

You can register a defined function as a continous task to be perform by Rackio. You can also provide functions as tasks lists

@app.rackit_on(period=1)
def reader():

    rand1 = tag_engine.read_tag("RAND1")
    rand2 = tag_engine.read_tag("RAND2")
    T1 = tag_engine.read_tag("T1")
    T2 = tag_engine.read_tag("T2")
    T3 = tag_engine.read_tag("T3")
        
    print("")
    print("RAND1: {}".format(rand1))
    print("RAND2: {}".format(rand2))
    print("T1   : {}".format(T1))
    print("T2   : {}".format(T2))
    print("T3   : {}".format(T3))

By specify its period, you can keep control of the time execution for these tasks.

Testing the RESTful API

Once your application is up and running, it will deploy a RESTful API with falcon, and the json format is the standard supported by this API.

Reading tags with httpie

Once your application is up and running you can access through the API, if you want to try with httpie, you can install it with the following command:

pip install httpie

Now execute the next command in your terminal

http localhost:8000/api/tags

you will get the following

HTTP/1.0 200 OK
Date: Tue, 11 Jun 2019 23:54:55 GMT
Server: WSGIServer/0.2 CPython/3.7.1
content-length: 177
content-type: application/json
[
    {
        "tag": "RAND1",
        "value": 25.597755601381692
    },
    {
        "tag": "RAND2",
        "value": 49.12890172456638
    },
    {
        "tag": "T1",
        "value": 57
    },
    {
        "tag": "T2",
        "value": 40
    },
    {
        "tag": "T3",
        "value": 97
    }
]

if you want to access an specific tag, for example tag T2

http localhost:8000/api/tags/T2

you will get the following

HTTP/1.0 200 OK
Date: Tue, 11 Jun 2019 23:58:40 GMT
Server: WSGIServer/0.2 CPython/3.7.1
content-length: 26
content-type: application/json
{
    "tag": "T2",
    "value": 40
}

Writing tags with httpie

You can change this tag value by executing

http POST localhost:8000/api/tags/T2 value=50

And you will get the following

HTTP/1.0 200 OK
Date: Wed, 12 Jun 2019 00:01:21 GMT
Server: WSGIServer/0.2 CPython/3.7.1
content-length: 16
content-type: application/json
{
    "result": true
}

Reading tags history

You can read tags history using the API also

http localhost:8000/api/tags/history/RAND1

And you will get the following

HTTP/1.0 200 OK
Date: Tue, 18 Jun 2019 02:52:43 GMT
Server: WSGIServer/0.2 CPython/3.7.1
content-length: 4917
content-type: application/json
{
    "tag": "RAND1",
    "value": [
        0.0,
        24.628376069489793,
        25.757258388362462,
        25.55412553374292,
        24.555658954786043,
        25.06933481716872,
        25.40130983961439,
        25.689521224514724,
        25.81125032707667,
        25.639558206736673,
        25.349485473327377,
        24.799801913324295,
        25.227466610598572,
        25.27254049615728,
        25.105421823573916,
        24.82832764778826,
        24.65831512999663,
        25.26014559203846,
        25.216187451359872,
        25.151243977491735
    ]
}

This way you can create your custom HMTL and Javascript Views to perform AJAX requests on Rackio.

Things to do

Rackio is work in progress framework, some features are still in development and they will be release soon for better applications, these features are listed below:

  • Finish RESTful API
  • Capability for users to add custom HTML files for HMI
  • Token Based Authentication for API access
  • Web Based Monitoring and Admin
  • Alarms definitions
  • Modbus and MQTT protocols
  • Automatic Datalogging
  • Trends and Historical data

Project details


Release history Release notifications | RSS feed

This version

0.1.8

Download files

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

Source Distribution

Rackio-0.1.8.win32.zip (50.4 kB view details)

Uploaded Source

Built Distributions

Rackio-0.1.8-py3.7.egg (47.9 kB view details)

Uploaded Source

Rackio-0.1.8-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file Rackio-0.1.8.win32.zip.

File metadata

  • Download URL: Rackio-0.1.8.win32.zip
  • Upload date:
  • Size: 50.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1

File hashes

Hashes for Rackio-0.1.8.win32.zip
Algorithm Hash digest
SHA256 a2ccef4ab58b56ae2c793abc96b41a033eabe45152825bbd5851d61a019d9126
MD5 f627070223c39acb5aceb60ffafe9c46
BLAKE2b-256 b0cec7349789d7a4d4613a22cc4fefdb9e52f7b7ce754f11f9814b5dc2527a8a

See more details on using hashes here.

File details

Details for the file Rackio-0.1.8-py3.7.egg.

File metadata

  • Download URL: Rackio-0.1.8-py3.7.egg
  • Upload date:
  • Size: 47.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1

File hashes

Hashes for Rackio-0.1.8-py3.7.egg
Algorithm Hash digest
SHA256 72d1c6034e6e9234e7a7e702eb1143825f36e7d5182b6474c0085dfba74173e3
MD5 a43d1fce1762303389cf65593b8384c6
BLAKE2b-256 09e62c5a630e3d7baf78d41543573561f74090712d1e9808026b9739efe7d3fa

See more details on using hashes here.

File details

Details for the file Rackio-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: Rackio-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1

File hashes

Hashes for Rackio-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 485998d1c536e043a59f45f87b1c49b299fd267de69477c468fe9401c043ca9a
MD5 e2c4741aab3412d07a5e9c7f58d9879c
BLAKE2b-256 24076d1ad56ffc1caff8764ff22bf7fd3de7417dd16720e03fb0284888865fe5

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