Commit f472763d authored by tongzifang's avatar tongzifang

增加默认brand和model

parent f323e3dd
...@@ -30,7 +30,7 @@ android { ...@@ -30,7 +30,7 @@ android {
} }
} }
group 'com.qmai.android.zqtoolkit' group 'com.qmai.android.zqtoolkit'
version '1.2.6' version '1.2.6.2'
gradlePublish { gradlePublish {
......
...@@ -78,6 +78,11 @@ object ScaleHub : ScaleBaseAction { ...@@ -78,6 +78,11 @@ object ScaleHub : ScaleBaseAction {
else -> null else -> null
} }
} }
//通过tryInitSDK连接的,如果没有指定brand和model,赋一个默认的,若连接成功会被保存
if (scaleKit != null && (scale.brand == null || scale.model == null)) {
scale.brand = QmScaleBrand.find(scaleKit)
scale.model = QmScaleModel.find(scaleKit)
}
} }
} }
...@@ -86,10 +91,6 @@ object ScaleHub : ScaleBaseAction { ...@@ -86,10 +91,6 @@ object ScaleHub : ScaleBaseAction {
SHOP_ASSITANT_2C -> tryInitSDK2C() SHOP_ASSITANT_2C -> tryInitSDK2C()
SHOP_ASSITANT_2B -> tryInitSDK(scale) SHOP_ASSITANT_2B -> tryInitSDK(scale)
} }
// //称只给连一个端口,其他端口用其他hub
// if (isScaleSuccess()) {
// return
// }
scaleKit?.run { scaleKit?.run {
if (connectJob == null) { if (connectJob == null) {
connectJob = CoroutineScope(EmptyCoroutineContext) connectJob = CoroutineScope(EmptyCoroutineContext)
......
...@@ -27,14 +27,14 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction { ...@@ -27,14 +27,14 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
var lastTryScale: ScaleInfo? = null var lastTryScale: ScaleInfo? = null
private var lastConnectScale: ScaleInfo? = null private var lastConnectScale: ScaleInfo? = null
val _connectState = MutableSharedFlow<ConnectState>() private val _connectState = MutableSharedFlow<ConnectState>()
val connectState: SharedFlow<ConnectState> = _connectState val connectState: SharedFlow<ConnectState> = _connectState
val _livingWeight = MutableSharedFlow<LivingWeight>() private val _livingWeight = MutableSharedFlow<LivingWeight>()
val livingWeight: SharedFlow<LivingWeight> = _livingWeight val livingWeight: SharedFlow<LivingWeight> = _livingWeight
val _scaleLog = MutableSharedFlow<String>() private val _scaleLog = MutableSharedFlow<String>()
val scaleLog: SharedFlow<String> = _scaleLog val scaleLog: SharedFlow<String> = _scaleLog
private var stableWeight = mutableListOf<LivingWeight>() private var stableWeight = mutableListOf<LivingWeight>()
......
package com.qmai.zqtoolkit.config package com.qmai.zqtoolkit.config
import com.qmai.zqtoolkit.base.AclasScaleKit
import com.qmai.zqtoolkit.base.SunmiScaleKit
import com.qmai.zqtoolkit.base.ZqScaleKit
import com.qmai.zqtoolkit.base.scale.ScaleBaseKit
/** /**
* tongzi * tongzi
* 2022/5/26 * 2022/5/26
...@@ -13,6 +18,14 @@ enum class QmScaleBrand( ...@@ -13,6 +18,14 @@ enum class QmScaleBrand(
fun list(): List<QmScaleBrandValue> { fun list(): List<QmScaleBrandValue> {
return values().map { QmScaleBrandValue(it) } return values().map { QmScaleBrandValue(it) }
} }
fun find(kit: ScaleBaseKit?): QmScaleBrandValue? {
return when (kit) {
ZqScaleKit -> QmScaleBrandValue(ZQEB)
AclasScaleKit -> QmScaleBrandValue(ACLAS)
SunmiScaleKit -> QmScaleBrandValue(SUNMI)
else -> null
}
}
} }
} }
...@@ -41,6 +54,16 @@ enum class QmScaleModel( ...@@ -41,6 +54,16 @@ enum class QmScaleModel(
QmScaleModelValue(it) QmScaleModelValue(it)
} }
} }
fun find(kit: ScaleBaseKit?): QmScaleModelValue? {
return when (kit) {
ZqScaleKit -> QmScaleModelValue(DEFAULT_ZQ)
AclasScaleKit -> QmScaleModelValue(DEFAULT_ACLAS)
SunmiScaleKit -> QmScaleModelValue(DEFAULT_SUNMI)
else -> null
}
}
} }
} }
......
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