private void button3_Click(object sender, EventArgs e) { if (client == null) { //Debug.WriteLine("Start"); var cc = new PModbusConnection(new EthernetDevice() { IPAddr = "192.168.1.170", Timeout = 1000, }); cc.AddToRead(new PModbusReadItem(0, 100, PModbusType.Input) { GroupID = 1, ReadCount = 1 }); cc.AddToRead(new PModbusReadItem(0, 100, PModbusType.Hold) { GroupID = 1, ReadCount = 1 }); client = new PModbusClient(cc, new PModbusStore(ref AppData.IDatas, ref AppData.ODatas)); client.Notify += Clienter_Notify; client.Start(); Debug.WriteLine(client.Connection.ToString()); } buttonStart.Enabled = false; button3.Enabled = false; button2.Enabled = true; }
private void buttonStart_Click(object sender, EventArgs e) { if (client == null) { //Debug.WriteLine("Start"); var cc = new PModbusConnection(new SerialPortDevice() { ComPort = "COM1", BandRate = 115200, Timeout = 1000, }); cc.AddToRead(new PModbusReadItem(0, 100, PModbusType.Input) { GroupID = 1, ReadCount = 1 }); cc.AddToRead(new PModbusReadItem(0, 100, PModbusType.Hold)); client = new PModbusClient(cc, new PModbusStore(ref AppData.IDatas, ref AppData.ODatas)); client.Notify += Clienter_Notify; client.Interval = 10; client.Start(); Debug.WriteLine(client.Connection.ToString()); } buttonStart.Enabled = false; button3.Enabled = false; button2.Enabled = true; }
private void button2_Click(object sender, EventArgs e) { if (client != null) { client.Stop(); //Debug.WriteLine("Stop"); client = null; } buttonStart.Enabled = true; button3.Enabled = true; button2.Enabled = false; }