# Going around in circles. Logic signals and priorities

**URL:** <https://discourse.nodered.org/t/going-around-in-circles-logic-signals-and-priorities/13058>\
**Category:** General\
**Created:** [9 July 2019 01:35 UTC](https://discourse.nodered.org/t/going-around-in-circles-logic-signals-and-priorities/13058 "2019-07-09T01:35:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [9 July 2019 01:35 UTC](https://discourse.nodered.org/t/going-around-in-circles-logic-signals-and-priorities/13058/1 "2019-07-09T01:35:08Z")

</div>

_(Though its better than going around squares - bad attempt at a pun. around......)_

I've had fun learning more about JS, but I am not sure that has helped me.

Problem:  
I am receiving a message from 3 different machines.  
Message: (eg)  
`{"_msgid":"849fba65.79ecd8","topic":"","payload":{"Who":"TelePi","Modem":"Online","Uplink":"Online"}}`

`{"_msgid":"849fba65.79ecd8","topic":"","payload":{"Who":"TimePi","Modem":"Online","Uplink":"Online"}}`

`{"_msgid":"849fba65.79ecd8","topic":"","payload":{"Who":"BedPi","Modem":"Online","Uplink":"Online"}}`

I want to feed that (those three messages) into _something_ and get two outputs.

The `Modem` and `Uplink` can be `Online`, `Offline` or `Unknown`  
The `Unknown` is if all 3 devices report back the `Modem` is `Offline`, and only for the `Uplink` output.

Each device's message will have a `colour` ..... field (?) to show _who_ is sending the message.  
If more than 1 device show the `Modem` as `Online`, a specific device's message is sent.

Similar with the `Uplink`.

I am sure I will nut it out, as I often do, but would like a bit of help in case I get dizzy going around the circle.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [9 July 2019 15:54 UTC](https://discourse.nodered.org/t/going-around-in-circles-logic-signals-and-priorities/13058/3 "2019-07-09T15:54:33Z")

</div>

> [@Trying\_to\_learn](#):
>
> I want to feed that (those three messages) into _something_ and get two outputs.

Please clarify 'two outputs', 2 debug messages or 2 output-ports on the node (ie function node).  
What should the output look like ? Per device, or do you just want an overal status of:  
`{modem:online/offline}` and `{uplink:online/offline/unknown}`

The unknown state will be a hassle to deal with as you won't know if 1 device won't send anything at all (ie if it is dead), so waiting for 3 messages won't work. Neither would keeping track of it with a counter for the same reason (plus when deploying you could mess up the counter).

I am not sure what you are trying to accomplish, but it sounds overly complicated.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 July 2019 06:24 UTC](https://discourse.nodered.org/t/going-around-in-circles-logic-signals-and-priorities/13058/4 "2019-07-10T06:24:36Z")

</div>

Hi Bakman2.

That post was bashed out in a hurry, I know.

I am/was wanting a way of getting the messages from 3 devices - all scanning 2 IP addresses and sending messages back - and displaying the result with 2 _indicators_ on the dashboard.

I believe I have got it resolved. Yesterday I was up at 06:15 local and though not the only thing I did all day I went to bed at 01:40 today.  
Basically from about 19:00 to 01:45 I was working on the problem.

Thus all my questions about `JSON` and messages.

It took 2 function nodes and context to do it. With a few other nodes to _format_ the messages.

There was also the priority of messages. If 2 devices sent back the same message: who's would be shown?  
Fun fun fun.

And with the arrival being a bit asynchronous, it made it just that little bit harder.

It seems to be working now, and I need to now give it a full test to see if things work correctly REALLY.

I made a mock of the flow on this machine - as deploys are seconds - but something went very wrong when I put it on the real machines - where deploy can take a minute or so.

If you want I could upload the dummy flow, but I don't know it would be of much use to anyone but for the sake of seeing what I was talking about.
