Files
Extrudex/backend/Domain/Entities/Printer.cs
rex-bot 311dd2ee7f
Some checks failed
Dev Build / build-test (pull_request) Failing after 58s
Dev Build / deploy-dev (pull_request) Has been skipped
Dev Build / notify-success (pull_request) Has been skipped
Dev Build / notify-failure (pull_request) Successful in 4s
feat(CUB-31): [Extrudex] Add filament usage tracking model
2026-04-26 18:35:37 +00:00

103 lines
3.5 KiB
C#

using Extrudex.Domain.Base;
using Extrudex.Domain.Enums;
namespace Extrudex.Domain.Entities;
/// <summary>
/// Represents a 3D printer in the fleet. Stores connection details for
/// MQTT (Bambu Lab) or Moonraker (Elegoo Centauri Carbon) integration.
/// </summary>
public class Printer : AuditableEntity
{
/// <summary>
/// Current operational status of the printer, updated via real-time telemetry.
/// </summary>
public PrinterStatus Status { get; set; } = PrinterStatus.Offline;
/// <summary>
/// Human-readable name for the printer (e.g., "Bambu X1C #1", "Elegoo Centauri").
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Manufacturer/brand of the printer (e.g., "Bambu Lab", "Elegoo").
/// </summary>
public string Manufacturer { get; set; } = string.Empty;
/// <summary>
/// Model name (e.g., "X1 Carbon", "Centauri Carbon").
/// </summary>
public string Model { get; set; } = string.Empty;
/// <summary>
/// The hardware type of the printer (FDM or Resin).
/// </summary>
public PrinterType PrinterType { get; set; } = PrinterType.Fdm;
/// <summary>
/// The connectivity protocol used by this printer (MQTT or Moonraker).
/// </summary>
public ConnectionType ConnectionType { get; set; } = ConnectionType.Mqtt;
/// <summary>
/// Hostname or IP address for connecting to the printer.
/// </summary>
public string HostnameOrIp { get; set; } = string.Empty;
/// <summary>
/// Port number for the printer connection. Defaults: 8883 (MQTT/TLS), 7125 (Moonraker).
/// </summary>
public int Port { get; set; }
/// <summary>
/// MQTT username for Bambu Lab printer authentication.
/// Stored only for MQTT connection type printers.
/// </summary>
public string MqttUsername { get; set; } = string.Empty;
/// <summary>
/// MQTT password for Bambu Lab printer authentication.
/// Stored only for MQTT connection type printers.
/// </summary>
public string MqttPassword { get; set; } = string.Empty;
/// <summary>
/// Whether to use TLS for the MQTT connection. Bambu Lab printers
/// require TLS on port 8883.
/// </summary>
public bool MqttUseTls { get; set; }
/// <summary>
/// Moonraker API key for Elegoo Centauri Carbon authentication.
/// Stored only for Moonraker connection type printers.
/// </summary>
public string ApiKey { get; set; } = string.Empty;
/// <summary>
/// Whether this printer is currently active and available for print jobs.
/// Inactive printers are retained for historical records.
/// </summary>
public bool IsActive { get; set; } = true;
/// <summary>
/// Timestamp of the last status update received from the printer (UTC).
/// Used to detect stale connections.
/// </summary>
public DateTime? LastSeenAt { get; set; }
/// <summary>
/// Navigation collection of AMS units installed on this printer.
/// </summary>
public ICollection<AmsUnit> AmsUnits { get; set; } = new List<AmsUnit>();
/// <summary>
/// Navigation collection of print jobs executed on this printer.
/// </summary>
public ICollection<PrintJob> PrintJobs { get; set; } = new List<PrintJob>();
/// <summary>
/// Navigation collection of filament usage records tracking consumption on this printer.
/// Enables querying per-printer filament usage and COGS.
/// </summary>
public ICollection<FilamentUsage> FilamentUsages { get; set; } = new List<FilamentUsage>();
}