- I have a program using script function “set_runstate_standard_digital_output_to_value(outputId, state)” in the function “generateScript()” from a program contribution node. When I set it to “Low when not running” in this function it works well, but when I go to IO tab, the IO used with the script function is still in this configuration even if the program is stopped. I cannot trigger it manually anymore until I change the IO used with the script function.
Also, when I go to Installation tab -> IO setup and I select the IO , the “action in in program” doesn’t reflect the IO state.
It seems there is no way I can programmaticaly handle this problem.
- I used the script function “set_runstate_standard_digital_output_to_value(outputId, state)” and set state to 1 in generateScript(), then I set state to 2 when I send a primary program through socket with a button. The state stays at 1 and is never overrided.
Can you help me with that?
- This is the expected functionality - it keeps the IO in that state when the program isn’t running. But as this was sent directly to the controller, Polyscope doesn’t realise that this change has been made and doesn’t reflect it.
I’m not sure if there is a way to do this through the Java API/Polyscope instead of directly with script. Perhaps Jacob can help on that.
- When I send the command to the primary interface it is executed as expected, so perhaps there’s an issue with the script you’re sending?
What is your intended behaviour here? Set the output low when the program stops but then allow the user to change it after that? I guess you could monitor the program state in a Daemon and send a simple set_standard_digital_out(outputId,False) when it stops instead?
“monitor the program state in a Daemon and send a simple set_standard_digital_out(outputId,False) when it stops instead?”
That’s exactly what i am doing for my test button.
I want to set the IO at Low when not running when using generateScript() function in ProgramNodeContibution and a want a test button in my interface to be able to turn ON this IO when pressed and turn OFF when released. But it seems that I am not able to override the Low when not running state once it is executed in the URScript, even if i send another URScript setting the runstate to High when not running.
When the runstate of an IO is set to go low, when program is not running, every time a program is not running the IO will not be able to go high.
If you want to set this high, the following option will not work:
- Sending “set_digital_out(x, True)” or similar to the client interface.
Why: Because this is executed as a single line program, so it will actually turn the IO on, but immediately after it is turned on, the program will stop again, turning the IO lack low
There are two possible ways to achieve the ability to “test high” on the IO.
- Send a program, that includes toggling the runstate to “neutral” - not “high when stopped”.
Basically set the runstate of the IO back to default (no action), followed by a statement to set the IO high.
You need to find an appropriate means to set it low again, when button is released.
- Send a program that keeps executing until the button is pressed. I.e. waiting for a signal to indicate the button is released. Hence the program is actually running for the entire duration of the press.
@jbm my understanding is that the issue here is that the runstate when stopped cannot be reset when it’s been defined in generateScript(). So your first suggestion wouldn’t work, but your second could be a good workaround.
Can you see any reason why putting the original set_runstate_standard_digital_output_to_value command in the generateScript() function would make it behave any different to setting it through Polyscope? It seems that it’s not possible to override it with another set_runstate_standard_digital_output_to_value command later, whether that’s to set it back to neutral or to high when stopped?
@j-p.royer as a test if you set the original runstate manually through Polyscope instead of automatically with your URCap, can your button successfully change the runstate when stopped?
I set my Digital_IO 7 to Low_when_not_running in installation tab and this script sending trhough socket with my test button :
It still doesn’t work.
It works for me. The third line of your script should be “set_standard_digital_out(7,True)” out not output. Also make sure you have a at least one space indent at the start of each line inside the function and a newline character after your end.
@ajp Thank you very much!