fistful of bytes


Added a readme

Posted almost 2 years ago.
Updated about 1 year ago.
3 commits

OPC Sample Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OPCAutomation;
namespace OPC
    public partial class Form1 : Form
        OPCServer ObjOPCServer;
        OPCGroups ObjOPCGroups;
        OPCGroup ObjOPCGroup;
        string OPCServerName;
        public Form1()
                OPCServerName = "{Here comes your OPC server’s name}";
                ObjOPCServer = new OPCServer();
                ObjOPCServer.Connect(OPCServerName, "";);
                ObjOPCGroups = ObjOPCServer.OPCGroups;
                ObjOPCGroup = ObjOPCGroups.Add("OPCGroup1");
                ObjOPCGroup.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(ObjOPCGroup_DataChange);
                ObjOPCGroup.OPCItems.AddItem("{tag name or address (like {plc name on server}!%mw0)}", 1);
                ObjOPCGroup.UpdateRate = 10;
                ObjOPCGroup.IsActive = true;
                ObjOPCGroup.IsSubscribed = true;
            catch (Exception e){

        private void button1_Click(object sender, EventArgs e)

        private void ObjOPCGroup_DataChange(int TransactionID, int NumItems, ref Array ClientHandles, ref Array ItemValues, ref Array Qualities, ref Array TimeStamps)
            for (int i = 1; i <= NumItems; i++)
                if ((Convert.ToInt32(ClientHandles.GetValue(i)) == 1))
                    textBox1.Text =  ItemValues.GetValue(i).ToString();

        private void Form1_Load(object sender, EventArgs e)
            OPCServerClass GlobalOPCServer = new OPCServerClass();
            Array ServerList = (Array)GlobalOPCServer.GetOPCServers(""); 
            for (int i = 1; i <= ServerList.Length; i++)

Just do a simple search for Interop.OPCAutomation.dll and download it…
i think it may be copyrighted so i can’t upload it.

Discussions, comments, and suggestions.
If you hate this send me a tweet.

Otherwise there are no discussions on this page, if you think there is something wrong with this post (chances are you right) fix it. Head over to github and open a new issue. Check out re-thinking blogging for more.