Author Topic: BasicLabel Does not Update After PLCAddress Change.  (Read 1884 times)

stix

  • Newbie
  • *
  • Posts: 5
    • View Profile
BasicLabel Does not Update After PLCAddress Change.
« on: June 20, 2016, 05:05:35 PM »
I have approximately 180 Labels programmatically added to a Windows Form. I iterate to create the PLCAddress , my labels do not update. They stay the same - no change in values. I believe it has something to do when the subscription is created, I have tried to modify the code for PLCAddress property and use place the Subscriptions.UnSubscribe method in the Setter but that did not work either. Any ideas ?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: BasicLabel Does not Update After PLCAddress Change.
« Reply #1 on: June 20, 2016, 05:14:47 PM »
Are you setting the ComComponent before setting PLCAddressValue?

stix

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: BasicLabel Does not Update After PLCAddress Change.
« Reply #2 on: June 21, 2016, 12:52:54 PM »
Yes - the com component is on the form and set, I add the controls programmatically - this works fine - strangely enough. If I then try to reassign addresses - I have issues with them reassigning.
I am seeing sometimes it works flawlessly and at other times not. It gets sluggish or locks the UI. They appear to eventually update  - but sometimes after the UI is hung and 30 seconds plus goes by and then I see changes and they may not always be what I expect.  I replied on the sluggish driver thread - because this seems to be the issue my code is posted there.
I think this post really belongs on that thread.
 I do notice when iterating the items to write simply : myDriver.Write(address,value) it can get confused and will not take the value into the PLC.; this same behaviour can also be noticed
when entering in on the keypad rapidly from one basiclabel to the other basiclabel etc.. will cause a similar effect. 


 


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: BasicLabel Does not Update After PLCAddress Change.
« Reply #3 on: June 21, 2016, 12:58:42 PM »
What version of AdvancedHMI are you using ? There was a fix somewhere around version 3.99c that addresses a problem with switching pages too fast and causing the driver to create excessive threads and coming to a near halt.

stix

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: BasicLabel Does not Update After PLCAddress Change.
« Reply #4 on: June 21, 2016, 03:08:26 PM »
AdvHMI V3.99K

I guess in what I am doing - the behavior might be comparable to changing forms quickly - the subscriptions in the driver are not being updated fast enough - maybe a race condition of sorts is happening. I cant see your driver code - so I am wondering how the transition of the subscriptions are done; especially considering with 180 elements on the Form. I wonder if you have the Subscriptions added to a queue or list(Of T) in the driver.


Again here is my code:

Code: [Select]
    Private Sub ReAssignPLCAddress(planningClass As String, Is_ReadOnly As Boolean)
        IsReadOnly = Is_ReadOnly
        tblPlan.SuspendLayout()
        Dim element As Integer = 0
        Dim total As Integer = tblPlan.RowCount - 1
        For element = 0 To total
            Dim rowIndexer As String = "[" + element.ToString() + "]."
            For gutters As Integer = 1 To 4
                Try
                    Dim num As String = gutters.ToString()
                    Dim gutterTag As String = "Length_Cog_" + num + "_Inches"
                    Dim plcPath As String = planningClass + rowIndexer + gutterTag
                    Dim tempLabel As BasicLabel = New BasicLabel()
                    Dim ctrlX As Control() = tblPlan.Controls.Find(element.ToString() + gutterTag, True)
                    Dim ctrl As Control = ctrlX(0)
                    If Not ctrl Is Nothing Then
                        If ctrl.GetType() Is GetType(AdvancedHMIControls.BasicLabel) Then
                            tempLabel = ctrl
                            tempLabel.PLCAddressValue = plcPath
                            If IsReadOnly Then
                                tempLabel.PLCAddressKeypad = ""
                            Else
                                tempLabel.PLCAddressKeypad = plcPath
                            End If
                        End If
                    End If
                Catch ex As Exception
                    Dim err As String = ex.ToString()
                End Try
            Next
        Next
        tblPlan.Update()
    End Sub
« Last Edit: June 21, 2016, 04:24:03 PM by stix »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: BasicLabel Does not Update After PLCAddress Change.
« Reply #5 on: June 23, 2016, 08:44:59 AM »
I am having trouble replicating this. I created a form with 3 BasicLabels and 3 buttons. One of the BasicLabels pointing to TimerTag.ACC and left alone so I can see the communications continue. The other 2 change PLCAddressValue when any of the 3 buttons are clicked.

I clicked through the buttons fast and slow. I left it run through the night and clicked the buttons many more times after 8 hours of running. Everything worked as expected.

When changing the PLCAddress there is a built in delay of about a half second, but it always switched to displaying the new tag value after that short delay.

Can you create a simpler test to see if you still have the problem? Maybe it only occurs with the high number of BasicLabels.

stix

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: BasicLabel Does not Update After PLCAddress Change.
« Reply #6 on: July 05, 2016, 03:09:25 PM »
I am thinking it is the higher number of labels (180) causing the issue as well -because it seems to work with a limited number. It will choke around 100 or so and sometimes further down, sometimes it will do all of them.
  I am not sure how your driver is coded internally , but my guess is your subscriptions are added to a list of some sort and it is the remove and add that get in the way of each other. It does seem to behave like an issue with access to the list removing and inserting. If I update a second time - the update seems to work (obviously fewer changes). Perhaps it would be nice to be able to do a bulk Address Change where a bulk of Addresses are removed first and then added - for example as a group. This might be more efficient for the driver. In my application I have basically the same layout for 4 to 6 Forms - I auto generate the form with the Labels. On any given form load I need to change the base address from System01, to System02 etc.. So I would like to have a single form with the layout and simply change the IO points. On the Button_Click handler. For System01, System02 etc... similar to   System01_Click(sender as object, e as eventargs) ChangeSystem("System01") End
ChangeSystem(systemName As String) '   Iterate Addresses and change to systemName.

Each of my labels has to do an unsubscribe and a resubscribe - I am sure other things are happening at the same time inside the driver - it makes it inefficient . So if I could unsubscribe all labels as a  group, and then Subscribe them as a different group of addresses ) I would be doing a bulk unsubscribe, then resubscribe .. Much like using SuspendLayout , ResumeLayout on a Winform control.
 


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: BasicLabel Does not Update After PLCAddress Change.
« Reply #7 on: July 05, 2016, 06:21:01 PM »
Each time a subscription is added, it triggers the driver to optimize the list of subscriptions. You can reduce the frequency this happens by setting DisableSubscriptions to True, change everything, then set DisableSubscriptions back to False.