Author Topic: controls on unviewed tabs of a form do not get PLC values until tab is selected  (Read 1917 times)

usapatriotforlife

  • Newbie
  • *
  • Posts: 39
    • View Profile
I have an program that displays PLC values on multiple tab pages of a .net tabcontrol.  I have noticed that advancedhmi components on unviewed tab pages do not receive data from the plc.  Or, to be as accurate as possible, I have noticed that the "valuechanged" event for an advancedhmi control will not fire on unviewed tab pages. 

I believe that this could be related to the comment posted at the top of the every advanced hmi form that reads:

Quote
    '*******************************************************************************
    '* Stop polling when the form is not visible in order to reduce communications
    '* Copy this section of code to every new form created
    '*******************************************************************************


Of course the associated code for that visiblechanged event deals with the form, but I figure that something very similar is happening for the other controls.  Digging through the code, I see lots of places where the component's visibility is checked to determine how to handle various events.

The workaround that I have come up with is in my formload event to manually select each tab like this:

Quote
        TabControl1.SelectTab(2)
        TabControl1.SelectTab(1)
        TabControl1.SelectTab(0)


But this just doesn't seem like the best way to deal with this.  Is there a better way?  And even more so, I would like to poll regardless of visibility.  A lot of what I do is database related where I take the PLC values and store them in SQL Server.  In these cases, the form does not need to be visible at all and I don't want to ever take the chance that the program is not getting PLC information.

As a side note, the method that you use in the visiblechanged event is to disable subscriptions on the AdvancedHMIDrivers.IComComponent class object.  Is this the same as disabling subscriptions of the Ethernet IP Comm driver object?  I ask, because I've noticed that setting this property to true for the IP Comm driver, in other words, subscriptions are disabled, does not stop plc messages from flowing in to advancedhmi for controls that already have existing subscriptions.

Thanks for building this wonderful HMI tool kit and for making it free!!  It is really an awesome group of controls.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5268
    • View Profile
    • AdvancedHMI
I'm not completely sure why this is happening. It may be something to do with the way the TabControl works. It probably does not create the control instance or it's handle until the first time it is displayed. The controls do not subscribe until it's handle is created.

You can see this in BasicLabel.vb at about line 459.

Code: [Select]
    Private Sub SubscribeToCommDriver()
        If Not DesignMode And IsHandleCreated Then