UniPRT SDK  v1.0.0.0
com.UniPRT.Sdk.Json.OdvMonitor Class Reference

Provide support for ODV related services. Module to facilitate listening/retrieval of printer unsolicited messaging related to ODV. More...

Inheritance diagram for com.UniPRT.Sdk.Json.OdvMonitor:
com.UniPRT.Sdk.Json.IOdvMonitor

Public Member Functions

OdvReportNotice GetOdvReportCallback ()
 Inherited from IOdvMonitor.OdvReportListening. More...
 
void SetOdvReportCallback (OdvReportNotice callback)
 Holds the function to call when ODV reports received. Function must match signature of OdvReportNotice. More...
 
boolean GetOdvReportListening ()
 Inherited from IOdvMonitor.OdvReportListening. More...
 
void SetOdvReportListening (boolean listening)
 Enable/disable listening/parsing unsolicited ODV reports sent from printer. More...
 
 OdvMonitor (TcpConnection connection)
 Must pass an opened comm connection that can remain opened for listening for unsolicited ODV reports. More...
 
 OdvMonitor (JsonComm mgmtComm)
 Constructor called when an mgmt comm object already exists for listening for mgmt msgs. More...
 
 OdvMonitor (String commDescriptor)
 Constructor called when creating a connection managed by the SDK. More...
 
void Dispose ()
 
void close () throws Exception
 

Protected Member Functions

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

Private Member Functions

void triggerCallbackForOdvReport (OdvReport report)
 
void MsgListenerCtrlRefresh ()
 
Map< String, String > MsgParser_OdvReport (String mgmtReportFrame)
 
void CallbackForOdvReport (OdvReport odvReport)
 

Private Attributes

TcpConnection _ptrComm
 
JsonComm _mgmtComm
 
Channel< String > _msgsFromPtr
 
String _myMgmtId = ""
 
AtomicBoolean _mgmtMsgListening = new AtomicBoolean(false)
 
AtomicBoolean _printerJobReporting = new AtomicBoolean(false)
 
AtomicBoolean _odvReportListening = new AtomicBoolean(false)
 
ExecutorService _executor = Executors.newSingleThreadExecutor()
 
Future<?> _listenerTask
 
ConcurrentLinkedQueue< String > _mgmtFilteredMsgs = new ConcurrentLinkedQueue<>()
 
OdvReportNotice OdvReportCallback
 
boolean _sdkManagedComm = false
 
String _managedDescriptor = ""
 
boolean _disposed = false
 

Static Private Attributes

static final int MAX_MSGS_FROM_PTR = 100
 
static final int MAX_ODV_MSGS = 2
 

Detailed Description

Provide support for ODV related services. Module to facilitate listening/retrieval of printer unsolicited messaging related to ODV.

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

Remarks
  • For ODV reports to be sent out by printer the following settings must be present:
    • On printer OVD menus: "Validator Active = Enable", "Telemetry Path = Network Port", "Telemetry Data = Full Report"

Examples

package com.test.UniPRTSdk;
public class OdvMonitorSnippet {
private static OdvMonitor _odvReportListener = null;
public static void test() {
System.out.println("Listening for ODV barcode reports.");
try {
//_odvReportListener = new OdvMonitor("127.0.0.1");
_odvReportListener = new OdvMonitor("192.168.1.55");
_odvReportListener.SetOdvReportListening(true); // enable parsing of unsolicited barcode report msgs from printer
_odvReportListener.SetOdvReportCallback(OdvMonitorSnippet::myOdvReportProcessing); // set the callback/delegate to call when reports received
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 (_odvReportListener != null) {
_odvReportListener.Dispose();
}
}
}
public static void myOdvReportProcessing(OdvReport odvReport) {
// Could also customize into CSV format based on needs
String userFriendlyResult = odvReport.Failed() ? "failed" : "passed"; // failure output as "failed"/"passed" to make more user friendly
System.out.println("\r\nShort CSV Format (customized ordered list): pass/fail, Grade, Data");
System.out.printf(" %s, %s, %s%n", userFriendlyResult, odvReport.OverallGrade(), odvReport.Data());
}
}

Output

Result after sending print job with barcode to printer and getting back barcode report.

