Plancia configurabile su Modbus RTU
Due programmi che condividono uModbusRTU e uGauge: - Console/PlanciaConsole: plancia nautica descritta da file XML, con modalita' plancia e modalita' configurazione. Comandi, spie, selettori, strumenti e allarmi sonori; il bus gira in un thread suo perche' la finestra non si fermi mai. - ProjectPlancia: il programma di prova piu' vecchio, usato per collaudare i canali. Le plance sono in Console/*.xml, la documentazione in Console/LEGGIMI.md. Esclusi dal versionamento i compilati (.exe, .dcu), i file dell'IDE e un audio da 17 MB. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
commit
4a01a2ec88
69 files changed
+11658
No files matched your search
@@ -0,0 +1,91 @@
|
||||
# Grafica della plancia multifunzione (plancia-mfd.xml), sul modello della
|
||||
# foto "Esempio plancia": cornice scura con il filo chiaro, schermo nero al
|
||||
# centro. Produce anche la sagoma della barca ANTAGO in chiaro, perche' quella
|
||||
# originale e' disegnata in nero e sullo schermo nero sparirebbe.
|
||||
#
|
||||
# powershell -File genera-mfd.ps1
|
||||
|
||||
param(
|
||||
[string]$Dir = 'D:\dev\Plancia\Console\immagini',
|
||||
[int]$W = 1900,
|
||||
[int]$H = 1080,
|
||||
# Schermo: deve coincidere con la disposizione degli elementi nell'XML.
|
||||
[int]$ScreenLeft = 214,
|
||||
[int]$ScreenTop = 34,
|
||||
[int]$ScreenRight = 1686,
|
||||
[int]$ScreenBottom = 716
|
||||
)
|
||||
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
function RoundRect([int]$x, [int]$y, [int]$w, [int]$h, [int]$r) {
|
||||
$p = New-Object System.Drawing.Drawing2D.GraphicsPath
|
||||
$d = 2 * $r
|
||||
$p.AddArc($x, $y, $d, $d, 180, 90)
|
||||
$p.AddArc(($x + $w - $d), $y, $d, $d, 270, 90)
|
||||
$p.AddArc(($x + $w - $d), ($y + $h - $d), $d, $d, 0, 90)
|
||||
$p.AddArc($x, ($y + $h - $d), $d, $d, 90, 90)
|
||||
$p.CloseFigure()
|
||||
return $p
|
||||
}
|
||||
|
||||
# --- sfondo --------------------------------------------------------------
|
||||
$bmp = New-Object System.Drawing.Bitmap($W, $H, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
||||
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
||||
$g.SmoothingMode = 'AntiAlias'
|
||||
|
||||
# Cornice: grafite opaca, appena piu' chiara in alto.
|
||||
$rect = New-Object System.Drawing.Rectangle(0, 0, $W, $H)
|
||||
$c1 = [System.Drawing.Color]::FromArgb(255, 44, 46, 50)
|
||||
$c2 = [System.Drawing.Color]::FromArgb(255, 22, 23, 26)
|
||||
$br = New-Object System.Drawing.Drawing2D.LinearGradientBrush($rect, $c1, $c2, 90.0)
|
||||
$g.FillRectangle($br, $rect)
|
||||
|
||||
$edge = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(255, 10, 10, 12)), 4
|
||||
$path = RoundRect 2 2 ($W - 5) ($H - 5) 26
|
||||
$g.DrawPath($edge, $path)
|
||||
|
||||
# Il filo chiaro che corre tutto attorno, come nella foto.
|
||||
$line = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(255, 200, 204, 209)), 2
|
||||
$path = RoundRect 16 16 ($W - 33) ($H - 33) 20
|
||||
$g.DrawPath($line, $path)
|
||||
|
||||
# Schermo: incassato (ombra scura attorno), nero, con un filo grigio.
|
||||
$sw = $ScreenRight - $ScreenLeft
|
||||
$sh = $ScreenBottom - $ScreenTop
|
||||
$shadow = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(255, 8, 8, 9)), 8
|
||||
$g.DrawRectangle($shadow, ($ScreenLeft - 4), ($ScreenTop - 4), ($sw + 8), ($sh + 8))
|
||||
$screen = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 4, 5, 6))
|
||||
$g.FillRectangle($screen, $ScreenLeft, $ScreenTop, $sw, $sh)
|
||||
$glass = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(255, 92, 97, 104)), 2
|
||||
$g.DrawRectangle($glass, $ScreenLeft, $ScreenTop, $sw, $sh)
|
||||
|
||||
# Separazione fra lo schermo e la fila dei selettori.
|
||||
$sep = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(255, 70, 74, 80)), 1
|
||||
$g.DrawLine($sep, 36, ($ScreenBottom + 16), ($W - 36), ($ScreenBottom + 16))
|
||||
|
||||
$g.Dispose()
|
||||
$out = Join-Path $Dir 'mfd-sfondo.png'
|
||||
$bmp.Save($out, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
$bmp.Dispose()
|
||||
Write-Output ("{0} {1}x{2}" -f $out, $W, $H)
|
||||
|
||||
# --- sagoma della barca in chiaro ---------------------------------------
|
||||
# Stessa trasparenza dell'originale, colore invertito: il tratto nero diventa
|
||||
# grigio chiaro, le sfumature di bordo restano sfumature.
|
||||
$src = New-Object System.Drawing.Bitmap (Join-Path $Dir 'antago-barca.png')
|
||||
$dst = New-Object System.Drawing.Bitmap($src.Width, $src.Height, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
||||
for ($y = 0; $y -lt $src.Height; $y++) {
|
||||
for ($x = 0; $x -lt $src.Width; $x++) {
|
||||
$p = $src.GetPixel($x, $y)
|
||||
if ($p.A -eq 0) { continue }
|
||||
$v = [int](220 - ($p.R + $p.G + $p.B) / 3 * 0.85)
|
||||
if ($v -lt 0) { $v = 0 }
|
||||
$dst.SetPixel($x, $y, [System.Drawing.Color]::FromArgb($p.A, $v, $v, [Math]::Min(255, $v + 6)))
|
||||
}
|
||||
}
|
||||
$out = Join-Path $Dir 'antago-barca-chiara.png'
|
||||
$dst.Save($out, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
$src.Dispose()
|
||||
$dst.Dispose()
|
||||
Write-Output ("{0}" -f $out)
|
||||
Reference in new issue
Block a user