My Blog

How To use IToolS OPC driver

by itools@albertoschiassi.it on giovedì 6 marzo 2031 09:33

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: 

 

 

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();
      }
   }
}

 

TestOpc.zip

Blogs Parent Separator IToolS Blog
Author

Tags