2.9 KiB
2.9 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Build & Run Commands
dotnet build # Build
dotnet run # Run
dotnet build -c Release
dotnet restore # Restore NuGet packages
No tests, no linting configured.
Architecture
WPF desktop application (.NET 8.0, C#) that monitors 3 contact states on industrial label printers and pushes state changes to TCP clients. Runs as a tray application — starts minimized to system tray, window opens on demand.
Three Monitored States
Per printer, exactly 3 boolean states:
- LTS Sensor — Label Take-away Sensor
- Druckerklappe — Printhead flap open/closed
- Keine Etiketten — Paper/labels empty
Push-Based TCP Protocol
Each printer gets its own TCP port (tcpPort in config). On state change, broadcasts "ABC\n" (3 chars, each 0/1) to all connected clients. On connect, client receives current state immediately.
Printer Drivers
- CabSquix (
Monitors/CabSquixMonitor.cs): OPC UA viaSquixOpcUaClientfrom../OPC UA Test/. Batch-reads 3 nodes in one call viaReadAllSensors(). - Zebra (
Monitors/ZebraMonitor.cs): TCP/JSON on port 9200. Sends{}{"sensor.peeler":null,"head.latch":null,"media.status":null}, parses response values (clear/not clear,ok/open,ok/out).
App Lifecycle (Tray Icon)
App.xaml:ShutdownMode="OnExplicitShutdown"— app runs until explicit exitApp.xaml.cs: CreatesTaskbarIcon(Hardcodet.NotifyIcon.Wpf.NetCore), startsPrinterServicein background- Double-click tray → opens
MainWindow; closing window → hides to tray - Right-click tray → "Anzeigen" / "Beenden"
MainWindow.OnClosingcancels close and hides instead
Data Flow
appsettings.json→PrinterService.StartAsync()spawns per-printer: polling loop +TcpPushServer- Poll returns
SimplePrinterState(3 bools, immutable,IEquatable) - Change detection →
TcpPushServer.BroadcastStateAsync()on change DashboardViewModelrefreshes every 500ms from status cache
GUI
- Tab "Status":
DashboardViewwith DataGrid (Name, Typ, Online, LTS, Klappe, Etiketten, TCP Port, Clients) - Tab "Einstellungen":
SettingsViewfor printer CRUD, saves toappsettings.json(requires restart)
Key Dependencies
../OPC UA Test/CabSquixOpcUaClient.csproj— OPC UA client (OPCFoundation.NetStandard.Opc.Ua)Hardcodet.NotifyIcon.Wpf.NetCore— System tray icon
Conventions
- Language: UI text, comments, and XML docs are in German
- Nullable reference types enabled project-wide
- Async/await with CancellationToken throughout
- Configuration in
appsettings.json(camelCase keys), editable via GUI or directly - Adding a new printer type: implement
IPrinterMonitor, register inPrinterService.CreateMonitor()