| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- import 'diagnostic_entry.dart';
- import 'temperature_sample.dart';
- class MachineState {
- final double temperature;
- final double targetTemperature;
- final bool isHeating;
- final bool isBrewing;
- /// Steam input active (V9/V10 `pid 65535 0 0 0` marker). The firmware
- /// switches the boiler on/off around the steam setpoint and sends no PID
- /// output, so [heatingPower] is unknown while this is set.
- final bool isSteaming;
- final int shotTimer;
- final String connectionStatus;
- final String? commandError;
- final List<double> temperatureHistory;
- final List<TemperatureSample> temperatureSamples;
- final List<DiagnosticEntry> diagnosticLog;
- final DateTime? lastTelemetryAt;
- final bool telemetryStale;
- final String transportName;
- final bool firmwareUpdating;
- final double firmwareProgress;
- final String firmwareUpdateStatus;
- // Second temperature sensor (group-head / inline sensor, when present)
- final double sensor2Temperature;
- final List<double> sensor2TemperatureHistory;
- // Configuration Parameters
- final double preinfusionTime;
- final int preinfusionPower;
- final double brewTemperature;
- final double steamTemperature;
- // PID Parameters
- final double pidP;
- final double pidI;
- final double pidD;
- final double pidIWindDownMin;
- final double pidIWindDownMax;
- final int pidPollingInterval;
- // Statistics
- final int shotCounter;
- final int grinderCounter;
- // Pressure Profiling
- final int pressureStart;
- final int pressureEnd;
- final int pressurePeriod;
- // Real-time Power
- final double heatingPower; // 0.0 to 1.0
- // Advanced Logic
- final bool valveClosedWhilePaused;
- final int proActivePercentage;
- final int autoShutoffMinutes;
- final bool autoShutoffEnabled; // tmrosdnbl – inactivity shut-off gate
- // Scheduling
- final bool wakeupEnabled;
- final String wakeupTime;
- final bool shutdownEnabled;
- final String shutdownTime;
- // Ionic 2 / Hardware features
- final bool preinfusionEnabled;
- final double preinfusionPauseTime;
- final int output0;
- final int output1;
- final int output2;
- final bool installedAsTimer;
- final bool powerButtonFlipsBack;
- // Firmware / compatibility
- final bool
- isLegacyV4Firmware; // V4 firmware uses scale=1 for pistrt/piprd instead of 1000
- final String
- firmwareVersion; // Full uname string from device (e.g. "meCoffee V5.3.1")
- // Automation
- final int maxShotTime; // shtmx – stops shot after N seconds (0 = disabled)
- final bool continuousMode; // tmpcntns – keep heating without shot trigger
- MachineState({
- this.temperature = 0.0,
- this.targetTemperature = 101.0,
- this.isHeating = false,
- this.isBrewing = false,
- this.isSteaming = false,
- this.shotTimer = 0,
- this.connectionStatus = 'Disconnected',
- this.commandError,
- this.temperatureHistory = const [],
- this.temperatureSamples = const [],
- this.diagnosticLog = const [],
- this.lastTelemetryAt,
- this.telemetryStale = true,
- this.transportName = '',
- this.firmwareUpdating = false,
- this.firmwareProgress = 0,
- this.firmwareUpdateStatus = '',
- this.sensor2Temperature = 0.0,
- this.sensor2TemperatureHistory = const [],
- this.preinfusionTime = 3.0,
- this.preinfusionPower = 100,
- this.brewTemperature = 101.0,
- this.steamTemperature = 125.0,
- this.pidP = 20.0,
- this.pidI = 0.3,
- this.pidD = 128.0,
- this.pidIWindDownMin = 0.0,
- this.pidIWindDownMax = 20.0,
- this.pidPollingInterval = 1000,
- this.shotCounter = 0,
- this.grinderCounter = 0,
- this.pressureStart = 100,
- this.pressureEnd = 100,
- this.pressurePeriod = 25,
- this.heatingPower = 0.0,
- this.valveClosedWhilePaused = false,
- this.proActivePercentage = 33,
- this.autoShutoffMinutes = 60,
- this.autoShutoffEnabled = false,
- this.wakeupEnabled = false,
- this.wakeupTime = "07:00",
- this.shutdownEnabled = false,
- this.shutdownTime = "22:00",
- this.preinfusionEnabled = true,
- this.preinfusionPauseTime = 3.0,
- this.output0 = 112,
- this.output1 = 98,
- this.output2 = 118,
- this.installedAsTimer = false,
- this.powerButtonFlipsBack = false,
- this.isLegacyV4Firmware = false,
- this.firmwareVersion = '',
- this.maxShotTime = 60,
- this.continuousMode = false,
- });
- MachineState copyWith({
- double? temperature,
- double? targetTemperature,
- bool? isHeating,
- bool? isBrewing,
- bool? isSteaming,
- int? shotTimer,
- String? connectionStatus,
- String? commandError,
- bool clearCommandError = false,
- List<double>? temperatureHistory,
- List<TemperatureSample>? temperatureSamples,
- List<DiagnosticEntry>? diagnosticLog,
- DateTime? lastTelemetryAt,
- bool clearLastTelemetry = false,
- bool? telemetryStale,
- String? transportName,
- bool? firmwareUpdating,
- double? firmwareProgress,
- String? firmwareUpdateStatus,
- double? sensor2Temperature,
- List<double>? sensor2TemperatureHistory,
- double? preinfusionTime,
- int? preinfusionPower,
- double? brewTemperature,
- double? steamTemperature,
- double? pidP,
- double? pidI,
- double? pidD,
- double? pidIWindDownMin,
- double? pidIWindDownMax,
- int? pidPollingInterval,
- int? shotCounter,
- int? grinderCounter,
- int? pressureStart,
- int? pressureEnd,
- int? pressurePeriod,
- double? heatingPower,
- bool? valveClosedWhilePaused,
- int? proActivePercentage,
- int? autoShutoffMinutes,
- bool? autoShutoffEnabled,
- bool? wakeupEnabled,
- String? wakeupTime,
- bool? shutdownEnabled,
- String? shutdownTime,
- bool? preinfusionEnabled,
- double? preinfusionPauseTime,
- int? output0,
- int? output1,
- int? output2,
- bool? installedAsTimer,
- bool? powerButtonFlipsBack,
- bool? isLegacyV4Firmware,
- String? firmwareVersion,
- int? maxShotTime,
- bool? continuousMode,
- }) {
- return MachineState(
- temperature: temperature ?? this.temperature,
- targetTemperature: targetTemperature ?? this.targetTemperature,
- isHeating: isHeating ?? this.isHeating,
- isBrewing: isBrewing ?? this.isBrewing,
- isSteaming: isSteaming ?? this.isSteaming,
- shotTimer: shotTimer ?? this.shotTimer,
- connectionStatus: connectionStatus ?? this.connectionStatus,
- commandError: clearCommandError
- ? null
- : commandError ?? this.commandError,
- temperatureHistory: temperatureHistory ?? this.temperatureHistory,
- temperatureSamples: temperatureSamples ?? this.temperatureSamples,
- diagnosticLog: diagnosticLog ?? this.diagnosticLog,
- lastTelemetryAt: clearLastTelemetry
- ? null
- : lastTelemetryAt ?? this.lastTelemetryAt,
- telemetryStale: telemetryStale ?? this.telemetryStale,
- transportName: transportName ?? this.transportName,
- firmwareUpdating: firmwareUpdating ?? this.firmwareUpdating,
- firmwareProgress: firmwareProgress ?? this.firmwareProgress,
- firmwareUpdateStatus: firmwareUpdateStatus ?? this.firmwareUpdateStatus,
- sensor2Temperature: sensor2Temperature ?? this.sensor2Temperature,
- sensor2TemperatureHistory:
- sensor2TemperatureHistory ?? this.sensor2TemperatureHistory,
- preinfusionTime: preinfusionTime ?? this.preinfusionTime,
- preinfusionPower: preinfusionPower ?? this.preinfusionPower,
- brewTemperature: brewTemperature ?? this.brewTemperature,
- steamTemperature: steamTemperature ?? this.steamTemperature,
- pidP: pidP ?? this.pidP,
- pidI: pidI ?? this.pidI,
- pidD: pidD ?? this.pidD,
- pidIWindDownMin: pidIWindDownMin ?? this.pidIWindDownMin,
- pidIWindDownMax: pidIWindDownMax ?? this.pidIWindDownMax,
- pidPollingInterval: pidPollingInterval ?? this.pidPollingInterval,
- shotCounter: shotCounter ?? this.shotCounter,
- grinderCounter: grinderCounter ?? this.grinderCounter,
- pressureStart: pressureStart ?? this.pressureStart,
- pressureEnd: pressureEnd ?? this.pressureEnd,
- pressurePeriod: pressurePeriod ?? this.pressurePeriod,
- heatingPower: heatingPower ?? this.heatingPower,
- valveClosedWhilePaused:
- valveClosedWhilePaused ?? this.valveClosedWhilePaused,
- proActivePercentage: proActivePercentage ?? this.proActivePercentage,
- autoShutoffMinutes: autoShutoffMinutes ?? this.autoShutoffMinutes,
- autoShutoffEnabled: autoShutoffEnabled ?? this.autoShutoffEnabled,
- wakeupEnabled: wakeupEnabled ?? this.wakeupEnabled,
- wakeupTime: wakeupTime ?? this.wakeupTime,
- shutdownEnabled: shutdownEnabled ?? this.shutdownEnabled,
- shutdownTime: shutdownTime ?? this.shutdownTime,
- preinfusionEnabled: preinfusionEnabled ?? this.preinfusionEnabled,
- preinfusionPauseTime: preinfusionPauseTime ?? this.preinfusionPauseTime,
- output0: output0 ?? this.output0,
- output1: output1 ?? this.output1,
- output2: output2 ?? this.output2,
- installedAsTimer: installedAsTimer ?? this.installedAsTimer,
- powerButtonFlipsBack: powerButtonFlipsBack ?? this.powerButtonFlipsBack,
- isLegacyV4Firmware: isLegacyV4Firmware ?? this.isLegacyV4Firmware,
- firmwareVersion: firmwareVersion ?? this.firmwareVersion,
- maxShotTime: maxShotTime ?? this.maxShotTime,
- continuousMode: continuousMode ?? this.continuousMode,
- );
- }
- }
|