Classes and methods related to Monitor.
More...
|
class | OdvMonitor |
| Provide support for ODV related services. Module to facilitate listening/retrieval of printer unsolicited messaging related to ODV. More...
|
|
class | PrinterMonitor |
| Module to facilitate listening/retrieval of printer unsolicited messaging or retrieval of printer status/information. More...
|
|
class | RfidMonitor |
| Provide support for RFID related services. Module to facilitate listening/retrieval of printer unsolicited messaging related to RFID. More...
|
|
Classes and methods related to Monitor.
For the Objective-C example:
Printer Monitor example
Rfid Monitor example
Odv Monitor example
For the Swift example:
Printer Monitor example
Rfid Monitor example
Odv Monitor example
Example
Objective-C:
Printer Monitor:
#import "ViewController.h"
@import UniPRT;
@interface ViewController ()
@property (strong)
TcpComm *tcpComm;
@property (nonatomic, strong) UITextField *ipTextField;
@property (nonatomic, strong) UITextView *resultTextView;
@property (nonatomic, strong) UITextView *callbackTextView;
@property (nonatomic, strong) UIButton *openButton;
@property (nonatomic, strong) UIButton *writeButton;
@property (nonatomic, strong) UIButton *readButton;
@property (nonatomic, strong) UIButton *connectCloseButton;
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) UISegmentedControl *connectionSegmentedControl;
@property (nonatomic, strong) UIButton *connectshowPrinterInfoTestButton;
@property (nonatomic, strong) UIButton *connectPrinterMonitorTestButton;
@property (nonatomic, strong) UIButton *connectPrintTestButton;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
scrollView.contentSize = CGSizeMake(self.view.bounds.size.width, 1500);
scrollView.userInteractionEnabled = YES;
scrollView.scrollEnabled = YES;
[self.view addSubview:scrollView];
self.ipTextField = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, 200, 30)];
self.ipTextField.placeholder = @"Enter IP Address";
self.ipTextField.borderStyle = UITextBorderStyleRoundedRect;
[scrollView addSubview:self.ipTextField];
self.ipTextField.text = @"10.0.10.180";
self.resultTextView = [[UITextView alloc] initWithFrame:CGRectMake(20, 150, 300, 200)];
self.resultTextView.editable = NO;
self.resultTextView.scrollEnabled = YES;
self.resultTextView.layer.borderWidth = 1.0;
self.resultTextView.layer.borderColor = [[UIColor blackColor] CGColor];
[scrollView addSubview:self.resultTextView];
self.callbackTextView = [[UITextView alloc] initWithFrame:CGRectMake(20, 550, 300, 1000)];
self.callbackTextView.editable = NO;
self.callbackTextView.scrollEnabled = YES;
self.callbackTextView.layer.borderWidth = 1.0;
self.callbackTextView.layer.borderColor = [[UIColor blackColor] CGColor];
[scrollView addSubview:self.callbackTextView];
self.connectCloseButton = [self createButtonWithTitle:@"Connect" frame:CGRectMake(20, 370, 300, 30)];
self.connectCloseButton.backgroundColor = [UIColor redColor];
[self.connectCloseButton addTarget:self action:@selector(connectCloseButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectCloseButton];
self.openButton = [self createButtonWithTitle:@"Open" frame:CGRectMake(20, 420, 300, 30)];
self.openButton.backgroundColor = [UIColor redColor];
[self.openButton addTarget:self action:@selector(openButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.openButton];
self.connectshowPrinterInfoTestButton = [self createButtonWithTitle:@"showPrinterInfoTest" frame:CGRectMake(20, 460, 300, 30)];
self.connectshowPrinterInfoTestButton.backgroundColor = [UIColor redColor];
[self.connectshowPrinterInfoTestButton addTarget:self action:@selector(showPrinterInfoTestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectshowPrinterInfoTestButton];
self.connectPrinterMonitorTestButton = [self createButtonWithTitle:@"PrinterMonitorTest" frame:CGRectMake(20, 500, 300, 30)];
self.connectPrinterMonitorTestButton.backgroundColor = [UIColor redColor];
[self.connectPrinterMonitorTestButton addTarget:self action:@selector(connectPrinterMonitorTestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectPrinterMonitorTestButton];
self.connectPrintTestButton = [self createButtonWithTitle:@"PrinterTest" frame:CGRectMake(20, 535, 300, 30)];
self.connectPrintTestButton.backgroundColor = [UIColor redColor];
[self.connectPrintTestButton addTarget:self action:@selector(connectPrintTestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectPrintTestButton];
}
- (UIButton *)createButtonWithTitle:(NSString *)title frame:(CGRect)frame {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = frame;
[button setTitle:title forState:UIControlStateNormal];
return button;
}
- (void)openButtonPressed {
[self.tcpComm open];
}
- (void)connectCloseButtonPressed {
NSString *currentTitle = [self.connectCloseButton titleForState:UIControlStateNormal];
if ([currentTitle isEqualToString:@"Connect"]) {
NSString *ipAddress = self.ipTextField.text;
self.tcpComm = [[
TcpComm alloc] initWithIPAddress:ipAddress port:DEFAULT_MGMT_PORT];
[self.connectCloseButton setTitle:@"Close" forState:UIControlStateNormal];
} else if ([currentTitle isEqualToString:@"Close"]) {
[self.tcpComm close];
[self.connectCloseButton setTitle:@"Connect" forState:UIControlStateNormal];
}
}
- (void)showPrinterInfoTestButtonPressed {
NSMutableString *receivedString = [[NSMutableString alloc] init];
[receivedString appendString:@"======= RFID Printer Info: \n"];
[receivedString appendFormat:@"Printer Model: %@\n", printerInfo.model];
[receivedString appendFormat:@"Printer SN: %@\n", printerInfo.serialNumber];
[receivedString appendFormat:@"Printer FW PN: %@\n", printerInfo.firmwarePartNumber];
[receivedString appendFormat:@"Printer FW Ver: %@\n", printerInfo.firmwareVersion];
[receivedString appendFormat:@"Printhead Resolution (Dots/Inch): %@\n", printerInfo.printheadResolution];
[receivedString appendFormat:@"Has odv: %@\n", printerInfo.hasOdvOption ? @"Yes" : @"No"];
NSLog(@"%@", receivedString);
self.resultTextView.text = receivedString;
}
- (void)connectPrinterMonitorTestButtonPressed {
NSMutableString *receivedString = [[NSMutableString alloc] init];
NSLog(@"Engine status update: %@", status);
[receivedString appendFormat:@"Engine status update: %@\n", status];
dispatch_async(dispatch_get_main_queue(), ^{
self.callbackTextView.text = receivedString;
});
};
NSLog(@"Display status update: %@", [status componentsJoinedByString:@", "]);
[receivedString appendFormat:@"Display status update: %@\n", [status componentsJoinedByString:@", "]];
dispatch_async(dispatch_get_main_queue(), ^{
self.callbackTextView.text = receivedString;
});
};
NSLog(@"Alert status update: %@", [status componentsJoinedByString:@", "]);
[receivedString appendFormat:@"Alert status update: %@\n", [status componentsJoinedByString:@", "]];
dispatch_async(dispatch_get_main_queue(), ^{
self.callbackTextView.text = receivedString;
});
};
}
- (void)connectPrintTestButtonPressed {
NSString *ipAddress = self.ipTextField.text;
TcpComm *tcpComm2 = [[
TcpComm alloc] initWithIPAddress:ipAddress port:DEFAULT_DATA_PORT];
[tcpComm2
sendPrintFile:ipAddress
fileName:@"/Users/realbuber/Documents/Objective-C IOS SDK example/Objective-C/TestPrinterMonitor/Hello_1.pgl"];
NSLog(@"Sending print job...");
}
@end
Printer information class to show printer attributes and other useful information.
Definition PrinterInfo.h:33
Module to facilitate listening/retrieval of printer unsolicited messaging or retrieval of printer sta...
Definition PrinterMonitor.h:45
void SetEngineStatusListening:(BOOL value)
Sets whether engine status listening is enabled.
EngineStatusCallback engineStatusCallback
Holds the function to call when engine status received from printer. Function must match signature of...
Definition PrinterMonitor.h:474
AlertStatusCallback alertStatusCallback
Holds the function to call when fault/alert messages are received from printer. Function must match s...
Definition PrinterMonitor.h:498
PrinterInfo * getPrinterInfo()
Get printer information.
void SetAlertStatusListening:(BOOL value)
Sets whether alert status listening is enabled.
void SetDisplayStatusListening:(BOOL value)
Sets whether display status listening is enabled.
DisplayStatusCallback displayStatusCallback
Holds the function to call when display text messages are received from printer. Function must match ...
Definition PrinterMonitor.h:486
A class for TCP communication, inheriting from AComm and conforming to the NSStreamDelegate protocol.
Definition TcpComm.h:101
void sendPrintFile:fileName:(NSString *ipAddress,[fileName] NSString *fileName)
Sends a print file to the specified IP address.
Rfid Monitor:
#import "ViewController.h"
@import UniPRT;
@interface ViewController ()
@property (strong)
TcpComm *tcpComm;
@property (nonatomic, strong) UITextField *ipTextField;
@property (nonatomic, strong) UITextField *macAddressTextField;
@property (nonatomic, strong) UITextView *resultTextView;
@property (nonatomic, strong) UITextView *callbackTextView;
@property (nonatomic, strong) UIButton *openButton;
@property (nonatomic, strong) UIButton *writeButton;
@property (nonatomic, strong) UIButton *readButton;
@property (nonatomic, strong) UIButton *connectCloseButton;
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) UISegmentedControl *connectionSegmentedControl;
@property (nonatomic, strong) UIButton *connectshowPrinterInfoTestButton;
@property (nonatomic, strong) UIButton *connectRfidMonitorTestButton;
@property (nonatomic, strong) UIButton *connectPrintTestButton;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
scrollView.contentSize = CGSizeMake(self.view.bounds.size.width, 1500);
scrollView.userInteractionEnabled = YES;
scrollView.scrollEnabled = YES;
[self.view addSubview:scrollView];
self.ipTextField = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, 200, 30)];
self.ipTextField.placeholder = @"Enter IP Address";
self.ipTextField.borderStyle = UITextBorderStyleRoundedRect;
[scrollView addSubview:self.ipTextField];
self.ipTextField.text = @"10.0.10.178";
self.resultTextView = [[UITextView alloc] initWithFrame:CGRectMake(20, 150, 300, 200)];
self.resultTextView.editable = NO;
self.resultTextView.scrollEnabled = YES;
self.resultTextView.layer.borderWidth = 1.0;
self.resultTextView.layer.borderColor = [[UIColor blackColor] CGColor];
[scrollView addSubview:self.resultTextView];
self.callbackTextView = [[UITextView alloc] initWithFrame:CGRectMake(20, 550, 300, 1000)];
self.callbackTextView.editable = NO;
self.callbackTextView.scrollEnabled = YES;
self.callbackTextView.layer.borderWidth = 1.0;
self.callbackTextView.layer.borderColor = [[UIColor blackColor] CGColor];
[scrollView addSubview:self.callbackTextView];
self.connectCloseButton = [self createButtonWithTitle:@"Connect" frame:CGRectMake(20, 370, 300, 30)];
self.connectCloseButton.backgroundColor = [UIColor redColor];
[self.connectCloseButton addTarget:self action:@selector(connectCloseButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectCloseButton];
self.openButton = [self createButtonWithTitle:@"Open" frame:CGRectMake(20, 420, 300, 30)];
self.openButton.backgroundColor = [UIColor redColor];
[self.openButton addTarget:self action:@selector(openButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.openButton];
self.connectshowPrinterInfoTestButton = [self createButtonWithTitle:@"showPrinterInfoTest" frame:CGRectMake(20, 460, 300, 30)];
self.connectshowPrinterInfoTestButton.backgroundColor = [UIColor redColor];
[self.connectshowPrinterInfoTestButton addTarget:self action:@selector(showPrinterInfoTestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectshowPrinterInfoTestButton];
self.connectRfidMonitorTestButton = [self createButtonWithTitle:@"RfidMonitorTest" frame:CGRectMake(20, 500, 300, 30)];
self.connectRfidMonitorTestButton.backgroundColor = [UIColor redColor];
[self.connectRfidMonitorTestButton addTarget:self action:@selector(connectRfidMonitorTestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectRfidMonitorTestButton];
self.connectPrintTestButton = [self createButtonWithTitle:@"PrinterTest" frame:CGRectMake(20, 535, 300, 30)];
self.connectPrintTestButton.backgroundColor = [UIColor redColor];
[self.connectPrintTestButton addTarget:self action:@selector(connectPrintTestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectPrintTestButton];
}
- (UIButton *)createButtonWithTitle:(NSString *)title frame:(CGRect)frame {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = frame;
[button setTitle:title forState:UIControlStateNormal];
return button;
}
- (void)openButtonPressed {
[self.tcpComm open];
}
- (void)connectCloseButtonPressed {
NSString *currentTitle = [self.connectCloseButton titleForState:UIControlStateNormal];
if ([currentTitle isEqualToString:@"Connect"]) {
NSString *ipAddress = self.ipTextField.text;
self.tcpComm = [[
TcpComm alloc] initWithIPAddress:ipAddress port:DEFAULT_MGMT_PORT];
[self.connectCloseButton setTitle:@"Close" forState:UIControlStateNormal];
} else if ([currentTitle isEqualToString:@"Close"]) {
[self.tcpComm close];
[self.connectCloseButton setTitle:@"Connect" forState:UIControlStateNormal];
}
}
- (void)showPrinterInfoTestButtonPressed {
NSMutableString *receivedString = [[NSMutableString alloc] init];
[receivedString appendString:@"======= RFID Printer Info: \n"];
[receivedString appendFormat:@"Printer Model: %@\n", printerInfo.model];
[receivedString appendFormat:@"Printer SN: %@\n", printerInfo.serialNumber];
[receivedString appendFormat:@"Printer FW PN: %@\n", printerInfo.firmwarePartNumber];
[receivedString appendFormat:@"Printer FW Ver: %@\n", printerInfo.firmwareVersion];
[receivedString appendFormat:@"Printhead Resolution (Dots/Inch): %@\n", printerInfo.printheadResolution];
[receivedString appendFormat:@"Has RFID: %@\n", printerInfo.hasRfidOption ? @"Yes" : @"No"];
NSLog(@"%@", receivedString);
self.resultTextView.text = receivedString;
}
- (void)connectRfidMonitorTestButtonPressed {
NSMutableString *receivedString = [[NSMutableString alloc] init];
if (report.failed) {
[receivedString appendFormat:@"\nRFID Failed."];
} else {
[receivedString appendFormat:@"\nRFID Passed."];
[receivedString appendFormat:@"Write Action: %@", report.isWriteOperation ? @"Yes" : @"No"];
[receivedString appendFormat:@"Data: \n%@", report.data];
dispatch_async(dispatch_get_main_queue(), ^{
self.callbackTextView.text = receivedString;
});
}
};
}
- (void)connectPrintTestButtonPressed {
NSString *ipAddress = self.ipTextField.text;
TcpComm *tcpComm2 = [[
TcpComm alloc] initWithIPAddress:ipAddress port:DEFAULT_DATA_PORT];
NSLog(@"Sending RFID print job...");
}
@end
Provide support for RFID related services. Module to facilitate listening/retrieval of printer unsoli...
Definition RfidMonitor.h:53
RfidReportCallback rfidReportCallback
Holds the function to call when RFID reports are received. Function must match signature of RfidRepor...
Definition RfidMonitor.h:302
void SetRfidReportListening:(BOOL value)
Sets whether RFID report listening is enabled.
Rfid report based on RFID tag messages received from printer.
Definition RfidReport.h:110
Odv Monitor:
#import "ViewController.h"
@import UniPRT;
@interface ViewController ()
@property (strong)
TcpComm *tcpComm;
@property (nonatomic, strong) UITextField *ipTextField;
@property (nonatomic, strong) UITextView *resultTextView;
@property (nonatomic, strong) UITextView *callbackTextView;
@property (nonatomic, strong) UIButton *openButton;
@property (nonatomic, strong) UIButton *readButton;
@property (nonatomic, strong) UIButton *connectCloseButton;
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) UISegmentedControl *connectionSegmentedControl;
@property (nonatomic, strong) UIButton *connectshowPrinterInfoTestButton;
@property (nonatomic, strong) UIButton *connectOdvMonitorTestButton;
@property (nonatomic, strong) UIButton *connectPrintTestButton;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
scrollView.contentSize = CGSizeMake(self.view.bounds.size.width, 1500);
scrollView.userInteractionEnabled = YES;
scrollView.scrollEnabled = YES;
[self.view addSubview:scrollView];
self.ipTextField = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, 200, 30)];
self.ipTextField.placeholder = @"Enter IP Address";
self.ipTextField.borderStyle = UITextBorderStyleRoundedRect;
[scrollView addSubview:self.ipTextField];
self.ipTextField.text = @"10.0.10.178";
self.resultTextView = [[UITextView alloc] initWithFrame:CGRectMake(20, 150, 300, 200)];
self.resultTextView.editable = NO;
self.resultTextView.scrollEnabled = YES;
self.resultTextView.layer.borderWidth = 1.0;
self.resultTextView.layer.borderColor = [[UIColor blackColor] CGColor];
[scrollView addSubview:self.resultTextView];
self.callbackTextView = [[UITextView alloc] initWithFrame:CGRectMake(20, 550, 300, 1000)];
self.callbackTextView.editable = NO;
self.callbackTextView.scrollEnabled = YES;
self.callbackTextView.layer.borderWidth = 1.0;
self.callbackTextView.layer.borderColor = [[UIColor blackColor] CGColor];
[scrollView addSubview:self.callbackTextView];
self.connectCloseButton = [self createButtonWithTitle:@"Connect" frame:CGRectMake(20, 370, 300, 30)];
self.connectCloseButton.backgroundColor = [UIColor redColor];
[self.connectCloseButton addTarget:self action:@selector(connectCloseButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectCloseButton];
self.openButton = [self createButtonWithTitle:@"Open" frame:CGRectMake(20, 420, 300, 30)];
self.openButton.backgroundColor = [UIColor redColor];
[self.openButton addTarget:self action:@selector(openButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.openButton];
self.connectshowPrinterInfoTestButton = [self createButtonWithTitle:@"showPrinterInfoTest" frame:CGRectMake(20, 460, 300, 30)];
self.connectshowPrinterInfoTestButton.backgroundColor = [UIColor redColor];
[self.connectshowPrinterInfoTestButton addTarget:self action:@selector(showPrinterInfoTestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectshowPrinterInfoTestButton];
self.connectOdvMonitorTestButton = [self createButtonWithTitle:@"OdvMonitorTest" frame:CGRectMake(20, 500, 300, 30)];
self.connectOdvMonitorTestButton.backgroundColor = [UIColor redColor];
[self.connectOdvMonitorTestButton addTarget:self action:@selector(odvMonitorTestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectOdvMonitorTestButton];
self.connectPrintTestButton = [self createButtonWithTitle:@"PrinterTest" frame:CGRectMake(20, 535, 300, 30)];
self.connectPrintTestButton.backgroundColor = [UIColor redColor];
[self.connectPrintTestButton addTarget:self action:@selector(connectPrintTestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:self.connectPrintTestButton];
}
- (UIButton *)createButtonWithTitle:(NSString *)title frame:(CGRect)frame {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = frame;
[button setTitle:title forState:UIControlStateNormal];
return button;
}
- (void)openButtonPressed {
[self.tcpComm open];
}
- (void)connectCloseButtonPressed {
NSString *currentTitle = [self.connectCloseButton titleForState:UIControlStateNormal];
if ([currentTitle isEqualToString:@"Connect"]) {
NSString *ipAddress = self.ipTextField.text;
self.tcpComm = [[
TcpComm alloc] initWithIPAddress:ipAddress port:3007];
[self.connectCloseButton setTitle:@"Close" forState:UIControlStateNormal];
} else if ([currentTitle isEqualToString:@"Close"]) {
[self.tcpComm close];
[self.connectCloseButton setTitle:@"Connect" forState:UIControlStateNormal];
}
}
- (void)showPrinterInfoTestButtonPressed {
NSMutableString *receivedString = [[NSMutableString alloc] init];
[receivedString appendString:@"======= ODV Printer Info: \n"];
[receivedString appendFormat:@"Printer Model: %@\n", printerInfo.model];
[receivedString appendFormat:@"Printer SN: %@\n", printerInfo.serialNumber];
[receivedString appendFormat:@"Printer FW PN: %@\n", printerInfo.firmwarePartNumber];
[receivedString appendFormat:@"Printer FW Ver: %@\n", printerInfo.firmwareVersion];
[receivedString appendFormat:@"Printhead Resolution (Dots/Inch): %@\n", printerInfo.printheadResolution];
[receivedString appendFormat:@"Has ODV: %@\n", printerInfo.hasOdvOption ? @"Yes" : @"No"];
NSLog(@"%@", receivedString);
self.resultTextView.text = receivedString;
}
- (void)odvMonitorTestButtonPressed {
NSMutableString *receivedString = [[NSMutableString alloc] init];
if ([report failed]) {
[receivedString appendFormat:@"\nBarcode Failed."];
} else {
[receivedString appendFormat:@"\nBarcode Passed."];
[receivedString appendFormat:@"Grade: %f", [report overallGradeAsFloat]];
if ([report overallGradeAsFloat] > 3.5) {
[receivedString appendFormat:@"Print Quality passed. \n Overall Grade= %.2f", [report overallGradeAsFloat]];
} else {
[receivedString appendFormat:@"Print Quality Failed. \n Overall Grade= %.2f", [report overallGradeAsFloat]];
}
[receivedString appendFormat:@"Barcode Symbology: %@", [report symbology]];
[receivedString appendFormat:@"Barcode Data: %@", [report data]];
dispatch_async(dispatch_get_main_queue(), ^{
self.callbackTextView.text = receivedString;
});
}
};
}
- (void)connectPrintTestButtonPressed {
NSString *ipAddress = self.ipTextField.text;
TcpComm *tcpComm2 = [[
TcpComm alloc] initWithIPAddress:ipAddress port:DEFAULT_DATA_PORT];
[tcpComm2
sendPrintFile:ipAddress
fileName:@"/Users/realbuber/Documents/doc/TestOdvMonitor/DM_PRINTRONIX_1.pgl"];
NSLog(@"Sending ODV print job...");
}
@end
Provide support for ODV related services. Module to facilitate listening/retrieval of printer unsolic...
Definition OdvMonitor.h:54
OdvReportCallback odvReportCallback
Holds the function to call when ODV reports are received. Function must match the signature of OdvRep...
Definition OdvMonitor.h:267
void SetOdvReportListening:(BOOL value)
Sets whether ODV report listening is enabled.
ODV Report class to show ODV/ODV2D data received from printer.
Definition OdvReport.h:33
Swift:
Printer Monitor:
import SwiftUI
import UniPRT
struct ContentView: View {
@State private var ipText = "10.0.10.170"
@State private var inputText = ""
@StateObject private var viewModel = CommunicationViewModel()
var body: some View {
NavigationView {
Form {
Section(header: Text("IP Address")) {
TextField("Enter IP Address", text: $ipText)
.keyboardType(.decimalPad)
}
Section(header: Text("Output")) {
ScrollView {
Text(viewModel.resultText)
.frame(maxWidth: .infinity, alignment: .leading)
.fixedSize(horizontal: false, vertical: true)
.font(.system(size: 8))
}
.frame(height: 300)
.border(Color.secondary, width: 1)
}
Button("Connect/Close") {
viewModel.connectCloseAction(ip: ipText)
}
Button("Open") {
viewModel.openAction()
}
Button("Get Printer Info") {
viewModel.fetchPrinterInfo()
}
Button("Test Printer Monitor") {
viewModel.printerListening()
}
Button("Send Print File") {
viewModel.printTest()
}
}
.navigationBarTitle("Communication")
}
}
}
@objcMembers class CommunicationViewModel: ObservableObject {
@Published var resultText = ""
var tcpComm: TcpComm?
func openAction() {
if tcpComm != nil {
tcpComm?.open()
DispatchQueue.main.async {
self.resultText = "TCP Connection opened"
}
} else {
DispatchQueue.main.async {
self.resultText = "No TCP Connection to open"
}
}
}
func fetchPrinterInfo() {
guard let tcpComm = tcpComm else {
DispatchQueue.main.async {
self.resultText = "No TCP Connection"
}
return
}
let printerMonitor = PrinterMonitor(tcpComm: tcpComm)
let printerInfo = printerMonitor?.getPrinterInfo()
DispatchQueue.main.async {
self.resultText = "======= RFID Printer Info: \n"
self.resultText += "Printer Model: \(String(describing: printerInfo?.model))\n"
self.resultText += "Printer SN: \(String(describing: printerInfo?.serialNumber))\n"
self.resultText += "Printer FW PN: \(String(describing: printerInfo?.firmwarePartNumber))\n"
self.resultText += "Printer FW Ver: \(String(describing: printerInfo?.firmwareVersion))\n"
self.resultText += "Printhead Resolution (Dots/Inch): \(String(describing: printerInfo?.printheadResolution))\n"
self.resultText += "Has RFID: \((printerInfo?.hasRfidOption != nil) ? "Yes" : "No")\n"
}
}
func connectCloseAction(ip: String) {
if tcpComm != nil {
tcpComm?.close()
tcpComm = nil
DispatchQueue.main.async {
self.resultText = "TCP Connection closed"
}
} else {
tcpComm = TcpComm(ipAddress: ip, port: 3007)
DispatchQueue.main.async {
self.resultText = "TCP Connected to \(ip)"
}
}
}
func printerListening() {
guard let tcpComm = tcpComm else {
DispatchQueue.main.async {
self.resultText = "No TCP Connection"
}
return
}
let printerMonitor = PrinterMonitor(tcpComm: tcpComm)
// Engine Status Update Callback
printerMonitor?.engineStatusCallback = { status in
DispatchQueue.main.async {
self.resultText += "Engine status update: \(String(describing: status))\n"
}
}
printerMonitor?.setEngineStatusListening(true)
// Display Status Update Callback
printerMonitor?.displayStatusCallback = { status in
DispatchQueue.main.async {
let statusString = (status ?? ["Unknown"]).compactMap { $0 }.joined(separator: ", ")
self.resultText += "Display status update: \(statusString)\n"
}
}
printerMonitor?.setDisplayStatusListening(true)
// Alert Status Update Callback
printerMonitor?.alertStatusCallback = { status in
DispatchQueue.main.async {
let statusString = (status ?? ["Unknown"]).compactMap { $0 }.joined(separator: ", ")
self.resultText += "Alert status update: \(statusString)\n"
}
}
printerMonitor?.setAlertStatusListening(true)
}
func printTest() {
let tcpComm2 = TcpComm(ipAddress: "10.0.10.170", port: 9100)
tcpComm2?.sendPrintFile("10.0.10.170", fileName: "/Users/realbuber/Documents/Objective-C IOS SDK example/Swift/TestPrinterMonitor/Hello_1.pgl")
}
}
#Preview {
ContentView()
}
Rfid Monitor:
import SwiftUI
import UniPRT
struct ContentView: View {
@State private var ipText = "10.0.10.178"
@StateObject private var viewModel = CommunicationViewModel()
var body: some View {
NavigationView {
Form {
Section(header: Text("IP Address")) {
TextField("Enter IP Address", text: $ipText)
.keyboardType(.decimalPad)
}
Section(header: Text("Output")) {
ScrollView {
Text(viewModel.resultText)
.frame(maxWidth: .infinity, alignment: .leading)
.fixedSize(horizontal: false, vertical: true)
.font(.system(size: 8))
}
.frame(height: 300)
.border(Color.secondary, width: 1)
}
Button("Connect/Close") {
viewModel.connectCloseAction(ip: ipText)
}
Button("Open") {
viewModel.openAction()
}
Button("Get Printer Info") {
viewModel.fetchPrinterInfo()
}
Button("Test RFID Monitor") {
viewModel.rfidListening()
}
Button("Send Print File") {
viewModel.printTest()
}
}
.navigationBarTitle("Communication")
}
}
}
@objcMembers class CommunicationViewModel: ObservableObject {
@Published var resultText = ""
var tcpComm: TcpComm?
func openAction() {
if tcpComm != nil {
tcpComm?.open()
DispatchQueue.main.async {
self.resultText = "TCP Connection opened"
}
} else {
DispatchQueue.main.async {
self.resultText = "No TCP Connection to open"
}
}
}
func fetchPrinterInfo() {
guard let tcpComm = tcpComm else {
DispatchQueue.main.async {
self.resultText = "No TCP Connection"
}
return
}
let printerMonitor = PrinterMonitor(tcpComm: tcpComm)
let printerInfo = printerMonitor?.getPrinterInfo()
DispatchQueue.main.async {
self.resultText = "======= RFID Printer Info: \n"
self.resultText += "Printer Model: \(String(describing: printerInfo?.model))\n"
self.resultText += "Printer SN: \(String(describing: printerInfo?.serialNumber))\n"
self.resultText += "Printer FW PN: \(String(describing: printerInfo?.firmwarePartNumber))\n"
self.resultText += "Printer FW Ver: \(String(describing: printerInfo?.firmwareVersion))\n"
self.resultText += "Printhead Resolution (Dots/Inch): \(String(describing: printerInfo?.printheadResolution))\n"
self.resultText += "Has RFID: \((printerInfo?.hasRfidOption != nil) ? "Yes" : "No")\n"
}
}
func connectCloseAction(ip: String) {
if tcpComm != nil {
tcpComm?.close()
tcpComm = nil
DispatchQueue.main.async {
self.resultText = "TCP Connection closed"
}
} else {
tcpComm = TcpComm(ipAddress: ip, port: 3007)
DispatchQueue.main.async {
self.resultText = "TCP Connected to \(ip)"
}
}
}
func rfidListening() {
guard let tcpComm = tcpComm else {
DispatchQueue.main.async {
self.resultText = "No TCP Connection"
}
return
}
let rfidMonitor = RfidMonitor(tcpComm: tcpComm)
rfidMonitor?.rfidReportCallback = { report in
DispatchQueue.main.async {
if report?.failed() == true {
self.resultText = "RFID Failed."
} else {
self.resultText += "RFID Passed. Write Action: \((report?.isWriteOperation() == true) ? "Yes" : "No"), Data: \n\(String(describing: report?.data()))"
}
}
}
rfidMonitor?.setRfidReportListening(true)
}
func printTest() {
let tcpComm2 = TcpComm(ipAddress: "10.0.10.170", port: 9100)
tcpComm2?.sendPrintFile("10.0.10.170", fileName: "/Users/realbuber/Documents/Objective-C IOS SDK example/Swift/TestRfidMonitor/rfid.pgl")
}
}
#Preview {
ContentView()
}
Odv Monitor:
import SwiftUI
import UniPRT
struct ContentView: View {
@State private var ipText = "10.0.10.170"
@State private var communicationType = 0 // 0 for TCP
@StateObject private var viewModel = CommunicationViewModel()
var body: some View {
NavigationView {
Form {
Section(header: Text("Connection Type")) {
Picker("Select Type", selection: $communicationType) {
Text("TCP").tag(0)
}
.pickerStyle(SegmentedPickerStyle())
}
Section(header: Text("IP Address")) {
TextField("Enter IP Address", text: $ipText)
.keyboardType(.decimalPad)
}
Section(header: Text("Output")) {
ScrollView {
Text(viewModel.resultText)
.frame(maxWidth: .infinity, alignment: .leading)
.fixedSize(horizontal: false, vertical: true)
.font(.system(size: 8))
}
.frame(height: 300)
.border(Color.secondary, width: 1)
}
Button("Connect/Close") {
viewModel.connectCloseAction(communicationType: communicationType, ip: ipText)
}
Button("Open") {
viewModel.openAction(communicationType: communicationType)
}
Button("Get Printer Info") {
viewModel.fetchPrinterInfo()
}
Button("Test ODV Monitor") {
viewModel.odvListening()
}
Button("Send Print File") {
viewModel.printTest()
}
}
.navigationBarTitle("Communication")
}
}
}
@objcMembers class CommunicationViewModel: ObservableObject {
@Published var resultText = ""
var tcpComm: TcpComm?
func openAction(communicationType: Int) {
self.resultText = "open error"
tcpComm?.open()
self.resultText = "TCP Connection opened"
}
func fetchPrinterInfo() {
let printerMonitor = PrinterMonitor(tcpComm: self.tcpComm)
let printerInfo = printerMonitor?.getPrinterInfo()
DispatchQueue.main.async {
self.resultText = "======= RFID Printer Info: \n"
self.resultText += "Printer Model: \(String(describing: printerInfo?.model))\n"
self.resultText += "Printer SN: \(String(describing: printerInfo?.serialNumber))\n"
self.resultText += "Printer FW PN: \(String(describing: printerInfo?.firmwarePartNumber))\n"
self.resultText += "Printer FW Ver: \(String(describing: printerInfo?.firmwareVersion))\n"
self.resultText += "Printhead Resolution (Dots/Inch): \(String(describing: printerInfo?.printheadResolution))\n"
self.resultText += "Has ODV: \((printerInfo?.hasOdvOption != nil) ? "Yes" : "No")\n"
}
}
func connectCloseAction(communicationType: Int, ip: String) {
if tcpComm != nil {
tcpComm?.close()
tcpComm = nil
self.resultText = "TCP Connection closed"
} else {
// Reconnect logic
tcpComm = TcpComm(ipAddress: ip, port: 3007)
self.resultText = "TCP Reconnected"
}
}
func odvListening() {
let odvMonitor = OdvMonitor(tcpComm: tcpComm)
odvMonitor?.odvReportCallback = { [weak self] report in
DispatchQueue.main.async {
var receivedString = NSMutableString()
if (report?.failed() == true) {
receivedString.append("\nBarcode Failed.")
} else {
receivedString.append("\nBarcode Passed.")
receivedString.appendFormat("Grade: %.2f", (report?.overallGradeAsFloat())!)
if report!.overallGradeAsFloat() > 3.5 {
receivedString.appendFormat("Print Quality passed. \n Overall Grade= %.2f", report!.overallGradeAsFloat())
} else {
receivedString.appendFormat("Print Quality Failed. \n Overall Grade= %.2f", report!.overallGradeAsFloat())
}
receivedString.appendFormat("Barcode Symbology: %@", report!.symbology())
receivedString.appendFormat("Barcode Data: %@", report!.data())
self?.resultText = receivedString as String
}
}
}
odvMonitor?.setOdvReportListening(true)
}
func printTest() {
let tcpComm2 = TcpComm(ipAddress: "10.0.10.178", port: 9100)
tcpComm2?.sendPrintFile("10.0.10.178", fileName: "/Users/realbuber/Documents/doc/TestOdvMonitor/DM_PRINTRONIX_1.pgl")
}
}
#Preview {
ContentView()
}