Commit f23d304c authored by tongzifang's avatar tongzifang

1.0.8

增加app默认版本判断 ,2B默认无称
parent 265c46d5
...@@ -30,7 +30,7 @@ android { ...@@ -30,7 +30,7 @@ android {
} }
} }
group 'com.qmai.android.zqtoolkit' group 'com.qmai.android.zqtoolkit'
version '1.0.7.47' version '1.0.8'
gradlePublish { gradlePublish {
......
...@@ -58,21 +58,21 @@ object ScaleHub : ScaleBaseAction { ...@@ -58,21 +58,21 @@ object ScaleHub : ScaleBaseAction {
/** /**
* fix-20220707 中崎称类型多,通过DeviceUtils.getModel()判断不准确,现改为默认中崎 * fix-20220707 中崎称类型多,通过DeviceUtils.getModel()判断不准确,现改为默认中崎
*/ */
private fun tryInit(): Boolean { private fun tryInit(appType: Int? = 0): Boolean {
if (scaleKit == null) { if (scaleKit == null) {
scaleKit = when { scaleKit = when {
ScaleChecker.isZQ() -> ZqScaleKit ScaleChecker.isZQ() -> ZqScaleKit
ScaleChecker.isSUNMI() -> SunmiScaleKit ScaleChecker.isSUNMI() -> SunmiScaleKit
ScaleChecker.isAclas() -> AclasScaleKit ScaleChecker.isAclas() -> AclasScaleKit
else -> ZqScaleKit else -> if (appType == null || appType == 0) null else ZqScaleKit
} }
} }
return scaleKit == null return scaleKit == null
} }
override fun connect(cxt: Context?, port: String?, buad: String?) { override fun connect(cxt: Context?, port: String?, buad: String?, appType: Int?) {
// var trueCxt = cxt?.applicationContext // var trueCxt = cxt?.applicationContext
if (tryInit()) { if (tryInit(appType)) {
return return
} }
//称只给连一个端口,其他端口用其他hub //称只给连一个端口,其他端口用其他hub
...@@ -92,6 +92,7 @@ object ScaleHub : ScaleBaseAction { ...@@ -92,6 +92,7 @@ object ScaleHub : ScaleBaseAction {
} }
private suspend fun collectConnectData() { private suspend fun collectConnectData() {
scaleKit?.connectState?.collect { scaleKit?.connectState?.collect {
_connectState.emit(it) _connectState.emit(it)
......
...@@ -57,14 +57,13 @@ object AclasScaleKit : ScaleBaseKit() { ...@@ -57,14 +57,13 @@ object AclasScaleKit : ScaleBaseKit() {
} }
override fun connect(cxt: Context?, port: String?, buad: String?) { override fun connect(cxt: Context?, port: String?, buad: String?, appType: Int?) {
super.connect(cxt, port, buad) super.connect(cxt, port, buad, appType)
if (aclasScaler == null) { if (aclasScaler == null) {
cxt?.let { cxt?.let {
aclasScaler = AclasScaler(AclasScaler.Type_USB, it, aclasScalerListener) aclasScaler = AclasScaler(AclasScaler.Type_USB, it, aclasScalerListener)
} }
} }
// //
val usbConnectIndex = getAclasScaleIndex() val usbConnectIndex = getAclasScaleIndex()
//val usbConnectIndex = 0 //val usbConnectIndex = 0
...@@ -144,7 +143,7 @@ object AclasScaleKit : ScaleBaseKit() { ...@@ -144,7 +143,7 @@ object AclasScaleKit : ScaleBaseKit() {
var comList = mutableListOf<String>() var comList = mutableListOf<String>()
aclasScaler?.getCommList(comList) aclasScaler?.getCommList(comList)
if (!comList.isNullOrEmpty()) { if (!comList.isNullOrEmpty()) {
usbIndex = comList.indexOfFirst { name -> name.contains(aclasPname)} usbIndex = comList.indexOfFirst { name -> name.contains(aclasPname) }
return usbIndex return usbIndex
} }
} }
......
...@@ -32,9 +32,9 @@ object SunmiScaleKit : ScaleBaseKit() { ...@@ -32,9 +32,9 @@ object SunmiScaleKit : ScaleBaseKit() {
override fun connect( override fun connect(
cxt: Context?, cxt: Context?,
port: String?, port: String?,
buad: String? buad: String?, appType: Int?
) { ) {
super.connect(cxt, port, buad) super.connect(cxt, port, buad, appType)
cxt?.let { cxt?.let {
mScaleManager = ScaleManager.getInstance(it) mScaleManager = ScaleManager.getInstance(it)
mScaleManager?.connectService(object : ScaleServiceConnection { mScaleManager?.connectService(object : ScaleServiceConnection {
......
...@@ -26,8 +26,8 @@ object ZqScaleKit : ScaleBaseKit() { ...@@ -26,8 +26,8 @@ object ZqScaleKit : ScaleBaseKit() {
override val SCALE_TYPE: QmScaleType override val SCALE_TYPE: QmScaleType
get() = QmScaleType.ZQEB get() = QmScaleType.ZQEB
override fun connect(cxt: Context?, port: String?, buad: String?) { override fun connect(cxt: Context?, port: String?, buad: String?, appType: Int?) {
super.connect(cxt, port, buad) super.connect(cxt, port, buad,appType)
val ebConnect = val ebConnect =
zqeb.EB_Connect(String.format("%s:%s", port ?: "ttyS4", buad ?: "9600"), cxt) zqeb.EB_Connect(String.format("%s:%s", port ?: "ttyS4", buad ?: "9600"), cxt)
val msg: String = when (ebConnect) { val msg: String = when (ebConnect) {
......
...@@ -10,11 +10,14 @@ import com.qmai.zqtoolkit.ScaleInfo ...@@ -10,11 +10,14 @@ import com.qmai.zqtoolkit.ScaleInfo
*/ */
interface ScaleBaseAction { interface ScaleBaseAction {
//电子秤连接 //电子秤连接
//appType 0是2B版本
fun connect( fun connect(
cxt: Context? = null, cxt: Context? = null,
port: String? = null, port: String? = null,
buad: String? = null buad: String? = null,
appType: Int? = 0
) )
//电子秤断开连接 //电子秤断开连接
fun disconnect() fun disconnect()
...@@ -31,7 +34,7 @@ interface ScaleBaseAction { ...@@ -31,7 +34,7 @@ interface ScaleBaseAction {
fun setNetWeight() fun setNetWeight()
//电子秤数字去皮 //电子秤数字去皮
fun setNetWeightByElec(tare:Double) fun setNetWeightByElec(tare: Double)
//电子秤清除去皮 //电子秤清除去皮
fun clearTare() fun clearTare()
......
...@@ -35,7 +35,8 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction { ...@@ -35,7 +35,8 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
private var stableWeight = mutableListOf<String>() private var stableWeight = mutableListOf<String>()
override fun connect(cxt: Context?, port: String?, buad: String?) {
override fun connect(cxt: Context?, port: String?, buad: String?, appType: Int?) {
lastTryScale = ScaleInfo(port, buad, SCALE_TYPE) lastTryScale = ScaleInfo(port, buad, SCALE_TYPE)
} }
......
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