Un rapido esempio che mostra come configurare il driver IToolS OpcFoundation per comunicare con un Opc server.
Il server utilizzato per questo esempio e’ il MatrikonOPC Server for Simulation and Testing, la piattaforma di compilazione deve essere x86:
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using IToolS.Components.Communication; using IToolS.Components.IOServers; using IToolS.Data; using IToolS.Data.Base; namespace TestOpc { public partial class Form1 : Form { private Group group1; private Clients clients1; private Client client1; private Variable variable1; private Variable variable2; private IOServer ioServer1; public Form1() { InitializeComponent(); group1 = new Group(); variable1 = new Variable(); variable2 = new Variable(); ioServer1 = new IOServer(); clients1 = new Clients(); client1 = new Client(); group1.Add(variable1); group1.Add(variable2); variable1.Address = "Bucket Brigade.Real4"; variable1.VariableType = VariableTypeConverter.Variant; variable1.VariableName = "variable1"; variable2.Address = "Bucket Brigade.Int1"; variable2.VariableType = VariableTypeConverter.Variant; variable2.VariableName = "variable2"; ioServer1.AdvancedProperties.Add( new AdvancedProperty("ServerName", "Matrikon.OPC.Simulation.1")); ioServer1.Name = "OpcFoundation"; clients1.Add(client1); client1.Group = group1; client1.IOServer = ioServer1; variablesWindow1.Group = group1; } private void Form1_Load(object sender, EventArgs e) { clients1.Start(); } } } |