ci-server-engineer/examples/CI-Eng-Sample/layouts/layout.ps1
cliu c9d2ead5d9 Sample: CIENG_* operator HMI displays, generator and CIENG_Operator / CIENG_Popup layouts
- displays/CIENG_{Header,Overview,Control,Trends,Alarms,System,AlarmBanner,TankFaceplate}.xml:
  dark dashboard in HTML mode (desktop + web), generated by displays/generator/build.py
  (cixml.py component library; README.md describes the tool and the R1.03 rules it follows)
- layouts/CIENG_Operator.xml now holds CIENG_Operator (menu, navigation toolbar, header frame,
  5-tab set, alarm banner, status line; navigate commands with stretchDisplay) and CIENG_Popup
  (faceplate); layout.ps1 message updated
- deploy_displays.cmd / remove_displays.cmd for the 8 new displays
- Live-data Start runs C:\Users\Public\CI-Eng-Sample\feed\cieng_feed_start.cmd on the server
- Tested on CI Server R1.03.00 2026-10-06 (ADMIN with ?l=CIENG_Operator / jwuipoi -layout):
  web layout, tabs, popup, faceplate navigation, combo write, server-side Start as CIX_PROCESS;
  desktop layout, stretched tabs, Start/Stop
- Old CIENG_Tank / CIENG_Menu / CIENG_TrendLab still present (removed in the next stage)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 10:23:54 +11:00

34 lines
1.8 KiB
PowerShell

# Add or remove the CI-Eng-Sample layout block in Layouts.xml (CI Server R1.03.00).
# Usage: powershell -ExecutionPolicy Bypass -File layout.ps1 [-Remove]
# The block between <!-- CIENG-SAMPLE-BEGIN and <!-- CIENG-SAMPLE-END --> is inserted after
# the last layout (before the translations; an existing block is replaced). The first run
# saves Layouts-before-CIENG.xml next to Layouts.xml.
# No admin rights needed. Reopen the Operator Interface (or View > Reload All) afterwards.
param([switch]$Remove)
$wap = $env:TLS_WAP_PATH
if (-not $wap) { $wap = 'C:\Users\Public\Yokogawa\tls\wap' }
$file = Join-Path $wap 'cfg\operatorInterfaces\DEPLOY\layouts\Layouts.xml'
$backup = Join-Path $wap 'cfg\operatorInterfaces\DEPLOY\layouts\Layouts-before-CIENG.xml'
$block = Join-Path $PSScriptRoot 'CIENG_Operator.xml'
if (-not (Test-Path $file)) { throw "Not found: $file" }
if (-not (Test-Path $backup)) { Copy-Item -LiteralPath $file -Destination $backup }
$text = [IO.File]::ReadAllText($file)
$pattern = '(?s)[ \t]*<!-- CIENG-SAMPLE-BEGIN.*?<!-- CIENG-SAMPLE-END -->\r?\n?'
$text = [regex]::Replace($text, $pattern, '')
if (-not $Remove) {
$add = [IO.File]::ReadAllText($block) -replace '(?<!\r)\n', "`r`n"
# Insert after the last layout: before the first <translations, else before </layouts>.
$m = [regex]::Match($text, '(?m)^[ \t]*<translations\b')
if ($m.Success) { $end = $m.Index } else { $end = $text.LastIndexOf('</layouts>') }
if ($end -lt 0) { throw 'No </layouts> in Layouts.xml' }
$text = $text.Substring(0, $end) + $add + $text.Substring($end)
}
# Check that the result is still well-formed XML before writing it.
[xml]$null = $text
[IO.File]::WriteAllText($file, $text, (New-Object Text.UTF8Encoding($false)))
if ($Remove) { 'CIENG_Operator / CIENG_Popup layouts removed' } else { 'CIENG_Operator / CIENG_Popup layouts added' }