使用PowerShell连接到OPC服务器

时间:2016-09-06 21:11:59

标签: powershell opc

我正在尝试使用PowerShell从OPC服务器读取值。我一直在做一些研究,但我看不到任何参考或类似的情况。

我安装了Matrikon OPC Simulation服务器并尝试加载OPCdotNETLib.dll程序集。程序集已成功加载。在使用对象操作时,我可以看到智能感知。我现在没有收到任何错误,但我认为没有成功连接。

$Path = "C:\OPCdotNETLib.dll"
Add-Type -Path $Path
[System.Reflection.Assembly]::LoadWithPartialName('System.Runtime.InteropServices') 

$OPCServer = New-Object OPC.Data.OpcServer
$OPCServer = [OPC.Data.OPCServer]::new()
$OPCServerName = "Matrikon.OPC.Simulation.1"
$OPCServer.Connect($OPCServerName) 

您是否有任何线索或帮助参考?

1 个答案:

答案 0 :(得分:1)

您可以使用QuickOPC(http://www.opclabs.com/products/quickopc;免责声明:这是一种自我推销)。 OPC读取完成如下:

if (this.scrollView.getParent() != null)
   ((ViewGroup)this.scrollView.getParent()).removeView(this.scrollView);    

setContentView(this.scrollView);

取自:http://kb.quickopc.com/How_to_read_an_OPC_item_value_in_PowerShell