1
Support Questions / Subscribe - EIPTransport.SendData Error, No Callback
« on: February 18, 2020, 11:36:42 AM »
Hi,
Version:3.99y Beta 34
I have the following program that subscribes to tags via code (ignore the IPAddress).
The tags get updated, but only on the initial execution of the program.
The following error messages appear at each poll:
The pollrate is quite high (5000ms), so i think this is okay.
Any ideas what it could be?
Version:3.99y Beta 34
I have the following program that subscribes to tags via code (ignore the IPAddress).
Code: [Select]
private EthernetIPforCLXCom PLCComms = null;
private List<int> SubscriptionIDs = new List<int>();
public K_AutoExternal AEX { get; set; } = new K_AutoExternal();
private string AEXParentTag = "Robot1";
public MainWindow()
{
InitializeComponent();
DataContext = this;
PLCComms = new EthernetIPforCLXCom();
PLCComms.BeginInit();
PLCComms.IniFileName = "CLX.ini";
PLCComms.IniFileSection = "PLCComms";
PLCComms.EndInit();
PLCComms.ComError += this.PLCComms_ComError;
SubscribeAEXTags();
PLCComms.ReadClock();
}
private void UnsubscribeAEXTags()
{
foreach (int i in SubscriptionIDs)
PLCComms.Unsubscribe(i);
SubscriptionIDs.Clear();
}
private void SubscribeAEXTags()
{
try
{
UnsubscribeAEXTags();
PropertyInfo[] properties = typeof(K_AutoExternal).GetProperties();
foreach (PropertyInfo property in properties)
SubscriptionIDs.Add(PLCComms.Subscribe(String.Format("{0}.{1}", AEXParentTag, property.Name), 1, 5000, SubscriptionCallback));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.TargetSite.Name);
}
}
private void SubscriptionCallback(object sender, PlcComEventArgs e)
{
if (e.ErrorId == 0 && e.Values != null && e.Values.Count > 0)
ParseData(e.PlcAddress, e.Values[0]);
}
private void ParseData(string tag, string value)
{
try
{
PropertyInfo[] properties = typeof(K_AutoExternal).GetProperties();
foreach (PropertyInfo property in properties)
{
if (String.Format("{0}.{1}", AEXParentTag, property.Name) == tag)
{
TypeConverter typeConverter = TypeDescriptor.GetConverter(AEX.GetType().GetProperty(property.Name).PropertyType);
object propValue = typeConverter.ConvertFromString(value);
AEX.GetType().GetProperty(property.Name).SetValue(AEX, propValue, null);
AEX.UpdateProperties();
break;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.TargetSite.Name);
}
}
private void PLCComms_ComError(object sender, PlcComEventArgs e)
{
Console.WriteLine(e.ErrorId + " - " + e.ErrorMessage);
}
The tags get updated, but only on the initial execution of the program.
The following error messages appear at each poll:
Code: [Select]
0 - EIPTransport.SendData-No Response
-22 - No Response from PLC(22)
The pollrate is quite high (5000ms), so i think this is okay.
Any ideas what it could be?