First WPF App
This guide builds a small WPF point panel: load a virtual Modbus slave from zeus.json, then bind channel state, temperature, and alarms through MVVM.
Use dotnet new zeus-wpf for the full skeleton. The repository sample Zeus.Samples.Wpf.QuickStart follows the same path. For a byte echo, see the console sample.
Run The Sample
From the repository code directory:
dotnet run --project samples/Zeus.Samples.Wpf.QuickStart
The window should show Open, a live temperature (0.0 C on an empty virtual slave), and High after you click Simulate high temperature.
Required Packages
dotnet add package Zeus.Communications
dotnet add package Zeus.Configuration
dotnet add package Zeus.Presentation.Wpf
dotnet add package Zeus.Protocols.Modbus
dotnet add package CommunityToolkit.Mvvm
dotnet add package Microsoft.Extensions.DependencyInjection
<TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
Copy zeus.json to the output directory. Remove StartupUri from App.xaml and create the window from the DI container, the same way the Chinese guide and the sample do.
Register the host with AddJsonFile("zeus.json"), attach it in the window with this.AttachZeus(host), and in the ViewModel call host.Bind(dispatcher) once, then _ui.Point("temperature", ...).
Use A Real Serial Port
Change the channel in zeus.json. Leave the ViewModel and XAML alone:
{
"name": "bus",
"type": "serial",
"options": {
"portName": "COM3",
"baudRate": 9600
}
}
Parity, data bits, and stop bits are not JSON fields yet. Set them in code with AddSerialPort(name, options => …).
Next: WPF Adapter or Serial Port.