public class PrinterStatusMessages extends Object
PrinterStatus
instance.
package test.zebra.sdk.printer.examples;
import com.zebra.sdk.comm.Connection;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.printer.PrinterStatus;
import com.zebra.sdk.printer.PrinterStatusMessages;
import com.zebra.sdk.printer.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
public class PrinterStatusMessagesExample {
public static void main(String[] args) throws Exception {
Connection connection = new TcpConnection("192.168.1.100", TcpConnection.DEFAULT_ZPL_TCP_PORT);
try {
connection.open();
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
PrinterStatus printerStatus = printer.getCurrentStatus();
if (printerStatus.isReadyToPrint) {
System.out.println("Ready To Print");
} else {
PrinterStatusMessages statusMessage = new PrinterStatusMessages(printerStatus);
String[] statusMessages = statusMessage.getStatusMessage();
String joinedStatusMessage = "";
for (int i = 0; i < statusMessages.length; i++) {
joinedStatusMessage += statusMessages[i] + ";";
}
System.out.println("Cannot Print: " + joinedStatusMessage);
}
} catch (ConnectionException e) {
e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
e.printStackTrace();
} finally {
connection.close();
}
}
}
Modifier and Type | Field and Description |
---|---|
static String |
HEAD_OPEN_MSG
Message to indicate the head is open
|
static String |
HEAD_TOO_HOT_MSG
Message to indicate the head is too hot
|
static String |
NULL_MSG
Message to indicate
printerStatus is null |
static String |
PAPER_OUT_MSG
Message to indicate the paper is out
|
static String |
PAUSE_MSG
Message to indicate printer is paused
|
static String |
RECEIVE_BUFFER_FULL_MSG
Message to indicate the receive buffer is full
|
static String |
RIBBON_OUT_MSG
Message to indicate the ribbon is out
|
Constructor and Description |
---|
PrinterStatusMessages(PrinterStatus printerStatus)
Used to acquire a human readable string of the current errors/warnings stored in
printerStatus |
public static final String HEAD_OPEN_MSG
public static final String HEAD_TOO_HOT_MSG
public static final String PAPER_OUT_MSG
public static final String RIBBON_OUT_MSG
public static final String RECEIVE_BUFFER_FULL_MSG
public static final String PAUSE_MSG
public static final String NULL_MSG
printerStatus
is nullpublic PrinterStatusMessages(PrinterStatus printerStatus)
printerStatus
printerStatus
- an instance of PrinterStatus
that will be used to acquire the human readable string
of warnings/errors stored in printerStatus
public String[] getStatusMessage()
© 2016 ZIH Corp. All Rights Reserved.