AdvancedHMI Software
General Category => Support Questions => Topic started by: PJonHar on May 23, 2017, 08:04:50 AM
-
Hi,
I am using the Subscribe on certain tags that a user can define via XML, which is then read in and the subscriptions made.
Private Sub QCompositeButtonPLCMessages_ItemActivated(sender As System.Object, e As Qios.DevSuite.Components.QCompositeEventArgs) Handles QCompositeButtonPLCMessages.ItemActivated
Try
Dim frmPLCMessages As New frmPLCMessages()
If frmPLCMessages.ShowDialog(Me) = DialogResult.OK Then
ApplicationPLCMessages = New PLCMessages().Load
SubscribePLCMessages()
End If
frmPLCMessages = Nothing
Catch ex As Exception
Log.ErrorMessage(ex.TargetSite.Name, ex.Message, "1410")
End Try
End Sub
Private Sub UnsubscribePLCMessages()
For Each i As Integer In SubscriptionIDs
PLC.UnSubscribe(i)
Next
SubscriptionIDs.Clear()
End Sub
Private Sub SubscribePLCMessages()
UnsubscribePLCMessages()
For Each pm As PLCMessage In ApplicationPLCMessages
If pm.Message.Length > 0 Then
SubscriptionIDs.Add(PLC.Subscribe(pm.Tag, 1, AddressOf SubscriptionCallback))
End If
Next
End Sub
Upon initial loading of the main form the method SubscribePLCMessages is ran and the subscription works.
If i open the form frmPLCMessages and then click OK to the form the SubscribePLCMessages is re-ran to ensure any changes made to the XML file take place. However, upon this second call to SubscribePLCMessages my program hangs on the line 'PLC.Subscribe(pm.Tag, 1, AddressOf SubscriptionCallback)'.
Any Ideas?
Thanks.
-
What driver and what version are you using?
-
Hi Archie,
I am using the ClxDriverV111R766.
-
bump
-
There is a SyncLock that prevents subscription changes while they are being updated. One possibility for a call to Subscribe to hang would be this:
On a callback of subscription data returned, if you hold that and at the same time wait for a call to subscribe to finish, you will be in a grid lock situation.
Also the Subscribe method in the driver does not check for duplicate subscriptions. So if you call Subscribe with the same parameters twice, then the driver will process the callback twice for every data update.