Commit 013d408b authored by tongzifang's avatar tongzifang

1.2.2

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