Output

Constructor & Destructor Documentation

◆ OdvMonitor() [1/3]

com.UniPRT.Sdk.Json.OdvMonitor.OdvMonitor ( TcpConnection  connection)

Must pass an opened comm connection that can remain opened for listening for unsolicited ODV reports.

A connection is necessary to send/receive msgs.

References com.UniPRT.Sdk.Json.OdvMonitor._mgmtComm, com.UniPRT.Sdk.Json.OdvMonitor._myMgmtId, com.UniPRT.Sdk.Json.OdvMonitor._ptrComm, com.UniPRT.Sdk.Json.JsonStringBuilder.GetRandomObjectId_Json(), and com.UniPRT.Sdk.Json.OdvMonitor.OdvReportCallback.

◆ OdvMonitor() [2/3]

com.UniPRT.Sdk.Json.OdvMonitor.OdvMonitor ( JsonComm  mgmtComm)

Constructor called when an mgmt comm object already exists for listening for mgmt msgs.

JsonComm object per printer that is listening and parsing fully formed mgmt msgs and forwarding to all mgmt msg listeners.

References com.UniPRT.Sdk.Json.OdvMonitor._mgmtComm, com.UniPRT.Sdk.Json.OdvMonitor._myMgmtId, com.UniPRT.Sdk.Json.JsonStringBuilder.GetRandomObjectId_Json(), and com.UniPRT.Sdk.Json.OdvMonitor.OdvReportCallback.

◆ OdvMonitor() [3/3]

com.UniPRT.Sdk.Json.OdvMonitor.OdvMonitor ( String  commDescriptor)

Constructor called when creating a connection managed by the SDK.

commDescriptor is descriptor for the communication used to connect with 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, default value is used.

References com.UniPRT.Sdk.Json.OdvMonitor._managedDescriptor, com.UniPRT.Sdk.Json.OdvMonitor._mgmtComm, com.UniPRT.Sdk.Json.OdvMonitor._myMgmtId, com.UniPRT.Sdk.Json.OdvMonitor._sdkManagedComm, com.UniPRT.Sdk.Json.JsonCommController.CreateMgmtComm(), com.UniPRT.Sdk.Json.JsonStringBuilder.GetRandomObjectId_Json(), com.UniPRT.Sdk.Json.JsonCommController.Instance(), and com.UniPRT.Sdk.Json.OdvMonitor.OdvReportCallback.

Member Function Documentation

◆ CallbackForOdvReport()

void com.UniPRT.Sdk.Json.OdvMonitor.CallbackForOdvReport ( OdvReport  odvReport)
private

◆ close()

void com.UniPRT.Sdk.Json.OdvMonitor.close ( ) throws Exception

◆ Dispose() [1/2]

void com.UniPRT.Sdk.Json.OdvMonitor.Dispose ( )

◆ Dispose() [2/2]

◆ finalize()

void com.UniPRT.Sdk.Json.OdvMonitor.finalize ( ) throws Throwable
protected

◆ GetOdvReportCallback()

OdvReportNotice com.UniPRT.Sdk.Json.OdvMonitor.GetOdvReportCallback ( )

Inherited from IOdvMonitor.OdvReportListening.

Implements com.UniPRT.Sdk.Json.IOdvMonitor.

References com.UniPRT.Sdk.Json.OdvMonitor.OdvReportCallback.

◆ GetOdvReportListening()

boolean com.UniPRT.Sdk.Json.OdvMonitor.GetOdvReportListening ( )

Inherited from IOdvMonitor.OdvReportListening.

Implements com.UniPRT.Sdk.Json.IOdvMonitor.

References com.UniPRT.Sdk.Json.OdvMonitor._odvReportListening.

◆ MsgListenerCtrlRefresh()

◆ MsgParser_OdvReport()

Map<String, String> com.UniPRT.Sdk.Json.OdvMonitor.MsgParser_OdvReport ( String  mgmtReportFrame)
private

◆ SetOdvReportCallback()

void com.UniPRT.Sdk.Json.OdvMonitor.SetOdvReportCallback ( OdvReportNotice  callback)

Holds the function to call when ODV reports received. Function must match signature of OdvReportNotice.

