RobotStudio event

SignalChangedEventArgs not working

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

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?

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • pavpav
    pavpav
    edited August 2015
    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? /Pav
  • 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.htm

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • Niklas Skoglund
    Niklas Skoglund ✭✭✭
    edited August 2015
    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.

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog