Commit 913e9a2b authored by fanghaitong's avatar fanghaitong

增加reply

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