The parameter passed into the function is a OdvReport object representing the ODV report received.

Implements com.UniPRT.Sdk.Json.IOdvMonitor.

◆ SetOdvReportListening()

void com.UniPRT.Sdk.Json.OdvMonitor.SetOdvReportListening ( boolean  listening)

Enable/disable listening/parsing unsolicited ODV reports sent from printer.

Note that this must be enabled in order to receive any notifications, OdvReportCallback, when barcode reports are received.

Implements com.UniPRT.Sdk.Json.IOdvMonitor.

References com.UniPRT.Sdk.Json.OdvMonitor._mgmtComm, com.UniPRT.Sdk.Json.OdvMonitor._myMgmtId, com.UniPRT.Sdk.Json.OdvMonitor._odvReportListening, com.UniPRT.Sdk.Json.JsonStringBuilder.CreateMsgFrame_Json(), com.UniPRT.Sdk.Json.OdvMonitor.MsgListenerCtrlRefresh(), and com.UniPRT.Sdk.Json.JsonComm.SendAndWaitForResponse().

◆ triggerCallbackForOdvReport()

void com.UniPRT.Sdk.Json.OdvMonitor.triggerCallbackForOdvReport ( OdvReport  report)
private

Member Data Documentation

◆ _disposed

boolean com.UniPRT.Sdk.Json.OdvMonitor._disposed = false
private

◆ _executor

ExecutorService com.UniPRT.Sdk.Json.OdvMonitor._executor = Executors.newSingleThreadExecutor()
private

◆ _listenerTask

Future<?> com.UniPRT.Sdk.Json.OdvMonitor._listenerTask
private

◆ _managedDescriptor

String com.UniPRT.Sdk.Json.OdvMonitor._managedDescriptor = ""
private

◆ _mgmtComm

◆ _mgmtFilteredMsgs

ConcurrentLinkedQueue<String> com.UniPRT.Sdk.Json.OdvMonitor._mgmtFilteredMsgs = new ConcurrentLinkedQueue<>()
private

◆ _mgmtMsgListening

AtomicBoolean com.UniPRT.Sdk.Json.OdvMonitor._mgmtMsgListening = new AtomicBoolean(false)
private

◆ _msgsFromPtr

Channel<String> com.UniPRT.Sdk.Json.OdvMonitor._msgsFromPtr
private

◆ _myMgmtId

String com.UniPRT.Sdk.Json.OdvMonitor._myMgmtId = ""
private

◆ _odvReportListening

AtomicBoolean com.UniPRT.Sdk.Json.OdvMonitor._odvReportListening = new AtomicBoolean(false)
private

◆ _printerJobReporting

AtomicBoolean com.UniPRT.Sdk.Json.OdvMonitor._printerJobReporting = new AtomicBoolean(false)
private

◆ _ptrComm

TcpConnection com.UniPRT.Sdk.Json.OdvMonitor._ptrComm
private

◆ _sdkManagedComm

boolean com.UniPRT.Sdk.Json.OdvMonitor._sdkManagedComm = false
private

◆ MAX_MSGS_FROM_PTR

final int com.UniPRT.Sdk.Json.OdvMonitor.MAX_MSGS_FROM_PTR = 100
staticprivate

◆ MAX_ODV_MSGS

final int com.UniPRT.Sdk.Json.OdvMonitor.MAX_ODV_MSGS = 2
staticprivate

◆ OdvReportCallback


The documentation for this class was generated from the following file:
com.UniPRT.Sdk.Json
Definition: AlertStatusNotice.java:1
com.UniPRT
com.UniPRT.Sdk.Json.OdvMonitor.OdvMonitor
OdvMonitor(TcpConnection connection)
Must pass an opened comm connection that can remain opened for listening for unsolicited ODV reports.
Definition: OdvMonitor.java:246
com.UniPRT.Sdk.Json.OdvReport
ODV Report class to show ODV/ODV2D data received from printer.
Definition: OdvReport.java:16
com.UniPRT.Sdk.Json.OdvMonitor
Provide support for ODV related services. Module to facilitate listening/retrieval of printer unsolic...
Definition: OdvMonitor.java:88
com.UniPRT.Sdk
com