Auto: ablegacy-11 — RSLogix 500/PLC-5 CSV symbol import

Closes #254
This commit is contained in:
Joseph Doherty
2026-04-26 04:13:13 -04:00
parent 4fdeef7a6c
commit 4e8df38bb2
19 changed files with 1644 additions and 0 deletions

View File

@@ -196,5 +196,54 @@ if ($DiagnosticsRequestCountNodeId) {
}
}
# ablegacy-11 / #254 — RSLogix CSV import smoke. Builds an in-memory canonical CSV
# (one row per N/F/B/L/ST/T/C/R file letter), invokes `import-rslogix --emit
# appsettings-fragment` against it, parses the resulting JSON, and asserts the Tags
# array carries exactly 8 entries. Doesn't talk to the PLC — purely offline parser
# coverage.
Write-Header "RSLogix CSV import"
$importCsvPath = Join-Path $env:TEMP "ablegacy-rslogix-canonical-$([guid]::NewGuid()).csv"
$importJsonPath = Join-Path $env:TEMP "ablegacy-rslogix-fragment-$([guid]::NewGuid()).json"
@"
Symbol,Address,Description,DataType,Scope
MotorSpeed,N7:0,Motor speed setpoint,INT,Global
TankLevel,F8:0,Tank level (gallons),REAL,Global
RunFlag,B3:0/0,Run command flag,BOOL,Global
TotalCount,L9:0,Total piece count,LINT,Global
RecipeName,ST10:0,"Recipe name, free-form text",STRING,Global
DwellTimer,T4:0.ACC,Dwell timer accumulator,TIMER,Global
PieceCounter,C5:0.ACC,Piece counter accumulator,COUNTER,Global
StateMachine,R6:0.LEN,State-machine control length,CONTROL,Global
"@ | Set-Content -Path $importCsvPath -Encoding UTF8
try {
$importResult = Invoke-Cli -Cli $abLegacyCli `
-Args @("import-rslogix", "--file", $importCsvPath, "--device", $Gateway,
"--emit", "appsettings-fragment", "--output", $importJsonPath)
if ($importResult.ExitCode -ne 0) {
Write-Fail "import-rslogix exit=$($importResult.ExitCode): $($importResult.Output)"
$results += @{ Passed = $false; Reason = "import-rslogix exit $($importResult.ExitCode)" }
}
elseif (-not (Test-Path $importJsonPath)) {
Write-Fail "import-rslogix produced no output file at $importJsonPath"
$results += @{ Passed = $false; Reason = "no output file" }
}
else {
$fragment = Get-Content $importJsonPath -Raw | ConvertFrom-Json
$tagCount = @($fragment.Tags).Count
if ($tagCount -eq 8) {
Write-Pass "import-rslogix emitted $tagCount tag(s) — matches CSV row count"
$results += @{ Passed = $true }
} else {
Write-Fail "import-rslogix emitted $tagCount tag(s); expected 8"
$results += @{ Passed = $false; Reason = "tag count $tagCount" }
}
}
}
finally {
Remove-Item -Path $importCsvPath -ErrorAction SilentlyContinue
Remove-Item -Path $importJsonPath -ErrorAction SilentlyContinue
}
Write-Summary -Title "AB Legacy e2e" -Results $results
if ($results | Where-Object { -not $_.Passed }) { exit 1 }