4.8. StarIoExtManager

プリンターと常時接続を行うことで、リアルタイムな状態取得機能を提供します。

  • プロパティ

    名称

    説明

    port

    SMPort オブジェクトを示します。

    lock

    portプロパティによる通信権利の排他制御オブジェクトを示します。

    delegate

    StarIoExtManagerのデリゲートオブジェクトを示します。

    printerStatus

    プリンターステータスを示します。

    printerPaperStatus

    プリンター用紙ステータスを示します。

    printerCoverStatus

    プリンターカバーステータスを示します。

    cashDrawerStatus

    キャッシュドロアーステータスを示します。

    barcodeReaderStatus

    バーコードリーダーステータスを示します。

    cashDrawerOpenActiveHigh

    キャッシュドロアー開閉センサーのモードを示します。

  • メソッド

    名称

    説明

    connectAsync

    マネージメントを開始します。

    connect

    マネージメントを開始します。

    disconnect

    マネージメントを停止します。

重要

SM-Sシリーズ、SM-Tシリーズでは、自動パワーダウンモードを"NO USE"(工場出荷時設定)に設定してください。

警告

  • 一台のプリンターに対して、一つのインスタンスのみ使用してください。

  • 本クラスの1つのインスタンスを複数スレッドから使用する場合は、排他制御を行ってください。

4.8.1. StarIoExtManagerType

マネージャタイプ定数です。

  • 宣言

    typedef NS_ENUM(NSUInteger, StarIoExtManagerType) {
        StarIoExtManagerTypeStandard = 0,
        StarIoExtManagerTypeWithBarcodeReader,
        StarIoExtManagerTypeOnlyBarcodeReader
    };
    
  • 定数

    名称

    説明

    StarIoExtManagerTypeStandard

    プリンター、キャッシュドロワのマネージメント

    StarIoExtManagerTypeWithBarcodeReader

    プリンター、キャッシュドロワ、バーコードリーダーのマネージメント

    StarIoExtManagerTypeOnlyBarcodeReader

    バーコードリーダーのマネージメント

4.8.2. StarIoExtManagerPrinterStatus

プリンターステータス定数です。

  • 宣言

    typedef NS_ENUM(NSInteger, StarIoExtManagerPrinterStatus) {
        StarIoExtManagerPrinterStatusInvalid = 0,
        StarIoExtManagerPrinterStatusImpossible,
        StarIoExtManagerPrinterStatusOnline,
        StarIoExtManagerPrinterStatusOffline
    };
    
  • 定数

    名称

    説明

    StarIoExtManagerPrinterStatusInvalid

    不定

    StarIoExtManagerPrinterStatusImpossible

    プリンター使用不能

    StarIoExtManagerPrinterStatusPrinterOnline

    プリンターオンライン検出

    StarIoExtManagerPrinterStatusPrinterOffline

    プリンターオフライン検出

4.8.3. StarIoExtManagerPrinterPaperStatus

プリンター用紙ステータス定数です。

  • 宣言

    typedef NS_ENUM(NSInteger, StarIoExtManagerPrinterPaperStatus) {
        StarIoExtManagerPrinterPaperStatusInvalid = 0,
        StarIoExtManagerPrinterPaperStatusImpossible,
        StarIoExtManagerPrinterPaperStatusReady,
        StarIoExtManagerPrinterPaperStatusNearEmpty,
        StarIoExtManagerPrinterPaperStatusEmpty
    };
    
  • 定数

    名称

    説明

    StarIoExtManagerPrinterPaperStatusInvalid

    不定

    StarIoExtManagerPrinterPaperStatusImpossible

    プリンター使用不能

    StarIoExtManagerPrinterPaperStatusReady

    プリンター用紙レディ検出

    StarIoExtManagerPrinterPaperStatusNearEmpty

    プリンター用紙ニアエンド検出

    StarIoExtManagerPrinterPaperStatusEmpty

    プリンター用紙エンプティ検出

4.8.4. StarIoExtManagerPrinterCoverStatus

