Node-Red - Actyx Pond V2 integration

Hello Community!

This package is already some days old, but after my last update, I like to bring it up once again in this category.


Node-RED Actyx Pond V2 integration

Node-red contribution to write you fish as nodes or emit events to ActyxOS

installation:

  1. Install in node red: MenuManage PalletInstall@actyx-contrib/node-red-contrib-actyx-pond
  2. Install in node-project: npm install @actyx-contrib/node-red-contrib-actyx-pond

New Nodes

Fore new nodes are added to node-red in the ‘Actyx Pond’ Category

  • Pond Emit
  • Fish
  • Pond Observe
  • Pond Observe

Pond Emit:

image

Behaves like Pond.emit(tag, payload).

The msg.payload is used as the payload and will be published as the event.

If the tags are defined as mustache template it is rendered with the data in the msg (e.g.: {{topic}} machine:{{payload.name}})

You will find more details in the Node Help.

Fish:

image

Behaves like Fish<State, Event>

Fish definition for Pond Observe Fish

Except from the FishId.version, all fields support mustache as template engine (e.g.: Name: {{payload.name}})

You will find more details in the Node Help.

Pond Observe Fish:

image

Behaves like Pond.observe(Fish(parameter), onStateChanged).

Observe the fish in the input signal and emit signals when the fish state changes.

Use the Fish node to inject a fish property into the signal

You will find more details in the Node Help .

Pond Observe:

image

Behaves like Pond.observe(Fish, onStateChanged).

Combines Fish and observe Fish in one node. This Node does not support inputs and can be used for singleton fish.

You will find more details in the Node Help.

1 Like

Reuse your existing fish:

Disclaimer:
I can not recommend using node-RED to observe complex fish without writing your own node-RED-node. Please keep in mind, that the feature-set of the Fish-Node is quite limited.

After this is said, if you like to observe some trivial fish, here is a little how-to.

Problem:

In the matter that node-RED is built for JavaScript, the fish implementations are restricted to JavaScript as well.
Unfortunately, we are not able to copy any TypeScript-Fish in the node-RED editor.

Solution

There are many ways to get around this issue, but this is probably the easiest one:

Transpile + Copy&Past

A very simple solution is, to transpile your fish with tsc and copy the content of the onEvent-function into the editor.

I cloned the DemoMachineKit repository from the advanced tutorial as an example.

Step1
Transpile fish code with npx tsc.

~/DemoMachineKit/src/fish $ npx tsc machineFish.ts

Step2
Open the output (machineFish.js) in any editor and copy the content of the onEvent-function.

and past it into the Fish-Node-OnEvent text area.

image

Step3

Adapt the other properties according to the original code.

Step4

Try it out:


Automate it

Is up to you

This is not really easy to maintain and a better solution would be, to integrate a CI/CD pipeline. This pipeline could update the flow with your current onEvent-function and the other fish parameters.

Happy hacking

2 Likes