Browse Source

mod:开发者设置

panqiuyao 8 months ago
parent
commit
df50a926f7

+ 7 - 3
electron/controller/socket.js

@@ -6,6 +6,11 @@ const CoreWindow = require('ee-core/electron/window');
 const WebSocket = require('ws'); // 引入原生 ws 库
 let socket = null;
 const { pyapp } = require('../config/app.config.json')
+
+const typeToMessage = {
+  run_mcu_single_finish:"seeting",
+  get_deviation_data:"developer"
+}
 class SocketController extends Controller {
   constructor(ctx) {
     super(ctx);
@@ -43,10 +48,9 @@ class SocketController extends Controller {
           console.log(this_data);
           if(this_data.msg_type){
             let channel = 'controller.socket.message_'+this_data.msg_type;
-            if(this_data.msg_type === 'run_mcu_single_finish' ){
-              this.app.electron['seeting'].webContents.send(channel, this_data);
+            if(typeToMessage[this_data.msg_type]){
+              this.app.electron[typeToMessage[this_data.msg_type]].webContents.send(channel, this_data);
             }else{
-
               win.webContents.send(channel, this_data);
             }
           }

+ 44 - 1
frontend/src/components/header-bar/index.vue

@@ -76,7 +76,12 @@ const menuType = reactive({
   remoteControl: {
     name: '模拟遥控器',
     icon: iconykq,
-    click: openSetting
+    click: openRemoteControl
+  },
+  developer: {
+    name: '开发者设置',
+    icon: iconykq,
+    click: openDeveloper
   }
 });
 
@@ -118,6 +123,44 @@ function openSetting() {
   clientStore.ipc.send(icpList.utils.openMain, params);
 }
 
+
+function openRemoteControl(){
+
+  const { href } = Router.resolve({
+    name: 'RemoteControl',
+  })
+
+  clientStore.ipc.removeAllListeners(icpList.utils.openMain);
+  let params = {
+    title: '模拟遥控器',
+    width: 350,
+    height: 600,
+    frame: true,
+    id: "RemoteControl",
+    url: getRouterUrl(href)
+  }
+  clientStore.ipc.send(icpList.utils.openMain, params);
+}
+
+
+function openDeveloper(){
+
+  const { href } = Router.resolve({
+    name: 'developer',
+  })
+
+  clientStore.ipc.removeAllListeners(icpList.utils.openMain);
+  let params = {
+    title: '开发者设置',
+    width: 900,
+    height: 620,
+    frame: true,
+    id: "developer",
+    url: getRouterUrl(href)
+  }
+  clientStore.ipc.send(icpList.utils.openMain, params);
+}
+
 function loginOut(){
   useUserInfoStore.loginOut();
   useUserInfoStore.updateLoginShow(true)

+ 9 - 1
frontend/src/router/index.ts

@@ -5,7 +5,7 @@ import { authGuard } from './plugins/authGuard'
 const routes: RouteRecordRaw[] = [
     {
         path: "/",
-        redirect: "/photography/check"
+        redirect: "/home"
     },
     {
         path: "/home",
@@ -63,6 +63,14 @@ const routes: RouteRecordRaw[] = [
             title: '遥控器'
         }
     },
+    {
+        path: "/developer",
+        name: "developer",
+        component: () => import("@/views/Developer/index.vue"),
+        meta: {
+            title: '遥控器'
+        }
+    },
 ];
 
 const router = createRouter({

+ 149 - 0
frontend/src/views/Developer/index.vue

@@ -0,0 +1,149 @@
+<template>
+
+
+  <headerBar
+    title="开发者配置"
+  />
+
+  <el-row>
+    <el-col :span="24"><h3>相机设置</h3></el-col>
+  </el-row>
+  <el-row>
+    <el-col :span="6">电机偏移mm:</el-col>
+    <el-col :span="12"><el-input v-model="editRowData.camera_high_motor_deviation" type="number"/></el-col>
+    <el-col :span="6"><el-button>设定</el-button></el-col>
+  </el-row>
+  <el-row class="mar-top-10">
+    <el-col :span="6">舵机偏移(度):</el-col>
+    <el-col :span="12"><el-input v-model="editRowData.camera_steering_deviation" type="number"/></el-col>
+    <el-col :span="6"><el-button>设定</el-button></el-col>
+  </el-row>
+
+
+
+  <el-row>
+    <el-col :span="24"><h3>转盘设置</h3></el-col>
+  </el-row>
+  <el-row>
+    <el-col :span="6">角度偏移 (度):</el-col>
+    <el-col :span="12"><el-input v-model="editRowData.turntable_steering_deviation" type="number"/></el-col>
+    <el-col :span="6"><el-button>设定</el-button></el-col>
+  </el-row>
+  <el-row class="mar-top-10">
+    <el-col :span="6">前后偏移:</el-col>
+    <el-col :span="12"><el-input v-model="editRowData.turntable_front_end_deviation" type="number"/></el-col>
+    <el-col :span="6"><el-button>设定</el-button></el-col>
+  </el-row>
+
+
+
+  <el-row>
+    <el-col :span="24"><h3>翻版舵机</h3></el-col>
+  </el-row>
+  <el-row>
+    <el-col :span="6">中位:</el-col>
+    <el-col :span="12"><el-input v-model="editRowData.overturn_steering_middle" type="number"/></el-col>
+    <el-col :span="6"><el-button>设定</el-button></el-col>
+  </el-row>
+  <el-row class="mar-top-10">
+    <el-col :span="6">高位:</el-col>
+    <el-col :span="12"><el-input v-model="editRowData.overturn_steering_high" type="number"/></el-col>
+    <el-col :span="6"><el-button>设定</el-button></el-col>
+  </el-row>
+  <el-row class="mar-top-10">
+    <el-col :span="6">上升速度:</el-col>
+    <el-col :span="12"><el-input v-model="editRowData.overturn_steering_up_speed" type="number"/></el-col>
+    <el-col :span="6"><el-button>设定</el-button></el-col>
+  </el-row>
+  <el-row class="mar-top-10">
+    <el-col :span="6">下降速度:</el-col>
+    <el-col :span="12"><el-input v-model="editRowData.overturn_steering_down_speed" type="number"/></el-col>
+    <el-col :span="6"><el-button>设定</el-button></el-col>
+  </el-row>
+
+
+  <el-row align="middle" justify="middle" class="mar-top-20">
+    <el-col :span="24">
+      <el-button type="primary" @click="get_deviation">读取偏移量</el-button>
+      <el-button type="primary" @click="connect_mcu__init">设备初始化</el-button>
+    </el-col>
+  </el-row>
+
+
+</template>
+
+<script setup lang="ts">
+
+import {ref,reactive,onMounted} from "vue";
+
+import client from "@/stores/modules/client";
+import  icpList from '@/utils/ipc'
+import socket from "@/stores/modules/socket";
+import {ElMessage} from "element-plus";
+const clientStore = client();
+const socketStore = socket()
+
+
+const editRowData = reactive({
+  "camera_high_motor_deviation": '',
+  "camera_steering_deviation": '',
+  "turntable_steering_deviation": '',
+  "turntable_front_end_deviation":'',
+  "overturn_steering_middle": '',
+  "overturn_steering_high": '',
+  "overturn_steering_up_speed": '',
+  "overturn_steering_down_speed": ''
+}); // 当前编辑行的数据
+
+onMounted(()=>{
+  get_deviation()
+})
+
+//获取配置
+async function  get_deviation(){
+  if(clientStore.isClient){
+
+    socketStore.sendMessage({
+      type: 'get_deviation',
+      data:"get_deviation"
+    })
+
+
+    clientStore.ipc.on(icpList.socket.message+'_get_deviation_data', (event, result) => {
+      console.log('_get_deviation_data')
+      console.log(result)
+      if(result.code === 0){
+        editRowData.camera_high_motor_deviation = result.data.camera_high_motor_deviation
+        editRowData.camera_steering_deviation = result.data.camera_steering_deviation
+        editRowData.turntable_steering_deviation = result.data.turntable_steering_deviation
+        editRowData.turntable_front_end_deviation = result.data.turntable_front_end_deviation
+
+        editRowData.overturn_steering_middle = result.data.overturn_steering_middle
+        editRowData.overturn_steering_high = result.data.overturn_steering_high
+        editRowData.overturn_steering_up_speed = result.data.overturn_steering_up_speed
+        editRowData.overturn_steering_down_speed = result.data.overturn_steering_down_speed
+      }else if(result.msg){
+        ElMessage.error(result.msg)
+      }
+      clientStore.ipc.removeAllListeners(icpList.socket.message+'_get_deviation_data');
+    });
+  }
+}
+
+
+
+//MCU初始化
+async function  connect_mcu__init(){
+  if(clientStore.isClient){
+
+    socketStore.sendMessage({
+      type: 'init_mcu',
+      data:"init_mcu"
+    })
+  }
+}
+
+</script>
+
+<style scoped lang="scss">
+</style>

+ 4 - 2
frontend/src/views/Home/index.vue

@@ -9,14 +9,16 @@
         },
         {
           type:'remoteControl'
-        },
+        },{
+            type: 'developer'
+        }
     ]"
   />
   <div class="mb-4">
 
     <template v-if="!show">
       <div>{{useUserInfoStore.userInfo.account_name}}</div>
-      <div>{{useUserInfoStore.userInfo.phone}}</div>
+      <div>{{useUserInfoStore.userInfo.brand_company_code}}</div>
     </template>
     <template v-else>
       <img :src="src" width="500px" height="500px"/>

+ 3 - 0
frontend/src/views/Photography/check.vue

@@ -88,6 +88,9 @@ function checkConfirm(init){
     menu.push({
       type:'setting'
     })
+    menu.push({
+      type:'developer'
+    })
   }
   if(!init) previewKey.value++;
 

+ 3 - 3
frontend/src/views/RemoteControl/index.vue

@@ -22,11 +22,11 @@
       <el-col :span="8"></el-col>
     </el-row>
     <el-row align="middle" class="mar-top-50">
-      <el-col :span="1"></el-col>
+      <el-col :span="3"></el-col>
       <el-col :span="8"><div class="button up">继续</div></el-col>
-      <el-col :span="6"></el-col>
+      <el-col :span="2"></el-col>
       <el-col :span="8"><div class="button up">停止</div></el-col>
-      <el-col :span="1"></el-col>
+      <el-col :span="3"></el-col>
     </el-row>
   </div>