ethercat-linux/scripts/tc-ads-mismatch-delta.ps1

16 lines
701 B
PowerShell
Raw Normal View History

#Requires -RunAsAdministrator
Add-Type -Path 'C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\v170\TwinCAT.Ads.dll'
$c = New-Object TwinCAT.Ads.TcAdsClient
$c.Connect('169.254.176.217.1.1', 851)
$h = $c.CreateVariableHandle('GVL_Sync.nMismatch')
$h2 = $c.CreateVariableHandle('GVL_Sync.bSync')
$m1 = $c.ReadAny($h, [int]); $b1 = $c.ReadAny($h2, [bool])
Write-Host ("t+15s : bSync=$b1 nMismatch=$m1")
Start-Sleep 30
$m2 = $c.ReadAny($h, [int]); $b2 = $c.ReadAny($h2, [bool])
Write-Host ("t+45s : bSync=$b2 nMismatch=$m2 delta=$($m2-$m1)")
Start-Sleep 30
$m3 = $c.ReadAny($h, [int]); $b3 = $c.ReadAny($h2, [bool])
Write-Host ("t+75s : bSync=$b3 nMismatch=$m3 delta=$($m3-$m2)")
$c.Dispose()