|
@@ -39,7 +39,7 @@ class GeneralParamFragmentVM @Inject constructor(private val mRepo: GeneralParam
|
|
|
var paramDataList = mutableMapOf<String, String>()
|
|
|
|
|
|
// val generalParamData: MutableList<String> get() = _generalParamData
|
|
|
- private var _readAllDataSuccess = MutableLiveData<Boolean>()//是否读取所有数据成功
|
|
|
+ private var _readAllDataSuccess = MutableLiveData(false)//是否读取所有数据成功
|
|
|
val readAllDataSuccess: LiveData<Boolean> get() = _readAllDataSuccess
|
|
|
|
|
|
//position
|
|
@@ -90,17 +90,41 @@ class GeneralParamFragmentVM @Inject constructor(private val mRepo: GeneralParam
|
|
|
// paramDataList.put(PlcParamAddressEnum.Param01.address,HexadecimalUtil.hex2dec(messageEvent.data.substring(22, 24)).toString())
|
|
|
// paramDataList.put(PlcParamAddressEnum.Param02.address,HexadecimalUtil.hex2dec(messageEvent.data.substring(24, 26)).toString())
|
|
|
// paramDataList.put(PlcParamAddressEnum.Param03.address,HexadecimalUtil.hex2dec(messageEvent.data.substring(26, 28)).toString())
|
|
|
- paramDataList.put(PlcParamAddressEnum.Param01.address, HexadecimalUtil.hex2dec(SBCHeartbeat.windSpeedLow).toString())
|
|
|
- paramDataList.put(PlcParamAddressEnum.Param02.address, HexadecimalUtil.hex2dec(SBCHeartbeat.windSpeedMid).toString())
|
|
|
- paramDataList.put(PlcParamAddressEnum.Param03.address, HexadecimalUtil.hex2dec(SBCHeartbeat.windSpeedHei).toString())
|
|
|
- paramDataList.put(PlcParamAddressEnum.Param04.address, HexadecimalUtil.hex2dec(messageEvent.data.substring(28, 30)).toString())
|
|
|
- paramDataList.put(PlcParamAddressEnum.Param05.address, HexadecimalUtil.hex2dec(messageEvent.data.substring(30, 32)).toString())
|
|
|
- paramDataList.put(PlcParamAddressEnum.Param06.address, HexadecimalUtil.hex2dec(messageEvent.data.substring(32, 36)).toString())
|
|
|
- paramDataList.put(PlcParamAddressEnum.Param07.address, HexadecimalUtil.hex2dec(messageEvent.data.substring(36, 38)).toString())
|
|
|
- paramDataList.put(PlcParamAddressEnum.Param08.address, HexadecimalUtil.hex2dec(messageEvent.data.substring(38, 40)).toString())
|
|
|
+ paramDataList.put(
|
|
|
+ PlcParamAddressEnum.Param01.address,
|
|
|
+ HexadecimalUtil.hex2dec(SBCHeartbeat.windSpeedLow).toString()
|
|
|
+ )
|
|
|
+ paramDataList.put(
|
|
|
+ PlcParamAddressEnum.Param02.address,
|
|
|
+ HexadecimalUtil.hex2dec(SBCHeartbeat.windSpeedMid).toString()
|
|
|
+ )
|
|
|
+ paramDataList.put(
|
|
|
+ PlcParamAddressEnum.Param03.address,
|
|
|
+ HexadecimalUtil.hex2dec(SBCHeartbeat.windSpeedHei).toString()
|
|
|
+ )
|
|
|
+ paramDataList.put(
|
|
|
+ PlcParamAddressEnum.Param04.address,
|
|
|
+ HexadecimalUtil.hex2dec(messageEvent.data.substring(28, 30)).toString()
|
|
|
+ )
|
|
|
+ paramDataList.put(
|
|
|
+ PlcParamAddressEnum.Param05.address,
|
|
|
+ HexadecimalUtil.hex2dec(messageEvent.data.substring(30, 32)).toString()
|
|
|
+ )
|
|
|
+ paramDataList.put(
|
|
|
+ PlcParamAddressEnum.Param06.address,
|
|
|
+ HexadecimalUtil.hex2dec(messageEvent.data.substring(32, 36)).toString()
|
|
|
+ )
|
|
|
+ paramDataList.put(
|
|
|
+ PlcParamAddressEnum.Param07.address,
|
|
|
+ HexadecimalUtil.hex2dec(messageEvent.data.substring(36, 38)).toString()
|
|
|
+ )
|
|
|
+ paramDataList.put(
|
|
|
+ PlcParamAddressEnum.Param08.address,
|
|
|
+ HexadecimalUtil.hex2dec(messageEvent.data.substring(38, 40)).toString()
|
|
|
+ )
|
|
|
ToastUtil.switchToastStyleToSuccess(UiUtil.getStringRes(R.string.backstage_update_success))
|
|
|
- mRepo.threadGeneralParam.isActiveParam = false
|
|
|
- mRepo.threadGeneralParam.jobParam?.cancel()
|
|
|
+ _readAllDataSuccess.value = true
|
|
|
+// mRepo.threadGeneralParam.jobParam?.cancel()
|
|
|
}
|
|
|
|
|
|
fun getThreadGeneralParam(): LifecycleObserver {
|
|
@@ -137,37 +161,33 @@ class GeneralParamFragmentVM @Inject constructor(private val mRepo: GeneralParam
|
|
|
// mRepo.threadGeneralParam.writeData(plcParamAddressEnum.address, data)
|
|
|
// }
|
|
|
fun disposeData(messageEvent: VBoxMessage) {
|
|
|
- when (messageEvent.cmd) {
|
|
|
- VboxCommand.CMD_HEARTBEAT -> {
|
|
|
- Log.d(TAG, "disposeData:1 回来的数据: " + messageEvent.data)
|
|
|
- when (messageEvent.data.substring(2, 4)) {
|
|
|
- "01" -> {
|
|
|
- cmdHeartbeat(messageEvent)
|
|
|
- Log.d(TAG, "disposeData:2 回来的数据: " + messageEvent.data)
|
|
|
- }
|
|
|
- "02" -> {
|
|
|
- if (mRepo.threadGeneralParam.isActiveParam ){
|
|
|
- getParam(messageEvent)
|
|
|
- }
|
|
|
- Log.d(TAG, "disposeData:3 GET_PARAM_ID")
|
|
|
- if (mRepo.threadGeneralParam.isActiveParam == false) {
|
|
|
- //关掉一些东西 ,比如:数据展示,关掉加载框,关掉全部的
|
|
|
- mRepo.threadGeneralParam.destroy()
|
|
|
- //设置readAllDataSuccess为true
|
|
|
- _readAllDataSuccess.value = true
|
|
|
- Log.d(TAG, "disposeData:4 GET_PARAM_ID")
|
|
|
- }
|
|
|
- }
|
|
|
+ val getSign = messageEvent.data.substring(2, 4)
|
|
|
+ when (getSign) {
|
|
|
+ "02" -> {
|
|
|
+ if (readAllDataSuccess.value == false) {
|
|
|
+ Log.d(TAG, "参数页 disposeData: ")
|
|
|
+ getParam(messageEvent)
|
|
|
}
|
|
|
+// Log.d(TAG, "disposeData:3 GET_PARAM_ID")
|
|
|
+// if (!mRepo.threadGeneralParam.isActiveParam) {
|
|
|
+// //关掉一些东西 ,比如:数据展示,关掉加载框,关掉全部的
|
|
|
+// mRepo.threadGeneralParam.destroy()
|
|
|
+// //设置readAllDataSuccess为true
|
|
|
+// _readAllDataSuccess.value = true
|
|
|
+// Log.d(TAG, "disposeData:4 GET_PARAM_ID")
|
|
|
+// }
|
|
|
+ }
|
|
|
+ "03" -> {
|
|
|
+ cmdHeartbeat(messageEvent)
|
|
|
+ Log.d(TAG, "disposeData:2 回来的数据: " + messageEvent.data)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private fun cmdHeartbeat(messageEvent: VBoxMessage) {
|
|
|
- //调试页的内容
|
|
|
val data = messageEvent.data.substring(76, 78)
|
|
|
Log.d(TAG, "CMD_PARAM 修改的参数: " + data + ":" + getAddress)
|
|
|
- if (data == getAddress) {
|
|
|
+ if (data!="00") {
|
|
|
mRepo.threadGeneralParam.jobWriteData?.cancel()
|
|
|
}
|
|
|
}
|