titanium-as / TitaniumAS.Opc.Client

Open source .NET client library for OPC DA
MIT License
193 stars 94 forks source link

How to View the Connectable Server Names #9

Closed KimYounGi closed 6 years ago

KimYounGi commented 7 years ago

Hello! alexey-kachalov

I'm Youn-gi kim

First of all, thank you for your source. :)

I have some questions to ask you.

I succeeded in connecting to the opc server as your source. However, you need to know the opc server name when connecting.

  1. How to Find the Connectable Server Names..?
  2. group.ValuesChanged += GroupOnValuesChanged; //not working // Is not it an event that reads periodically whenever a value changes? // If not, can you periodically read values to multiple addresses using thread and etc..? best regards,

ps - I am not good at English myself so I used Google Translate. Sorry

alexey-kachalov commented 7 years ago

Hi Youn-gi kim! Glad to hear your thank. :)

There is my answers:

  1. Class OpcDaServer has three constructors:
    • OpcDaServer(Uri uri), with OPC URL argument which you can create using UrlBuilder helper class. This class creates URI object for you. The OPC URL is somthing like that "opcda://hostname/ProgId";
    • OpcDaServer(string progIdOrClsid, string host = null);
    • OpcDaServer(Guid clsid, string host = null). You need to know the ProgId or the CLSID of you OPC DA server and a hostname which contain the OPC DA server. Then you can use either constructor to create correct OpcDaServer object.
  2. The ValuesChanged event emits by OPC DA server itself. There is no polling timer there. You can create it yourself. In order to get notifications by event you need to setup an OPC group with property UpdateRate. The group also should be active (group.IsActive = true;) and should have OPC items added.
KimYounGi commented 7 years ago

Hi! alexey-kachalov

I appreciate your answers. :)

Is there a way to find the opc server name that I can connect to on my PC? -The name of opc server that can be connected with pc is unknown

Do you think I understood this first answer?

alexey-kachalov commented 7 years ago

You can find all of your OPC servers using for example MatrikonOPC Explorer (https://www.matrikonopc.com/downloads/176/index.aspx). It also provides OPC server for simulation. I suggest you to install this tool alongside with your work environment.