Author Topic: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a  (Read 5383 times)

romana

  • Newbie
  • *
  • Posts: 2
    • View Profile
Bug report

Tools:
for application development I am using: RSLogix Emulate 5000 to emulate PLC, RSLinx Classic as OPC server and wanted to try AdvancedHMI v3.97a.

Bug:
I open a new basic AdvancedHMI project, add communication driver OPCDaCom and set its all neccessary parameters then add any HMI controls like BasicLabel for example and set a PLCAddressValue and build and run application. Main Forms opens but the BasicLabel is not updated with the PLC read value, nothing happens, no any faults. I try the previous version 3.7 of AdvancedHMI and follow the same pattern. Result: works great, I try the newest relase v3.97c and the same: no updates, nothing happends on the screen.

Some troubleshooting:
When this happends I can see in RSLinx Classic: OPC Group Diagnosctics that groups are added properly and Subscription Packets are flowing. Also Active DDE/OPC Topic/Item List shows that desired tag is being read from a PLC. So subscriptions work there is sth wrong with callbacks

Possible root cause:
After studing the code for a little I have found the following conditional in SubscriptionHandler.vb in SubscibedDataReturned sub

Code: [Select]
Private Sub SubscribedDataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
        For Each Subscript In SubscriptionList
            Dim address As String = Subscript.PLCAddress
            If Subscript.Invert Then
                address = Subscript.PLCAddress.Substring(4)
            End If

            If (e.PlcAddress Is Nothing) OrElse (String.Compare(address, e.PlcAddress, True) = 0) Then
 
[and so on until control update]
the second part of the last conditional compares two strings but when using OpcDaCom driver the address variable is in the form:
address=PLCtag
while e.PlcAddress=[OPCTopic]PLCtag what may cause the problem
so even when everything os OK the condition fails and the control is never updated on the screen. When I change the condition everything works, controls are updated but this is not a solution for the problem

Best Regards

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a
« Reply #1 on: January 15, 2015, 06:21:25 PM »
Thanks for the detailed report. Based on your findings, I believe a change will have to be made on line 300 of the OpcDaCom.vb

Instead of using values(0).ItemName directly, it will have to be processed to remove the topic.

Care will have to be taken because this latest version has been tested with Bosch OPC server, so any changes must be sure not to break other OPC servers that do not use topics.

Modify OpcDaCom.vb and test this to see if it works:

        Dim PLCAddress As String = values(0).ItemName
        If m_OPCTopic IsNot Nothing AndAlso Not String.IsNullOrEmpty(m_OPCTopic) Then
            PLCAddress = PLCAddress.Substring(m_OPCTopic.Length)
        End If
        Dim x As New MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs(ReturnValues, PLCAddress, CUShort(clientHandle))
        OnDataReceived(x)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a
« Reply #2 on: January 15, 2015, 09:47:11 PM »
I think this should fix the problem. Go to OpcDaCom.vb to about line 300:

    Dim PLCAddress As String = values(0).ItemName
    If m_OPCTopic IsNot Nothing AndAlso Not String.IsNullOrEmpty(m_OPCTopic) Then
        PLCAddress = PLCAddress.Substring(m_OPCTopic.Length + 2)
    End If

    Dim x As New MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs(ReturnValues, PLCAddress, CUShort(clientHandle))
    OnDataReceived(x)

romana

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a
« Reply #3 on: January 18, 2015, 06:27:32 PM »
Yes it fixed the problem but not in the AsyncReadCompleteCallback method around line 300 but in the DataChangedCallBack sub around line 476. So the driver uses onChange event of OPC server not sync reads at least in case of RS Linx Classic. There is a For iteration loop so instead values(0) there should be values(i). I am not sure if sync and async callbacks are ever used by AdvancedHMI controls on the screen, I play with basic labels and messagedisplaybyvalue controls and it seems not but I suggest to apply the change whenever the following line or similar construction appears
Code: [Select]
Dim x As New MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs(ReturnValues, values(0).ItemName, CUShort(clientHandle))
Anyway the final version of DataChangedCallBack is this:
Code: [Select]
Private Sub DataChangedCallBack(ByVal clientHandle As Object, ByVal requestHandle As Object, ByVal values() As Opc.Da.ItemValueResult)

For i = 0 To values.Length - 1
Dim ReturnedValues() As String = {Convert.ToString(values(i).Value)}
Dim PolledAddress As PolledAddressInfo = DirectCast(values(i).ClientHandle, PolledAddressInfo)

Dim PLCAddress As String = values(i).ItemName
If m_OPCTopic IsNot Nothing AndAlso Not String.IsNullOrEmpty(m_OPCTopic) Then
PLCAddress = PLCAddress.Substring(m_OPCTopic.Length + 2)
End If

Dim x As New MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs(ReturnedValues, PLCAddress, 0)
x.SubscriptionID = PolledAddress.ID
Dim z() As Object = {Me, x}
m_SynchronizingObject.BeginInvoke(PolledAddress.dlgCallBack, z)

Next
End Sub
and it works thus closes the topic for me.
Thanks for fast reply.

Also after some tries with fast updating PLC tags such as production counter of a machine (decorator - offset printer) running 1500 products per minute I add the following line

Code: [Select]
SubscriptionState.UpdateRate = 250 after
Code: [Select]
SubscriptionState.Name = "SubscribedGroup" on the line 383. This will set another parameter of any OPC group that correspondents to update rate of a group. When a Update Rate is set to 250ms for example instead of default 1ms then my production counter is updated more continuously without freezing

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a
« Reply #4 on: January 18, 2015, 07:10:09 PM »
Thanks for the update. I put those changes in so they will be part of the next release.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a
« Reply #5 on: December 14, 2015, 03:20:00 PM »
Archie, I am using AAHMIv3.99a.  Using MatrikonOPC Explorer, I can see  my tag value is updating. see picture.

I setup one OPCDa driver with one BasicLabel.  it run and read the value on first run, but not updating thereafter. This topic seemed to say the problem is fixed, but I am still experiencing it.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a
« Reply #6 on: December 14, 2015, 03:43:57 PM »
The OpcDaCom driver relies on the Data Changed Callback from the OPC Server. In OpcDaCom.vb at line 524, you will see this routine:

   Private Sub DataChangedCallBack(ByVal clientHandle As Object, ByVal requestHandle As Object, ByVal values() As Opc.Da.ItemValueResult)


Put a breakpoint at the first line that subroutine to see if it is being called by the OPC Server.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a
« Reply #7 on: December 14, 2015, 03:54:03 PM »
I set the break point , but it did not call DataChangedCallBack sub.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a
« Reply #8 on: December 14, 2015, 04:17:19 PM »
I found the problem. I need OPCGroup, cant have it blank.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

baguinn

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: AdvHMI controls are not being updated on OpcDaCom driver, soft ver 3.97a
« Reply #9 on: December 14, 2015, 06:56:52 PM »
Your problem sounds like the one I had. It looks like you are using a remote OPC server. If this is the case,  you are having DCOM issues. I'd like to say I know all about it,  but what I do know is that these are security measures inside of Windows. I got some help from some folks much smarter than me, they created me another OPC driver with all the security stuff. Not exactly sure what all that involves and if it fixes every case.