Files
Plancia/Console/strumenti/ringtest.dpr
T
f.bittiandClaude Opus 5 4a01a2ec88 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>
2026-09-22 16:56:34 +02:00

123 lines
3.7 KiB
ObjectPascal

program ringtest;
{
Banco di prova per l'aspetto degli elementi: disegna la stessa scena di giorno
e di notte, spenta e accesa, e salva l'immagine. Serve a giudicare una
modifica ai colori guardandola invece che immaginandola.
Uso: ringtest [file.bmp]
}
{$APPTYPE CONSOLE}
uses
Winapi.Windows, System.SysUtils, System.Classes,
Vcl.Forms, Vcl.Graphics, Vcl.Controls, Vcl.ExtCtrls,
uPlanciaElements in '..\uPlanciaElements.pas',
uImageLib in '..\uImageLib.pas',
uModbusRTU in '..\..\uModbusRTU.pas';
const
PANE_W = 430;
PANE_H = 330;
var
Host: TForm;
Lib: TImageLibrary;
Bmp: TBitmap;
OutFile: string;
/// Un elemento nello stato voluto, dentro il riquadro indicato.
procedure Place(APane: TWinControl; AKind: TElementKind; AShape: TKeyShape;
ALeft, ATop, AW, AH: Integer; AOn, ANight: Boolean; const ACaption: string;
AOffColor: TColor);
var
Def: TElementDef;
El: TPlanciaElement;
begin
Def := TElementDef.Create(AKind);
Def.Shape := AShape;
Def.Caption := ACaption;
Def.CaptionPos := cpBelow;
Def.OffColor := AOffColor;
Def.Left := ALeft;
Def.Top := ATop;
Def.Width := AW;
Def.Height := AH;
El := TPlanciaElement.CreateElement(Host, Def, Lib);
El.Parent := APane;
El.Color := APane.Brush.Color;
El.NightMode := ANight;
El.SyncState(AOn);
end;
/// La stessa scena, cambia solo se e' notte.
procedure Scene(APane: TPanel; ANight: Boolean);
begin
// Tondi: spento e acceso, con lente neutra e lente rossa.
Place(APane, ekSwitch, ksRound, 20, 20, 96, 96, False, ANight, 'SPENTO', clNone);
Place(APane, ekSwitch, ksRound, 130, 20, 96, 96, True, ANight, 'ACCESO', clNone);
Place(APane, ekSwitch, ksRound, 240, 20, 96, 96, False, ANight, 'FIRE', TColor($001818B0));
Place(APane, ekSwitch, ksRound, 340, 20, 96, 96, True, ANight, 'FIRE ON', TColor($001818B0));
// Squadrati: qui lo stato sta tutto nel bordo.
Place(APane, ekButton, ksRect, 20, 150, 110, 44, False, ANight, 'RECT', clNone);
Place(APane, ekButton, ksRect, 150, 150, 110, 44, True, ANight, 'RECT ON', clNone);
// Spia: questa il colore lo cambia eccome.
Place(APane, ekLamp, ksAuto, 290, 150, 70, 60, False, ANight, 'SPIA', clNone);
Place(APane, ekLamp, ksAuto, 365, 150, 70, 60, True, ANight, 'SPIA ON', clNone);
// Scritta serigrafata: di notte deve passare all'ambra, non sparire.
Place(APane, ekLabel, ksAuto, 20, 250, 200, 50, False, ANight, 'ZEBRA', clNone);
Place(APane, ekGauge, ksAuto, 250, 225, 100, 95, False, ANight, 'LIVELLO', clNone);
end;
var
PaneDay, PaneNight: TPanel;
begin
OutFile := 'ringtest.bmp';
if ParamCount >= 1 then
OutFile := ParamStr(1);
Application.Initialize;
Lib := TImageLibrary.Create;
Host := TForm.Create(nil);
try
Host.BorderStyle := bsNone;
Host.ClientWidth := PANE_W * 2;
Host.ClientHeight := PANE_H;
PaneDay := TPanel.Create(Host);
PaneDay.Parent := Host;
PaneDay.SetBounds(0, 0, PANE_W, PANE_H);
PaneDay.BevelOuter := bvNone;
PaneDay.Color := clBtnFace;
PaneDay.ParentBackground := False;
PaneNight := TPanel.Create(Host);
PaneNight.Parent := Host;
PaneNight.SetBounds(PANE_W, 0, PANE_W, PANE_H);
PaneNight.BevelOuter := bvNone;
PaneNight.Color := CLR_NIGHT_BG;
PaneNight.ParentBackground := False;
Scene(PaneDay, False);
Scene(PaneNight, True);
Host.Show;
Application.ProcessMessages;
Bmp := TBitmap.Create;
try
Bmp.SetSize(Host.ClientWidth, Host.ClientHeight);
Host.PaintTo(Bmp.Canvas.Handle, 0, 0);
Bmp.SaveToFile(OutFile);
Writeln(Format('scritto %s (%dx%d)', [OutFile, Bmp.Width, Bmp.Height]));
finally
Bmp.Free;
end;
finally
Host.Free;
Lib.Free;
end;
end.