Browse Source

mod:mcu 初始化

panqiuyao 8 months ago
parent
commit
71216ae258
2 changed files with 39 additions and 2 deletions
  1. 1 1
      frontend/src/components/check/index.vue
  2. 38 1
      frontend/src/stores/modules/check.ts

+ 1 - 1
frontend/src/components/check/index.vue

@@ -51,7 +51,7 @@
     </div>
     <template #footer v-if="!checkLoading">
         <div class="flex" v-if="!checkSuccess">
-            <div class="check-btn" @click="reCheck">重新监测</div>
+            <div class="check-btn cu-p" @click="reCheck">重新监测</div>
         </div>
         <div class="flex" v-else>
             <div class="check-btn cu-p" style="width: 180px" @click="confirm()">正常,开始下一步</div>

+ 38 - 1
frontend/src/stores/modules/check.ts

@@ -8,6 +8,7 @@ const socketStore = socket();
 const clientStore = client();
 
 export const checkInfo = defineStore('checkInfo', () => {
+
     // 定义设备列表
     const devices = reactive({
         mcu: {
@@ -35,6 +36,11 @@ export const checkInfo = defineStore('checkInfo', () => {
     const checkTime = ref(0)
     let CKTimerInterval:any = null
 
+    //mcu 初始化
+    const mcu = reactive({
+        isInitSend:false,
+        status:0,
+    })
     // 计算完成进度
     const getProgress = computed(() => {
         let completed = 0;
@@ -47,10 +53,18 @@ export const checkInfo = defineStore('checkInfo', () => {
 
     // 获取错误信息
     const getErrorMsg = computed(() => {
+
+        if(mcu.status === -1){
+            clearInterval(CKTimerInterval)
+            checkTime.value = 0
+            mcu.isInitSend = false
+            return '相机初始化失败,请重新监测或强制初始化!';
+        }
         for (const device of Object.values(devices)) {
             if (device.status === -1) {
                 clearInterval(CKTimerInterval)
                 checkTime.value = 0
+                mcu.isInitSend = false
                 return device.msg;
             }
         }
@@ -99,8 +113,31 @@ export const checkInfo = defineStore('checkInfo', () => {
             await socketStore.connectSocket();
             await socketStore.sendMessage({ type: messageType });
             clientStore.ipc.on(icpList.socket.message+'_'+deviceName, (event, result) => {
+
+                console.log(result);
                 if (result && checkTime.value > 0) {
-                    if([-1,0,2].includes(result.status)){
+                    if(deviceName === 'mcu'){
+                        console.log(result);
+                        if(result.status === 2 ){
+                            if(!mcu.isInitSend){
+                                socketStore.sendMessage({ type: 'init_mcu' });
+                                mcu.isInitSend = true
+                                mcu.status = 1
+                            }
+                            if(mcu.isInitSend && result.msg === '设备初始化完成'){
+                                devices[deviceName].status = result.status;
+                                devices[deviceName].msg = result.msg;
+                                mcu.status = 2
+                            }
+                            if(checkTime.value >= 60 &&   mcu.status !== 2){
+                                mcu.status == -1;
+                            }
+                        }
+                        if([-1,0].includes(result.status)){
+                            devices[deviceName].status = result.status;
+                            devices[deviceName].msg = result.msg;
+                        }
+                    }else if([-1,0,2].includes(result.status)){
                         devices[deviceName].status = result.status;
                         devices[deviceName].msg = result.msg;
                     }