UniPRT SDK  v1.0.0.0
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 OdvMonitor:
IOdvMonitor

Public Member Functions

 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...
 
 OdvMonitor (TcpConnection connection)
 Must pass an opened comm connection that can remain opened for listening for unsolicited ODV reports. More...
 
void close () throws Exception
 
void Dispose ()
 
OdvReportNotice GetOdvReportCallback ()
 Inherited from IOdvMonitor.OdvReportListening.
 
boolean GetOdvReportListening ()
 Inherited from IOdvMonitor.OdvReportListening.
 
void SetOdvReportCallback (OdvReportNotice callback)
 Holds the function to call when ODV reports received. Function must match signature of OdvReportNotice. More...
 
void SetOdvReportListening (boolean listening)
 Enable/disable listening/parsing unsolicited ODV reports sent from printer. More...
 

Protected Member Functions

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

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;
import java.util.Arrays;
import com.UniPRT.Sdk.Json.OdvMonitor;
import com.UniPRT.Sdk.Json.OdvReport;
public class OdvMonitorSnippet {
private static OdvMonitor _odvReportListener = null;
public static void main(String[] args) {
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]

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.

◆ OdvMonitor() [2/3]

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.

◆ OdvMonitor() [3/3]

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.

Member Function Documentation

◆ SetOdvReportCallback()

void 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 IOdvMonitor.

◆ SetOdvReportListening()

void 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 IOdvMonitor.

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