First WinForms App
This guide builds a small WinForms point panel: load a virtual Modbus slave from zeus.json, then show channel state, temperature, and alarms.
Use dotnet new zeus-winforms for the full skeleton. The repository sample Zeus.Samples.WinForms.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.WinForms.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.WinForms
dotnet add package Zeus.Protocols.Modbus
<TargetFramework>net8.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
Copy zeus.json to the output directory.
Minimal Form Code
Put the layout in MainForm.Designer.cs. The code-behind only attaches Zeus:
using Zeus;
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
var attachment = this.AttachZeus(builder =>
builder.AddJsonFile(Path.Combine(AppContext.BaseDirectory, "zeus.json")));
attachment.Host.Channels.Get("bus").BindState(stateLabel);
attachment.Host.Points.BindText("temperature", temperatureLabel, value => $"{value:0.0} C");
}
}
stateLabel and temperatureLabel are declared by the designer.
Use a Real Serial Port
Change the channel in zeus.json. Leave the form code 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: WinForms Adapter or Serial Port.