diff --git a/playbook/shopfloor-setup/gea-shopfloor-cmm/09-Setup-CMM.ps1 b/playbook/shopfloor-setup/gea-shopfloor-cmm/09-Setup-CMM.ps1 index 5648853..789a667 100644 --- a/playbook/shopfloor-setup/gea-shopfloor-cmm/09-Setup-CMM.ps1 +++ b/playbook/shopfloor-setup/gea-shopfloor-cmm/09-Setup-CMM.ps1 @@ -238,30 +238,42 @@ foreach ($exe in $pcdmisExes) { } # ============================================================================ -# Step 2.7: Seed goCMM Shared Data Directory + grant Users write on the key +# Step 2.7: Seed goCMM registry path values + grant Users write on the key # ============================================================================ -# goCMM (.NET x86 WPF app) stores its program-source path in the registry at -# HKLM\SOFTWARE\WOW6432Node\General Electric\goCMM, value "Shared Data -# Directory" (the folder it browses for *.prg PC-DMIS measurement routines). -# It is a 32-bit MSI / 32-bit process, so both the install seed and runtime -# reads land in the WOW6432Node view. Because the value lives in HKLM, a -# non-admin shopfloor user cannot set it via goCMM's settings UI - and cannot -# save a "Selected Part Group" switch either (same key). So we do two things -# here in admin context: -# 1. Seed "Shared Data Directory" to the per-bay path resolved by -# resolve-cmm-bay-config.ps1 (C:\Enrollment\cmm\shareddatadir.txt). -# 2. Grant BUILTIN\Users write on the key so runtime writes (part-group -# switching, or a deliberate path change) succeed without elevation. -# This mirrors Step 2.5, which grants Users Modify on the install dirs. +# goCMM (.NET x86 WPF app) stores its config in the registry at +# HKLM\SOFTWARE\WOW6432Node\General Electric\goCMM (32-bit MSI / 32-bit +# process, so install seed and runtime reads both land in the WOW6432Node +# view). A capture from a working CMM4 bay shows the two values that matter: +# Shared Data Directory = C:\geaofi\ (constant) +# Selected Part Group = \\tsgwp00525.wjs.geaerospace.net\SHARED\CMM\CMM4\Spool (per-bay UNC) +# i.e. the PER-BAY program path is "Selected Part Group" (a UNC to the +# tsgwp00525 SHARED share), and "Shared Data Directory" is the constant local +# C:\geaofi\. Both live in HKLM, so a non-admin shopfloor user cannot set +# them (nor save a part-group switch) without elevation. So in admin context +# we: seed both values, and grant BUILTIN\Users write on the key so runtime +# switches succeed without UAC. Mirrors Step 2.5 (install-dir ACL grant). $goCmmKey = 'HKLM:\SOFTWARE\WOW6432Node\General Electric\goCMM' -# Path may contain internal spaces (e.g. CMM8 "Venture CMM8"). Get-Content -# + Trim keeps internal spaces; the value is passed as a single -Value arg, +# Constant local data dir on every bay. +$goCmmDataDir = 'C:\geaofi\' + +# Host that S: maps to. Selected Part Group is stored as a UNC to this host's +# SHARED share. Kept in one place so a domain/host change is a one-line edit. +$partGroupShareRoot = '\\tsgwp00525.wjs.geaerospace.net\SHARED' + +# Per-bay part group, resolved by resolve-cmm-bay-config.ps1 into +# C:\Enrollment\cmm\partgroup.txt as a friendly S:\... path. Convert the S: +# drive prefix to the UNC share root. Get-Content + Trim keeps internal spaces +# (e.g. CMM8 "Venture CMM8"); the value is passed as a single -Value arg, # never through a command line, so the space cannot split the path. -$sharedDataDir = '' -$sddFile = 'C:\Enrollment\cmm\shareddatadir.txt' -if (Test-Path -LiteralPath $sddFile) { - $sharedDataDir = (Get-Content -LiteralPath $sddFile -First 1 -EA 0).Trim() +$partGroup = '' +$pgFile = 'C:\Enrollment\cmm\partgroup.txt' +if (Test-Path -LiteralPath $pgFile) { + $raw = (Get-Content -LiteralPath $pgFile -First 1 -EA 0).Trim() + if ($raw) { + # ^S:\ -> \\host\SHARED\ (case-insensitive). Leave non-S: values as-is. + $partGroup = $raw -replace '(?i)^S:\\', "$partGroupShareRoot\" + } } if (-not (Test-Path $goCmmKey)) { @@ -269,15 +281,24 @@ if (-not (Test-Path $goCmmKey)) { try { New-Item -Path $goCmmKey -Force | Out-Null } catch { Write-CMMLog "Could not create $goCmmKey : $_" 'WARN' } } -if ($sharedDataDir) { +# Shared Data Directory (constant) +try { + New-ItemProperty -Path $goCmmKey -Name 'Shared Data Directory' -Value $goCmmDataDir -PropertyType String -Force | Out-Null + Write-CMMLog "Set goCMM 'Shared Data Directory' = $goCmmDataDir" +} catch { + Write-CMMLog "Failed to set goCMM 'Shared Data Directory': $_" 'WARN' +} + +# Selected Part Group (per-bay UNC) +if ($partGroup) { try { - New-ItemProperty -Path $goCmmKey -Name 'Shared Data Directory' -Value $sharedDataDir -PropertyType String -Force | Out-Null - Write-CMMLog "Set goCMM 'Shared Data Directory' = $sharedDataDir" + New-ItemProperty -Path $goCmmKey -Name 'Selected Part Group' -Value $partGroup -PropertyType String -Force | Out-Null + Write-CMMLog "Set goCMM 'Selected Part Group' = $partGroup" } catch { - Write-CMMLog "Failed to set goCMM 'Shared Data Directory': $_" 'WARN' + Write-CMMLog "Failed to set goCMM 'Selected Part Group': $_" 'WARN' } } else { - Write-CMMLog "No shareddatadir.txt (bay not in bay-config, or manual CMM ID) - leaving goCMM path unset" 'WARN' + Write-CMMLog "No partgroup.txt (bay not in bay-config, or manual CMM ID) - leaving 'Selected Part Group' unset" 'WARN' } # Grant BUILTIN\Users ReadKey+WriteKey (WriteKey = SetValue + CreateSubKey). diff --git a/playbook/shopfloor-setup/gea-shopfloor-cmm/cmm-bay-config.csv b/playbook/shopfloor-setup/gea-shopfloor-cmm/cmm-bay-config.csv index f97dea7..38a998c 100644 --- a/playbook/shopfloor-setup/gea-shopfloor-cmm/cmm-bay-config.csv +++ b/playbook/shopfloor-setup/gea-shopfloor-cmm/cmm-bay-config.csv @@ -1,4 +1,4 @@ -cmm_id,pcdmis_version,doda,shared_data_dir +cmm_id,pcdmis_version,doda,part_group CMM1,2019,no,S:\CMM\CMM1\HPTCMM1 CMM2,2019,no,S:\CMM\CMM2\HPT CMM3,2019,no,S:\CMM\CMM3\VENTURE_CMM3 diff --git a/playbook/shopfloor-setup/gea-shopfloor-cmm/resolve-cmm-bay-config.ps1 b/playbook/shopfloor-setup/gea-shopfloor-cmm/resolve-cmm-bay-config.ps1 index 8b4234b..22bb2a3 100644 --- a/playbook/shopfloor-setup/gea-shopfloor-cmm/resolve-cmm-bay-config.ps1 +++ b/playbook/shopfloor-setup/gea-shopfloor-cmm/resolve-cmm-bay-config.ps1 @@ -40,21 +40,23 @@ if (-not (Test-Path $OutDir)) { $version = $match.pcdmis_version.Trim() $doda = $match.doda.Trim().ToLower() -# shared_data_dir may legitimately contain spaces (e.g. CMM8 "Venture CMM8"). -# Trim() strips only leading/trailing whitespace, never internal spaces. -$sharedDataDir = '' -if ($match.PSObject.Properties['shared_data_dir'] -and $match.shared_data_dir) { - $sharedDataDir = $match.shared_data_dir.Trim() +# part_group is the goCMM "Selected Part Group" path. It may legitimately +# contain spaces (e.g. CMM8 "Venture CMM8"); Trim() strips only leading/ +# trailing whitespace, never internal spaces. Stored in the friendly S:\ +# form; 09-Setup-CMM converts it to the tsgwp00525 UNC at apply time. +$partGroup = '' +if ($match.PSObject.Properties['part_group'] -and $match.part_group) { + $partGroup = $match.part_group.Trim() } [System.IO.File]::WriteAllText((Join-Path $OutDir 'version.txt'), $version) [System.IO.File]::WriteAllText((Join-Path $OutDir 'doda.txt'), $doda) -if ($sharedDataDir) { - [System.IO.File]::WriteAllText((Join-Path $OutDir 'shareddatadir.txt'), $sharedDataDir) +if ($partGroup) { + [System.IO.File]::WriteAllText((Join-Path $OutDir 'partgroup.txt'), $partGroup) } -Write-Host "Resolved $CmmId -> PC-DMIS $version, DODA=$doda, SharedDataDir=$(if ($sharedDataDir) { $sharedDataDir } else { '(none)' })" -Write-Host " version.txt -> $OutDir\version.txt" -Write-Host " doda.txt -> $OutDir\doda.txt" -if ($sharedDataDir) { Write-Host " shareddatadir.txt -> $OutDir\shareddatadir.txt" } +Write-Host "Resolved $CmmId -> PC-DMIS $version, DODA=$doda, PartGroup=$(if ($partGroup) { $partGroup } else { '(none)' })" +Write-Host " version.txt -> $OutDir\version.txt" +Write-Host " doda.txt -> $OutDir\doda.txt" +if ($partGroup) { Write-Host " partgroup.txt -> $OutDir\partgroup.txt" } exit 0