Commit 013d408b authored by tongzifang's avatar tongzifang

1.2.2

parent eb25ae3d
......@@ -30,7 +30,7 @@ android {
}
}
group 'com.qmai.android.zqtoolkit'
version '1.2.1.2'
version '1.2.2'
gradlePublish {
......
......@@ -175,10 +175,10 @@ object ScaleHub : ScaleBaseAction {
weightJob = CoroutineScope(EmptyCoroutineContext)
}
connectJob?.launch(context = Dispatchers.IO) {
scaleKit?.readData()
weightJob?.launch(context = Dispatchers.IO) {
collectWeightData()
}
scaleKit?.readData()
}
private suspend fun collectWeightData() {
......
......@@ -13,6 +13,6 @@ data class ScaleInfo(
var buad: String? = null,
var brand: QmScaleBrandValue? = null,
var model: QmScaleModelValue? = null,
var connectType: Int?,
var connectType: Int? = 1, // connectType 0串口 1usb
var appType: Int? = SHOP_ASSITANT_2C
)
\ No newline at end of file
......@@ -43,7 +43,6 @@ object AclasScaleKit : ScaleBaseKit() {
override fun onRcvData(weght: AclasScaler.WeightInfoNew?) {
updateScaleInfo("$TAG :onRcvData " + TimeUtils.getNowString() + " data: " + GsonUtils.toJson(weght))
Log.v(TAG, GsonUtils.toJson(weght))
// getTare()
updateWeight(
LivingWeight(
......@@ -55,7 +54,6 @@ object AclasScaleKit : ScaleBaseKit() {
override fun onError(p0: Int, p1: String?) {
updateScaleInfo("$TAG :onError " + TimeUtils.getNowString() + " data: p0" + p0 + " p1" + p1)
Log.v(TAG, "onError:$p0$p1")
}
override fun onUpdateProcess(p0: Int, p1: Int) {
......
......@@ -24,7 +24,7 @@ object ZqScaleKit : ScaleBaseKit() {
override val TAG: String
get() = "ZqScaleKit"
override val STABLE_COUNT: Int
get() = 4
get() = 8
override val CONECT_CHECK_COUNT: Int
get() = 4
override val SCALE_TYPE: QmScaleBrand
......@@ -132,7 +132,7 @@ object ZqScaleKit : ScaleBaseKit() {
private val weightFlow = flow {
while (true) {
emit(Unit)
delay(80)
delay(100)
}
}
......
package com.qmai.zqtoolkit.base.scale
import android.content.Context
import android.util.Log
import com.blankj.utilcode.util.GsonUtils
import com.qmai.zqtoolkit.ConnectState
import com.qmai.zqtoolkit.LivingWeight
import com.qmai.zqtoolkit.ScaleInfo
......@@ -35,7 +37,7 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
val _scaleLog = MutableSharedFlow<String>()
val scaleLog: SharedFlow<String> = _scaleLog
private var stableWeight = mutableListOf<String>()
private var stableWeight = mutableListOf<LivingWeight>()
var connectCache = mutableListOf<Boolean>()
......@@ -71,24 +73,27 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
}
override fun updateWeight(weight: LivingWeight) {
GlobalScope.launch(context = Dispatchers.IO) {
GlobalScope.launch {
//稳定状态且读数正常
if (weight.isStable && !weight.isReadErr) {
readErrCache.clear()
when {
stableWeight.size == STABLE_COUNT -> {
if (stableWeight.toSet().size == 1) {
var single = stableWeight.distinctBy { it.weight }
if (single.size == 1) {
//给业务的unit要小写
if (weight.unit.isNotEmpty())
weight.unit = weight.unit.lowercase()
_livingWeight.emit(weight)
single.firstOrNull()?.let {
_livingWeight.emit(it)
}
}
stableWeight.clear()
}
stableWeight.size > STABLE_COUNT -> {
stableWeight.clear()
}
else -> stableWeight.add(weight.weight)
else -> stableWeight.add(weight)
}
} else {
_livingWeight.emit(weight)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment