Rongta 80mm printer: driver, role-based failover, live status monitoring
Add the rongta PrinterDevice driver (ESC/POS over raw TCP 9100) and the device-agnostic pieces around it: - Roles + failover: each printer declares a role (entry-dispenser/booth- receipt) and failoverRank; printer-routing.ts picks the best healthy printer and falls back outside->booth for entry tickets (never the reverse). - Live status: MonitorableDevice.readStatus()/PrinterStatus capability. The Rongta driver scrapes the device's own /prn_stat.htm (Cover/Cutter/Paper End/Near End/Off-Line) rather than hand-decoding DLE EOT, whose reply bytes on this clone don't match the canonical ESC/POS bit layout (verified on hardware) -- avoids a false-healthy. Maps to ready/degraded/offline, fail safe on an unreachable or unexpected page. - Server PrinterMonitor polls enabled printers (PRINTER_POLL_MS, default 5s), caches latest, emits "printer-status" on change. Exposed via GET /api/printers/status and an SSE stream for the booth UI. Verified against 10.0.10.6: ready when healthy, offline when unreachable (no throw), bus emits on change and suppresses unchanged reads. Wiki: new rongta-printer entity, printer-roles-failover and printer-status-monitoring concepts; BOM/index/log updated.
This commit is contained in:
@@ -191,3 +191,37 @@ export interface TicketData {
|
||||
export interface PrinterDevice extends Device {
|
||||
printTicket(data: TicketData): Promise<void>;
|
||||
}
|
||||
|
||||
// --- Live printer status (consumable / mechanical faults) ----------------
|
||||
// Optional capability: a printer that reports the operator-actionable faults a
|
||||
// basic `healthCheck` (reachability) can't see — paper out, cover open, cutter
|
||||
// jam. Used by the live status monitor so the booth knows BEFORE a driver presses
|
||||
// the entry button and no ticket comes out. The Rongta board exposes these via
|
||||
// its own status web page (it decodes the ESC/POS bits for us — more reliable
|
||||
// than trusting a clone's DLE EOT bit layout). See wiki/concepts/printer-status-monitoring.md.
|
||||
export interface PrinterStatus {
|
||||
/** Reachable + no fault = ready; reachable + fault = degraded; unreachable = offline. */
|
||||
readonly status: "ready" | "degraded" | "offline";
|
||||
/** Out of paper — the printer cannot print. */
|
||||
readonly paperEnd?: boolean;
|
||||
/** Paper low — still prints, but warn the operator to reload. */
|
||||
readonly paperNearEnd?: boolean;
|
||||
/** Cover/lid open — will not print. */
|
||||
readonly coverOpen?: boolean;
|
||||
/** Cutter jammed/errored. */
|
||||
readonly cutterError?: boolean;
|
||||
/** Printer reports itself off-line (its own flag, distinct from unreachable). */
|
||||
readonly offline?: boolean;
|
||||
/** Human-readable summary (e.g. "paper out", or the unreachable error). */
|
||||
readonly detail?: string;
|
||||
readonly checkedAt: string; // ISO-8601
|
||||
}
|
||||
|
||||
export interface MonitorableDevice {
|
||||
/** Richer, operator-actionable status beyond reachability. */
|
||||
readStatus(): Promise<PrinterStatus>;
|
||||
}
|
||||
|
||||
export function isMonitorable(device: Device): device is Device & MonitorableDevice {
|
||||
return typeof (device as Partial<MonitorableDevice>).readStatus === "function";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user