46 Zeilen
1.2 KiB
C#
46 Zeilen
1.2 KiB
C#
using PrinterMonitor.Configuration;
|
|
using PrinterMonitor.Interfaces;
|
|
using PrinterMonitor.Models;
|
|
|
|
namespace PrinterMonitor.Monitors;
|
|
|
|
/// <summary>
|
|
/// Simulation-Drucker: kein Netzwerk, kein OPC UA.
|
|
/// Die Sensor-Zustände werden manuell über SetState() gesetzt.
|
|
/// PollStateAsync() gibt immer sofort den aktuellen manuellen Zustand zurück.
|
|
/// </summary>
|
|
public class SimulationMonitor : IPrinterMonitor
|
|
{
|
|
private SimplePrinterState _state = new();
|
|
|
|
public string PrinterName { get; }
|
|
public bool IsConnected => true;
|
|
|
|
public SimulationMonitor(PrinterConfig config)
|
|
{
|
|
PrinterName = config.Name;
|
|
}
|
|
|
|
public void SetState(bool ltsSensor, bool druckerklappe, bool keineEtiketten)
|
|
{
|
|
_state = new SimplePrinterState
|
|
{
|
|
LtsSensor = ltsSensor,
|
|
Druckerklappe = druckerklappe,
|
|
KeineEtiketten = keineEtiketten
|
|
};
|
|
}
|
|
|
|
public Task ConnectAsync(CancellationToken ct = default)
|
|
=> Task.CompletedTask;
|
|
|
|
public Task DisconnectAsync()
|
|
=> Task.CompletedTask;
|
|
|
|
public Task<SimplePrinterState> PollStateAsync(CancellationToken ct = default)
|
|
=> Task.FromResult(_state);
|
|
|
|
public ValueTask DisposeAsync()
|
|
=> ValueTask.CompletedTask;
|
|
}
|