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

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

  • 宣言

    public enum StarIoExtManagerType : Int {
        case standard
        case withBarcodeReader
        case onlyBarcodeReader
    }
    
  • 定数

    名称

    説明

    standard

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

    withBarcodeReader

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

    onlyBarcodeReader

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

4.8.2. StarIoExtManagerPrinterStatus

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

  • 宣言

    public enum StarIoExtManagerPrinterStatus : Int {
        case invalid
        case impossible
        case online
        case offline
    }
    
  • 定数

    名称

    説明

    invalid

    不定

    impossible

    プリンター使用不能

    online

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

    offline

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

4.8.3. StarIoExtManagerPrinterPaperStatus

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

  • 宣言

    public enum StarIoExtManagerPrinterPaperStatus : Int {
        case invalid
        case impossible
        case ready
        case nearEmpty
        case empty
    }
    
  • 定数

    名称

    説明

    invalid

    不定

    impossible

    プリンター使用不能

    ready

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

    nearEmpty

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

    empty

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

4.8.4. StarIoExtManagerPrinterCoverStatus

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

  • 宣言

    public enum StarIoExtManagerPrinterCoverStatus : Int {
        case invalid
        case impossible
        case open
        case close
    }
    
  • 定数

    名称

    説明

    invalid

    不定

    impossible

    プリンター使用不能

    open

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

    close

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

4.8.5. StarIoExtManagerCashDrawerStatus

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

  • 宣言

    public enum StarIoExtManagerCashDrawerStatus : Int {
        case invalid
        case impossible
        case open
        case close
    }
    
  • 定数

    名称

    説明

    invalid

    不定

    impossible

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

    open

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

    close

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

4.8.6. StarIoExtManagerBarcodeReaderStatus

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

  • 宣言

    public enum StarIoExtManagerBarcodeReaderStatus : Int {
        case invalid
        case impossible
        case connect
        case disconnect
    }
    
  • 定数

    名称

    説明

    invalid

    不定

    impossible

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

    connect

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

    disconnect

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

4.8.7. port

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

  • 宣言

    open var port: UnsafeMutablePointer<Int32>! { get }
    

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 クラスはプリンター状態の監視を再開します。

  • 宣言

    open var lock: NSRecursiveLock! { get }
    

4.8.9. delegate

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

  • 宣言

    weak open var delegate: StarIoExtManagerDelegate!
    

4.8.10. printerStatus

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

  • 宣言

    open var printerStatus: StarIoExtManagerPrinterStatus { get }
    

4.8.11. printerPaperStatus

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

  • 宣言

    open var printerPaperStatus: StarIoExtManagerPrinterPaperStatus { get }
    

4.8.12. printerCoverStatus

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

  • 宣言

    open var printerCoverStatus: StarIoExtManagerPrinterCoverStatus { get }
    

4.8.13. cashDrawerStatus

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

  • 宣言

    open var cashDrawerStatus: StarIoExtManagerCashDrawerStatus { get }
    

4.8.14. barcodeReaderStatus

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

  • 宣言

    open var barcodeReaderStatus: StarIoExtManagerBarcodeReaderStatus { get }
    

4.8.15. cashDrawerOpenActiveHigh

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

true はHighアクティブ、 false はLowアクティブを示します。

  • 宣言

    open var cashDrawerOpenActiveHigh: Bool
    

4.8.16. initWithType

StarIoExtManager を初期化します。

  • 宣言

    public init!(type: StarIoExtManagerType, portName: String!, portSettings: String!, ioTimeoutMillis: UInt)
    
  • 引数

    名称

    説明

    type

    マネージャタイプ

    StarIoExtManagerType

    portName

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

    String

    portSettings

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

    String

    ioTimeoutMillis

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

    UInt

  • 戻り値

    説明

    StarIoExtManager オブジェクト

    StarIoExtManager

4.8.17. connectAsync

added in version 1.11.0

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

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

  • 宣言

    open func connectAsync()
    
  • 引数

    なし

  • 戻り値

    なし

4.8.18. connect

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

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

  • 宣言

    open func connect() -> Bool
    
  • 引数

    なし

  • 戻り値

    説明

    結果
    true ... 成功
    false ... 失敗

    Bool

4.8.19. disconnect

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

  • 宣言

    open func disconnect() -> Bool
    
  • 引数

    なし

  • 戻り値

    説明

    結果
    true ... 成功
    false ... 失敗

    Bool