package zs.qimai.com.printer2.manager

import java.io.InputStream
import java.io.OutputStream

/****
 * 设备基类
 * **/
abstract class DeviceManager {

    var mOutPutStream: OutputStream? = null
    var mInPutStream: InputStream? = null
    var mStatus = false
    var address: String? = null
    var deviceId: String = ""
    var mPrintMode: Int? = null
    abstract var mType: Int
    var name: String? = null
    @Deprecated("后续用 mPrintSize 代替打印杯贴大小")
    var maxLineChars: Int = 55
    var mPrintSize:Int = -1
    companion object {
        //小票模式
        val ESC = 1
        //标签模式
        val TSC = 2
        //蓝牙
        val BT = 1
        //usb
        val USB = 2
        //wifi（网线）
        const val WIFI = 3
        //支持小票尺寸
        const val TSC_40_30 = 10
        const val TSC_40_40 = 11
        const val TSC_60_40 = 12
    }

    //连接
    abstract fun openPort()

    //断开连接
    abstract fun closePort()

    abstract fun readData(bytes: ByteArray): Int
    abstract fun writeData(bytes: ByteArray)

    override fun equals(other: Any?): Boolean {
        if (other == null || other !is DeviceManager) {
            return false
        } else {
            return other.deviceId == this.deviceId
        }
    }

    override fun hashCode(): Int {
        return deviceId.hashCode()
    }


}