Device Model
Devices turn protocol addresses into business meaning. Your UI and business services should use the point table or device APIs such as ModbusDevice, McDevice, S7Device, FinsDevice, HostLinkDevice, and EtherNetIpDevice, instead of assembling hex frames in window code.
Registration
Register a channel first, then a device:
builder.AddAcquisition(TimeSpan.FromMilliseconds(500));
builder.AddVirtualChannel("bus", new ModbusSlaveResponder(1, ModbusTransport.Rtu));
builder.AddModbusRtu("oven", "bus", unitId: 1, points: map =>
{
map.HoldingRegister("temperature", 0, 0.1);
map.HoldingRegister("setpoint", 1, 0.1).Writable("setpoint");
});
Custom devices must expose IDevice.Channel; deriving from DeviceBase is the easiest way. If the device implements IAcquisitionSource and declares points, the host acquisition loop polls it automatically. If it also implements IPointWriter, writable points can be written by name.
public sealed class TemperatureMeter : DeviceBase, IAcquisitionSource
{
public TemperatureMeter(string name, IChannel channel)
: base(name, channel)
{
Points = [new PointDefinition("temperature", name, PointValueKind.Double)];
}
public IReadOnlyList<PointDefinition> Points { get; }
public async Task PollAsync(IPointTableWriter table, CancellationToken cancellationToken)
{
// Read channel/protocol data, convert it, then table.Publish(...)
}
}
Runtime Access
app.Points.Get<double>("temperature")reads the current point value.await app.Points.WriteAsync("setpoint", 80.0)writes a writable point by name.app.Devices.Get<ModbusDevice>("oven")orapp.Devices.Get<S7Device>("plc")gives direct protocol access.
Conventions
- One device binds to one channel.
- Avoid concurrent requests when multiple devices share one channel; the acquisition loop polls devices sequentially.
- Device names are unique in the host and case-insensitive.
- Point names are unique within a device; use
device.pointwhen multiple devices expose the same short name. - Device types should not reference WinForms or WPF.