normal.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <headerBar
  3. title="初始设备调频设置"
  4. />
  5. <div class="page">
  6. <el-row>
  7. <el-col :span="24"><h3>相机设置</h3></el-col>
  8. </el-row>
  9. <el-row>
  10. <el-col :span="6">相机高度mm:</el-col>
  11. <el-col :span="12"><el-input
  12. @change="changeNum('相机电机','move_deviation','camera_high_motor_deviation',0, 50)"
  13. :min="0" :max="50"
  14. :step="1"
  15. v-model="editRowData.camera_high_motor_deviation" type="number"/>
  16. <div class="error-msg">最小0,最大50</div>
  17. </el-col>
  18. <el-col :span="6"><el-button
  19. @click="changeNum('相机电机','set_deviation','camera_high_motor_deviation',0, 50)"
  20. >设定</el-button></el-col>
  21. </el-row>
  22. <el-row class="mar-top-10">
  23. <el-col :span="6">相机角度(度):</el-col>
  24. <el-col :span="12"><el-input
  25. @change="changeNum('相机舵机','move_deviation','camera_steering_deviation',-90, 90)"
  26. :min="-90" :max="90"
  27. :step="0.1"
  28. v-model="editRowData.camera_steering_deviation" type="number"/>
  29. <div class="error-msg">最小-90,最大90</div>
  30. </el-col>
  31. <el-col :span="6"><el-button @click="changeNum('相机舵机','set_deviation','camera_steering_deviation',-90, 90)">设定</el-button></el-col>
  32. </el-row>
  33. <el-row>
  34. <el-col :span="24"><h3>转盘设置</h3></el-col>
  35. </el-row>
  36. <el-row>
  37. <el-col :span="6">角度偏移 (度):</el-col>
  38. <el-col :span="12"><el-input
  39. @change="changeNum('转盘舵机','move_deviation','turntable_steering_deviation',-720, 720)"
  40. :min="-720" :max="720"
  41. :step="1"
  42. v-model="editRowData.turntable_steering_deviation" type="number"/>
  43. <div class="error-msg">最小-720,最大720</div>
  44. </el-col>
  45. <el-col :span="6"><el-button @click="changeNum('转盘舵机','set_deviation','turntable_steering_deviation',-720, 720)">设定</el-button></el-col>
  46. </el-row>
  47. <el-row class="mar-top-10">
  48. <el-col :span="6">前后偏移:</el-col>
  49. <el-col :span="12"><el-input
  50. @change="changeNum('转盘前后电机','move_deviation','turntable_front_end_deviation',0, 950)"
  51. :min="0" :max="950"
  52. :step="1"
  53. v-model="editRowData.turntable_front_end_deviation" type="number"/>
  54. <div class="error-msg">最小0,最大950</div>
  55. </el-col>
  56. <el-col :span="6"><!--<el-button @click="changeNum('转盘前后电机','set_deviation','turntable_front_end_deviation',0, 950)">设定</el-button>--></el-col>
  57. </el-row>
  58. <el-row>
  59. <el-col :span="24"><h3>翻版舵机</h3></el-col>
  60. </el-row>
  61. <el-row>
  62. <el-col :span="6">中位:</el-col>
  63. <el-col :span="12"><el-input
  64. @change="changeNum('翻板舵机中位','move_deviation','overturn_steering_middle',0, 180)"
  65. :min="0" :max="180"
  66. :step="0.5"
  67. v-model="editRowData.overturn_steering_middle" type="number"/>
  68. <div class="error-msg">最小0,最大180</div>
  69. </el-col>
  70. <el-col :span="6"><el-button @click="changeNum('翻板舵机中位','set_deviation','overturn_steering_middle',0, 180)">设定</el-button></el-col>
  71. </el-row>
  72. <el-row class="mar-top-10">
  73. <el-col :span="6">高位:</el-col>
  74. <el-col :span="12"><el-input
  75. @change="changeNum('翻板舵机高位','move_deviation','overturn_steering_high',0, 180)"
  76. :min="0" :max="180"
  77. :step="0.5"
  78. v-model="editRowData.overturn_steering_high" type="number"/>
  79. <div class="error-msg">最小0,最大180</div>
  80. </el-col>
  81. <el-col :span="6"><el-button @click="changeNum('翻板舵机高位','set_deviation','overturn_steering_high',0, 180)">设定</el-button></el-col>
  82. </el-row>
  83. <el-row class="mar-top-10">
  84. <el-col :span="6">上升速度:</el-col>
  85. <el-col :span="12"><el-input
  86. @change="changeNum('翻板舵机上升速度','move_deviation','overturn_steering_up_speed',0, 10)"
  87. :min="0" :max="10"
  88. :step="1"
  89. v-model="editRowData.overturn_steering_up_speed" type="number"/>
  90. <div class="error-msg">最小0,最大10</div>
  91. </el-col>
  92. <el-col :span="6"><el-button @click="changeNum('翻板舵机上升速度','set_deviation','overturn_steering_up_speed',0, 10)">设定</el-button></el-col>
  93. </el-row>
  94. <el-row class="mar-top-10">
  95. <el-col :span="6">下降速度:</el-col>
  96. <el-col :span="12"><el-input
  97. @change="changeNum('翻板舵机下降速度','move_deviation','overturn_steering_down_speed',0, 10)"
  98. :min="0" :max="10"
  99. :step="1"
  100. v-model="editRowData.overturn_steering_down_speed" type="number"/>
  101. <div class="error-msg">最小0,最大10</div>
  102. </el-col>
  103. <el-col :span="6"><el-button @click="changeNum('翻板舵机下降速度','set_deviation','overturn_steering_down_speed',0, 10)">设定</el-button></el-col>
  104. </el-row>
  105. <el-row align="middle" justify="middle" class="mar-top-20 bottom-wrap">
  106. <el-col :span="24">
  107. <el-button type="primary" @click="connect_mcu__init">设备初始化</el-button>
  108. <el-button type="primary" @click="get_deviation">读取偏移量并运行</el-button>
  109. <el-button type="primary" @click="AllChangeNum">整体设定</el-button>
  110. </el-col>
  111. </el-row>
  112. </div>
  113. </template>
  114. <script setup lang="ts">
  115. import {ref,reactive,onMounted} from "vue";
  116. import client from "@/stores/modules/client";
  117. import icpList from '@/utils/ipc'
  118. import socket from "@/stores/modules/socket";
  119. import {ElMessage} from "element-plus";
  120. const clientStore = client();
  121. const socketStore = socket()
  122. const editRowData = ref({
  123. "camera_high_motor_deviation": '',
  124. "camera_steering_deviation": '',
  125. "turntable_steering_deviation": '',
  126. "turntable_front_end_deviation":'',
  127. "overturn_steering_middle": '',
  128. "overturn_steering_high": '',
  129. "overturn_steering_up_speed": '',
  130. "overturn_steering_down_speed": ''
  131. }); // 当前编辑行的数据
  132. onMounted(()=>{
  133. get_deviation()
  134. })
  135. //获取配置
  136. async function get_deviation(){
  137. if(clientStore.isClient){
  138. socketStore.sendMessage({
  139. type: 'get_deviation',
  140. data:"get_deviation"
  141. })
  142. clientStore.ipc.on(icpList.socket.message+'_get_deviation_data', (event, result) => {
  143. console.log('_get_deviation_data')
  144. console.log(result)
  145. if(result.code === 0){
  146. editRowData.value.camera_high_motor_deviation = result.data.camera_high_motor_deviation
  147. editRowData.value.camera_steering_deviation = result.data.camera_steering_deviation
  148. editRowData.value.turntable_steering_deviation = result.data.turntable_steering_deviation
  149. editRowData.value.turntable_front_end_deviation = result.data.turntable_front_end_deviation
  150. editRowData.value.overturn_steering_middle = result.data.overturn_steering_middle
  151. editRowData.value.overturn_steering_high = result.data.overturn_steering_high
  152. editRowData.value.overturn_steering_up_speed = result.data.overturn_steering_up_speed
  153. editRowData.value.overturn_steering_down_speed = result.data.overturn_steering_down_speed
  154. changeNum('相机电机','move_deviation','camera_high_motor_deviation',0, 50)
  155. changeNum('相机舵机','move_deviation','camera_steering_deviation',-90, 90)
  156. changeNum('转盘舵机','move_deviation','turntable_steering_deviation',-720, 720)
  157. changeNum('转盘前后电机','move_deviation','turntable_front_end_deviation',0, 950)
  158. changeNum('翻板舵机中位','move_deviation','overturn_steering_middle',0, 180)
  159. // changeNum('翻板舵机高位','move_deviation','overturn_steering_high',0, 180)
  160. // changeNum('翻板舵机上升速度','move_deviation','overturn_steering_up_speed',0, 10)
  161. // changeNum('翻板舵机下降速度','move_deviation','overturn_steering_down_speed',0, 10)
  162. }else if(result.msg){
  163. ElMessage.error(result.msg)
  164. }
  165. clientStore.ipc.removeAllListeners(icpList.socket.message+'_get_deviation_data');
  166. });
  167. }
  168. }
  169. //MCU初始化
  170. async function connect_mcu__init(){
  171. if(clientStore.isClient){
  172. socketStore.sendMessage({
  173. type: 'init_mcu',
  174. data:{
  175. value:true
  176. }
  177. })
  178. }
  179. }
  180. const allTipsCount = ref(0)
  181. async function AllChangeNum (){
  182. allTipsCount.value = 7
  183. changeNum('相机电机','set_deviation','camera_high_motor_deviation',0, 50)
  184. changeNum('相机舵机','set_deviation','camera_steering_deviation',-90, 90)
  185. changeNum('转盘舵机','set_deviation','turntable_steering_deviation',-720, 720)
  186. // changeNum('转盘前后电机','set_deviation','turntable_front_end_deviation',0, 950)
  187. changeNum('翻板舵机中位','set_deviation','overturn_steering_middle',0, 180)
  188. changeNum('翻板舵机高位','set_deviation','overturn_steering_high',0, 180)
  189. changeNum('翻板舵机上升速度','set_deviation','overturn_steering_up_speed',0, 10)
  190. changeNum('翻板舵机下降速度','set_deviation','overturn_steering_down_speed',0, 10)
  191. }
  192. //设置 移动 调整
  193. async function changeNum(action_name, type, key, min, max) {
  194. if(key && (min || max)){
  195. if(editRowData.value[key] < min || editRowData.value[key] > max){
  196. if(editRowData.value[key] < min){
  197. editRowData.value[key] = min;
  198. }else{
  199. editRowData.value[key] = max;
  200. }
  201. ElMessage.error(`${action_name}值应在${min}到${max}之间`);
  202. }
  203. }
  204. socketStore.sendMessage({
  205. type,
  206. data: {
  207. action_name,
  208. value:Number(editRowData.value[key]) || 0
  209. }
  210. });
  211. clientStore.ipc.removeAllListeners(icpList.socket.message+'_set_deviation');
  212. clientStore.ipc.on(icpList.socket.message+'_set_deviation', (event, result) => {
  213. console.log('set_deviation')
  214. console.log(result)
  215. if(result.code === 0){
  216. if(result.msg === "相机舵机 设置成功"){
  217. editRowData.value.camera_steering_deviation = 0
  218. }
  219. if(allTipsCount.value === 1){
  220. allTipsCount.value--;
  221. ElMessage.success('设定成功')
  222. return;
  223. }
  224. if(allTipsCount.value > 0){
  225. allTipsCount.value--;
  226. return;
  227. }
  228. ElMessage.success(result.msg)
  229. }else if(result.msg){
  230. ElMessage.error(result.msg)
  231. }
  232. clientStore.ipc.removeAllListeners(icpList.socket.message+'_get_deviation_data');
  233. });
  234. }
  235. </script>
  236. <style scoped lang="scss">
  237. .bottom-wrap {
  238. position: fixed;
  239. bottom:0px;
  240. left: 0;
  241. right: 0;
  242. padding: 10px 0;
  243. background: #fff;
  244. }
  245. .page {
  246. padding-bottom: 60px;
  247. }
  248. .el-col {
  249. position: relative;
  250. ::v-deep {
  251. .error-msg{
  252. display: none;
  253. position: absolute;
  254. top: 28px;
  255. left: 8px;
  256. z-index: 22;
  257. color: #dc2626;
  258. font-size: 12px;
  259. }
  260. &:hover{
  261. .error-msg{
  262. display: block;
  263. }
  264. }
  265. }
  266. }
  267. </style>