1
Support Questions / Re: Problem with subscribing via code for AllenBradleySLCMicro driver
« on: November 11, 2015, 04:20:17 PM »
OK - that's what I figured. Thanks for the help and the great product!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
private AdvancedHMIDrivers.EthernetIPforSLCMicroCom myMicroLogix = new EthernetIPforSLCMicroCom();
List<int> subscriptionReturn = new List<int>();
<snipped irrelevant code>
myMicroLogix.IPAddress = _config.IPAddress;
myMicroLogix.Port = int.Parse(_config.Port); //I do want to throw an exception if there is a config problem
//Record object will hold the items to return
foreach (var item in _config.RegisterDictionary)
{
//Subscribe to the given register with the register address (stored in value)
subscriptionReturn.Add(myMicroLogix.Subscribe(item.Value, 1, 2000, ReadPLC_Subscribe));
//Test reading the register
var value = myMicroLogix.Read(item.Value);
}
<snipped irrelevant code>
/// <summary>
/// Subscription callback for after the PLC subscription fires. We want to parse and send it back as a message to the actor for further processing
/// </summary>
/// <param name="stateInfo"></param>
/// <param name="plcArgs"></param>
private void ReadPLC_Subscribe(object stateInfo, PlcComEventArgs plcArgs)
{
RegisterCallbackData registerCallbackData = new RegisterCallbackData(plcArgs);
_self.Tell(registerCallbackData);
}
Dim z() As Object = {Me, x}
If SynchronizingObject Is Nothing Then
If SubscriptionList(i).dlgCallBack IsNot Nothing Then
SubscriptionList(i).dlgCallBack.Invoke(Me, x)
End If
Else If DirectCast(SynchronizingObject, Windows.Forms.Control).IsHandleCreated
SynchronizingObject.BeginInvoke(SubscriptionList(i).dlgCallBack, z)
End If