UniPRT SDK  v1.0.0.0
UniPRT.Sdk.Monitor.PrinterMonitor Class Reference

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

Inheritance diagram for UniPRT.Sdk.Monitor.PrinterMonitor:
UniPRT.Sdk.Monitor.IPrinterMonitor

Public Member Functions

 PrinterMonitor (string commDescriptor)
 Constructor called when creating a connection managed by the SDK. More...
 
void Dispose ()
 
string GetEngineStatus ()
 Inherited from IPrinterMonitor.GetEngineStatus.
 
string[] GetFaultStatus ()
 Inherited from IPrinterMonitor.GetFaultStatus.
 
PrinterInfo GetPrinterInfo ()
 Inherited from IPrinterMonitor.GetPrinterInfo.
 

Protected Member Functions

virtual void Dispose (bool disposing)
 

Properties

AlertStatusNotice AlertStatusCallback [get, set]
 Inherited from IPrinterMonitor.AlertStatusCallback.
 
bool? AlertStatusListening [get, set]
 Inherited from IPrinterMonitor.AlertStatusListening.
 
DisplayStatusNotice DisplayStatusCallback [get, set]
 Inherited from IPrinterMonitor.DisplayStatusCallback.
 
bool? DisplayStatusListening [get, set]
 Inherited from IPrinterMonitor.DisplayStatusListening.
 
EngineStatusNotice EngineStatusCallback [get, set]
 Inherited from IPrinterMonitor.EngineStatusCallback.
 
bool? EngineStatusListening [get, set]
 Inherited from IPrinterMonitor.EngineStatusListening.
 

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

using System;
namespace Snippets
{
public class MyPrinterMonitoring
{
// setup a comm and xml parser for listening to xml msgs from printer
private static PrinterMonitor _PrinterMntr = null;
public static void MainPrinterMonitor(string[] args)
{
Console.WriteLine("Monitoring Printer.");
try
{
_PrinterMntr = new PrinterMonitor("192.168.1.57");
// setup for listening for alerts
_PrinterMntr.AlertStatusListening = true; // enable unsolicited alert status msgs from printer
_PrinterMntr.AlertStatusCallback = PtrAlertNoticeListener;
// setup for listening for Engine Status
_PrinterMntr.EngineStatusListening = true; // enable unsolicited engine status msgs from printer
_PrinterMntr.EngineStatusCallback = PtrEngineStatusNoticeListener;
// setup for listening for display text msgs
_PrinterMntr.DisplayStatusListening = true; // enable unsolicited display text msgs from printer
_PrinterMntr.DisplayStatusCallback = PtrDisplayStatusNoticeListener;
while (true) // wait for something to happen
{
// pretend to be busy doing some other work here...
}
}
catch (Exception e)
{
Console.WriteLine($"Exception Msg: {e.Message}");
}
finally
{
_PrinterMntr?.Dispose();
}
}
private static void PtrAlertNoticeListener(string[] newAlertText)
{
// Print out alerts: e.g. "2418" ("Print Head Open" fault/alert)
Console.WriteLine($"Printer Alert #: \r\n {newAlertText[0]} - {newAlertText[1]}\r\n");
}
private static void PtrEngineStatusNoticeListener(string newEngineStatus)
{
// Print out engine status: e.g. "idle", "offline", "online", "printing"...
Console.WriteLine($"Engine Status: \r\n {newEngineStatus} \r\n");
}
private static void PtrDisplayStatusNoticeListener(string[] newDisplayText)
{
// Print display msgs: e.g. "ONLINE" "ETHERNET/PGL/LP+" or "PRINT HEAD UP" "Close Print Head"
Console.WriteLine("Printer Display: ");
foreach (string txtLine in newDisplayText)
{
Console.WriteLine($" {txtLine}");
}
}
}
}

Output

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

Output

Constructor & Destructor Documentation

◆ PrinterMonitor()

UniPRT.Sdk.Monitor.PrinterMonitor.PrinterMonitor ( string  commDescriptor)

Constructor called when creating a connection managed by the SDK.

commDescriptor is the descriptor for the communication used to connect with the printer.
TCP descriptor format: "ip" or "ip:port"
e.g. "127.0.0.1" or "127.0.0.1:3007"
If port is not provided, the default value is used.

UniPRT
Provide support for different communication interfaces/ports.
Definition: Communication.cs:9
UniPRT.Sdk
Definition: Communication.cs:9
UniPRT.Sdk.Monitor
Definition: OdvMonitor.cs:14