Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

QuickOPC with PowerShell - Register-ObjectEvent

More
12 Dec 2017 10:38 #5717 by support
Hello,

1. Can you try to make it happen when connecting to our public demo server instead? If so, we could then try to reproduce the same, and investigate here.

2. Can you use Visual Studio to attach to the running process and perhaps obtain more information about the crash?

Best regards

Please Log in or Create an account to join the conversation.

More
12 Dec 2017 10:08 - 12 Dec 2017 10:35 #5716 by Enrico
Hi,

we are trying to use the QuickOPC together with the PowerShell to establish a simple data logger. The script gets all Nodes that are linked to the top Node, defined in the parameter. Then the array for the EasyUAMonitoredItemArguments is established.

That works all fine, the subscription are established and the data are logged. The big issue with that is, that the logger crashes in an non deterministic way. Sometimes it crashes immediately, sometimes it runs for 5 minutes.

The PowerShell ISE (5.1) as well as the PowerShell (V5.1) are crashing without giving further details. Just a message box, that the PowerShell has crashed and will be restarted. Thus I have no idea, what to do to avoid this behavior.

Any idea how to make it more robust. Using the PowerShell is a requirement, thus using any other programming language is not an option.
try {
    Add-Type -Path 'C:\Program Files (x86)\OPC Labs QuickOPC 2017.2\Assemblies\net452\OpcLabs.EasyOpcUA.dll'
}
catch
{}
 
function writeDataLog($myEventArgs) {
    $OutString = $myEventArgs.Arguments.NodeDescriptor.DisplayString + ";" + $myEventArgs.AttributeData.Value + ";" + $myEventArgs.AttributeData.DisplayString
    $OutString >> .\DataLogger.csv
}
#Definition
$DataNodes = [OpcLabs.EasyOpc.UA.AddressSpace.UANodeElementCollection]::new()
$DataNode = [OpcLabs.EasyOpc.UA.AddressSpace.UANodeElement]::new()
$arrMonitoredItems = @()
 
$client = New-Object OpcLabs.EasyOpc.UA.EasyUAClient
# Definition für Data Transport Server
    $sEndPoint = "opc.tcp://TEXUS-Dellap:49580"
    $browseNode = "nsu=urn:NationalInstruments:uaserver:LabVIEW;ns=2;s=CAMP.ExpName"
 
$DataNode.NodeId = $browseNode
 
. C:\Workspace\PowerShell\ClassServerAccess.ps1
$myServer = [ServerAccessOPCUA]::new($client, $sEndPoint)
 
$tmpCollection = $myServer.getChildNodes($DataNode)
$tmpCollection > .\collection.txt
foreach($OPCUANode in $tmpCollection) {
    if ($OPCUANode.NodeClass -like "Variable") {
        $DataNodes.add($OPCUANode)
    }
}
 
$DataNodes.Count >> .\collection.txt
 
#$DataNodes.add($DataNode)
foreach($DataNode in $DataNodes) {
    $myVar = [ OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments]::new("", $sEndPoint, $DataNode.NodeID)
    $myVar.SubscriptionParameters = 1000
    $myVar.MonitoringParameters = 100
    $arrMonitoredItems += $myVar
}
 
$myEventHandler = Register-ObjectEvent -InputObject $client -EventName DataChangeNotification -Action { try {writeDataLog $EventArgs} Catch{} }
$client.SubscribeMultipleMonitoredItems($arrMonitoredItems)
Last edit: 12 Dec 2017 10:35 by support.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.054 seconds