Browse Source

mod:拍摄物体 镜头矫正

panqiuyao 7 months ago
parent
commit
56243914b1

+ 10 - 0
electron/api/setting.js

@@ -21,6 +21,16 @@ module.exports = {
       }
     })
   },
+  //根据条件查询可执行程序-单条
+  getDeviceConfigDetailQuery(data){
+    return post({
+      url: '/device_config_detail_query',
+      data: data,
+      headers:{
+        'Content-Type':"application/json",
+      }
+    })
+  },
 
 
   //删除

+ 6 - 2
electron/controller/setting.js

@@ -5,7 +5,7 @@ const Log = require('ee-core/log');
 const Services = require('ee-core/services');
 const path = require('path');
 const fs = require('fs');
-const { getDeviceConfigs, getDeviceConfigDetail, removeConfig, saveDeviceConfig, resetDeviceConfig,updateSysConfigs,getSysConfig } = require('../api/setting');
+const { getDeviceConfigs, getDeviceConfigDetail,getDeviceConfigDetailQuery, removeConfig, saveDeviceConfig, resetDeviceConfig,updateSysConfigs,getSysConfig } = require('../api/setting');
 
 const errData = {
   msg :'请求失败,请联系管理员',
@@ -43,7 +43,11 @@ class SettingController extends Controller {
    */
   async getDeviceConfigDetail(args) {
     try {
-      const result = await getDeviceConfigDetail(args);
+      let fun = getDeviceConfigDetail
+      if(!args.id) {
+        fun =  getDeviceConfigDetailQuery
+      }
+      const result = await fun(args);
       if(result.data)  return result.data
       return errData;
     } catch (error) {

+ 86 - 54
frontend/src/views/Photography/check.vue

@@ -1,20 +1,24 @@
 <template>
 
   <headerBar
+      v-if="!isSetting"
       title="拍摄物体镜头矫正"
       :menu="menu"
       showUser
   />
-  <div class="check-wrap flex">
+  <div class="check-wrap">
 
-    <div class="check-page flex-col">
+    <div class="check-page flex-col" :class="isSetting ? 'check-page_seeting' : '' ">
       <div class="main-container flex-col">
         <div class="content-wrapper flex-row justify-between">
           <div class="left-panel flex-col justify-between">
             <div class="tips-container flex-row" v-if="show">
-              <img class="tips-icon" referrerpolicy="no-referrer" src="@/assets/images/Photography/tips-icon.png" />
-              <span class="tips-tex">请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐</span>
-              <img class="close-icon cu-p" referrerpolicy="no-referrer" src="@/assets/images/Photography/close-icon.png"  @click="show = false"/>
+                <spanc  v-if="isSetting" class="tips-tex">
+                  请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐,如果光亮不够,可以打开光源。
+                </spanc>
+                <span v-else class="tips-tex">
+                  请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐,可以打开光源。
+                </span>
             </div>
             <div class="camera-preview  flex col center ">
               <span v-if="step === 1" class="fs-14">
@@ -24,56 +28,78 @@
                 <img class="camera-img" :src="imageUrl+'?key='+imageUrlkey" />
                 <span  class="camera-description">这是一张用于检查镜头是否合适的测试图</span>
               </template>
+
+              <div class="example-image flex-col" v-if="!isSetting"><img src="https://huilimaimg.cnhqt.com/frontend/zhihuiyin/demo.jpg?x-oss-process=image/resize,w_400"></div>
             </div>
           </div>
-          <div class="example-image flex-col"><img src="https://huilimaimg.cnhqt.com/frontend/zhihuiyin/demo.jpg?x-oss-process=image/resize,w_400"></div>
-        </div>
-        <div v-if="step === 1" class="action-button flex cente">
-          <div @click="takePictures" class="check-button  button--primary1 flex-col"><span class="button-text" v-loading="loading">拍照检查</span>
-          </div>
         </div>
 
-        <div v-else class="action-button flex center">
-          <div @click="checkConfirm(false)" class="check-button  button--white flex-col">
-            <span class="button-text cu-p">重新拍照检查</span>
+        <template v-if="!isSetting">
+          <div v-if="step === 1" class="action-button flex cente">
+            <div @click="takePictures" class="check-button  button--primary1 flex-col"><span class="button-text" v-loading="loading">拍照检查</span>
+            </div>
           </div>
-          <router-link class="mar-left-20 " :to="{
-            name: 'PhotographyShot'
-          }">
-            <div class="check-button   button--primary1 flex-col">
-              <span class="button-text cu-p">确认无误,下一步</span>
+
+          <div v-else class="action-button flex center">
+            <div @click="checkConfirm(false)" class="check-button  button--white flex-col">
+              <span class="button-text cu-p">重新拍照检查</span>
             </div>
-          </router-link>
+            <router-link class="mar-left-20 " :to="{
+              name: 'PhotographyShot'
+            }">
+              <div class="check-button   button--primary1 flex-col">
+                <span class="button-text cu-p">确认无误,下一步</span>
+              </div>
+            </router-link>
 
-        </div>
+          </div>
+
+        </template>
       </div>
     </div>
 
-  </div>
+    <editRow
+      :id="id"
+      @confirm="confirm"
+    />
 
+  </div>
+<!--
   <hardware-check
    isInitCheck
    @confirm="checkConfirm(true)"
-  />
+  />-->
 </template>
 <script setup lang="ts">
-import  { watchEffect,ref, reactive } from  'vue'
+import {watchEffect, ref, reactive, defineEmits, defineProps, computed, onBeforeUnmount} from 'vue'
 import client from "@/stores/modules/client";
 import icpList from '@/utils/ipc'
 import useUserInfo from "@/stores/modules/user";
 import headerBar from '@/components/header-bar/index.vue'
+import  editRow  from './components/editRow'
 const clientStore = client();
 
+const emit = defineEmits([ 'confirm']);
+// 定义 props
+const props = defineProps({
+  id:{
+    type: Number||String,
+    default: 0
+  }
+})
 const menu = reactive([])
 const show = ref(true)
 
+const isSetting = computed(()=>{
+  return props.id
+})
+
 const useUserInfoStore = useUserInfo()
 import HardwareCheck from '@/components/check/index.vue'
-function onCheckComplete(){
-
+function confirm(){
+  emit('confirm')
 }
 
-import { ref,onBeforeUnmount } from 'vue'
 import socket from "../../stores/modules/socket";
 import { digiCamControlWEB } from  '@/utils/appconfig'
 const imageUrl = ref(digiCamControlWEB+'preview.jpg')
@@ -169,36 +195,34 @@ onBeforeUnmount(() => {
 </script>
 <style scoped lang="scss">
 .check-wrap {
-
   background-color: rgba(234, 236, 237, 1);
-  width: 100%;
-  min-height: calc(100vh - 30px);
   display: flex;
+  justify-content: left;
 }
 .check-page {
+  width: calc(100% - 330px) ;
   position: relative;
-  width: 1200px;
-  height: 768px;
+  min-height: calc(100vh - 35px);
   overflow: hidden;
+  background: #fff;
 
   .main-container {
-    width: 1200px;
-    height: 739px;
+    width: 100%;
+    min-height: calc(100vh - 35px);
     margin-bottom: 1px;
 
     .content-wrapper {
-      width: 896px;
-      height: 644px;
-      margin: 10px 0 0 284px;
+      width:100%;
+      padding: 10px;
 
       .left-panel {
-        width: 633px;
-        height: 644px;
+        width: 100%;
+        height: calc(100% - 80px);
 
         .tips-container {
           background-color: rgba(255, 241, 222, 0.8);
           border-radius: 4px;
-          width: 633px;
+          width: 100%;
           height: 40px;
           border: 1px solid rgba(255, 228, 190, 1);
           justify-content: flex-center;
@@ -232,11 +256,10 @@ onBeforeUnmount(() => {
         .camera-preview {
           box-shadow: 0px 2px 10px 0px rgba(0, 32, 78, 0.1);
           background-color: rgba(255, 255, 255, 1);
-          height: 600px;
-          width: 600px;
-          margin: 4px 0 0 16px;
+          height:  calc(100vh - 200px);
+          position: relative;
+          margin-top: 20px;
           position: relative;
-
           .camera-description {
             position: absolute;
             bottom: 20px;
@@ -251,20 +274,23 @@ onBeforeUnmount(() => {
             width: 100%;
 
           }
+          .example-image {
+            position: absolute;
+            right: 10px;
+            bottom: 10px;
+            background-color: rgba(216, 216, 216, 1);
+            height: 200px;
+            margin-top: 10px;
+            width: 200px;
+            img {
+              width: 200px;
+              height: 200px;
+              display: block;
+            }
+          }
         }
       }
 
-      .example-image {
-        background-color: rgba(216, 216, 216, 1);
-        height: 200px;
-        margin-top: 10px;
-        width: 200px;
-        img {
-          width: 200px;
-          height: 200px;
-          display: block;
-        }
-      }
     }
 
     .action-button {
@@ -286,4 +312,10 @@ onBeforeUnmount(() => {
     }
   }
 }
+.check-page_seeting {
+  min-height: calc(100vh - 5px);
+  .main-container {
+    min-height: calc(100vh - 5px);
+  }
+}
 </style>

+ 341 - 0
frontend/src/views/Photography/components/editRow.vue

@@ -0,0 +1,341 @@
+<template>
+  <div class="editrow_wrap" v-if="initStatus">
+    <div class="config-type">参数值编辑:<el-checkbox v-model="isDefault">开启运动调试</el-checkbox></div>
+    <el-form class="editForm" :model="editRowData" label-width="100px">
+      <el-form-item label="动作名称">
+        <el-input v-model="editRowData.action_name" style="width: 170px;"/>
+      </el-form-item>
+      <el-form-item label="是否拍照">
+        <el-radio-group v-model="editRowData.take_picture">
+          <el-radio :label="true">拍照</el-radio>
+          <el-radio :label="false">不拍照</el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item label="相机高度(mm)">
+        <el-input v-model="editRowData.camera_height" @change="changeNum('camera_high_motor',0, 400)" :min="0" :max="400" :step="1"  style="width: 170px;" type="number">
+        </el-input>
+        <div class="error-msg">最小0,最大400</div>
+      </el-form-item>
+      <el-form-item label="相机倾角">
+        <el-input v-model="editRowData.camera_angle" :min="-40" :max="40" :step=".1" @change="changeNum('camera_steering',-40, 40)" style="width: 170px;" type="number">
+        </el-input>
+        <div class="error-msg">最小-40,最大40</div>
+      </el-form-item>
+      <el-form-item label="转盘前后位置">
+        <el-input v-model="editRowData.turntable_position" @change="changeNum('turntable_position_motor',0, 800)" :min="0" :max="800" :step="1"  style="width: 170px;" type="number">
+        </el-input>
+        <div class="error-msg">最小0,最大800</div>
+      </el-form-item>
+      <el-form-item label="转盘角度">
+        <el-input v-model="editRowData.turntable_angle" @change="changeNum('turntable_steering',-720, 720)" :min="-720" :max="720" :step="1"  style="width: 170px;" type="number">
+        </el-input>
+        <div class="error-msg">最小-720,最大720</div>
+      </el-form-item>
+      <el-form-item label="鞋子翻转">
+        <div class="flex-row">
+          <el-radio-group v-model="editRowData.shoe_upturn">
+            <el-radio :label="true">翻转</el-radio>
+            <el-radio :label="false">不翻转</el-radio>
+          </el-radio-group>
+          <a class="cursor-pointer" @click="changeNum('overturn_steering')">测试翻转</a>
+        </div>
+      </el-form-item>
+      <el-form-item label="LED灯光开光" @change="changeNum('laser_position')">
+        <el-radio-group v-model="editRowData.led_switch">
+          <el-radio :label="false">关闭</el-radio>
+          <el-radio :label="true">开启</el-radio>
+        </el-radio-group>
+      </el-form-item>
+      <el-form-item label="对焦次数">
+        <el-input v-model="editRowData.number_focus" @change="changeNum('take_picture',0, 1)" :min="0" :max="1" :step="1"  style="width: 170px;" type="number">
+        </el-input>
+        <div class="error-msg">最小0,最大1</div>
+      </el-form-item>
+      <el-form-item label="拍照前延时(秒)">
+        <el-input v-model="editRowData.pre_delay" :min="0" :max="99" :step="1" @change="changeNum('pre_delay',0, 99)" style="width: 170px;" type="number">
+        </el-input>
+        <div class="error-msg">最小0,最大99</div>
+      </el-form-item>
+      <el-form-item label="拍照后延时(秒)">
+        <el-input v-model="editRowData.after_delay" :min="0" :max="99" :step="1" @change="changeNum('after_delay',0, 99)" style="width: 170px;" type="number">
+        </el-input>
+        <div class="error-msg">最小0,最大99</div>
+      </el-form-item>
+    </el-form>
+    <div class="btn-row">
+        <div class="primary-btn" @click="saveRow" v-if="id">{{ id ? '保存并关闭' : '保存' }}</div>
+      </div>
+  </div>
+
+</template>
+
+<script setup lang="ts">
+import { ref, defineProps, defineEmits , watch, onMounted } from 'vue'
+import icpList from '@/utils/ipc';
+import { digiCamControlWEB } from  '@/utils/appconfig'
+import {ElMessage} from "element-plus";
+import client from "@/stores/modules/client";
+const clientStore = client();
+import socket from "@/stores/modules/socket";
+const socketStore = socket(); // WebSocket状态管理实例
+
+const emit = defineEmits([ 'confirm']);
+// 定义 props
+const props = defineProps({
+  id:{
+    type: Number||String,
+    default: 0
+  }
+})
+
+const initStatus = ref(false)
+const isDefault = ref(true); // 是否为默认配置
+const editRowData = ref({}); // 当前编辑行的数据
+onMounted(()=>{
+  let params = {
+    id: props.id
+  }
+  if(!props.id) params = {
+    mode_type:"执行左脚程序",
+    action_name:"侧视图",
+  }
+  clientStore.ipc.removeAllListeners(icpList.setting.getDeviceConfigDetail);
+  clientStore.ipc.send(icpList.setting.getDeviceConfigDetail, params);
+  clientStore.ipc.on(icpList.setting.getDeviceConfigDetail, (event, result) => {
+    editRowData.value = result.data;
+    clientStore.ipc.removeAllListeners(icpList.setting.getDeviceConfigDetail);
+    initStatus.value = true;
+  });
+
+})
+
+
+/**
+ * 修改设备配置数值。
+ * @param {string} type - 配置类型
+ */
+async function changeNum(type, min, max) {
+  let socketValue = {
+    'camera_high_motor': 'camera_height',
+    'turntable_steering': 'turntable_angle',
+    'turntable_position_motor': 'turntable_position',
+    'camera_steering': 'camera_angle',
+    'overturn_steering': 'shoe_upturn',
+    'laser_position': 'led_switch',
+    'take_picture': 'number_focus',
+  };
+  if(min || max){
+    if(editRowData.value[socketValue[type]] < min || editRowData.value[socketValue[type]] > max){
+      if(editRowData.value[socketValue[type]] < min){
+        editRowData.value[socketValue[type]] = min;
+      }else{
+        editRowData.value[socketValue[type]] = max;
+      }
+      ElMessage.error(`${type}值应在${min}到${max}之间`);
+      return;
+    }
+  }
+  if(type=='pre_delay' || type=='after_delay'){
+    return
+  }
+  if (isDefault.value) {
+    socketStore.sendMessage({
+      type: 'control_mcu',
+      data: {
+        device_name: type,
+        value: type == 'laser_position' ? (editRowData.value.led_switch ? "1" : "0") : editRowData.value[socketValue[type]]
+      }
+    });
+  }
+}
+
+
+/*测试拍照*/
+const captureLoading = ref(false)
+const imageUrl = ref(digiCamControlWEB+'preview.jpg')
+const imageUrlkey = ref(0)
+function testShoesFlip(){
+  if (clientStore.isClient) {
+
+    socketStore.sendMessage({
+      type: 'run_mcu_single',
+      data: {
+        camera_height: Number(editRowData.value.camera_height),
+        camera_angle:  Number(editRowData.value.camera_angle),
+        led_switch:editRowData.value.led_switch,
+        id:0,
+        mode_type:'执行'+ activeTab.value === 'left' ? '左脚' : '右脚'+'程序',
+        turntable_position:Number(editRowData.value.turntable_position),
+        action_name:editRowData.value.action_name || '测试',
+        turntable_angle: Number(editRowData.value.turntable_angle),
+        shoe_upturn: Number(editRowData.value.shoe_upturn),
+        action_index:1,
+        number_focus:0,
+        take_picture:false,
+        pre_delay:0,
+        after_delay:0,
+      }
+    });
+    captureLoading.value = true;
+
+
+    clientStore.ipc.on(icpList.socket.message+'_run_mcu_single_finish', async (event, result) => {
+      console.log('_run_mcu_single_finish')
+      setTimeout(()=>{
+        clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
+        clientStore.ipc.send(icpList.camera.takePictures,false);
+        clientStore.ipc.on(icpList.camera.takePictures, async (event, result) => {
+          setTimeout(()=>{
+            imageUrlkey.value++;
+            console.log('preview')
+            preview(imageUrl.value+'?key='+imageUrlkey.value)
+            captureLoading.value = false;
+          },8000)
+          clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
+        })
+      },1000)
+
+
+    })
+  }
+}
+
+
+/**
+ * 保存当前编辑的配置。
+ */
+const saveRow = () => {
+  clientStore.ipc.send(icpList.setting.saveDeviceConfig, {
+    ...editRowData.value
+  });
+  clientStore.ipc.on(icpList.setting.saveDeviceConfig, (event, result) => {
+    if (result.code == 0) {
+      emit('confirm')
+      ElMessage.success('保存成功');
+      clientStore.ipc.removeAllListeners(icpList.setting.saveDeviceConfig);
+    } else {
+      ElMessage.error('保存失败');
+    }
+  });
+};
+
+
+</script>
+<style>
+</style>
+
+<style lang="scss" scoped>
+.editrow_wrap {
+}
+.config-type{
+  font-size: 16px;
+  color: #333333;
+  display: flex;
+  align-items: center;
+  justify-content: flex-start;
+  padding: 10px;
+  border-bottom: 1px solid #CCCCCC;
+  .el-checkbox{
+    margin-left: 10px;
+  }
+}
+.editForm{
+  padding: 10px;
+  display: grid;
+  grid-template-columns: repeat(1, 1fr);
+  gap: 0;
+  .flex-row{
+    display: flex;
+    align-items: center;
+    :deep(.el-radio){
+      margin-right: 6px !important;
+    }
+    :deep(.el-radio__label){
+      padding-left: 4px;
+    }
+  }
+  :deep(.el-form-item) {
+    margin-bottom: 0;
+    .el-form-item__label {
+      width: 120px !important;
+      padding-right: 0 !important;
+      background: #FBFCFF;
+      border: 1px solid #EEEEEE;
+      height: 41px;
+      line-height: 41px;
+      padding-left: 5px;
+      text-align: left;
+    }
+    .el-form-item__content {
+      width: 190px;
+      position: relative;
+      height: 41px;
+      background: #FFFFFF;
+      padding-left: 7px;
+      border: 1px solid #EEEEEE;
+      .el-input__wrapper {
+        box-shadow: none;
+      }
+      .error-msg{
+        display: none;
+        position: absolute;
+        top: 41px;
+        top: 28px;
+        left: 8px;
+        z-index: 22;
+        color: #dc2626;
+        font-size: 12px;
+      }
+      &:hover{
+        .error-msg{
+          display: block;
+        }
+      }
+
+      // 确保number类型输入框的上下箭头始终显示
+      input[type="number"]::-webkit-inner-spin-button,
+      input[type="number"]::-webkit-outer-spin-button {
+        opacity: 1;
+        height: 28px;
+        position: absolute;
+        top: 2px;
+        right: 2px;
+        cursor: pointer;
+      }
+
+      input[type="number"] {
+        -moz-appearance: number-input; /* Firefox */
+      }
+    }
+  }
+}
+
+.btn-row{
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  gap: 10px;
+}
+.primary-btn{
+  width: 100px;
+  height: 30px;
+  background: linear-gradient( 135deg, #2FB0FF 0%, #B863FB 100%);
+  border-radius: 4px;
+  color: #fff;
+  font-size: 14px;
+  text-align: center;
+  line-height: 30px;
+  cursor: pointer;
+}
+.normal-btn{
+  width: 100px;
+  height: 30px;
+  background: #fff;
+  border: 1px solid #CCCCCC;
+  border-radius: 4px;
+  font-size: 14px;
+  text-align: center;
+  line-height: 30px;
+  cursor: pointer;
+}
+</style>

+ 0 - 89
frontend/src/views/Setting/index.vue

@@ -772,95 +772,6 @@ const resetConfig = () => {
   });
 };
 
-/**
- * 修改设备配置数值。
- * @param {string} type - 配置类型
- */
-async function changeNum(type, min, max) {
-    let socketValue = {
-      'camera_high_motor': 'camera_height',
-      'turntable_steering': 'turntable_angle',
-      'turntable_position_motor': 'turntable_position',
-      'camera_steering': 'camera_angle',
-      'overturn_steering': 'shoe_upturn',
-      'laser_position': 'led_switch',
-      'take_picture': 'number_focus',
-    };
-    if(min || max){
-      if(editRowData.value[socketValue[type]] < min || editRowData.value[socketValue[type]] > max){
-        if(editRowData.value[socketValue[type]] < min){
-          editRowData.value[socketValue[type]] = min;
-        }else{
-          editRowData.value[socketValue[type]] = max;
-        }
-        ElMessage.error(`${type}值应在${min}到${max}之间`);
-        return;
-      }
-    }
-    if(type=='pre_delay' || type=='after_delay'){
-      return
-    }
-  if (isDefault.value) {
-    socketStore.sendMessage({
-      type: 'control_mcu',
-      data: {
-        device_name: type,
-        value: type == 'laser_position' ? (editRowData.value.led_switch ? "1" : "0") : editRowData.value[socketValue[type]]
-      }
-    });
-  }
-}
-
-
-/*测试拍照*/
-const captureLoading = ref(false)
-const imageUrl = ref(digiCamControlWEB+'preview.jpg')
-const imageUrlkey = ref(0)
-function testShoesFlip(){
-  if (clientStore.isClient) {
-
-    socketStore.sendMessage({
-      type: 'run_mcu_single',
-      data: {
-        camera_height: Number(editRowData.value.camera_height),
-        camera_angle:  Number(editRowData.value.camera_angle),
-        led_switch:editRowData.value.led_switch,
-        id:0,
-        mode_type:'执行'+ activeTab.value === 'left' ? '左脚' : '右脚'+'程序',
-        turntable_position:Number(editRowData.value.turntable_position),
-        action_name:editRowData.value.action_name || '测试',
-        turntable_angle: Number(editRowData.value.turntable_angle),
-        shoe_upturn: Number(editRowData.value.shoe_upturn),
-        action_index:1,
-        number_focus:0,
-        take_picture:false,
-        pre_delay:0,
-        after_delay:0,
-      }
-    });
-      captureLoading.value = true;
-
-
-    clientStore.ipc.on(icpList.socket.message+'_run_mcu_single_finish', async (event, result) => {
-      console.log('_run_mcu_single_finish')
-      setTimeout(()=>{
-        clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
-        clientStore.ipc.send(icpList.camera.takePictures,false);
-        clientStore.ipc.on(icpList.camera.takePictures, async (event, result) => {
-          setTimeout(()=>{
-            imageUrlkey.value++;
-            console.log('preview')
-            preview(imageUrl.value+'?key='+imageUrlkey.value)
-            captureLoading.value = false;
-          },8000)
-          clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
-        })
-      },1000)
-
-
-    })
-  }
-}