4.8. StarIoExtManager
Always connect to the printer. Provides a real-time status acquisition function.
Constant
Name
Contents
Manager type constants
Printer status constants
Printer paper status constants
Printer cover status constants
Cash drawer status constants
Barcode reader status constants
Constructor
Name
Contents
Initializes the StarIoManager object.
Property
Name
Contents
Gets the SMPort object.
Exclusive access control object of communication by port property.
Delegate of the StarIoExtManager.
Printer status.
Printer paper status.
Printer cover status.
Cash drawer status.
Barcode reader status.
Mode of cash drawer open sensor active.
Method
Name
Contents
Management start.
Management start.
Management stop.
Important
Please use SM-S and SM-T series in Auto Power Down function “NO USE” setting (Default setting).
Warning
Only one instance should be used for a single printer.
When using an instance of this class from multiple threads, please use exclusive control.
4.8.1. StarIoExtManagerType
Manager type constants.
Declaration
typedef NS_ENUM(NSUInteger, StarIoExtManagerType) { StarIoExtManagerTypeStandard = 0, StarIoExtManagerTypeWithBarcodeReader, StarIoExtManagerTypeOnlyBarcodeReader };
Constants
Name
Contents
StarIoExtManagerTypeStandard
Management of the printer and the cash drawer.
StarIoExtManagerTypeWithBarcodeReader
Management of the printer, cash drawer and the barcode reader.
StarIoExtManagerTypeOnlyBarcodeReader
Management of the barcode reader.
4.8.2. StarIoExtManagerPrinterStatus
Printer status constants.
Declaration
typedef NS_ENUM(NSInteger, StarIoExtManagerPrinterStatus) { StarIoExtManagerPrinterStatusInvalid = 0, StarIoExtManagerPrinterStatusImpossible, StarIoExtManagerPrinterStatusOnline, StarIoExtManagerPrinterStatusOffline };
Constants
Name
Contents
StarIoExtManagerPrinterStatusInvalid
Invalid.
StarIoExtManagerPrinterStatusImpossible
Impossible to use printer.
StarIoExtManagerPrinterStatusPrinterOnline
Detect Printer online.
StarIoExtManagerPrinterStatusPrinterOffline
Detect Printer offline.
4.8.3. StarIoExtManagerPrinterPaperStatus
Printer paper status constants.
Declaration
typedef NS_ENUM(NSInteger, StarIoExtManagerPrinterPaperStatus) { StarIoExtManagerPrinterPaperStatusInvalid = 0, StarIoExtManagerPrinterPaperStatusImpossible, StarIoExtManagerPrinterPaperStatusReady, StarIoExtManagerPrinterPaperStatusNearEmpty, StarIoExtManagerPrinterPaperStatusEmpty };
Constants
Name
Contents
StarIoExtManagerPrinterPaperStatusInvalid
Invalid.
StarIoExtManagerPrinterPaperStatusImpossible
Impossible to use printer.
StarIoExtManagerPrinterPaperStatusReady
Detect Printer paper ready.
StarIoExtManagerPrinterPaperStatusNearEmpty
Detect Printer paper near end.
StarIoExtManagerPrinterPaperStatusEmpty
Detect Printer paper empty.
4.8.4. StarIoExtManagerPrinterCoverStatus
Printer cover status constants.
Declaration
typedef NS_ENUM(NSInteger, StarIoExtManagerPrinterCoverStatus) { StarIoExtManagerPrinterCoverStatusInvalid = 0, StarIoExtManagerPrinterCoverStatusImpossible, StarIoExtManagerPrinterCoverStatusOpen, StarIoExtManagerPrinterCoverStatusClose };
Constants
Name
Contents
StarIoExtManagerPrinterCoverStatusInvalid
Invalid.
StarIoExtManagerPrinterCoverStatusImpossible
Impossible to use printer.
StarIoExtManagerPrinterCoverStatusOpen
Detect Printer cover open.
StarIoExtManagerPrinterCoverStatusClose
Detect Printer cover close.
4.8.5. StarIoExtManagerCashDrawerStatus
Cash drawer status constants.
Declaration
typedef NS_ENUM(NSInteger, StarIoExtManagerCashDrawerStatus) { StarIoExtManagerCashDrawerStatusInvalid = 0, StarIoExtManagerCashDrawerStatusImpossible, StarIoExtManagerCashDrawerStatusOpen, StarIoExtManagerCashDrawerStatusClose };
Constants
Name
Contents
StarIoExtManagerCashDrawerStatusInvalid
Invalid.
StarIoExtManagerCashDrawerStatusImpossible
Impossible to use Cash drawer.
StarIoExtManagerCashDrawerStatusOpen
Detect Cash drawer open.
StarIoExtManagerCashDrawerStatusClose
Detect Cash drawer close.
4.8.6. StarIoExtManagerBarcodeReaderStatus
Barcode reader status constants.
Declaration
typedef NS_ENUM(NSInteger, StarIoExtManagerBarcodeReaderStatus) { StarIoExtManagerBarcodeReaderStatusInvalid = 0, StarIoExtManagerBarcodeReaderStatusImpossible, StarIoExtManagerBarcodeReaderStatusConnect, StarIoExtManagerBarcodeReaderStatusDisconnect };
Constants
Name
Contents
StarIoExtManagerBarcodeReaderStatusInvalid
Invalid.
StarIoExtManagerBarcodeReaderStatusImpossible
Impossible to use Barcode reader.
StarIoExtManagerBarcodeReaderStatusConnect
Detect Barcode reader connection.
StarIoExtManagerBarcodeReaderStatusDisconnect
Detect Barcode reader disconnection.
4.8.7. port
SMPort object.
Declaration
@property (readonly, nonatomic) SMPort *port;
4.8.8. lock
Exclusive access control object of communication by port property.
By using the lock property, an application can acquire a right to use the port property of StarIoExtManager class.
StarIoExtManager class starts monitoring printer status automatically after connect method is successfully complete.The printer status monitoring process uses the port property of StarIoExtManager class to communicate with a printer.If an application executes method of the port property during monitoring, the port property is used by two at the same time and method of the port property cannot work properly.
When an application executes lock() method of the lock property, StarIoExtManager class stops monitoring printer status, and the application regains a right to use the port property from StarIoExtManager class. As a result, the application can execute method of the port property properly.
After an application finishes using method of the port property, execute unlock() method of the lock property.StarIoExtManager class regains a right to use the port property from the application and resumes monitoring printer status.
Declaration
@property (readonly, nonatomic) NSRecursiveLock *lock;
Examples
- (IBAction)touchUpInsidePrintButton:(id)sender { ... [_starIoExtManager.lock lock]; [Communication sendCommands:commands port:[_starIoExtManager port]]; [_starIoExtManager.lock unlock]; ... }
Refer to PrinterExtViewController.m, CashDrawerExtViewController.m and CombinationExtViewController.m.
4.8.9. delegate
Delegate of the StarIoExtManager .
Declaration
@property (weak, nonatomic) id<StarIoExtManagerDelegate> delegate;
Examples
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. _starIoExtManager = [[StarIoExtManager alloc] initWithType:StarIoExtManagerTypeOnlyBarcodeReader portName:[AppDelegate getPortName] portSettings:[AppDelegate getPortSettings] ioTimeoutMillis:10000]; // 10000mS!!! _starIoExtManager.delegate = self; }
Refer to PrinterExtViewController.m, CashDrawerExtViewController.m, BarcodeReaderExtViewController.m and CombinationExtViewController.m.
4.8.10. printerStatus
Printer Online status.
Declaration
@property (readonly, nonatomic) StarIoExtManagerPrinterStatus printerStatus;
4.8.11. printerPaperStatus
Printer paper status.
Declaration
@property (readonly, nonatomic) StarIoExtManagerPrinterPaperStatus printerPaperStatus;
4.8.12. printerCoverStatus
Printer cover status.
Declaration
@property (readonly, nonatomic) StarIoExtManagerPrinterCoverStatus printerCoverStatus;
4.8.13. cashDrawerStatus
Gets the cash drawer status.
Declaration
@property (readonly, nonatomic) StarIoExtManagerCashDrawerStatus cashDrawerStatus;
4.8.14. barcodeReaderStatus
Barcode reader status.
Declaration
@property (readonly, nonatomic) StarIoExtManagerBarcodeReaderStatus barcodeReaderStatus;
4.8.15. cashDrawerOpenActiveHigh
Mode of cash drawer open sensor active.
YES … Active high. NO … Active low.
Declaration
@property (nonatomic) BOOL cashDrawerOpenActiveHigh;
4.8.16. initWithType
Initializes the StarIoExtManager .
Declaration
- (id)initWithType:(StarIoExtManagerType)type portName:(NSString *)portName portSettings:(NSString *)portSettings ioTimeoutMillis:(NSUInteger)ioTimeoutMillis;
Parameter
Name
Contents
Type
type
Manager type
portName
It is the same as the portName of the getPort method.
NSString *
portSettings
It is the same as the portSetting of the getPort method.
NSString *
ioTimeoutMillis
Acquires and specifies the timeout time for internal control and API (unit: millisecond)
NSUInteger
Return value
Contents
Type
StarIoExtManager object
Examples
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. _starIoExtManager = [[StarIoExtManager alloc] initWithType:StarIoExtManagerTypeStandard portName:[AppDelegate getPortName] portSettings:[AppDelegate getPortSettings] ioTimeoutMillis:10000]; // 10000mS!!! _starIoExtManager.delegate = self; }
Refer to PrinterExtViewController.m, CashDrawerExtViewController.m, BarcodeReaderExtViewController.m and CombinationExtViewController.m.
4.8.17. connectAsync
added in version 1.11.0
Management start.
This method is executed asynchronously, and the connection result is sent to the object that was set in the delegate property. If the connection with the printer was successful, the didConnectPort method is called. If the connection failed, the didFailToConnectPort method is called.
Declaration
- (void)connectAsync;
Parameter
None
Return value
None
Examples
- (void)refreshPrinter { self.blind = YES; [self.starIoExtManager disconnect]; [self.starIoExtManager connectAsync]; }
Refer to PrinterExtWithConnectAsyncViewController.m.
4.8.18. connect
Management start.
This method is executed synchronously.
Declaration
- (BOOL)connect;
Parameter
None
Return value
Contents
Type
ResultYES … SuccessNO … FailureBOOL
Examples
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if (_starIoExtManager.port != nil) { [_starIoExtManager disconnect]; } if ([_starIoExtManager connect] == NO) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Fail to Open Port." message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } }
Refer to PrinterExtViewController.m, CashDrawerExtViewController.m, BarcodeReaderExtViewController.m and CombinationExtViewController.m.
4.8.19. disconnect
Management stop.
Declaration
- (BOOL)disconnect;
Parameter
None
Return value
Contents
Type
ResultYES … SuccessNO … FailureBOOL
Examples
- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [_starIoExtManager disconnect]; }
Refer to PrinterExtViewController.m, CashDrawerExtViewController.m, BarcodeReaderExtViewController.m and CombinationExtViewController.m.