1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace FastReadDataFromIToolSDriver { using IToolS.Components.Communication; using IToolS.Components.IOServers; class Program { // query a remote device using itools in six lines of code static void Main(string[] args) { // 1) select the desired protocol (S7Tcp, ModbusMaster, FinsTcp, EthernetIP, ecc...) IOServer ioserver = new IOServer() { Name = "Simulation" }; // 2,3) select area and address Variable variable = new Variable() { Address = "0", Area = "E" }; Client client = new Client() { IOServer = ioserver }; // 4) start the driver client.StartSync(); // 5,6) read data from device Object[] values; client.ReadSync(new Variable[] { variable }, out values); // print the value Console.WriteLine("Value is: " + Convert.ToString(values[0])); Console.WriteLine("Press \"ENTER\" to exit"); Console.ReadLine(); } } } |