From 54dddaa760dfd402c34605cd2cd842cd23655f74 Mon Sep 17 00:00:00 2001 From: cproudlock Date: Sun, 24 May 2026 07:04:15 -0400 Subject: [PATCH] Wax/Trace: per-bay FormTracePak version via bay-config.csv Bays span 7 FormTracePak versions (5.510 - 6.213) and 3 sub-versions (AVANT / CV-4500 / CV-3200), each with a unique licensing USER ID. Previously all bays got v6.213 with no model/USER hint to the tech. - bay-config.csv: 15 rows mapping asset_tag to ftpak_version + model + user_id. - resolve-bay-config.ps1: WinPE-runnable resolver. Looks up the asset and writes version.txt / model.txt / userid.txt / bay-info.txt under W:\Enrollment\waxtrace\. - startnet.cmd: xcopy WaxTrace bundle minus formtracepak\, invoke the resolver with %MACHINENUM%, then cherry-pick only the matching FORMTRACEPAK-V.iso (~2 GB local vs ~12 GB if all were staged). - 09-Setup-WaxAndTrace.ps1: read the per-bay files, mount the right ISO, drop -FTPak-install-info.txt on SupportUser's desktop, and print a banner with MODEL + USER ID so the tech has them top-of-mind when Setup.exe dialogs come up. - sync-waxtrace.sh: loop over all FORMTRACEPAK-V*.iso instead of hard-coding v6.213; also push bay-config.csv + resolve-bay-config.ps1 to the share. --- .../09-Setup-WaxAndTrace.ps1 | 140 +++++++++++++----- .../gea-shopfloor-waxtrace/bay-config.csv | 16 ++ .../resolve-bay-config.ps1 | 90 +++++++++++ playbook/startnet.cmd | 48 ++++-- playbook/sync-waxtrace.sh | 32 +++- 5 files changed, 273 insertions(+), 53 deletions(-) create mode 100644 playbook/shopfloor-setup/gea-shopfloor-waxtrace/bay-config.csv create mode 100644 playbook/shopfloor-setup/gea-shopfloor-waxtrace/resolve-bay-config.ps1 diff --git a/playbook/shopfloor-setup/gea-shopfloor-waxtrace/09-Setup-WaxAndTrace.ps1 b/playbook/shopfloor-setup/gea-shopfloor-waxtrace/09-Setup-WaxAndTrace.ps1 index 1421444..ef364c7 100644 --- a/playbook/shopfloor-setup/gea-shopfloor-waxtrace/09-Setup-WaxAndTrace.ps1 +++ b/playbook/shopfloor-setup/gea-shopfloor-waxtrace/09-Setup-WaxAndTrace.ps1 @@ -91,53 +91,121 @@ if (-not (Test-Path $manifestPath)) { } # ============================================================================ -# Step 2: FormTracePak v6.213 vendor install (Mount-DiskImage + Setup.exe) +# Step 2: FormTracePak vendor install - per-bay version + sub-version # ============================================================================ # Detection: skip if Formtracepak already present (re-run safe). $ftpakExe = 'C:\Program Files (x86)\MitutoyoApp\Formtracepak\Formtracepak.exe' if (Test-Path -LiteralPath $ftpakExe) { Write-WTLog "Formtracepak.exe already present - skipping vendor install" } else { - $ftpakIso = Join-Path $stagingRoot 'formtracepak\FORMTRACEPAK-V6.213.iso' - if (-not (Test-Path -LiteralPath $ftpakIso)) { - Write-WTLog "FormTracePak ISO not found at $ftpakIso" 'ERROR' + # Per-bay config resolved by resolve-bay-config.ps1 at WinPE time + written + # to C:\Enrollment\waxtrace\. Drives BOTH which FTPak ISO to mount AND what + # to relay to the tech in the pre-install banner + desktop reference file. + $waxCfgDir = 'C:\Enrollment\waxtrace' + $bayAsset = $null + $bayVersion = $null + $bayModel = $null + $bayUserId = $null + foreach ($pair in @( + @{ Var='bayAsset'; File='C:\Enrollment\machine-number.txt' }, + @{ Var='bayVersion'; File=(Join-Path $waxCfgDir 'version.txt') }, + @{ Var='bayModel'; File=(Join-Path $waxCfgDir 'model.txt') }, + @{ Var='bayUserId'; File=(Join-Path $waxCfgDir 'userid.txt') } + )) { + if (Test-Path -LiteralPath $pair.File) { + $val = (Get-Content -LiteralPath $pair.File -First 1 -ErrorAction SilentlyContinue) + if ($val) { Set-Variable -Name $pair.Var -Value $val.Trim() } + } + } + Write-WTLog "Bay config: asset=$bayAsset version=$bayVersion model=$bayModel userid=$bayUserId" + + if (-not $bayVersion) { + Write-WTLog "No FormTracePak version in $waxCfgDir\version.txt - bay-config did not resolve (asset_tag not in bay-config.csv?). Manual install required." 'ERROR' } else { - Write-WTLog "Mounting FormTracePak ISO: $ftpakIso" - try { - $img = Mount-DiskImage -ImagePath $ftpakIso -PassThru -ErrorAction Stop - Start-Sleep -Seconds 8 - $vol = Get-DiskImage -ImagePath $ftpakIso | Get-Volume - $ftpakDrive = $vol.DriveLetter - if (-not $ftpakDrive) { - Write-WTLog " Mount succeeded but no drive letter assigned" 'ERROR' - } else { - Write-WTLog " mounted at ${ftpakDrive}: (volume label=$($vol.FileSystemLabel))" - $setupExe = "${ftpakDrive}:\Setup.exe" - if (-not [System.IO.File]::Exists($setupExe)) { - Write-WTLog " Setup.exe not found at $setupExe" 'ERROR' + $ftpakIso = Join-Path $stagingRoot ("formtracepak\FORMTRACEPAK-V$bayVersion.iso") + if (-not (Test-Path -LiteralPath $ftpakIso)) { + Write-WTLog "FormTracePak ISO missing: $ftpakIso" 'ERROR' + Write-WTLog " Bay needs V$bayVersion but no matching ISO at the expected path. Either bay-config.csv has the wrong version, or sync-waxtrace.sh did not push the right ISO. Manual install required." 'ERROR' + } else { + # Drop a reference text file on the SupportUser Desktop so the tech + # always has the model + USER ID in front of them when the Setup.exe + # dialogs come up. File persists post-imaging. + try { + $desktop = 'C:\Users\SupportUser\Desktop' + if (-not (Test-Path -LiteralPath $desktop)) { $desktop = 'C:\Users\Public\Desktop' } + $deskFile = Join-Path $desktop ("$bayAsset-FTPak-install-info.txt") + $deskContent = @( + '========================================', + 'FormTracePak install info for this bay', + '========================================', + '', + "Bay: $bayAsset", + "FormTracePak: V$bayVersion", + "Sub-version: $bayModel <- SELECT THIS IN THE Setup.exe DIALOG", + "USER ID: $bayUserId <- ENTER THIS AT THE LICENSING PROMPT", + '', + 'Reference file. Open this whenever you need to recall the USER ID', + 'during the install dialogs.', + '', + "Generated at imaging time by 09-Setup-WaxAndTrace.ps1 ($(Get-Date -Format 'yyyy-MM-dd HH:mm:ss'))" + ) -join "`r`n" + Set-Content -LiteralPath $deskFile -Value $deskContent -Force + Write-WTLog "Wrote reference file to $deskFile" + } catch { + Write-WTLog "Failed to write desktop reference file: $_" 'WARN' + } + + # Big banner in the PS host window. Operator sees this BEFORE Setup.exe + # opens so the model + USER ID are top-of-mind when the dialogs come up. + $bannerLines = @( + '', + '================================================================', + " BAY: $bayAsset", + " FORMTRACEPAK: V$bayVersion", + " SELECT MODEL: $bayModel", + " USER ID: $bayUserId", + '================================================================', + ' Setup.exe is about to launch. In its dialogs:', + " - Pick the MODEL '$bayModel' on the language / model page.", + " - Enter USER ID '$bayUserId' at the licensing prompt.", + " - A reference text file with these values has been placed on", + " SupportUser's desktop ($bayAsset-FTPak-install-info.txt).", + '================================================================', + '' + ) + foreach ($l in $bannerLines) { Write-WTLog $l } + + Write-WTLog "Mounting FormTracePak ISO: $ftpakIso" + try { + $img = Mount-DiskImage -ImagePath $ftpakIso -PassThru -ErrorAction Stop + Start-Sleep -Seconds 8 + $vol = Get-DiskImage -ImagePath $ftpakIso | Get-Volume + $ftpakDrive = $vol.DriveLetter + if (-not $ftpakDrive) { + Write-WTLog " Mount succeeded but no drive letter assigned" 'ERROR' } else { - Write-WTLog " running $setupExe (VB6 wrapper - requires DRIVE_CDROM)" - # Setup.exe is the VB6 wrapper. /silent + /qn flags often - # ignored - the wrapper drives appSetup.exe + msiexec from - # its own UI. If the wrapper insists on interactive, a tech - # at the bay clicks through. Acceptable today; quieter - # path is a future improvement (drive msiexec direct on - # the wrapper's bundled MSIs). - try { - $p = Start-Process -FilePath $setupExe ` - -WorkingDirectory "${ftpakDrive}:\" ` - -ArgumentList '/silent' ` - -Wait -PassThru - Write-WTLog " Setup.exe exit $($p.ExitCode)" - } catch { - Write-WTLog " Setup.exe failed: $_" 'ERROR' + Write-WTLog " mounted at ${ftpakDrive}: (volume label=$($vol.FileSystemLabel))" + $setupExe = "${ftpakDrive}:\Setup.exe" + if (-not [System.IO.File]::Exists($setupExe)) { + Write-WTLog " Setup.exe not found at $setupExe" 'ERROR' + } else { + Write-WTLog " running $setupExe (VB6 wrapper - requires DRIVE_CDROM)" + try { + $p = Start-Process -FilePath $setupExe ` + -WorkingDirectory "${ftpakDrive}:\" ` + -ArgumentList '/silent' ` + -Wait -PassThru + Write-WTLog " Setup.exe exit $($p.ExitCode)" + } catch { + Write-WTLog " Setup.exe failed: $_" 'ERROR' + } } } + Dismount-DiskImage -ImagePath $ftpakIso -ErrorAction SilentlyContinue | Out-Null + Write-WTLog " FormTracePak ISO dismounted" + } catch { + Write-WTLog " Mount-DiskImage failed: $_" 'ERROR' } - Dismount-DiskImage -ImagePath $ftpakIso -ErrorAction SilentlyContinue | Out-Null - Write-WTLog " FormTracePak ISO dismounted" - } catch { - Write-WTLog " Mount-DiskImage failed: $_" 'ERROR' } } } diff --git a/playbook/shopfloor-setup/gea-shopfloor-waxtrace/bay-config.csv b/playbook/shopfloor-setup/gea-shopfloor-waxtrace/bay-config.csv new file mode 100644 index 0000000..83b4462 --- /dev/null +++ b/playbook/shopfloor-setup/gea-shopfloor-waxtrace/bay-config.csv @@ -0,0 +1,16 @@ +asset_tag,ftpak_version,model,user_id +WJF00159,6.103,AVANT,3974839712 +WJRP3689,5.510,CV-4500,3744284509 +WJRP2660,6.0,CV-4500,2365986521 +WJRP2659,6.0,CV-4500,2709054503 +WJF00545,6.213,AVANT,3878777362 +WJRP3638,5.602,CV-4500,0720778210 +WJF00052,6.103,AVANT,3270314998 +WJF00084,6.103,AVANT,1476212857 +WJF00083,6.103,AVANT,2934506987 +WJRP3025,6.0,CV-3200,2292822471 +WJF00197,6.104,AVANT,1191612605 +WJRP4802,6.002,AVANT,0920866935 +WJRP2347,6.0,CV-4500,3585172946 +WJRP2035,6.0,CV-4500,2292822471 +WJRP2335,6.0,CV-4500,1780916688 diff --git a/playbook/shopfloor-setup/gea-shopfloor-waxtrace/resolve-bay-config.ps1 b/playbook/shopfloor-setup/gea-shopfloor-waxtrace/resolve-bay-config.ps1 new file mode 100644 index 0000000..6c2ba3e --- /dev/null +++ b/playbook/shopfloor-setup/gea-shopfloor-waxtrace/resolve-bay-config.ps1 @@ -0,0 +1,90 @@ +# resolve-bay-config.ps1 - WinPE-runnable bay-config resolver. +# +# Reads bay-config.csv (per-asset ftpak_version + model + user_id) and +# writes the matched row into per-field text files under $OutDir, so the +# rest of startnet.cmd + the post-imaging 09-Setup-WaxAndTrace.ps1 can +# read them as single-line files (cheaper than re-parsing CSV in batch). +# +# Outputs (under $OutDir, default W:\Enrollment\waxtrace\): +# version.txt - exact FormTracePak version (matches an installer ISO label) +# model.txt - sub-version (AVANT / CV-4500 / CV-3200) +# userid.txt - per-bay license USER ID +# bay-info.txt - human-readable audit dump (timestamped) +# +# Exit codes: +# 0 - row found + files written +# 1 - asset_tag not in bay-config.csv (Wax/Trace install will abort cleanly) +# 2 - bay-config.csv missing or unparseable + +[CmdletBinding()] +param( + [Parameter(Mandatory=$true)][string]$Asset, + [string]$ConfigCsv = '', + [string]$OutDir = 'W:\Enrollment\waxtrace' +) + +# Default ConfigCsv: bay-config.csv next to this script on the share OR +# under the script's own directory in the local C:\WaxTrace-Install\ tree +# (depending on where the caller invokes us from). +if (-not $ConfigCsv) { + $cands = @( + (Join-Path $PSScriptRoot 'bay-config.csv'), + (Join-Path $PSScriptRoot '..\bay-config.csv'), + 'Y:\installers-post\waxtrace\bay-config.csv', + 'C:\WaxTrace-Install\bay-config.csv' + ) + foreach ($c in $cands) { + if (Test-Path -LiteralPath $c) { $ConfigCsv = $c; break } + } +} + +if (-not (Test-Path -LiteralPath $ConfigCsv)) { + Write-Warning "bay-config.csv not found (looked under $PSScriptRoot, ..\, Y:\installers-post\waxtrace\, C:\WaxTrace-Install\)" + exit 2 +} + +Write-Host "resolve-bay-config.ps1: looking up '$Asset' in $ConfigCsv" + +try { + $rows = @(Import-Csv -LiteralPath $ConfigCsv) +} catch { + Write-Warning "Failed to parse ${ConfigCsv}: $_" + exit 2 +} + +$row = $rows | Where-Object { $_.asset_tag -ieq $Asset } | Select-Object -First 1 +if (-not $row) { + Write-Warning "Asset '$Asset' not in $ConfigCsv. Available asset_tags: $(($rows.asset_tag | Sort-Object) -join ', ')" + exit 1 +} + +if (-not (Test-Path -LiteralPath $OutDir)) { + New-Item -ItemType Directory -Path $OutDir -Force | Out-Null +} + +function Write-Line { + param([string]$Name, [string]$Value) + $p = Join-Path $OutDir $Name + Set-Content -LiteralPath $p -Value $Value -NoNewline -Force + Write-Host " wrote $p = '$Value'" +} + +Write-Line 'version.txt' $row.ftpak_version +Write-Line 'model.txt' $row.model +Write-Line 'userid.txt' $row.user_id + +$infoLines = @( + "Bay-config resolved at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')", + " Asset: $($row.asset_tag)", + " FormTracePak: V$($row.ftpak_version)", + " Sub-version: $($row.model)", + " USER ID: $($row.user_id)", + "", + "Source: $ConfigCsv" +) +$infoPath = Join-Path $OutDir 'bay-info.txt' +Set-Content -LiteralPath $infoPath -Value ($infoLines -join "`r`n") -Force +Write-Host " wrote $infoPath" + +Write-Host "resolve-bay-config.ps1: OK" +exit 0 diff --git a/playbook/startnet.cmd b/playbook/startnet.cmd index 2bfba07..b2933c1 100644 --- a/playbook/startnet.cmd +++ b/playbook/startnet.cmd @@ -482,18 +482,48 @@ if exist "Y:\installers-post\keyence\%KEYENCEMODEL%\manifest.json" ( :skip_keyence_stage REM --- Stage WaxTrace bootstrap bundle (wax/trace gea-shopfloor-waxtrace only) --- -REM Copies the FormTracePak master capture (~110 MB compressed) + HASP + -REM VC++ redists + per-machine cal ISOs from the enrollment share onto the -REM target disk so 09-Setup-WaxAndTrace.ps1 can install FormTracePak via -REM xcopy + reg-import (bypassing Mitutoyo's CD-ROM-bound VB6 wrapper). +REM Three-step process: +REM 1. xcopy installers-post\waxtrace -> W:\WaxTrace-Install (everything +REM EXCEPT the formtracepak\ subdir which carries all 7 version ISOs) +REM 2. resolve-bay-config.ps1: reads bay-config.csv + asset_tag, writes +REM W:\Enrollment\waxtrace\{version,model,userid}.txt for 09-Setup to read +REM 3. xcopy ONLY the bay's matching FORMTRACEPAK-V.iso from +REM Y:\installers-post\waxtrace\formtracepak\ onto the target disk +REM (so 09-Setup-WaxAndTrace.ps1 mounts the right version per bay) if /i not "%PCTYPE%"=="gea-shopfloor-waxtrace" goto skip_waxtrace_stage -if exist "Y:\installers-post\waxtrace\waxtrace-manifest.json" ( - mkdir W:\WaxTrace-Install 2>NUL - xcopy /E /Y /I "Y:\installers-post\waxtrace" "W:\WaxTrace-Install\" - echo Staged WaxTrace bootstrap to W:\WaxTrace-Install. +if not exist "Y:\installers-post\waxtrace\waxtrace-manifest.json" goto skip_waxtrace_missing +mkdir W:\WaxTrace-Install 2>NUL +REM xcopy everything except the formtracepak\ dir (we cherry-pick one ISO below). +xcopy /E /Y /I /EXCLUDE:NUL "Y:\installers-post\waxtrace" "W:\WaxTrace-Install\" >NUL 2>NUL +REM (Exclude file via /EXCLUDE expects a file; simpler to xcopy the whole tree +REM then delete the formtracepak\ subdir + re-create with just the matched ISO.) +if exist "W:\WaxTrace-Install\formtracepak" rmdir /S /Q "W:\WaxTrace-Install\formtracepak" +mkdir W:\WaxTrace-Install\formtracepak 2>NUL +echo Staged WaxTrace bootstrap minus formtracepak\ to W:\WaxTrace-Install. +REM Resolve bay-config: writes W:\Enrollment\waxtrace\{version,model,userid}.txt +mkdir W:\Enrollment\waxtrace 2>NUL +if not "%MACHINENUM%"=="" ( + powershell.exe -NoProfile -ExecutionPolicy Bypass -File "Y:\installers-post\waxtrace\resolve-bay-config.ps1" -Asset "%MACHINENUM%" -OutDir "W:\Enrollment\waxtrace" ) else ( - echo WARNING: Y:\installers-post\waxtrace not found - WaxTrace PC cannot install FormTracePak at imaging time. + echo WARNING: no MACHINENUM set - skipping bay-config resolve. 09-Setup-WaxAndTrace will abort cleanly with no version. ) +REM Read the resolved version + xcopy ONLY that FTPak ISO (avoids dumping 12 GB +REM of ISOs on the bay disk; only the matched ~2 GB ISO lands locally). +set WTVER= +if exist W:\Enrollment\waxtrace\version.txt set /p WTVER=.iso based on +# bay-config.csv lookup, xcopies just that one to the local disk (~2 GB). +# Total on PXE share: ~12 GB; per-bay xcopy: ~2 GB. +FTPAK_ISO_DIR="${FTPAK_ISO_DIR:-/home/camp/pxe-images/iso}" +FTPAK_COUNT=0 +for iso in "$FTPAK_ISO_DIR"/FORMTRACEPAK-V*.iso; do + [ -f "$iso" ] || continue + cp "$iso" "$STAGE/formtracepak/" + FTPAK_COUNT=$((FTPAK_COUNT+1)) +done +if [ "$FTPAK_COUNT" -eq 0 ]; then + echo "WARNING: no FORMTRACEPAK-V*.iso in $FTPAK_ISO_DIR - bays cannot install at imaging time." else - echo "WARNING: FormTracePak ISO not found at $FTPAK_ISO - bays cannot install at imaging time." + echo "Staged $FTPAK_COUNT FormTracePak version ISO(s) from $FTPAK_ISO_DIR" fi # Cal ISOs - one per wax/trace bay