namespace Extrudex.Domain.Interfaces; /// /// Client for communicating with Moonraker REST API on Klipper-based printers /// (e.g., Elegoo Centauri Carbon). Retrieves print job metadata including /// filament usage data. /// public interface IMoonrakerClient { /// /// Retrieves the current printer status from Moonraker. /// /// Printer hostname or IP address. /// Moonraker port (default: 7125). /// Optional API key for authentication. /// Cancellation token. /// The printer status string (e.g., "idle", "printing", "paused", "error"). Task GetPrinterStatusAsync( string hostnameOrIp, int port, string? apiKey = null, CancellationToken cancellationToken = default); /// /// Retrieves filament usage data from the current or most recent print job. /// Moonraker exposes this via the /api/objects endpoint querying /// "history" and "print_stats" objects. /// /// Printer hostname or IP address. /// Moonraker port (default: 7125). /// Optional API key for authentication. /// Cancellation token. /// Filament usage data from Moonraker, or null if unavailable. Task GetFilamentUsageAsync( string hostnameOrIp, int port, string? apiKey = null, CancellationToken cancellationToken = default); } /// /// Represents filament usage data retrieved from a Moonraker-equipped printer. /// Maps to Moonraker's print_stats and history objects. /// public class MoonrakerFilamentUsage { /// /// Millimeters of filament extruded during the print job. /// public decimal MmExtruded { get; set; } /// /// The filename of the G-code file being or recently printed. /// public string? GcodeFileName { get; set; } /// /// Current print state from Moonraker (e.g., "printing", "complete", "error"). /// public string PrintState { get; set; } = string.Empty; /// /// Total print time in seconds, if available from Moonraker. /// public double? PrintDurationSeconds { get; set; } /// /// Timestamp (UTC) when the print job was started, if available. /// public DateTime? StartedAt { get; set; } /// /// Timestamp (UTC) when the print job completed, if available. /// public DateTime? CompletedAt { get; set; } }