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

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

Inheritance diagram for com.UniPRT.Sdk.Json.RfidMonitor:
com.UniPRT.Sdk.Json.IRfidMonitor

Public Member Functions

RfidReportNotice GetRfidReportCallback ()
 Inherited from IRfidMonitor.RfidReportCallback
More...
 
void SetRfidReportCallback (RfidReportNotice callback)
 Holds the function to call when RFID reports are received. Function must match the signature of RfidReportNotice. More...
 
boolean GetRfidReportListening ()
 Inherited from IRfidMonitor.RfidReportListening. More...
 
void SetRfidReportListening (boolean listening)
 Enable/disable listening/parsing unsolicited RFID reports sent from the printer. More...
 
 RfidMonitor (TcpConnection connection)
 Must pass an opened comm connection that can remain opened for listening for unsolicited RFID reports. More...
 
 RfidMonitor (JsonComm mgmtComm)
 Constructor called when an mgmt comm object already exists for listening for mgmt msgs. More...
 
 RfidMonitor (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 triggerCallbackForRfidReport (RfidReport report)
 
void MsgListenerCtrlRefresh ()
 
Map< String, String > MsgParser_RfidReport (String mgmtReportFrame)
 
void CallbackForRfidReport (RfidReport RfidReport)
 

Private Attributes

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

Static Private Attributes

static final int MAX_MSGS_FROM_PTR = 100
 
static final int MAX_Rfid_MSGS = 2
 

Detailed Description

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

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 RFID reports to be sent out by printer the following settings must be present:
    • On printer RFID menus: "AutoID Mgr Rpt = Enable"

Examples

package com.test.UniPRTSdk;
import java.util.Arrays;
public class PrinterMonitorSnippet {
// setup a comm and xml parser for listening to xml msgs from printer
private static PrinterMonitor _PrinterMntr = null;
public static void test() {
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 sending print job with that writes to EPC, USR and reads USR memory.

Output


Constructor & Destructor Documentation

◆ RfidMonitor() [1/3]

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

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

A connection is necessary to send/receive msgs.

References com.UniPRT.Sdk.Json.RfidMonitor._mgmtComm, com.UniPRT.Sdk.Json.RfidMonitor._myMgmtId, com.UniPRT.Sdk.Json.RfidMonitor._ptrComm, com.UniPRT.Sdk.Json.JsonStringBuilder.GetRandomObjectId_Json(), and com.UniPRT.Sdk.Json.RfidMonitor.RfidReportCallback.

◆ RfidMonitor() [2/3]

com.UniPRT.Sdk.Json.RfidMonitor.RfidMonitor ( 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.RfidMonitor._mgmtComm, com.UniPRT.Sdk.Json.RfidMonitor._myMgmtId, com.UniPRT.Sdk.Json.JsonStringBuilder.GetRandomObjectId_Json(), and com.UniPRT.Sdk.Json.RfidMonitor.RfidReportCallback.

◆ RfidMonitor() [3/3]

com.UniPRT.Sdk.Json.RfidMonitor.RfidMonitor ( 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.RfidMonitor._managedDescriptor, com.UniPRT.Sdk.Json.RfidMonitor._mgmtComm, com.UniPRT.Sdk.Json.RfidMonitor._myMgmtId, com.UniPRT.Sdk.Json.RfidMonitor._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.RfidMonitor.RfidReportCallback.

Member Function Documentation

◆ CallbackForRfidReport()

void com.UniPRT.Sdk.Json.RfidMonitor.CallbackForRfidReport ( RfidReport  RfidReport)
private

◆ close()

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

◆ Dispose() [1/2]

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

◆ Dispose() [2/2]

◆ finalize()

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

◆ GetRfidReportCallback()

RfidReportNotice com.UniPRT.Sdk.Json.RfidMonitor.GetRfidReportCallback ( )

Inherited from IRfidMonitor.RfidReportCallback

Implements com.UniPRT.Sdk.Json.IRfidMonitor.

References com.UniPRT.Sdk.Json.RfidMonitor.RfidReportCallback.

◆ GetRfidReportListening()

boolean com.UniPRT.Sdk.Json.RfidMonitor.GetRfidReportListening ( )

Inherited from IRfidMonitor.RfidReportListening.

Implements com.UniPRT.Sdk.Json.IRfidMonitor.

References com.UniPRT.Sdk.Json.RfidMonitor._rfidReportListening.

◆ MsgListenerCtrlRefresh()

◆ MsgParser_RfidReport()

Map<String, String> com.UniPRT.Sdk.Json.RfidMonitor.MsgParser_RfidReport ( String  mgmtReportFrame)
private

◆ SetRfidReportCallback()

void com.UniPRT.Sdk.Json.RfidMonitor.SetRfidReportCallback ( RfidReportNotice  callback)

Holds the function to call when RFID reports are received. Function must match the signature of RfidReportNotice.

The parameter passed into the function is an OdvReport object representing the RFID report received.

Implements com.UniPRT.Sdk.Json.IRfidMonitor.

◆ SetRfidReportListening()

void com.UniPRT.Sdk.Json.RfidMonitor.SetRfidReportListening ( boolean  listening)

Enable/disable listening/parsing unsolicited RFID reports sent from the printer.

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

Implements com.UniPRT.Sdk.Json.IRfidMonitor.

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

◆ triggerCallbackForRfidReport()

void com.UniPRT.Sdk.Json.RfidMonitor.triggerCallbackForRfidReport ( RfidReport  report)
private

Member Data Documentation

◆ _disposed

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

◆ _executor

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

◆ _listenerTask

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

◆ _managedDescriptor

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

◆ _mgmtComm

◆ _mgmtFilteredMsgs

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

◆ _mgmtMsgListening

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

◆ _msgsFromPtr

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

◆ _myMgmtId

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

◆ _printerJobReporting

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

◆ _ptrComm

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

◆ _rfidReportListening

AtomicBoolean com.UniPRT.Sdk.Json.RfidMonitor._rfidReportListening = new AtomicBoolean(false)
private

◆ _sdkManagedComm

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

◆ MAX_MSGS_FROM_PTR

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

◆ MAX_Rfid_MSGS

final int com.UniPRT.Sdk.Json.RfidMonitor.MAX_Rfid_MSGS = 2
staticprivate

◆ RfidReportCallback


The documentation for this class was generated from the following file:
com.UniPRT.Sdk.Json
Definition: AlertStatusNotice.java:1
com.UniPRT.Sdk.Json.PrinterMonitor
Module to facilitate listening/retrieval of printer unsolicited messaging or retrieval of printer sta...
Definition: PrinterMonitor.java:77
com.UniPRT
com.UniPRT.Sdk
com