プリンターカバーステータス定数です。

  • 宣言

    typedef NS_ENUM(NSInteger, StarIoExtManagerPrinterCoverStatus) {
        StarIoExtManagerPrinterCoverStatusInvalid = 0,
        StarIoExtManagerPrinterCoverStatusImpossible,
        StarIoExtManagerPrinterCoverStatusOpen,
        StarIoExtManagerPrinterCoverStatusClose
    };
    
  • 定数

    名称

    説明

    StarIoExtManagerPrinterCoverStatusInvalid

    不定

    StarIoExtManagerPrinterCoverStatusImpossible

    プリンター使用不能

    StarIoExtManagerPrinterCoverStatusOpen

    プリンターカバーオープン検出

    StarIoExtManagerPrinterCoverStatusClose

    プリンターカバークローズ検出

4.8.5. StarIoExtManagerCashDrawerStatus

キャッシュドロアーステータス定数です。

  • 宣言

    typedef NS_ENUM(NSInteger, StarIoExtManagerCashDrawerStatus) {
        StarIoExtManagerCashDrawerStatusInvalid = 0,
        StarIoExtManagerCashDrawerStatusImpossible,
        StarIoExtManagerCashDrawerStatusOpen,
        StarIoExtManagerCashDrawerStatusClose
    };
    
  • 定数

    名称

    説明

    StarIoExtManagerCashDrawerStatusInvalid

    不定

    StarIoExtManagerCashDrawerStatusImpossible

    キャッシュドロアー使用不能

    StarIoExtManagerCashDrawerStatusOpen

    キャッシュドロアーオープン検出

    StarIoExtManagerCashDrawerStatusClose

    キャッシュドロアークローズ検出

4.8.6. StarIoExtManagerBarcodeReaderStatus

バーコードリーダーステータス定数です。

  • 宣言

    typedef NS_ENUM(NSInteger, StarIoExtManagerBarcodeReaderStatus) {
        StarIoExtManagerBarcodeReaderStatusInvalid = 0,
        StarIoExtManagerBarcodeReaderStatusImpossible,
        StarIoExtManagerBarcodeReaderStatusConnect,
        StarIoExtManagerBarcodeReaderStatusDisconnect
    };
    
  • 定数

    名称

    説明

    StarIoExtManagerBarcodeReaderStatusInvalid

    不定

    StarIoExtManagerBarcodeReaderStatusImpossible

    バーコードリーダー使用不能

    StarIoExtManagerBarcodeReaderStatusConnect

    バーコードリーダー接続検出

    StarIoExtManagerBarcodeReaderStatusDisconnect

    バーコードリーダー切断検出

4.8.7. port

SMPort オブジェクトを示します。

  • 宣言

    @property (readonly, nonatomic) SMPort *port;
    

4.8.8. lock

portプロパティによる通信権利の排他制御オブジェクト

lockプロパティを使用する事で、アプリはStarIoExtManagerクラスのportプロパティの使用権を獲得できます。

StarIoExtManagerクラスは、connectメソッド成功後に自動的にプリンター状態の監視を開始します。 プリンター状態の監視処理は、プリンターとの通信にStarIoExtManagerクラスのportプロパティを使用します。 上記の監視中にアプリがportプロパティのメソッドを実行すると、portプロパティは同時に二カ所から利用される事になり、portプロパティのメソッドは正常に動作しません。

アプリがlockプロパティのlockメソッドを実行すると、StarIoExtManagerクラスはプリンター状態の監視を停止し、アプリはStarIoExtManagerクラスからportプロパティの使用権を獲得します。 その結果、アプリはportプロパティのメソッドを正常に実行できるようになります。

アプリがportプロパティのメソッドを使い終わった後は、必ずlockプロパティのunlockメソッドを実行してください。 アプリからStarIoExtManagerクラスに portプロパティの使用権が戻り、StarIoExtManager クラスはプリンター状態の監視を再開します。

  • 宣言

    @property (readonly, nonatomic) NSRecursiveLock *lock;
    
  • 実装例

    - (IBAction)touchUpInsidePrintButton:(id)sender {
       ...
    
       [_starIoExtManager.lock lock];
    
       [Communication sendCommands:commands port:[_starIoExtManager port]];
    
       [_starIoExtManager.lock unlock];
    
       ...
    }
    

    PrinterExtViewController.m / CashDrawerExtViewController.m / CombinationExtViewController.m を参照ください。

4.8.9. delegate

