114 lines
4.1 KiB
PowerShell
114 lines
4.1 KiB
PowerShell
#Requires -Version 7.0
|
|
<#
|
|
.SYNOPSIS
|
|
End-to-end CLI test for the FOCAS (Fanuc CNC) driver.
|
|
|
|
.DESCRIPTION
|
|
**Hardware-gated.** There is no public FOCAS simulator; the driver's
|
|
FwlibFocasClient P/Invokes Fanuc's licensed Fwlib32.dll. Against a dev
|
|
box without the DLL on PATH the test will skip with a clear message.
|
|
Against a real CNC with the DLL present it runs probe / driver-loopback /
|
|
server-bridge the same way the other scripts do.
|
|
|
|
Set FOCAS_TRUST_WIRE=1 when -CncHost points at a real CNC to un-gate.
|
|
|
|
.PARAMETER CncHost
|
|
IP or hostname of the CNC. Default 127.0.0.1 — override for real runs.
|
|
|
|
.PARAMETER CncPort
|
|
FOCAS TCP port. Default 8193.
|
|
|
|
.PARAMETER Address
|
|
FOCAS address to exercise. Default R100 (PMC R-file register).
|
|
|
|
.PARAMETER OpcUaUrl
|
|
OtOpcUa server endpoint.
|
|
|
|
.PARAMETER BridgeNodeId
|
|
NodeId at which the server publishes the Address.
|
|
|
|
.PARAMETER Write
|
|
Issue #268 / plan PR F4-a — opts the script into the post-F4-a write
|
|
stages. F4-a ships the write infrastructure (driver-level Writes.Enabled
|
|
flag + per-tag Writable opt-in) without any actual wire writes; F4-b/c
|
|
populate this stage with real macro / parameter / PMC write coverage.
|
|
Until then the switch is a no-op marker so the e2e harness records that
|
|
the write surface was deliberately exercised (or skipped).
|
|
#>
|
|
|
|
param(
|
|
[string]$CncHost = "127.0.0.1",
|
|
[int]$CncPort = 8193,
|
|
[string]$Address = "R100",
|
|
[string]$OpcUaUrl = "opc.tcp://localhost:4840",
|
|
[Parameter(Mandatory)] [string]$BridgeNodeId,
|
|
[switch]$Write
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
. "$PSScriptRoot/_common.ps1"
|
|
|
|
if (-not ($env:FOCAS_TRUST_WIRE -eq "1" -or $env:FOCAS_TRUST_WIRE -eq "true")) {
|
|
Write-Skip "FOCAS_TRUST_WIRE not set — no public simulator exists (task #222 tracks the lab rig). Set =1 when -CncHost points at a real CNC with Fwlib32.dll on PATH."
|
|
exit 0
|
|
}
|
|
|
|
$focasCli = Get-CliInvocation `
|
|
-ProjectFolder "src/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Cli" `
|
|
-ExeName "otopcua-focas-cli"
|
|
$opcUaCli = Get-CliInvocation `
|
|
-ProjectFolder "src/ZB.MOM.WW.OtOpcUa.Client.CLI" `
|
|
-ExeName "otopcua-cli"
|
|
|
|
$commonFocas = @("-h", $CncHost, "-p", $CncPort)
|
|
$results = @()
|
|
|
|
$results += Test-Probe `
|
|
-Cli $focasCli `
|
|
-ProbeArgs (@("probe") + $commonFocas + @("-a", $Address, "--type", "Int16"))
|
|
|
|
$writeValue = Get-Random -Minimum 1 -Maximum 9999
|
|
$results += Test-DriverLoopback `
|
|
-Cli $focasCli `
|
|
-WriteArgs (@("write") + $commonFocas + @("-a", $Address, "-t", "Int16", "-v", $writeValue)) `
|
|
-ReadArgs (@("read") + $commonFocas + @("-a", $Address, "-t", "Int16")) `
|
|
-ExpectedValue "$writeValue"
|
|
|
|
$bridgeValue = Get-Random -Minimum 10000 -Maximum 19999
|
|
$results += Test-ServerBridge `
|
|
-DriverCli $focasCli `
|
|
-DriverWriteArgs (@("write") + $commonFocas + @("-a", $Address, "-t", "Int16", "-v", $bridgeValue)) `
|
|
-OpcUaCli $opcUaCli `
|
|
-OpcUaUrl $OpcUaUrl `
|
|
-OpcUaNodeId $BridgeNodeId `
|
|
-ExpectedValue "$bridgeValue"
|
|
|
|
$reverseValue = Get-Random -Minimum 20000 -Maximum 29999
|
|
$results += Test-OpcUaWriteBridge `
|
|
-OpcUaCli $opcUaCli `
|
|
-OpcUaUrl $OpcUaUrl `
|
|
-OpcUaNodeId $BridgeNodeId `
|
|
-DriverCli $focasCli `
|
|
-DriverReadArgs (@("read") + $commonFocas + @("-a", $Address, "-t", "Int16")) `
|
|
-ExpectedValue "$reverseValue"
|
|
|
|
$subValue = Get-Random -Minimum 30000 -Maximum 32766
|
|
$results += Test-SubscribeSeesChange `
|
|
-OpcUaCli $opcUaCli `
|
|
-OpcUaUrl $OpcUaUrl `
|
|
-OpcUaNodeId $BridgeNodeId `
|
|
-DriverCli $focasCli `
|
|
-DriverWriteArgs (@("write") + $commonFocas + @("-a", $Address, "-t", "Int16", "-v", $subValue)) `
|
|
-ExpectedValue "$subValue"
|
|
|
|
if ($Write) {
|
|
# F4-a no-op stage. Real per-kind write coverage lands in F4-b/c which extend the wire
|
|
# client past the BadNotSupported short-circuit + populate this branch with
|
|
# macro / parameter / PMC write assertions. Logged here so the harness records that the
|
|
# operator deliberately requested the write path.
|
|
Write-Host "[skip] -Write requested; F4-a ships infrastructure only — wire-write stages land in F4-b/c (issue #268)."
|
|
}
|
|
|
|
Write-Summary -Title "FOCAS e2e" -Results $results
|
|
if ($results | Where-Object { -not $_.Passed }) { exit 1 }
|