Commit 913e9a2b authored by fanghaitong's avatar fanghaitong

增加reply

parent 416cdaa4
...@@ -164,12 +164,12 @@ class ZqToolActivity : AppCompatActivity() { ...@@ -164,12 +164,12 @@ class ZqToolActivity : AppCompatActivity() {
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
ZqScaleKit.instance.stopReadData() ZqScaleKit.instance.stopReadData()
// m_bThreadAutoReadExit = true m_bThreadAutoReadExit = true
// if (m_bConnected) { if (m_bConnected) {
// m_bConnected = false m_bConnected = false
// ZqScaleKit.instance.disconnect() ZqScaleKit.instance.disconnect()
// butConnect!!.text = "连接" butConnect!!.text = "连接"
// } }
} }
private val MyClickListener = private val MyClickListener =
......
...@@ -27,10 +27,7 @@ class ZqScaleKit private constructor() { ...@@ -27,10 +27,7 @@ class ZqScaleKit private constructor() {
zqebsdk() zqebsdk()
} }
private var stableWeight = mutableListOf<String>() private var stableWeight = mutableListOf<String>()
private val _connectState = MutableSharedFlow<ConnectState>( private val _connectState = MutableSharedFlow<ConnectState>(replay = 1)
replay = 1, extraBufferCapacity = 0,
onBufferOverflow = BufferOverflow.SUSPEND
)
val connectState: SharedFlow<ConnectState> = _connectState val connectState: SharedFlow<ConnectState> = _connectState
private val _livingWeight = MutableSharedFlow<LivingWeight>() private val _livingWeight = MutableSharedFlow<LivingWeight>()
val livingWeight: SharedFlow<LivingWeight> = _livingWeight val livingWeight: SharedFlow<LivingWeight> = _livingWeight
...@@ -64,24 +61,28 @@ class ZqScaleKit private constructor() { ...@@ -64,24 +61,28 @@ class ZqScaleKit private constructor() {
fun disconnect() { fun disconnect() {
// stopReadData() // stopReadData()
zqeb.EB_Disconnect() val ebDisconnect = zqeb.EB_Disconnect()
Log.v("ZqScaleKit", String.format("ebDisconnect: %s", ebDisconnect))
} }
fun setZero() { fun setZero() {
if (_connectState.replayCache.isNullOrEmpty() && _connectState.replayCache.last().isConnect) { if (!_connectState.replayCache.isNullOrEmpty() && _connectState.replayCache.last().isConnect) {
zqeb.EB_SetZero() val ebSetzero = zqeb.EB_SetZero()
Log.v("ZqScaleKit", String.format("ebSetzero: %s", ebSetzero))
} }
} }
fun setNetWeight() { fun setNetWeight() {
if (_connectState.replayCache.isNullOrEmpty() && _connectState.replayCache.last().isConnect) { if (!_connectState.replayCache.isNullOrEmpty() && _connectState.replayCache.last().isConnect) {
zqeb.EB_SetNetWeight() val ebSetnetweight = zqeb.EB_SetNetWeight()
Log.v("ZqScaleKit", String.format("ebSetnetweight: %s", ebSetnetweight))
} }
} }
fun clearTare() { fun clearTare() {
if (_connectState.replayCache.isNullOrEmpty() && _connectState.replayCache.last().isConnect) { if (!_connectState.replayCache.isNullOrEmpty() && _connectState.replayCache.last().isConnect) {
zqeb.EB_ClearTare() val ebCleartare = zqeb.EB_ClearTare()
Log.v("ZqScaleKit", String.format("ebCleartare: %s", ebCleartare))
} }
} }
......
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