ethercat-linux/scripts/tc-verify.ps1

85 lines
2.7 KiB
PowerShell
Raw Normal View History

#Requires -Version 5.1
<#
.SYNOPSIS
Dump EL6695 configuration XML (offline or online) for verification.
.DESCRIPTION
Opens the solution, locates the EL6695 box in the IO tree, and exports
its ProduceXml to a file. Checks for expected PDO entries (0x1608/0x1A08).
.PARAMETER Solution
Path to the .sln file.
.PARAMETER OutputFile
Where to save the EL6695 XML. Default: Logs\el6695_dump.xml
.EXAMPLE
.\tc-verify.ps1
.\tc-verify.ps1 -Visible # show XAE window
#>
[CmdletBinding()]
param(
[string]$Solution = $null,
[string]$OutputFile = $null,
[switch]$Visible
)
. "$PSScriptRoot\tc-common.ps1"
if (-not $Solution) { $Solution = $script:DefaultSolution }
if (-not $OutputFile) { $OutputFile = Join-Path $script:DefaultLogDir "el6695_dump.xml" }
New-Log $script:DefaultLogDir
$LogFile = Join-Path $script:DefaultLogDir "verify.log"
Write-Log "=== Verify EL6695 Configuration ===" $LogFile
$dte = Get-Dte -Visible:$Visible
try {
if (-not (Open-Solution -Dte $dte -Solution $Solution)) { throw "Solution did not open" }
$sysMgr = Get-SysManager -Dte $dte
# Find EL6695
$io = Find-TreeItem -SysMgr $sysMgr -Paths @("TIID")
if (-not $io) { throw "TIID node not found" }
$box = Find-Box -Node $io -Pattern "*EL6695*"
if (-not $box) { throw "EL6695 box not found under TIID" }
Write-Log "Found: $($box.Name) at $($box.PathName)" $LogFile
# Export XML
$xml = $box.ProduceXml($true)
[System.IO.File]::WriteAllText($OutputFile, $xml, [System.Text.Encoding]::UTF8)
Write-Log "XML saved: $OutputFile ($($xml.Length) bytes)" $LogFile
# Parse key fields
[xml]$doc = $xml
$pdo1608 = $doc.SelectSingleNode("//Pdo[@Index='#x1608']")
$pdo1A08 = $doc.SelectSingleNode("//Pdo[@Index='#x1a08']")
$pdo1A01 = $doc.SelectSingleNode("//Pdo[@Index='#x1a01']")
Write-Log "0x1608 (IO Outputs): $(@($pdo1608.Entry).Count) entries" $LogFile
Write-Log "0x1A08 (IO Inputs): $(@($pdo1A08.Entry).Count) entries" $LogFile
Write-Log "0x1A01 (SYNC Inputs): $(if ($pdo1A01) { 'present' } else { 'absent' })" $LogFile
if ($pdo1A08) {
foreach ($entry in $pdo1A08.Entry) {
$type = $entry.Type
$bitSize = $entry.BitSize
Write-Log " 0x1A08 entry: $($entry.Name) Index=$($entry.Index):$($entry.Sub) Type=$type BitSize=$bitSize" $LogFile
}
}
if ($pdo1608) {
foreach ($entry in $pdo1608.Entry) {
$type = $entry.Type
$bitSize = $entry.BitSize
Write-Log " 0x1608 entry: $($entry.Name) Index=$($entry.Index):$($entry.Sub) Type=$type BitSize=$bitSize" $LogFile
}
}
Write-Log "=== Verify complete ===" $LogFile
}
finally {
try { $dte.Quit() } catch { }
}