com.rscja.deviceapi.interfaces

## Interface IPrinter

- All Known Implementing Classes:
    Printer

      public interface IPrinter

  打印机操作类
  Printer operation type
  Author:
    Administrator

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearCache()` 立即清空打印缓存,清空打印机接收缓冲区和打印缓冲区 Clear up printing cache, clear printer receive zone and buffer zone
    `boolean` | `eraseFlash()`
    `boolean` | `eraseFW(long size)`
    `boolean` | `free()` 关闭打印机模块 Switch off printer module
    `int` | `getPrintCodePage()`
    `int` | `getPrinterType()`
    `java.lang.String` | `getVersion()`
    `boolean` | `init(int isUpgrade)` 打开打印机模块 Switch on printer module
    `boolean` | `initFW()`
    `boolean` | `initPrinterGpio(boolean isUpgrade)`
    `boolean` | `isPowerOn()`
    `boolean` | `openPrinterSerialPort(boolean isUpgrade)`
    `void` | `print(Bitmap bitmap)` 打印图片 print picture
    `void` | `print(Bitmap bitmap, int interval)` 打印图片 print picture
    `void` | `print(Bitmap bitmap, int mode, int interval)` 打印图片 print pciture
    `void` | `print(byte[] content)` 打印字符 print character
    `void` | `print(java.lang.String content)` 打印字符 printe character
    `void` | `print(java.lang.String barcodeData, Printer.BarcodeType barcodeType)` 打印条码 print barcode
    `void` | `print(java.lang.String content, java.lang.String charsetName)` 打印字符 print character
    `int` | `receiveData(byte[] outData)` 接收串口数据 receive serial port data
    `boolean` | `releasePrinterGpio()`
    `void` | `restoreDefault()` 参数还原默认值 parameter reset to default
    `int` | `sendAndReceiveData(byte[] sendData, byte[] outData)` 收发数据 sent/received data
    `int` | `sendData(byte[] sendData)` 发送数据到串口 send data to serial port
    `void` | `setBarcodeHeight(int height)` 设置一维条码的高度 Setup 1D barcode height
    `void` | `setBarcodeHRI(int position)` 设置一维条码可读字符（HRI）打印位置 setup 1D barcode readable character (HRI) print position
    `void` | `setBarcodeWidth(int width)` 设置一维条码的宽度 Setup 1D barcode width
    `void` | `setFeedRow(int n)` 打印并进纸 n行 print and paper infeed n
    `void` | `setPrintCharacterStyle(boolean italic, boolean frame, boolean bold, boolean doubleWidth, boolean doubleHigh, boolean white, boolean underline)` 设置字体样式 set font style
    `void` | `setPrintCodePage(int page)`
    `void` | `setPrinterStatusCallBack(Printer.PrinterStatusCallBack callBack)` 设置接收打印机状态的回调 set call back of printer received status
    `void` | `setPrinterStatusCallBackEnable(boolean b)` 设置是否接收打印机状态回调消息 Setup receive printer status return message or not
    `void` | `setPrinterType(int type)`
    `void` | `setPrintGrayLevel(int gray)` 设置打印 灰度 setup print grey level
    `void` | `setPrintLeftMargin(int margin)` 设置左边距 Setup left margin
    `void` | `setPrintRightMargin(int margin)` 设置左边距 Setup right margin
    `void` | `setPrintRowSpacing(int spacing)` 设置行间距(若设定的行间距小于一行中的最大字符高度，那么该行行间距等于最大字符高度) Setup line spacing (if the set value is less than max.charater height, then the line spacing equals to max.character height)
    `void` | `setPrintSpeed(int speed)` 设置打印速度 setup print velocity
    `boolean` | `upgradeFont(int packageCount, int index, int currSize, byte[] data)`
    `boolean` | `upgradeFW(int packageCount, int index, int currSize, byte[] data)`
    `boolean` | `verifyFW(int upgradeCRC)`

- - ### Method Detail

    - #### setPrinterStatusCallBackEnable

          void setPrinterStatusCallBackEnable(boolean b)

      设置是否接收打印机状态回调消息
      Setup receive printer status return message or not
      Parameters:
        `b` - true:表示接收打印机回调消息，false:表示不接收回调消息,默认是true
        ture: means receive return infor of printer, false: means donot receive return infor,default is ture.

    - #### receiveData

          int receiveData(byte[] outData)

      接收串口数据
      receive serial port data
      Parameters:
        `outData` - 接收到的数据
        outData received data
      Returns:
        返回接收数据的长度
        length of returned data

    - #### sendData

          int sendData(byte[] sendData)

      发送数据到串口
      send data to serial port
      Parameters:
        `sendData` - 发送的数据
        send data
      Returns:
        返回发送数据的长度
        length of return sent data

    - #### sendAndReceiveData

          int sendAndReceiveData(byte[] sendData,
                                 byte[] outData)

      收发数据
      sent/received data
      Parameters:
        `sendData` - 发送的数据
        sent data
        `outData` - 接收的数据
        received data
      Returns:
        返回接收的数据长度(- 1表示发送失败)
        returned data length(-1 means send failed)

    - #### setPrinterStatusCallBack

          void setPrinterStatusCallBack(Printer.PrinterStatusCallBack callBack)

      设置接收打印机状态的回调
      set call back of printer received status
      Parameters:
        `callBack` -

    - #### init

          boolean init(int isUpgrade)

      打开打印机模块
      Switch on printer module
      Returns:
        成功true，失败false

    - #### initPrinterGpio

          boolean initPrinterGpio(boolean isUpgrade)

    - #### releasePrinterGpio

          boolean releasePrinterGpio()

    - #### openPrinterSerialPort

          boolean openPrinterSerialPort(boolean isUpgrade)

    - #### free

          boolean free()

      关闭打印机模块
      Switch off printer module
      Returns:
        成功true，失败false
        true means success, false means failed

    - #### print

          void print(byte[] content)

      打印字符
      print character
      Parameters:
        `content` - 打印的内容

    - #### print

          void print(java.lang.String content)

      打印字符
      printe character
      Parameters:
        `content` - 打印的内容
        print content

    - #### print

          void print(java.lang.String content,
                     java.lang.String charsetName)

      打印字符
      print character
      Parameters:
        `content` - 打印的内容
        print content
        `charsetName` - 字符编码格式
        character coding format

    - #### print

          void print(Bitmap bitmap,
                     int mode,
                     int interval)

      打印图片
      print pciture
      Parameters:
        `bitmap` - 要打印的图片
        picture for printing
        `mode(0,1,32,33)` - 点图格式:
        picture format:
        模式 水平比例 垂直比例
        format horizontal scale vertical scale
        0: 8 点单密度 ×2 ×3
        0: 8 point single density ×2 ×3
        1: 8 点双密度 ×1 ×3
        1: 8 point dual density ×1 ×3
        32:24 点单密度 ×2 ×1
        32:24 point single density ×2 ×1
        33:24 点双密度 ×1 ×1
        33:24 point dual density ×1 ×1

    - #### print

          void print(Bitmap bitmap,
                     int interval)

      打印图片
      print picture
      Parameters:
        `bitmap` - 图片数据
        bitmap picture data
        `interval` - 发送每行数据的时间间隔
        Time interval for sending per row of data

    - #### print

          void print(Bitmap bitmap)

      打印图片
      print picture
      Parameters:
        `bitmap` - 图片数据
        bitmap picture data

    - #### print

          void print(java.lang.String barcodeData,
                     Printer.BarcodeType barcodeType)
              throws PrinterBarcodeInvalidException

      打印条码
      print barcode
      Parameters:
        `barcodeData` - 条码数据
        barcodeData
        `barcodeType` - 条码类型
        barcodeType
      Throws:
        `PrinterBarcodeInvalidException`

    - #### setFeedRow

          void setFeedRow(int n)

      打印并进纸 n行
      print and paper infeed n
      Parameters:
        `n(0-255)` -

    - #### setPrintRowSpacing

          void setPrintRowSpacing(int spacing)

      设置行间距(若设定的行间距小于一行中的最大字符高度，那么该行行间距等于最大字符高度)
      Setup line spacing (if the set value is less than max.charater height, then the line spacing equals to max.character height)
      Parameters:
        `spacing` - (0 ≤ spacing ≤ 255), 默认值33
        spacing (0≤ spacing ≤ 255), default 33

    - #### setPrintLeftMargin

          void setPrintLeftMargin(int margin)

      设置左边距
      Setup left margin
      Parameters:
        `margin` - (0 ≤ left margin ≤ 47，且 0 ≤ （左边距 + 右边距） ≤ 47), 默认值0
        margin (0 ≤ left margin ≤ 47,0 ≤ （left margin + right margin, ≤ 47),default 0.

    - #### setPrintRightMargin

          void setPrintRightMargin(int margin)

      设置左边距
      Setup right margin
      Parameters:
        `margin` - (0 ≤ left margin ≤ 47，且 0 ≤ （左边距 + 右边距） ≤ 47), 默认值0
        margin (0 ≤ left margin ≤ 47,0 ≤ （left margin + right margin, ≤ 47),default 0.

    - #### setPrintCharacterStyle

          void setPrintCharacterStyle(boolean italic,
                                      boolean frame,
                                      boolean bold,
                                      boolean doubleWidth,
                                      boolean doubleHigh,
                                      boolean white,
                                      boolean underline)

      设置字体样式
      set font style
      Parameters:
        `italic` - 斜体
        italic
        `frame` - 边框
        frame
        `bold` - 加粗
        bold
        `doubleWidth` - 倍宽
        doubleWidth
        `doubleHigh` - 倍高
        douleHigh
        `white` - 反白
        white
        `underline` - 下划线
        underline

    - #### setPrintSpeed

          void setPrintSpeed(int speed)

      设置打印速度
      setup print velocity
      Parameters:
        `speed` - 0:低速,1:中速,2:高速
        speed 0:low,1:medium,2:high
        备注：默认是1
        comment: default is 1

    - #### setPrintGrayLevel

          void setPrintGrayLevel(int gray)

      设置打印 灰度
      setup print grey level
      Parameters:
        `gray` - 1-8
        gray 1-8
        备注：默认是4
        comment: default is 4

    - #### restoreDefault

          void restoreDefault()

      参数还原默认值
      parameter reset to default

    - #### clearCache

          void clearCache()

      立即清空打印缓存,清空打印机接收缓冲区和打印缓冲区
      Clear up printing cache, clear printer receive zone and buffer zone

    - #### setBarcodeHeight

          void setBarcodeHeight(int height)

      设置一维条码的高度
      Setup 1D barcode height
      Parameters:
        `height` - 高度(1-255),默认值:64
        height(1-255), default:64

    - #### setBarcodeWidth

          void setBarcodeWidth(int width)

      设置一维条码的宽度
      Setup 1D barcode width
      Parameters:
        `width` - 宽度(1-6),默认值:2
        width(1-6), default:2

    - #### setBarcodeHRI

          void setBarcodeHRI(int position)

      设置一维条码可读字符（HRI）打印位置
      setup 1D barcode readable character (HRI) print position
      Parameters:
        `position(0-3)` - 默认是0; [0:不打印, 1: 条码的上方 , 2:条码的下方, 3:条码的上方和下方]
        position(0-3) default is 0; [0:not print, 1:barcode up side 2: barcode down side, 3: barcode up and down]

    - #### isPowerOn

          boolean isPowerOn()

    - #### getVersion

          java.lang.String getVersion()

    - #### setPrinterType

          void setPrinterType(int type)

    - #### getPrinterType

          int getPrinterType()

    - #### setPrintCodePage

          void setPrintCodePage(int page)

    - #### getPrintCodePage

          int getPrintCodePage()

    - #### initFW

          boolean initFW()

    - #### eraseFW

          boolean eraseFW(long size)

    - #### upgradeFW

          boolean upgradeFW(int packageCount,
                            int index,
                            int currSize,
                            byte[] data)

    - #### verifyFW

          boolean verifyFW(int upgradeCRC)

    - #### eraseFlash

          boolean eraseFlash()

    - #### upgradeFont

          boolean upgradeFont(int packageCount,
                              int index,
                              int currSize,
                              byte[] data)