UniPRT SDK  v1.0.0.0
PrinterMonitor Class Reference

Module to facilitate listening/retrieval of printer unsolicited messaging or retrieval of printer status/information. More...

Inheritance diagram for PrinterMonitor:
IPrinterMonitor

Public Member Functions

 PrinterMonitor (JsonComm mgmtComm)
 
 PrinterMonitor (String commDescriptor)
 
 PrinterMonitor (TcpConnection connection)
 
void close () throws Exception
 
void Dispose ()
 
AlertStatusNotice GetAlertStatusCallback ()
 
boolean GetAlertStatusListening ()
 Inherited from IPrinterMonitor.AlertStatusListening.
 
DisplayStatusNotice GetDisplayStatusCallback ()
 
boolean GetDisplayStatusListening ()
 Inherited from IPrinterMonitor.DisplayStatusListening.
 
String GetEngineStatus ()
 Inherited from IPrinterMonitor.GetEngineStatus

 
EngineStatusNotice GetEngineStatusCallback ()
 
boolean GetEngineStatusListening ()
 Inherited from IPrinterMonitor.EngineStatusListening.
 
String[] GetFaultStatus ()
 Inherited from IPrinterMonitor.GetFaultStatus

 
PrinterInfo GetPrinterInfo ()
 Inherited from IPrinterMonitor.GetPrinterInfo

 
void SetAlertStatusCallback (AlertStatusNotice callback)
 Holds the function to call when fault/alert msgs received from printer. Function must match signature of AlertStatusNotice.
 
void SetAlertStatusListening (boolean listening)
 Enable/disable listening/parsing unsolicited fault status alerts from printer. More...
 
void SetDisplayStatusCallback (DisplayStatusNotice callback)
 Holds the function to call when display text msgs received from printer. Function must match signature of DisplayStatusNotice.
 
void SetDisplayStatusListening (boolean listening)
 Enable/disable listening/parsing unsolicited front panel display text from printer. More...
 
void SetEngineStatusCallback (EngineStatusNotice callback)
 Holds the function to call when engine status received from printer. Function must match signature of EngineStatusNotice.
 
void SetEngineStatusListening (boolean listening)
 Enable/disable listening/parsing unsolicited engine status from printer. More...
 

Protected Member Functions

void Dispose (boolean disposing)
 
void finalize () throws Throwable
 

Detailed Description

Module to facilitate listening/retrieval of printer unsolicited messaging or retrieval of printer status/information.

Unsolicited messages, if enabled on printer, can be sent at any time. This module requires a constant connection to the printer's management port in order to listen for any messaging sent out by printer.

Examples

package com.test.UniPRTSdk;
import java.util.Arrays;
import com.UniPRT.Sdk.Json.PrinterMonitor;
public class PrinterMonitorSnippet {
// setup a comm and xml parser for listening to xml msgs from printer
private static PrinterMonitor _PrinterMntr = null;
public static void main(String[] args) {
System.out.println("Monitoring Printer.");
try {
_PrinterMntr = new PrinterMonitor("192.168.1.57");
// setup for listening for alerts
_PrinterMntr.SetAlertStatusListening(true); // enable unsolicited alert status msgs from printer
_PrinterMntr.SetAlertStatusCallback(PrinterMonitorSnippet::PtrAlertNoticeListener);
// setup for listening for Engine Status
_PrinterMntr.SetEngineStatusListening(true); // enable unsolicited engine status msgs from printer
_PrinterMntr.SetEngineStatusCallback(PrinterMonitorSnippet::PtrEngineStatusNoticeListener);
// setup for listening for display text msgs
_PrinterMntr.SetDisplayStatusListening(true); // enable unsolicited display text msgs from printer
_PrinterMntr.SetDisplayStatusCallback(PrinterMonitorSnippet::PtrDisplayStatusNoticeListener);
while (true) { // wait for something to happen
// pretend to be busy doing some other work here...
Thread.sleep(1000); // simulate work
}
} catch (Exception e) {
System.out.printf("Exception Msg: %s%n", e.getMessage());
} finally {
if (_PrinterMntr != null) {
_PrinterMntr.Dispose();
}
}
}
private static void PtrAlertNoticeListener(String[] newAlertText) {
// Print out alerts: e.g. "2418" ("Print Head Open" fault/alert)
System.out.printf("Printer Alert #: %n %s - %s%n", newAlertText[0], newAlertText[1]);
}
private static void PtrEngineStatusNoticeListener(String newEngineStatus) {
// Print out engine status: e.g. "idle", "offline", "online", "printing"...
System.out.printf("Engine Status: %n %s%n", newEngineStatus);
}
private static void PtrDisplayStatusNoticeListener(String[] newDisplayText) {
// Print display msgs: e.g. "ONLINE" "ETHERNET/PGL/LP+" or "PRINT HEAD UP" "Close Print Head"
System.out.println("Printer Display: ");
Arrays.stream(newDisplayText).forEach(txtLine -> System.out.printf(" %s%n", txtLine));
}
}

Output

Result after causing fault by opening/closing print head, and pressing the pause button on printer to place printer "offline"/"online".

Output


Member Function Documentation

◆ SetAlertStatusListening()

void SetAlertStatusListening ( boolean  listening)

Enable/disable listening/parsing unsolicited fault status alerts from printer.

Note that this must be enabled in order to receive any notifications, AlertStatusCallback, from printer.

Implements IPrinterMonitor.

◆ SetDisplayStatusListening()

void SetDisplayStatusListening ( boolean  listening)

Enable/disable listening/parsing unsolicited front panel display text from printer.

Note that this must be enabled in order to receive any notifications, DisplayStatusCallback, from printer.

Implements IPrinterMonitor.

◆ SetEngineStatusListening()

void SetEngineStatusListening ( boolean  listening)

Enable/disable listening/parsing unsolicited engine status from printer.

Note that this must be enabled in order to receive any notifications, EngineStatusCallback, from printer.

Implements IPrinterMonitor.