|
@@ -16,12 +16,13 @@ import com.hboxs.serialport.sbc.frame.VboxCommand
|
|
|
import com.hboxs.serialport.sbc.frame.VboxWriteCommand
|
|
|
import com.module.backstage.model.ApkInfoBean
|
|
|
import com.quyunshuo.sbm10.base.BaseApplication
|
|
|
-import com.quyunshuo.sbm10.base.addressenum.PlcSettingAddressEnum
|
|
|
import com.quyunshuo.sbm10.base.ktx.launchIO
|
|
|
import com.quyunshuo.sbm10.base.mvvm.vm.BaseViewModel
|
|
|
import com.quyunshuo.sbm10.base.utils.SpUtils
|
|
|
import com.quyunshuo.sbm10.common.constant.Heartbeat
|
|
|
import com.quyunshuo.sbm10.common.constant.MMKVName
|
|
|
+import com.quyunshuo.sbm10.common.constant.MqName
|
|
|
+import com.quyunshuo.sbm10.common.constant.event.ApiMessageEvent
|
|
|
import com.quyunshuo.sbm10.common.enums.ConnectStateEnum
|
|
|
import com.quyunshuo.sbm10.common.util.ToastUtil
|
|
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
@@ -31,6 +32,7 @@ import kotlinx.coroutines.Job
|
|
|
import kotlinx.coroutines.delay
|
|
|
import kotlinx.coroutines.flow.catch
|
|
|
import kotlinx.coroutines.launch
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
import javax.inject.Inject
|
|
|
|
|
|
/**
|
|
@@ -100,24 +102,24 @@ class SettingViewModel @Inject constructor(private val mRepo: SettingRepository)
|
|
|
}
|
|
|
|
|
|
fun initOutSystem() {
|
|
|
- if (Heartbeat.clientId == null || Heartbeat.clientId == ""&&SpUtils.getString(
|
|
|
- MMKVName.MANAGER_ID,
|
|
|
- "")!="2855") {
|
|
|
+// if (Heartbeat.clientId == null || Heartbeat.clientId == "" && SpUtils.getString(MMKVName.MANAGER_ID, "") != "2855") {
|
|
|
+ if (SpUtils.getString(MMKVName.MANAGER_ID, "") != "2855"&&SpUtils.getString(MMKVName.MANAGER_ID, "") != "39034") {
|
|
|
ToastUtil.switchToastStyleToWarn("无法脱离系统")
|
|
|
return
|
|
|
}
|
|
|
+ EventBus.getDefault().post(ApiMessageEvent(MqName.DIVORCE_SYSTEM, ""))
|
|
|
+
|
|
|
//脱离系统
|
|
|
- viewModelScope.launch(Dispatchers.IO) {
|
|
|
- mRepo.initOutSystem().catch {
|
|
|
- Log.d(TAG, "initDev onerror: " + it)
|
|
|
- }.collect {
|
|
|
- CoroutineScope(Dispatchers.Main).launch {
|
|
|
- Log.d(TAG, "initDev onnext: " + it)
|
|
|
- ToastUtil.switchToastStyleToSuccess(it)
|
|
|
- _connectOut.value=true
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// viewModelScope.launch(Dispatchers.IO) {
|
|
|
+// mRepo.initOutSystem().catch {
|
|
|
+// Log.d(TAG, "initDev onerror: " + it)
|
|
|
+// }.collect {
|
|
|
+// CoroutineScope(Dispatchers.Main).launch {
|
|
|
+// Log.d(TAG, "initDev onnext: " + it)
|
|
|
+// _connectOut.value=true
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
fun initDev(text: String?) {
|