shopfloor menu: data-driven from menu.json (picker + webapp editor)
Replace the hardcoded GEA Shopfloor PC-type sub-menu with a data-driven one:
- menu.json on the enrollment share lists the shopfloor items {key=PCTYPE, label, hint, enabled}; key must match a shopfloor-setup/gea-shopfloor-* handler dir.
- select-shopfloor-type.ps1 renders it in WinPE and writes the chosen PCTYPE (mirrors the CMM bay picker); startnet.cmd runs it and falls back to the baked-in menu if the share/picker is unavailable.
- Webapp /shopfloor-menu editor: reorder/rename/hide/add items; the PC-type is a dropdown of existing handler dirs (can't wire a choice to a non-existent type); writes menu.json. Nav link under Tools.
Kills the duplicated-knowledge problem (menu list was hardcoded in startnet AND the handler dirs AND site-config); add a PC-type = drop in the handler dir + it appears in the menu.
This commit is contained in:
15
playbook/shopfloor-setup/menu.json
Normal file
15
playbook/shopfloor-setup/menu.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"_comment": "Data-driven WinPE shopfloor PC-type menu. Read at boot by select-shopfloor-type.ps1 (mirrors the CMM bay picker) and edited by the PXE webapp. 'key' is the PCTYPE value - it MUST match a shopfloor-setup/gea-shopfloor-<x> handler dir. Order = display order. Set enabled=false to hide without deleting. Deployed to the enrollment share; startnet.cmd falls back to its baked-in menu if this file or the picker is unavailable.",
|
||||
"shopfloor": [
|
||||
{ "key": "gea-shopfloor-collections", "label": "Machine with Collections", "hint": "eDNC + UDC + Plant Apps", "enabled": true },
|
||||
{ "key": "gea-shopfloor-nocollections", "label": "Machine without Collections", "hint": "eDNC + Plant Apps, no UDC", "enabled": true },
|
||||
{ "key": "gea-shopfloor-common", "label": "Common", "hint": "Timeclock, Lab; WJ Shopfloor only", "enabled": true },
|
||||
{ "key": "gea-shopfloor-keyence", "label": "Keyence", "hint": "VR-3000 / VR-5000 / VR-6000 microscope","enabled": true },
|
||||
{ "key": "gea-shopfloor-cmm", "label": "CMM", "hint": "Hexagon PC-DMIS + Protect Viewer", "enabled": true },
|
||||
{ "key": "gea-shopfloor-genspect", "label": "Genspect", "hint": "", "enabled": true },
|
||||
{ "key": "gea-shopfloor-heattreat", "label": "Heattreat", "hint": "eDNC + HeatTreat app", "enabled": true },
|
||||
{ "key": "gea-shopfloor-waxtrace", "label": "Wax and Trace", "hint": "", "enabled": true },
|
||||
{ "key": "gea-shopfloor-display", "label": "Display", "hint": "kiosk dashboard", "enabled": true },
|
||||
{ "key": "gea-shopfloor-partmarker", "label": "Part Marker", "hint": "eDNC + Telesis Mark", "enabled": true }
|
||||
]
|
||||
}
|
||||
63
playbook/shopfloor-setup/select-shopfloor-type.ps1
Normal file
63
playbook/shopfloor-setup/select-shopfloor-type.ps1
Normal file
@@ -0,0 +1,63 @@
|
||||
<#
|
||||
select-shopfloor-type.ps1 - data-driven GEA Shopfloor PC-type picker for WinPE.
|
||||
|
||||
Reads the shopfloor menu from menu.json (edited by the PXE webapp), renders a
|
||||
numbered menu, and writes the chosen PCTYPE key (e.g. gea-shopfloor-cmm) to
|
||||
-OutFile. startnet.cmd runs this instead of a hardcoded menu, and falls back
|
||||
to its baked-in menu if this script or menu.json is missing. Mirrors the CMM
|
||||
bay picker (select-cmm-bay.ps1).
|
||||
|
||||
Usage (from startnet.cmd):
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File select-shopfloor-type.ps1 `
|
||||
-MenuJson Y:\menu.json -OutFile X:\pctype.txt
|
||||
Exit 0 + a written key on success; non-zero (and no file) on any failure so
|
||||
the batch fallback kicks in.
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$MenuJson,
|
||||
[Parameter(Mandatory = $true)][string]$OutFile
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Remove-Item -LiteralPath $OutFile -ErrorAction SilentlyContinue
|
||||
|
||||
try {
|
||||
if (-not (Test-Path -LiteralPath $MenuJson)) { Write-Host "menu.json not found: $MenuJson"; exit 2 }
|
||||
$data = Get-Content -LiteralPath $MenuJson -Raw | ConvertFrom-Json
|
||||
$items = @($data.shopfloor | Where-Object { $_.key -and ($_.enabled -ne $false) })
|
||||
if ($items.Count -eq 0) { Write-Host "menu.json has no enabled shopfloor items"; exit 3 }
|
||||
|
||||
while ($true) {
|
||||
Clear-Host
|
||||
Write-Host ""
|
||||
Write-Host "========================================"
|
||||
Write-Host " GEA Shopfloor PC Sub-Type"
|
||||
Write-Host "========================================"
|
||||
Write-Host ""
|
||||
for ($i = 0; $i -lt $items.Count; $i++) {
|
||||
$n = $i + 1
|
||||
$lbl = $items[$i].label
|
||||
$hint = $items[$i].hint
|
||||
$line = "{0,3}. {1}" -f $n, $lbl
|
||||
if ($hint) { $line = "{0,-45} ({1})" -f $line, $hint }
|
||||
Write-Host $line
|
||||
}
|
||||
Write-Host ""
|
||||
$sel = Read-Host ("Enter your choice (1-{0})" -f $items.Count)
|
||||
$num = 0
|
||||
if ([int]::TryParse($sel, [ref]$num) -and $num -ge 1 -and $num -le $items.Count) {
|
||||
$key = $items[$num - 1].key
|
||||
# OutFile is on X: (WinPE scratch); write the bare PCTYPE key, no BOM/newline surprises
|
||||
[System.IO.File]::WriteAllText($OutFile, $key)
|
||||
Write-Host ""
|
||||
Write-Host ("Selected: {0} ({1})" -f $items[$num - 1].label, $key)
|
||||
exit 0
|
||||
}
|
||||
Write-Host "Invalid choice - try again."
|
||||
Start-Sleep -Milliseconds 800
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "shopfloor picker error: $($_.Exception.Message)"
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user