# Prevent calling openView() method on Robot Program Execution

**URL:** https://forum.universal-robots.com/t/prevent-calling-openview-method-on-robot-program-execution/8450
**Category:** URCap Development
**Created:** [August 13, 2020, 8:14am UTC](https://forum.universal-robots.com/t/prevent-calling-openview-method-on-robot-program-execution/8450 "2020-08-13T08:14:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)
#### Post date: [August 13, 2020, 8:14am UTC](https://forum.universal-robots.com/t/prevent-calling-openview-method-on-robot-program-execution/8450/1 "2020-08-13T08:14:01Z")

</div>

Hi,

when running a Robot Program, it comes to Situations where URCaps in the Program Tree are randomly opened and closed which also triggers the openView() and closeView() methods.

This behavior causes issues for us, because we implemented serveral method callings in the openView() method, e.g. setting a Profinet IO which then calls another program through a socket because there is still no interface for doing this with the URCap API. Doing so, the Main Robot Program is stopped because of the new Socket Program.

Is this random open/close behavior desired or can i consider this a bug?

Is there a workaround to prevent calling the openView() on Robot Program Runtime? (without calling another socket function to read the state which overloads the thing even more)

Thank You!

---

<div class="post-metadata">

### Author: ![sam.verity-hilton](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/sam.verity-hilton/32/6046_2.png) [@sam.verity-hilton](https://forum.universal-robots.com/u/sam.verity-hilton)
#### Post date: [August 13, 2020, 8:31am UTC](https://forum.universal-robots.com/t/prevent-calling-openview-method-on-robot-program-execution/8450/2 "2020-08-13T08:31:50Z")

</div>

The only thing i an think of for a work around is having your calls wrapped behind a boolean field that is set to false in generate script to avoid them being called when a program is running, and using the dashboard server to monitor the program state to set the field back to true so that methods are called again once the program has stopped, not the cleanest solution though.

---

<div class="post-metadata">

### Author: ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)
#### Post date: [August 13, 2020, 8:39am UTC](https://forum.universal-robots.com/t/prevent-calling-openview-method-on-robot-program-execution/8450/3 "2020-08-13T08:39:53Z")

</div>

Hi @anon33452205,

the idea with the field in generateScript is good, the resetting is the problem tho. i could also use a IO which has prog-stop low behavior and read that back with the DigitalIO Interface or RTDE to reset the field… _sigh_

It would also cause another problem when saving a program: the field should be immedeately resetted because the view would no longer be updated 🙄

---

<div class="post-metadata">

### Author: ![sam.verity-hilton](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/sam.verity-hilton/32/6046_2.png) [@sam.verity-hilton](https://forum.universal-robots.com/u/sam.verity-hilton)
#### Post date: [August 13, 2020, 12:29pm UTC](https://forum.universal-robots.com/t/prevent-calling-openview-method-on-robot-program-execution/8450/4 "2020-08-13T12:29:54Z")

</div>

Actually having thought about it a little more, you could just query the dashboard server everytime `openview()` is called, and simply check whether the program running flag is high, and use that to check whether or not to run your methods. I think this should get around the saving/not resetting field issue 🙂

---

<div class="post-metadata">

### Author: ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)
#### Post date: [August 13, 2020, 1:47pm UTC](https://forum.universal-robots.com/t/prevent-calling-openview-method-on-robot-program-execution/8450/5 "2020-08-13T13:47:33Z")

</div>

Hi,

i ended up using the realtime interface because it responds faster than the dashboard server. Still not a cool solution but it works for now 👍

Thank you
