AdvancedHMI Software
General Category => Support Questions => Topic started by: romana on January 15, 2015, 05:35:18 PM
-
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
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
-
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)
-
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)
-
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
Dim x As New MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs(ReturnValues, values(0).ItemName, CUShort(clientHandle))
Anyway the final version of DataChangedCallBack is this:
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
SubscriptionState.UpdateRate = 250
after 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
-
Thanks for the update. I put those changes in so they will be part of the next release.
-
Archie, I am using AAHMIv3.99a. Using MatrikonOPC Explorer, I can see my tag value is updating. see picture.
(http://)
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.
-
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.
-
I set the break point , but it did not call DataChangedCallBack sub.
-
I found the problem. I need OPCGroup, cant have it blank.(http://)
-
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.