Node Red - Reading a Pac Control Variable While Still Looping

Hello,

I’m trying to get node-red to work as a archiver for an error log. I’m already using nodered for data collection - which is easier to set up as the interval of collection is regular i.e ever 5 seconds grab data. The data log is irregular, as I only would like to publish the error log information when an alarm is generated otherwise the log floods with the same error.

My question is: is there a way to inject on reading a variable rather than creating a loop in node red? The loop eats up a lot of the CPU% - I tried avoiding this using a delay, but I’m wondering if there is a better way of going about this.

Thanks for your time.

Dan

This loop:

is a problem.

How often is bYellowAlarm changing? You may need to describe the sequence of what you are trying to accomplish - assume there are better ways.

I agree that the top loop is concerning, what is your reasoning for having it wired like that? What conditions are the two switch nodes checking?

If you take that top loop out, just temporarily, do you see your CPU usage go down? I’d be very suspicious of that getting caught in a very fast and inefficient self-perpetuating loop.

The circled Pac Read nodes are polling either a 1 or 0 from the control strategy. This is based on the state of the error log. I’d like to push the first entry of the string table to the CSV file one time and then for NodeRed to wait until a new error pops up ,then repeat. The problem I am hitting without looping is that NodeRed sends the inject message into nothing. When the inject is gone, the flow doesn’t really do anything. I could be going about this in the completely wrong way - just looking for some suggestions.

After switching things up a bit the CPU is only at 30 - 40% which may be high considering this is the only chart I have running on NodeRed.

I watched one of your videos and saw the filter node. I used that instead - to catch if the log value changes from the previous value.

Works much better. CPU is down to 1.5%.

2 Likes