StarIoExtManager のデリゲートオブジェクトです。

  • 宣言

    @property (weak, nonatomic) id<StarIoExtManagerDelegate> delegate;
    
  • 実装例

    - (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;
    }
    

    PrinterExtViewController.m / CashDrawerExtViewController.m / BarcodeReaderExtViewController.m / CombinationExtViewController.mを参照ください。

4.8.10. printerStatus

プリンターオンラインステータスを示します。

  • 宣言

    @property (readonly, nonatomic) StarIoExtManagerPrinterStatus printerStatus;
    

4.8.11. printerPaperStatus

プリンター用紙ステータスを示します。

  • 宣言

    @property (readonly, nonatomic) StarIoExtManagerPrinterPaperStatus printerPaperStatus;
    

4.8.12. printerCoverStatus

プリンターカバーステータスを示します。

  • 宣言

    @property (readonly, nonatomic) StarIoExtManagerPrinterCoverStatus printerCoverStatus;
    

4.8.13. cashDrawerStatus

キャッシュドロアーステータスを取得します。

  • 宣言

    @property (readonly, nonatomic) StarIoExtManagerCashDrawerStatus cashDrawerStatus;
    

4.8.14. barcodeReaderStatus

バーコードリーダーステータスを示します。

  • 宣言

    @property (readonly, nonatomic) StarIoExtManagerBarcodeReaderStatus barcodeReaderStatus;
    

4.8.15. cashDrawerOpenActiveHigh

キャッシュドロアー開閉センサのモードを示します。

YES はHighアクティブ、 NO はLowアクティブを示します。

  • 宣言

    @property (nonatomic) BOOL cashDrawerOpenActiveHigh;
    

4.8.16. initWithType

StarIoExtManager を初期化します。

  • 宣言

    - (id)initWithType:(StarIoExtManagerType)type portName:(NSString *)portName portSettings:(NSString *)portSettings ioTimeoutMillis:(NSUInteger)ioTimeoutMillis;
    
  • 引数

    名称

    説明

    type

    マネージャタイプ

    StarIoExtManagerType

    portName

    getPort メソッドのportNameと同じです。

    NSString *

    portSettings

    getPort メソッドのportSettingと同じです。

    NSString *

    ioTimeoutMillis

    内部制御およびAPIのタイムアウト値

    NSUInteger

  • 戻り値

    説明

    StarIoExtManager オブジェクト

    StarIoExtManager

  • 実装例

    - (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;
    }
    

    PrinterExtViewController.m / CashDrawerExtViewController.m / BarcodeReaderExtViewController.m / CombinationExtViewController.m を参照ください。

4.8.17. connectAsync

added in version 1.11.0

マネージメントを開始します。

本メソッドは非同期的に実行され、接続結果はdelegateプロパティにセットしたオブジェクトに通知されます。 プリンターとの接続に成功した場合はdidConnectPortメソッドが呼ばれ、失敗した場合はdidFailToConnectPortメソッドが呼ばれます。

  • 宣言

    - (void)connectAsync;
    
  • 引数

    なし

  • 戻り値

    なし

  • 実装例

    - (void)refreshPrinter {
        self.blind = YES;
    
        [self.starIoExtManager disconnect];
    
        [self.starIoExtManager connectAsync];
    }
    

    PrinterExtWithConnectAsyncViewController.m を参照ください。

4.8.18. connect

マネージメントを開始します。

本メソッドは同期的に実行されます。

  • 宣言

    - (BOOL)connect;
    
  • 引数

    なし

  • 戻り値

    説明

    結果
    YES ... 成功
    NO ... 失敗

    BOOL

  • 実装例

    - (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];
        }
    }
    

    PrinterExtViewController.m / CashDrawerExtViewController.m / BarcodeReaderExtViewController.m / CombinationExtViewController.m を参照ください。

4.8.19. disconnect

マネージメントを停止します。

  • 宣言

    - (BOOL)disconnect;
    
  • 引数

    なし

  • 戻り値

    説明

    結果
    YES ... 成功
    NO ... 失敗

    BOOL

  • 実装例

    - (void)viewWillDisappear:(BOOL)animated {
        [super viewWillDisappear:animated];
    
        [_starIoExtManager disconnect];
    }
    

    PrinterExtViewController.m / CashDrawerExtViewController.m / BarcodeReaderExtViewController.m / CombinationExtViewController.m を参照ください。