Skip to main content

Introduction

This package enables you to:

  1. Create software that connects to IoT devices for monitoring and control

  2. Create microservices

NodeWire uses a dataflow programming model. Nodes have input and output ports through which it receives and sends messages. A NodeWire program can connect to other nodes to monitor and send messagesto it.

Hello NodeWire

import asyncio
from nodewire import Node

class MyNode(Node):
    def on_reset(self, value, sender):
        self.count = value

    def get_status(self, sender):
        return {
            'counting': self.start==1,
            'count': self.count
        }

    async def loop(self):
        print('connected')
        while True:
            await asyncio.sleep(1)
            if self.start==1:
                self.count = self.count + 1

mynode = MyNode(nodename='hello', inputs='start reset', outputs='count status',  server='localhost')
mynode.nw.debug = True
mynode.nw.run()

First we created our node class. In this class, we defined message handlers that will be called when the system wants to determine the value of our output ports (get_portname) or when it wants to forward a new value to us (on_portname). Note that you can chose to define handlers for some ports (reset and status in this example), or chose not to (start and count). You also have the choice to make thehandler syncronous or asyncronous. If the handler is going to take a long time to run, then it is better to make it asyncronous and use asyncio.sleep every once in a while, so that other tasks will get a chance to run.

The loop function is special. It is called only once, the first time the node establishes a successful connection to the server. It must be an async function. This function is meant to serve as the mainloop of your nodewire application but you can also terminate it without any effect on the overal running of the run. The loop function is optional

Control and Monitor

from nodewire import Node

class MyNode(Node):
    def got_count(self, nodename):
        print(counter.count)
        if counter.count == 10:
            counter.reset = 0

    async def loop(self):
        global counter
        print('connected')
        counter = await self.get_node('hello')
        counter.start = 1
        counter.on_count = self.got_count

mynode = MyNode(nodename='control', server='localhost')
mynode.nw.run()

Metadata

Release files for nodewire 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nodewire 2.0.2
File Size Uploaded
nodewire-2.0.2.tar.gz 11.0 kB Details

Release files / nodewire-2.0.2.tar.gz

Download URL nodewire-2.0.2.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
46078eee6ef3dde82d26bafeef191f97b00dd5480ecb585cacd824e9b584e5a8
BLAKE2b-256 checksum
How to use checksums
aeb95674358a6bd0cd00ef95504387419cf90b76e9dc6537e055953cc130cc56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

Release history Release notifications | RSS feed

This release

2.0.2 This release

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.9.9

1 release file

0.9.8

1 release file

0.9.7

1 release file

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.3

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.9

1 release file

0.8.8

1 release file

0.8.7

1 release file

0.8.6

1 release file

0.8.5

1 release file

0.8.4

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8

1 release file

0.7

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6

1 release file

0.5.6

1 release file

0.5.5

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1.5

1 release file

0.4.1.4

1 release file

0.4.1.3

1 release file

0.4.1.2

1 release file

0.4.1

1 release file

0.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page