hail all,
i have tried basic addition dynamicly for DataSubscriber2 but i coudnt get any values.
i added a ModbusTCPCom modbusTCPCom1 from toolbox as drag and drop,
then i added dynamicly a DataSubscriber2 ds, ModbusTCPCom mbDelta and PLCAddressItem item0 = new PLCAddressItem { PLCAddress = "U44597", Name = "L1" };
when the ds.Comcomponent = modbusTCPCom1; is ok i read my first object L1 by ds.GetValuesByName("L1");
but ds.Comcomponent = mbDelta; is not working.
i tried to copy all setup for modbusTCPCom1 from designer.cs even more =) i miss something here. anyway code is below,
public partial class Form1 : Form
{
PLCAddressItem item0 = new PLCAddressItem { PLCAddress = "U44597", Name = "L1" };
ModbusTCPCom mbDelta = new ModbusTCPCom();
DataSubscriber2 ds = new DataSubscriber2();
public Form1()
{
InitializeComponent();
mbDelta.BeginInit();
ds.BeginInit();
mbDelta.DisableSubscriptions = false;
mbDelta.IniFileName = "";
mbDelta.IniFileSection = null;
mbDelta.IPAddress = "192.168.1.5";
mbDelta.MaxReadGroupSize = 20;
mbDelta.PollRateOverride = 500;
mbDelta.SwapBytes = true;
mbDelta.SwapWords = true;
mbDelta.TcpipPort = ((ushort)(502));
mbDelta.TimeOut = 20000;
mbDelta.UnitId = ((byte)(1));
ds.ComComponent = mbDelta;
ds.PLCAddressValueItems.Add(item0);
ds.PollRate = 0;
ds.SynchronizingObject = this;
ds.Value = null;
ds.EndInit();
mbDelta.EndInit();
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
richTextBox1.Text = ds.GetValueByName("L1");
}
}