Coverting word to bit status


What do you suggest I use in a workflow too convert a word to bit values?
For example 8 would be 0000 1000, and 12 would be 0000 1100, and so on?

Each bit would mean different alarms going on /off.

This is a common way to relay alarm information from PLC’s.


At the moment, I think you would need to use a Function node, and write custom javascript to extract those values (take a look at But you are right, this is not an uncommon thing to need to do, and we should add some features around this into the workflow engine!


We do this a lot.

I usually have a data table with the bits defined along with the messages. For instance converting NFPA codes on a genset.

So I use the following to unpick the bits, = []

    function intToUint(int, nbit) {
        var u = new Uint32Array(1);
        nbit = +nbit || 32;
        if (nbit > 32) throw new RangeError('intToUint only supports ints up to 32 bits');
        u[0] = int;
        if (nbit < 32) { // don't accidentally sign again
            int = Math.pow(2, nbit) - 1;
            return u[0] & int;
        } else {
            return u[0];
    } = intToUint(,16).toString(2).split("").reverse().join("");

Then will loop of state_bits using each item in the loop as the key for the item in the datatable.

A simple node to at least unpick the bits would be good.

I can build this in a custom node, but would prefer to run this on the agent, and custom nodes aren’t supported on agents. yet.