|
@@ -593,18 +593,20 @@ class AddedChemicalsActivity : BaseCountDownActivity<ActivityAddedChemicalsBindi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun getControlConfigs(chemicalNumber: String) {
|
|
private fun getControlConfigs(chemicalNumber: String) {
|
|
|
|
|
+
|
|
|
showLoading("提交中...")
|
|
showLoading("提交中...")
|
|
|
val disposable = ApiRepository.controlConfigs(modelA.chemicalLevel)
|
|
val disposable = ApiRepository.controlConfigs(modelA.chemicalLevel)
|
|
|
.subscribe({ data ->
|
|
.subscribe({ data ->
|
|
|
dismissLoading()
|
|
dismissLoading()
|
|
|
mChemicalConfsBean = data
|
|
mChemicalConfsBean = data
|
|
|
-// searchProducer()
|
|
|
|
|
|
|
+ // searchProducer()
|
|
|
certitude(chemicalNumber)
|
|
certitude(chemicalNumber)
|
|
|
}, { throwable ->
|
|
}, { throwable ->
|
|
|
showNetError(throwable)
|
|
showNetError(throwable)
|
|
|
dismissLoading()
|
|
dismissLoading()
|
|
|
})
|
|
})
|
|
|
addDisposable(disposable)
|
|
addDisposable(disposable)
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private fun getCheckRfids(rfid: String, tagCode: String, wxCode: String, position: Int) {
|
|
private fun getCheckRfids(rfid: String, tagCode: String, wxCode: String, position: Int) {
|
|
@@ -1050,88 +1052,88 @@ class AddedChemicalsActivity : BaseCountDownActivity<ActivityAddedChemicalsBindi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- private suspend fun connectToDeviceWithTimeout() {
|
|
|
|
|
|
|
+ private suspend fun connectToDeviceWithTimeout() {
|
|
|
showToast("连接中...", Toast.LENGTH_SHORT)
|
|
showToast("连接中...", Toast.LENGTH_SHORT)
|
|
|
// lifecycleScope.launch {
|
|
// lifecycleScope.launch {
|
|
|
|
|
|
|
|
- val deviceAddress = withContext(Dispatchers.IO) {
|
|
|
|
|
- BluetoothConnectionManager.getDeviceAddress()
|
|
|
|
|
|
|
+ val deviceAddress = withContext(Dispatchers.IO) {
|
|
|
|
|
+ BluetoothConnectionManager.getDeviceAddress()
|
|
|
|
|
+ }
|
|
|
|
|
+ if (deviceAddress != null) {
|
|
|
|
|
+ val socket = withContext(Dispatchers.IO) {
|
|
|
|
|
+ BluetoothConnectionManager.connectToDevice(deviceAddress)
|
|
|
}
|
|
}
|
|
|
- if (deviceAddress != null) {
|
|
|
|
|
- val socket = withContext(Dispatchers.IO) {
|
|
|
|
|
- BluetoothConnectionManager.connectToDevice(deviceAddress)
|
|
|
|
|
- }
|
|
|
|
|
- if (socket != null) {
|
|
|
|
|
- // 连接成功后的处理逻辑
|
|
|
|
|
- // 在这里使用返回的 BluetoothSocket 对象进行后续操作
|
|
|
|
|
- MediaPlayerHelper.playRawMp3(
|
|
|
|
|
- this@AddedChemicalsActivity,
|
|
|
|
|
- R.raw.qing_zheng_zhong
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ if (socket != null) {
|
|
|
|
|
+ // 连接成功后的处理逻辑
|
|
|
|
|
+ // 在这里使用返回的 BluetoothSocket 对象进行后续操作
|
|
|
|
|
+ MediaPlayerHelper.playRawMp3(
|
|
|
|
|
+ this@AddedChemicalsActivity,
|
|
|
|
|
+ R.raw.qing_zheng_zhong
|
|
|
|
|
+ )
|
|
|
// showToast("连接成功", Toast.LENGTH_SHORT)
|
|
// showToast("连接成功", Toast.LENGTH_SHORT)
|
|
|
- // 连接成功后的处理逻辑
|
|
|
|
|
- // 切换回主线程更新 UI
|
|
|
|
|
- withContext(Dispatchers.Main) {
|
|
|
|
|
- do {
|
|
|
|
|
- val inputStream = socket!!.inputStream
|
|
|
|
|
- val bt = ByteArray(1024)
|
|
|
|
|
- val content = inputStream!!.read(bt)
|
|
|
|
|
- if (content != null && content > 0) {
|
|
|
|
|
- val contents = String(
|
|
|
|
|
- bt,
|
|
|
|
|
- 0,
|
|
|
|
|
- content,
|
|
|
|
|
- StandardCharsets.UTF_8
|
|
|
|
|
- )
|
|
|
|
|
- val split = contents.split("\n")
|
|
|
|
|
- val weight = split[0].trim()
|
|
|
|
|
- RcLog.info("===================称重未处理之前=======$contents")
|
|
|
|
|
- RcLog.info("===================weight=======$weight")
|
|
|
|
|
- RcLog.info("=====称重数据$weight $taskStarted ${mWeighingValue!!.text.toString()}")
|
|
|
|
|
- if (weight.toDouble() > 2999) {
|
|
|
|
|
- turnOffWeighing()
|
|
|
|
|
- } else {
|
|
|
|
|
- if (weight.toDouble() > 0) {
|
|
|
|
|
- if (mWeighingValue!!.text.toString().trim()
|
|
|
|
|
- .isNotEmpty()
|
|
|
|
|
|
|
+ // 连接成功后的处理逻辑
|
|
|
|
|
+ // 切换回主线程更新 UI
|
|
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
|
|
+ do {
|
|
|
|
|
+ val inputStream = socket!!.inputStream
|
|
|
|
|
+ val bt = ByteArray(1024)
|
|
|
|
|
+ val content = inputStream!!.read(bt)
|
|
|
|
|
+ if (content != null && content > 0) {
|
|
|
|
|
+ val contents = String(
|
|
|
|
|
+ bt,
|
|
|
|
|
+ 0,
|
|
|
|
|
+ content,
|
|
|
|
|
+ StandardCharsets.UTF_8
|
|
|
|
|
+ )
|
|
|
|
|
+ val split = contents.split("\n")
|
|
|
|
|
+ val weight = split[0].trim()
|
|
|
|
|
+ RcLog.info("===================称重未处理之前=======$contents")
|
|
|
|
|
+ RcLog.info("===================weight=======$weight")
|
|
|
|
|
+ RcLog.info("=====称重数据$weight $taskStarted ${mWeighingValue!!.text.toString()}")
|
|
|
|
|
+ if (weight.toDouble() > 2999) {
|
|
|
|
|
+ turnOffWeighing()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (weight.toDouble() > 0) {
|
|
|
|
|
+ if (mWeighingValue!!.text.toString().trim()
|
|
|
|
|
+ .isNotEmpty()
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (weight.toDouble() == mWeighingValue!!.text.toString()
|
|
|
|
|
+ .trim().toDouble()
|
|
|
) {
|
|
) {
|
|
|
- if (weight.toDouble() == mWeighingValue!!.text.toString()
|
|
|
|
|
- .trim().toDouble()
|
|
|
|
|
- ) {
|
|
|
|
|
- if (taskStarted == false) {
|
|
|
|
|
- taskStarted = true
|
|
|
|
|
- RcLog.info("=====执行了")
|
|
|
|
|
- socket.close()
|
|
|
|
|
- delayedTaskToUpdateUI()
|
|
|
|
|
- break
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (taskStarted == false) {
|
|
|
|
|
+ taskStarted = true
|
|
|
|
|
+ RcLog.info("=====执行了")
|
|
|
|
|
+ socket.close()
|
|
|
|
|
+ delayedTaskToUpdateUI()
|
|
|
|
|
+ break
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- mWeighingValue!!.setText("$weight")
|
|
|
|
|
- } else {
|
|
|
|
|
- mWeighingValue!!.setText("")
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ mWeighingValue!!.setText("$weight")
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mWeighingValue!!.setText("")
|
|
|
}
|
|
}
|
|
|
- RcLog.info("==========蓝牙称 内存测试")
|
|
|
|
|
- delay(200)
|
|
|
|
|
- } else {
|
|
|
|
|
- showToast("请手动输入")
|
|
|
|
|
- weiView()
|
|
|
|
|
- break
|
|
|
|
|
}
|
|
}
|
|
|
- } while (true)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- // 连接失败的处理逻辑
|
|
|
|
|
- showToast("连接失败或超时", Toast.LENGTH_SHORT)
|
|
|
|
|
- weiView()
|
|
|
|
|
|
|
+ RcLog.info("==========蓝牙称 内存测试")
|
|
|
|
|
+ delay(200)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showToast("请手动输入")
|
|
|
|
|
+ weiView()
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ } while (true)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
- // 根据设备名称获取的设备地址为空,处理无法找到设备的情况
|
|
|
|
|
- showToast("找不到设备", Toast.LENGTH_SHORT)
|
|
|
|
|
|
|
+ // 连接失败的处理逻辑
|
|
|
|
|
+ showToast("连接失败或超时", Toast.LENGTH_SHORT)
|
|
|
weiView()
|
|
weiView()
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 根据设备名称获取的设备地址为空,处理无法找到设备的情况
|
|
|
|
|
+ showToast("找不到设备", Toast.LENGTH_SHORT)
|
|
|
|
|
+ weiView()
|
|
|
|
|
+ }
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
}
|