Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset counts as input #10

Open
SlevenCalevra opened this issue Oct 19, 2019 · 2 comments · May be fixed by #12
Open

Reset counts as input #10

SlevenCalevra opened this issue Oct 19, 2019 · 2 comments · May be fixed by #12

Comments

@SlevenCalevra
Copy link

Hi, I have an issue with this node. I set it up using "by block size" using 3.
Now it works perfectly when I inject let's say 15 messages. only the first 3 passes through. and when I reset it discards of the rest... Perfect.
But if you by accident inject reset twice, the second reset counts as one of the messages and it only passes through 2 of the messages.

Is there a way to block the reset to count as a message when injecting it more than once.

The reset in my case is a touch button on a 3.5inch LCD hat. so for a person to reset twice or three times is normal. especially if you don't know that the reset went through.

@shbatm
Copy link

shbatm commented Jun 8, 2020

I'd like to add a second use case for this. I use node as a "gate" with the by reset option in some logic associated with timers to only allow a single execution of a node within a time frame.

My trouble is there is a way for the upstream logic to send "reset" twice, which should just "keep the throttle open" but instead actually triggers the throttle on the second "reset" message.

In my opinion, all "reset" messages should not be passed through or count as an input message.

@shbatm
Copy link

shbatm commented Jun 8, 2020

I think both cases could be solved by flipping the if else if statements. For example:

            // throttle by reset
            else if( node.throttleType === "reset" ) {
                if( !node.reset ) {
                    node.reset = true;
                    node.send(msg);
                }
                else if( msg.reset ) {
                    node.reset = false;
                }
            }
// CHANGE TO:
            // throttle by reset
            else if( node.throttleType === "reset" ) {
                if( msg.reset ) {
                    node.reset = false;
                }
                else if( !node.reset ) {
                    node.reset = true;
                    node.send(msg);
                }
            }

@shbatm shbatm linked a pull request Jun 8, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants