package com.qmai.zqtoolkit

import com.qmai.zqtoolkit.base.ZqLEDKit
import com.qmai.zqtoolkit.base.led.LEDBaseAction

/**
 * tongzi
 * 2022/5/7
 * led hub
 */
object LEDHub : LEDBaseAction {

    private val ledKit by lazy {
        ZqLEDKit
    }

    override fun connect(port: String?, buad: String?) {
        ledKit.connect(port, buad)
    }


    override fun sendData(data: ByteArray) {
        if (isLEDSuccess()) {
            ledKit.sendData(data)
        }
    }

    override fun sendLEDWeight(weight: String) {
        if (isLEDSuccess())
            ledKit.sendLEDWeight(weight)
    }

    override fun sendLEDUnitPrice(price: String) {
        if (isLEDSuccess())
            ledKit.sendLEDUnitPrice(price)
    }

    override fun sendLEDTotalPrice(price: String) {
        if (isLEDSuccess())
            ledKit.sendLEDTotalPrice(price)
    }

    override fun sendLEDLight(zero: Boolean, stable: Boolean, tare: Boolean) {
        if (isLEDSuccess())
            ledKit.sendLEDLight(zero, stable, tare)
    }

    override fun clearLED() {
        if (isLEDSuccess())
            ledKit.clearLED()
    }

    override fun isLEDSuccess(): Boolean {
        return ledKit.isLEDSuccess()
    }
}
