@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user