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