An agent has a list of input streams, a list of output streams, a state, possibly additional keyword arguments and a function that reads input streams and then appends values to output streams and changes the agent’s state. An agent does not terminate execution: it continues to wait to read new values on its input streams.

An agent can be a network of agents. You create a network of agents by connecting output streams of agents to input streams of agents. The figure below shows a network constructed by connecting a compute_stress agent, a valve_setting agent and a wall_stress agent. The network is itself an agent with input streams temperature, pressure and limit, and with output streams control and alerts.

Creating agents using wrappers and decorators. You can create an agent using a Python function called a wrapper that takes a non-streaming, conventional (non-IoTPy) function as input. You can also use Python decorators. A decorator provides the same functionality as a wrapper and it can be more syntactically convenient. Get an overview of wrapper categories here.

Links to different categories of decorators.

Read about categories of decorators in the following sections.

  • Single input stream, single output stream: map

  • Multiple input streams, single output stream: merge

  • Single input stream, multiple output streams: split

  • Single input stream, no output stream: sink

  • Multiple input streams, multiple output streams: multi

A simple example, using map and merge, to generate an echo is found here. (In addition to these wrappers/decorators the library has simple wrappers called iot and iot_merge that wrap functions that use streams. See the documentation in the code.)

Links to different categories of wrappers

  • Single input stream, single output stream: map

  • Multiple input streams, single output stream: merge

  • Single input stream, multiple output streams: split

  • Single input stream, no output stream: sink

Multiple input streams, multiple output streams: multi

Next look at different ways in which you can integrate non-IoTPy code with IoTPy code in different ways.