Remote operator dialog box can't send answer
I’m trying to create a remote operator dialog with my PC app but can’t get the SendAnswer() method to work.
I have followed this guide: http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/ae435101-731d-4fb3-be77-96e70b9aff19.htm
I have managed to catch the event, create a operator dialog and display header & messages. But I can’t return answer to robotcontroller.
I have tried the following code both on a virtual and a real controller.
I don’t get any error messages when trying the send the answer, nothing just happens.
If I answer the operator dialog on the robotcontroller my dialog is closed in the PC app so abort message is working fine.
Tpwrite & Tperase also works fine, and everything with uimsgbox works except sendanswer.
First I have created a subscription on the event.
<p>//subscribing to event</p><p><br></p><p>robcontroller.Rapid.UIInstruction.UIInstructionEvent += new UIInstructionEventHandler(OnUIInstructionEvent);</p><p> </p>
This is my eventhandler.
<p>void OnUIInstructionEvent(object sender, ABB.Robotics.Controllers.RapidDomain.UIInstructionEventArgs e) {</p><p><br></p><p> //Check what eventType is coming in</p><p><br></p><p>if (e.InstructionEventType == UIInstructionEventType.Post)</p><p><br></p><p>{</p><p><br></p><p> if (e.InstructionType == UIInstructionType.TPWrite) </p><p> </p><p>{</p><p><br></p><p> //Put latest tpwrite message on main screen</p><p><br></p><p>Form3.Instance.labelTpwrite.Text = e.EventMessage;</p><p><br></p><p>//Creat a listviewitem to add message to log listview</p><p><br></p><p>ListViewItem _temp = new ListViewItem(e.TaskName);</p><p><br></p><p>_temp.SubItems.Add(e.EventMessage);</p><p><br></p><p>//Add item to top of listview</p><p><br></p><p>tpwrite.Instance.listView1.Items.Insert(0,_temp);</p><p><br></p><p>} </p><p><br></p><p>if (e.InstructionType == UIInstructionType.TPErase) </p><p><br></p><p>{ </p><p><br></p><p>//Clear listview </p><p><br></p><p>tpwrite.Instance.listView1.Items.Clear();</p><p><br></p><p> }</p><p><br></p><p>}</p><p><br></p><p> </p><p> else if (e.InstructionEventType == UIInstructionEventType.Send) {</p><p><br></p><p>//If new op dialog is created, change image to alert operator message is avalible. </p><p><br></p><p>Form3.Instance.pDialog.Image = Properties.Resources.dialog_new;</p><p><br></p><p>if (e.InstructionType == UIInstructionType.UIMessageBox) {</p><p><br></p><p>//If messagetype is uimsgbox create new dialog window</p><p><br></p><p>uimsgbox Newbox = new uimsgbox(e);</p><p><br></p><p>}</p><p><br></p><p>else if (e.InstructionType == UIInstructionType.UIAlphaEntry) {</p><p><br></p><p>//If messagetype is AlphaEntry create new dialog window </p><p> </p><p>var aen = e as UIAlphaEntryEventArgs;</p><p><br></p><p>uialpha newal = new uialpha(aen);</p><p><br></p><p>} </p><p><br></p><p>}</p><p><br></p><p>else if (e.InstructionEventType == UIInstructionEventType.Abort) {</p><p><br></p><p>//Abort dialog in the current task if there is any</p><p><br></p><p>foreach (TabPage _tab in opDialog.Instance.tabControl1.TabPages) {</p><p><br></p><p>if (_tab.Name == e.TaskName) { </p><p><br></p><p>_tab.Dispose(); </p><p><br></p><p>}</p><p><br></p><p>}</p><p><br></p><p>//If there is no avalible dialog reset dialog image. </p><p><br></p><p>if (opDialog.Instance.tabControl1.TabPages.Count == 0) Form3.Instance.pDialog.Image = Properties.Resources.dialog1;</p><p><br></p><p>}</p><p><br></p><p>}</p><p> </p>
This is my operator window object:
<p> public partial class uimsgbox : UserControl</p><p><br></p><p>{</p><p><br></p><p>UIMessageBoxEventArgs eventobj;</p><p><br></p><p>public uimsgbox(UIInstructionEventArgs _e) {</p><p><br></p><p>InitializeComponent();</p><p><br></p><p>this.Dock = DockStyle.Fill;</p><p><br></p><p>//Add data from event object to local UIMessageBoxEventArgs object</p><p><br></p><p>eventobj = _e as UIMessageBoxEventArgs;</p><p><br></p><p>//I have also tried to instantly send answer when creating object but it dosen't work either</p><p><br></p><p>//eventobj.SendAnswer(UIButtonResult.OK);</p><p><br></p><p>//Fill dialog with header & message lines.</p><p><br></p><p>labelHeader.Text = eventobj.Header;</p><p><br></p><p>labelmsgline1.Text = eventobj.MsgArray[0].ToString();</p><p><br></p><p>labelmsgline2.Text = eventobj.MsgArray[1].ToString();</p><p><br></p><p>labelmsgline3.Text = eventobj.MsgArray[2].ToString();</p><p><br></p><p>labelmsgline4.Text = eventobj.MsgArray[3].ToString();</p><p><br></p><p>labelmsgline5.Text = eventobj.MsgArray[4].ToString();</p><p><br></p><p>//Create a new tabpage and add this control to page</p><p><br></p><p>TabPage _page = new TabPage(eventobj.TaskName);</p><p><br></p><p>_page.Name = eventobj.TaskName;</p><p><br></p><p>_page.Controls.Add(this);</p><p><br></p><p>opDialog.Instance.tabControl1.TabPages.Add(_page);</p><p><br></p><p>}</p><p><br></p><p> </p><p> private void button1_Click(object sender, EventArgs e){</p><p><br></p><p>eventobj.SendAnswer(UIButtonResult.Abort);</p><p><br></p><p>}</p><p><br></p><p> </p><p> private void button2_Click(object sender, EventArgs e){</p><p><br></p><p>eventobj.SendAnswer(UIButtonResult.Cancel);</p><p><br></p><p>}</p><p><br></p><p><br></p><p> </p><p> private void button3_Click(object sender, EventArgs e){</p><p><br></p><p><br></p><p>eventobj.SendAnswer(UIButtonResult.Ignore);</p><p><br></p><p><br></p><p>}</p><p><br></p><p> </p><p> private void button4_Click(object sender, EventArgs e){</p><p><br></p><p>eventobj.SendAnswer(UIButtonResult.No);</p><p><br></p><p>}</p><p><br></p><p> </p><p> private void button5_Click(object sender, EventArgs e){</p><p><br></p><p><br></p><p>eventobj.SendAnswer(UIButtonResult.OK);</p><p><br></p><p><br></p><p>}</p><p><br></p><p><br></p><p> </p><p> private void button6_Click(object sender, EventArgs e){</p><p><br></p><p>eventobj.SendAnswer(UIButtonResult.Retry);</p><p><br></p><p>}</p><p><br></p><p> </p><p> private void button7_Click(object sender, EventArgs e){</p><p><br></p><p>eventobj.SendAnswer(UIButtonResult.Yes);</p><p><br></p><p>}</p><p><br></p><p>}</p>
I have created 7 buttons because I have tried every message available to return but none of them works.
Rapid code for messagebox:
<p></p><p>UIMsgBox\Header:=<b>"This is a header"</b>,<b>"my simple message"</b>;</p>
Image of operator dialog in PC app.
Can anyone tell me what I have done wrong?
I have tried everything I can think of.
Robotware: 6.07
PC SDK: 6.07
PC: Windows 10 pro
If I helped, please press Vote Up
☑️2024 - RobotStudio® User Group
Best Answer
-
Hi, you need RAPID mastership to write the answer. E.g.
IMastershipResource r = _ctrl.Rapid;<br> r.Request();<br> eventobj.SendAnswer(UIButtonResult.OK);<br> r.Release();Johannes Weiman
Software Engineer
RobotStudio Team, ABB Robotics5
Answers
-
Excuse me for the crappy indentation I have tried to format the post in a readable fashion but it's not really displayed as in the editor.Systemintegrator - Web / C# / Rapid / Robotstudio
If I helped, please press Vote Up
☑️2024 - RobotStudio® User Group0 -
Thank you @Johannes Weiman this solved the problem.
The manual was a little bit tricky to understand when it states "There is no mastership handling involved in using Remote operator dialog."
But all good now thanks!Systemintegrator - Web / C# / Rapid / Robotstudio
If I helped, please press Vote Up
☑️2024 - RobotStudio® User Group0 -
I try to create following to the tutorial on developer center but it's not working. The OnUIInstructionEvent isn't called, the pointer is moved to next command. Here is my code:private void cb1_SelectionChanged(object sender, SelectionChangedEventArgs e){scanner = new NetworkScanner();scanner.Scan();//scan all avaiable controllersControllerInfoCollection controllers = scanner.Controllers;//save all avaiable controllersforeach (ControllerInfo controllerInfo in controllers)//search all avaiable controller and save into list{if(controllerInfo.SystemName == cb1.SelectedItem.ToString()){c = ControllerFactory.CreateFrom(controllerInfo);c.Logon(UserInfo.DefaultUser);lb_message.Content = "User was logon into " + c.SystemName + "!";c.Rapid.UIInstruction.UIInstructionEvent += new UIInstructionEventHandler(OnUIInstructionEvent);}}}public void OnUIInstructionEvent(object sender, UIInstructionEventArgs e){lb_message.Content = "A";if (e.InstructionEventType == UIInstructionEventType.Send){if (e.InstructionType == UIInstructionType.UIMsgBox){lb_message.Content = e.EventMessage;}}}0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 798 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings