Skip to content

7 Modbus.Net.OPC(E)

luosheng edited this page Jun 7, 2023 · 5 revisions

class OPC

Basic Concept

OPC is a real time communication protocol by OPC Foundation, based on two ways, OPC DA based on DCOM, and OPC UA based on TCP.

Address

Modbus.Net.Opc has a special Formater called AddressFormaterOpc.

There is a Lambda Function in paramter, the param of this lambda function is machine and address, please create OPC Tag by using these two instances.

e.g.

If your tag is "1.15.Value_Opening", 1 is Id, 15 is station no, and Value_Opening is the name of address.

(baseMachine, addressUnit) => return new string[]{baseMachine.Id+"."+((XXUnitExtend)addressUnit.unitExtend).stationId+"."+addressUnit.Name};

Permission

You should run your application as Administrator if your OPC Server is hosted on Administrator, otherwise code will throw error when creating a connection.

How to write OPC Link address.

OPC DA should like "opcda://PC-Name/OPC-Software-Name".
But when you got E_NOINTERFACE by IOPCServerList2, you should add CLSID to the address.
opcda://PC-Name/OPC-Software-Name/{CLSID}

OPC UA should like "opc.tcp://{PC-Name}/{Opc-Software-Name}"。

Home

Clone this wiki locally