Forum

Physical Switch for...
 
Notifications
Clear all

Physical Switch for Resume/Continue

7 Posts
2 Users
0 Likes
6,928 Views
(@hemicharger99)
Active Member
Joined: 6 years ago
Posts: 10
Topic starter  

On my panel, I have a momentary switch that I'd like to use to Resume the process, similar to having a "Continue" button on the BruC workspace. Instead of performing a wait on the "Continue" button, as it is currently, I wrote a script to loop through and wait for either the "Continue" button to be clicked, or for the physical button to be pressed. 

 

It is wired up as a sinking type switch, and it does show as "Off" and "On" on the device in the workspace, but in the script code I am unable to determine how I should check for the button press. The button device is set for Active Low, but checking the button ActiveLow as true or false makes no difference.

 

[continueWait]
if "CONTINUE" State == true
goto hitContinue
else if "ResetButton" ActiveLow == false
goto hitContinue
endif

sleep 150
goto continueWait

[hitContinue]

Any ideas what I'm doing wrong?


   
Quote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
 

Hi,

Three things...

1. It looks like you are missing an 'endif' statement. The script engine does not currently have an "elseif" statement, so it gets evaluated separately. For simplicity (depending on your perspective), just use separate if statements as they are not interdependent.

2. The second if should just evaluate the input's state. You would set the input to be in Active Low mode in its settings, then just evaluate if it is on or off.

3. Make sure to reset the state of the button "CONTINUE" as releasing it will not do it. This is due to toggle modes.

Hope this helps!

[continueWait]
if "CONTINUE" State == true
goto hitContinue
endif
if "ResetButton" Value == on
goto hitContinue
endif

sleep 150
goto continueWait

[hitContinue]
"CONTINUE" State = false

   
ReplyQuote
(@hemicharger99)
Active Member
Joined: 6 years ago
Posts: 10
Topic starter  

Thanks for catching that. That's the problem with working with about 7+ different languages, I can never keep them all straight.

Since this uses a DigitalInput, the documentation didn't show a State property, just ActiveLow and Value, neither of which worked for me.

I will give this a shot tonight when I get home and see how it goes. 


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
 

I just realized that I made a mistake based on your comment... just when I thought I knew the script cold!!

I fixed it above, but that line should be:

if "ResetButton" Value == on

   
ReplyQuote
(@hemicharger99)
Active Member
Joined: 6 years ago
Posts: 10
Topic starter  

Worked like a charm! Thanks for your help with this. I may pick your brain on another issue if I can't resolve it in the next few days.

For other people that may want to use this, here are a few code snippets:

Elements

  1. "CONTINUE" - Button element, manual continue button from Workspace
  2. "ContinueSwitch" - Switch element, hidden
  3. "Panel Alarm" - Alarm element, with panel alarm digital output
  4. "Reset Button" - Digital input from physical resume button

Main script <Brew.script>

start "ResetButtonOrContinue"
sleep 1500
wait "ContinueSwitch" State == true
print "Continue clicked. Starting Prep Fill"

Continue Script <ResetButtonOrContinue.script>

"ContinueSwitch" State = false
"CONTINUE" State = false

print "Waiting for continue"
"Panel Alarm" Active = true

[continueWait]
if "CONTINUE" State == true
goto hitContinue
endif

if "ResetButton" Value == on
goto hitContinue
endif

sleep 150
goto continueWait

[hitContinue]
"Panel Alarm" Active = false
sleep 100
"CONTINUE" State = false
sleep 100
"ContinueSwitch" State = true
sleep 100

stop "ResetButtonOrContinue"

   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
 

Awesome. Feel free to pick anytime!


   
ReplyQuote
Share: