Design Details - GerardT/Arro GitHub Wiki

This section describes in more detail the sw components in the Runtime Environment.

ServerEngine

The ServerEngine maintains a socket connection to the (Eclipse) host and listens for commands to execute:

  • “echo”
  • “ls” - list the files on the target computer (Runtime environment).
  • “put” - download a file to the target computer.
  • “protobuf” - run the protobuf command - the Protocol Buffers compiler.
  • “run” - kick off NodeDb to run the downloaded program.
  • “terminate” - terminate NodeDb.
  • “pwd”

When the Host wants to run a program, it uses “put” to FTP all necessary files to the Download folder on the Runtime environment:

Then it needs to do preparations, depending on the downloaded file:

  • issue “protobuf” to run a Protobuf compilation at the target computer.
  • expand all function blocks into elementary blocks and register them in NodeDb.
  • make sure all python classes are available and all Native plug ins are available to NodeDb.

After this, the Host issues “run” to run the NodeDb in a separate thread. If thereafter the Host issues “terminate” it will exit that thread.

NodeDb

NodeDb provides an API to register all instances of Elementary Blocks and their connections. When running the program, it will run on its own thread. And when the program is stopped, the thread is terminated.

NodeDb also provides an API for Elementary Blocks to communicate with:

  • INodeContext
  • INodeDefinition

NodeDb uses a Factory pattern to instantiate sw plug-ins when a new Elementary Block is instantiated / registered.

The following sub sections described currently available plug-ins.

Python

Running Python code involves:

  • PythonGlue - provides getMessage and sendMessage that can be called by Python code.
  • NodePython - calls Python method runCycle.

NodePython is made such that it will upon creation (object instantiation) create a Python object and keep it as long as the NodePython object exists. This means that the Python object may keep class data members that will be retained over multiple calls of runCycle.

File arro_pgm.py contains (NewCodePython being the example Python module name):

import sys
sys.path.append('.')

from NewCodePython import NewCodePython

So basically it declares all Python classes; this files needs to be read once by Python interpreter and after that individual classes can be instantiated.

There is one more Python function that may be called from within C (captureError), which is used to decode Python tracebacks:

PyErr_Fetch(&type, &value, &traceback);
if(traceback == 0) {
    Py_INCREF(Py_None);
    traceback = Py_None;
}
mod = PyImport_ImportModule("traceback");  // Return value: New reference.
if (!mod) {
    /* print some error */
    return;
}

list= PyObject_CallMethod(mod,
                          (char*)”format_exception",
                          (char*)"OOO",
                          type,
                          value,
                          traceback);  // Return value: New reference.

Native

A node written in C computer language should adhere to the APIs INodeDefition and INodeContext.

A problem with such nodes is that the code also relies on types generated by protobuf. So it needs to generate before compiling the code.

UiIn / UiOut

UiIn - any User Input components registers as UiIn. UiIn components are different from Native components since they communicate to a web client using SocketClient / WebServer. UiOut - any User Output components registers as UiIn. UiOut components are different from Native components since they communicate to a web client using SocketClient / WebServer.

Sfc

Sequential Function Chart nodes support state behaviour for Modules. The SFCs are edited in the Eclipse IDE and as part of arro.xml downloaded to the Runtime. The Runtime will forward the encoded SFCs to the SFC nodes which will run it.

The SFC node is part of a Module just a node like any other node. It will monitor / control other nodes by special connections to these nodes that the Runtime adds just before running the Arro program. These connections will convey: “action” messages - these trigger a new activity in a node, e.g. “move arm”. “step” messages - these reflect that state (“step” is equivalent to “state” in SFC parlance) that a node is in, e.g. “move ready”.

In order to create the additional connections, Runtime adds the following pads: “_action” pad in each existing node in the diagram, receiving action messages for the module. “_step” pad in each existing node in the diagram, providing current state the module is in. The initial state (step) is always “start”. to _SFC node: “action” for each existing node in the diagram, to send actions to each node. “_action” - to receive action messages for this module from the outside world. “step<node name” for each existing node in the diagram, for receiving the current state of each node. “_step” - to provide the current state of this module for the outside world.

Please see below where all connections are added.

SFC node

Note that all added elements are preceded by “”. A user cannot create names starting with “” so name clashes are avoided. Note there is no SFC for UI elements. Let’s create a dummy one.

Config

SocketClient

The SocketClient provide a TCP/IP socket connection from UiIn or UiOut component to the web server, which forwards the communication to HTML web components that are capable of using web sockets.

Web server

Web server that support web socket communication.

⚠️ **GitHub.com Fallback** ⚠️