SignalChangedEventArgs not working
pavpav
✭
Hi all
I am trying to create an event handler for signal change as in the PC SDK application manual.
I have a virtual controller at which i am changing a signal "DO_testing" but during debugging the event handler does not seem to react to changed signal value.
This is my code:
in the Form_Load:
Signal sig = controller.IOSystem.GetSignal("DO_testing");
sig.Changed += new EventHandler(sig_Changed);
sig.Subscribe(sig_Changed, EventPriority.High);
private void sig_Changed(object sender, SignalChangedEventArgs e)
{
this.Invoke(new EventHandler(UpdateUI), new Object[] { sender, e });
}
private void UpdateUI(object sender, SignalChangedEventArgs e)
{
SignalState state = e.NewSignalState;
float val = state.Value;
}
The program pointer never enters the sig_Changed void as i Set/Reset my DO signal.
/Pav
0
Comments
-
Hi Pav, I see that you first make a "normal subscription" using += and then using the Subscribe method. Try first commenting out the call to Subscribe and check if the event fires. We have had a bug in the implementation of high priority subscriptions. Which version of PC SDK are you using?0
-
Hello Niklas. Thanks for reply. Im using sdk 6.01 but i found out what my problem was, i was closing the thread of the first form and starting a new one. After revoking this, the event seems to be working. The forum seems to be trimming my posts and removing all the empty rows, how can i keep some empty rows to have some separation in my message? /Pav1
-
Great that it works now! Threading can be tricky I think you are aware of this already, but if anyone else is reading - remember to not directly access your UI from the controller event handlers. Read more here - http://developercenter.robotstudio.com:80/Index.aspx?DevCenter=RobotCommunication&OpenDocument&Url=html/be2d634e-7ea6-47d0-88a4-6f031be633d1.htm0
-
Sorry I forgot your feedback on the forum itself. You are right. I also made a post with some new lines in it and when viewing it in preview and after it has been posted - new lines are trimmed. Something has happened... When I edit the post again it looks correct. So it seems that the content is available behind the scenes but when the post is rendered something is trimmed away. I'll ask the forum team to have a look at it.0
Categories
- All Categories
- 5.5K RobotStudio
- 395 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings