OPC服务器的作用是通过OPC协议将DCS的数据取出,并开放,一般一个OPC服务器下面连接一个或多个客户端,客户端通过安装相应的软件(也支持OPC协议),来取得DCS的协议
乐拾芗逸盆然朵邢浏晔链特磊枫待谨璀楷塘丞彰OPC
server和OPC
client的区别:
1、执行的功能不同:
OPC
Server/Client
是一套利用微软的
COM/DCOM
技术达成工业自动化资料取得的架构。OPC
Server
提供了许多的接口,Client
端通过这些接口,可以取得与
OPC
Server
相连的硬件装置的信息,而无须了解这些硬件装置的细节信息。
2、开发环境不同:
当开发OPC
Client程序时,最好使用Windows桌面程序方式,这种方式可兼容OPC
Server程序运行在Windows桌面程序方式和Windows
NT服务方式,而当开发OPC
Server程序时,最好使用Windows
NT服务方式。
3、运行的标准不同:
可以将OPC
Server看作是协议转换器,OPC
Server使用设备的专用协议与设备通信,然后使用OPC
Classic和OPC
UA规范定义的标准化格式提供对该数据的访问。通常情况下,OPC
Server在OPC
Client请求读取或写入数据之前不会执行任何 *** 作。
参考资料来源:百度百科-OPC
Server
参考资料来源:百度百科-开放平台通信public void ListAll(Guid catid, out OpcServers[] serverslist)
{
serverslist = null;
Dispose();
Guid guid = new Guid("13486D51-4821-11D2-A494-3CB306C10000");
Type typeoflist = TypeGetTypeFromCLSID(guid);
OPCListObj = ActivatorCreateInstance(typeoflist);
ifList = (IOPCServerList)OPCListObj;
if (ifList == null)
MarshalThrowExceptionForHR(HRESULTSE_ABORT);
ifListEnumClassesOfCategories(1, ref catid, 0, ref catid, out EnumObj);
if (EnumObj == null)
MarshalThrowExceptionForHR(HRESULTSE_ABORT);
ifEnum = (IEnumGUID)EnumObj;
if (ifEnum == null)
MarshalThrowExceptionForHR(HRESULTSE_ABORT);
int maxcount = 300;
IntPtr ptrGuid = MarshalAllocCoTaskMem(maxcount 16);
int count = 0;
ifEnumNext(maxcount, ptrGuid, out count);
if (count < 1)
{ MarshalFreeCoTaskMem(ptrGuid); return; }
serverslist = new OpcServers[count];
byte[] guidbin = new byte[16];
int runGuid = (int)ptrGuid;
for (int i = 0; i < count; i++)
{
serverslist[i] = new OpcServers();
MarshalCopy((IntPtr)runGuid, guidbin, 0, 16);
serverslist[i]ClsID = new Guid(guidbin);
ifListGetClassDetails(ref serverslist[i]ClsID,
out serverslist[i]ProgID, out serverslist[i]ServerName);
runGuid += 16;
}
MarshalFreeCoTaskMem(ptrGuid);
Dispose();
}你先得确认那个OPC服务器是OPC DA的还是OPC UA的才行,如果是早期的OPC DA服务器,肯定是不支持OPC UA的。
如果那个服务器支持OPC UA,那么只要你的客户端写的规范点,应该可以连接上。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)