Difference between revisions of "How to subscribe to OPC data changes in PowerShell"
Jump to navigation
Jump to search
(Created page with "Category:.NET Category:Console application Category:PowerShell Category:How to Category:OPC DA The following PowerShell code subscribes to an OPC item and...") |
|||
Line 15: | Line 15: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | We have tested this with QuickOPC 5.40 and PowerShell 3.0. | + | We have tested this with QuickOPC 5.40 and PowerShell 3.0. For some issues and limitations, see [[How to read an OPC item value in PowerShell]]. |
Revision as of 17:26, 7 September 2016
The following PowerShell code subscribes to an OPC item and displays the incoming data changes:
Add-Type -Path OpcLabs.EasyOpcClassic.dll
# Create EasyOPC-DA component
$client = New-Object OpcLabs.EasyOpc.DataAccess.EasyDAClient
# Hook events
Register-ObjectEvent -InputObject $client -EventName ItemChanged -Action { Write-Host $EventArgs }
# Subscribe
$client.SubscribeItem("", "OPCLabs.KitServer.2", "Demo.Single", 1000)
We have tested this with QuickOPC 5.40 and PowerShell 3.0. For some issues and limitations, see How to read an OPC item value in PowerShell.