You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

425 lines
24 KiB

2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
  1. <script lang="ts" setup>
  2. import { socket } from 'libs/socket'
  3. import { cmdNameMap, formatDateTime } from 'libs/utils'
  4. import { useDebugStore } from 'stores/debugStore'
  5. import { useSystemStore } from 'stores/systemStore'
  6. import { onMounted, onUnmounted, ref } from 'vue'
  7. const systemStore = useSystemStore()
  8. const debugStore = useDebugStore()
  9. let currentCommandId = ''
  10. onMounted(() => {
  11. socket.init(receiveMessage, 'cmd_debug')
  12. socket.init(receiveMessage, 'cmd_response')
  13. })
  14. onUnmounted(() => {
  15. socket.unregisterCallback(receiveMessage, 'cmd_debug')
  16. socket.unregisterCallback(receiveMessage, 'cmd_response')
  17. })
  18. const receiveMessage = (data: Socket.cmdData) => {
  19. data.commandId === currentCommandId && systemStore.pushSystemList(data)
  20. if (['start', 'success', 'fail'].includes(data.status)) {
  21. const cmdName = cmdNameMap[data.command as keyof typeof cmdNameMap] || data.command
  22. systemStore.insertLog({ cmdName, status: data.status as System.SystemLog['status'], time: formatDateTime() })
  23. }
  24. }
  25. const savePositionVisible = ref(false)
  26. const commandHandle = async (command: string, params?: unknown) => {
  27. currentCommandId = Date.now().toString()
  28. const data = {
  29. commandId: currentCommandId,
  30. command,
  31. params,
  32. }
  33. await debugStore.sendControl(data)
  34. }
  35. </script>
  36. <template lang="pug">
  37. div.debug-content
  38. el-row.button-content
  39. el-col(:span="8")
  40. div.button-box
  41. ft-button(type="primary", :click-handle="() => commandHandle('enable_all_motor')")
  42. | 使能所有电机
  43. el-col(:span="8")
  44. div.button-box
  45. ft-button(type="primary", :click-handle="() => commandHandle('disable_all_motor')")
  46. | 失能所有电机
  47. el-col(:span="8")
  48. div.button-box
  49. ft-button(type="primary", :click-handle="() => commandHandle('stop_all_motor')")
  50. | 停止所有电机
  51. el-row(:gutter="10", class="card-content")
  52. el-col(:span="8")
  53. el-card
  54. template(#header)
  55. div.card-header
  56. span 转运模组
  57. el-divider 机械臂-大臂
  58. div.card-box
  59. el-form
  60. el-form-item(label="角度")
  61. el-input(v-model="debugStore.formData.transferModule.bigMotorData.relative.angle", type="number", placeholder="请输入角度")
  62. template(#append)
  63. | °
  64. el-form-item(label="速度")
  65. el-input(v-model="debugStore.formData.transferModule.bigMotorData.relative.speed", type="number", placeholder="请输入速度")
  66. template(#append)
  67. | rpm/min
  68. el-form-item(label="循环")
  69. el-input(v-model="debugStore.formData.transferModule.bigMotorData.relative.times", type="number", placeholder="请输入次数")
  70. template(#append)
  71. |
  72. el-form-item
  73. ft-button(size="small", type="primary", :click-handle="() => commandHandle('robotic_arm_big_move_by', { ...debugStore.formData.transferModule.bigMotorData.relative, angle: debugStore.formData.transferModule.bigMotorData.relative.angle })")
  74. | 右转
  75. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('robotic_arm_big_stop')")
  76. | 停止
  77. ft-button(size="small", type="primary", :click-handle="() => commandHandle('robotic_arm_big_move_by', { ...debugStore.formData.transferModule.bigMotorData.relative, angle: -(debugStore.formData.transferModule.bigMotorData.relative.angle ?? 0) })")
  78. | 左转
  79. ft-button(type="primary", size="small", :click-handle="() => commandHandle('robotic_arm_big_origin')")
  80. | 回原点
  81. ft-button(size="small", type="primary", :click-handle="() => commandHandle('robotic_arm_big_enable')")
  82. | 电机使能
  83. ft-button(size="small", :click-handle="() => commandHandle('robotic_arm_big_disable')")
  84. | 电机失能
  85. el-form-item(label="角度")
  86. el-input(v-model="debugStore.formData.transferModule.bigMotorData.absolute.angle", type="number", placeholder="请输入目标角度")
  87. template(#append)
  88. | °
  89. el-form-item(label="速度")
  90. el-input(v-model="debugStore.formData.transferModule.bigMotorData.absolute.speed", type="number", placeholder="请输入速度")
  91. template(#append)
  92. | rpm/min
  93. el-form-item
  94. ft-button(size="small", type="primary", :click-handle="() => commandHandle('robotic_arm_big_move_to', debugStore.formData.transferModule.bigMotorData.absolute)")
  95. | 开始
  96. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('robotic_arm_big_stop')")
  97. | 停止
  98. el-divider 机械臂-小臂
  99. div.card-box
  100. el-form
  101. el-form-item(label="角度")
  102. el-input(v-model="debugStore.formData.transferModule.smallMotorData.relative.angle", type="number", placeholder="请输入角度")
  103. template(#append)
  104. | °
  105. el-form-item(label="速度")
  106. el-input(v-model="debugStore.formData.transferModule.smallMotorData.relative.speed", type="number", placeholder="请输入速度")
  107. template(#append)
  108. | rpm/min
  109. el-form-item(label="循环")
  110. el-input(v-model="debugStore.formData.transferModule.smallMotorData.relative.times", type="number", placeholder="请输入次数")
  111. template(#append)
  112. |
  113. el-form-item
  114. ft-button(size="small", type="primary", :click-handle="() => commandHandle('robotic_arm_small_move_by', { ...debugStore.formData.transferModule.smallMotorData.relative, distance: debugStore.formData.transferModule.smallMotorData.relative.angle })")
  115. | 前进
  116. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('robotic_arm_small_stop')")
  117. | 停止
  118. ft-button(size="small", type="primary", :click-handle="() => commandHandle('robotic_arm_small_move_by', { ...debugStore.formData.transferModule.smallMotorData.relative, distance: -(debugStore.formData.transferModule.smallMotorData.relative.angle ?? 0) })")
  119. | 后退
  120. ft-button(type="primary", size="small", :click-handle="() => commandHandle('robotic_arm_small_origin')")
  121. | 回原点
  122. ft-button(size="small", type="primary", :click-handle="() => commandHandle('robotic_arm_small_enable')")
  123. | 电机使能
  124. ft-button(size="small", :click-handle="() => commandHandle('robotic_arm_small_disable')")
  125. | 电机失能
  126. el-divider Z轴电机
  127. div.card-box
  128. el-form
  129. el-form-item(label="距离")
  130. el-input(v-model="debugStore.formData.transferModule.zMotorData.relative.distance", type="number", placeholder="请输入距离")
  131. template(#append)
  132. | mm
  133. el-form-item(label="速度")
  134. el-input(v-model="debugStore.formData.transferModule.zMotorData.relative.speed", type="number", placeholder="请输入速度")
  135. template(#append)
  136. | rpm/min
  137. el-form-item(label="循环")
  138. el-input(v-model="debugStore.formData.transferModule.zMotorData.relative.times", type="number", placeholder="请输入次数")
  139. template(#append)
  140. |
  141. el-form-item
  142. ft-button(size="small", type="primary", :click-handle="() => commandHandle('z_move_by', { ...debugStore.formData.transferModule.zMotorData.relative, distance: debugStore.formData.transferModule.zMotorData.relative.distance })")
  143. | 前进
  144. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('z_stop')")
  145. | 停止
  146. ft-button(size="small", type="primary", :click-handle="() => commandHandle('z_move_by', { ...debugStore.formData.transferModule.zMotorData.relative, distance: -(debugStore.formData.transferModule.zMotorData.relative.distance ?? 0) })")
  147. | 后退
  148. ft-button(type="primary", size="small", :click-handle="() => commandHandle('z_origin')")
  149. | 回原点
  150. ft-button(size="small", type="primary", :click-handle="() => commandHandle('z_enable')")
  151. | 电机使能
  152. ft-button(size="small", :click-handle="() => commandHandle('z_disable')")
  153. | 电机失能
  154. el-divider 夹爪电机
  155. div.card-box
  156. el-form
  157. el-form-item(label="距离")
  158. el-input(v-model="debugStore.formData.transferModule.clawMotorData.distance", type="number", placeholder="请输入距离")
  159. template(#append)
  160. | mm
  161. el-form-item(label="速度")
  162. el-input(v-model="debugStore.formData.transferModule.clawMotorData.speed", type="number", placeholder="请输入速度")
  163. template(#append)
  164. | rpm/min
  165. el-form-item(label="循环")
  166. el-input(v-model="debugStore.formData.transferModule.clawMotorData.times", type="number", placeholder="请输入次数")
  167. template(#append)
  168. |
  169. el-form-item
  170. ft-button(size="small", type="primary", :click-handle="() => commandHandle('claw_open', { ...debugStore.formData.transferModule.clawMotorData, distance: debugStore.formData.transferModule.clawMotorData.distance })")
  171. | 打开
  172. ft-button(size="small", type="primary", :click-handle="() => commandHandle('claw_open', { ...debugStore.formData.transferModule.clawMotorData, distance: -(debugStore.formData.transferModule.clawMotorData.distance ?? 0) })")
  173. | 闭合
  174. ft-button(size="small", type="primary", :click-handle="() => commandHandle('claw_stop', {})")
  175. | 停止
  176. el-col(:span="8")
  177. el-card
  178. template(#header)
  179. div.card-header
  180. span 蠕动泵
  181. el-divider 陶瓷蠕动泵
  182. div.card-box
  183. el-form
  184. el-form-item(label="距离")
  185. el-input(v-model="debugStore.formData.peristalticPumpData.ceramicPump.distance", type="number", placeholder="请输入距离")
  186. template(#append)
  187. | mL
  188. el-form-item(label="速度")
  189. el-input(v-model="debugStore.formData.peristalticPumpData.ceramicPump.speed", type="number", placeholder="请输入速度")
  190. template(#append)
  191. | rpm/min
  192. el-form-item(label="泵")
  193. el-select(v-model="debugStore.formData.peristalticPumpData.ceramicPump.pumpCode", placeholder="请选择泵")
  194. el-option(v-for="item in 2", :key="item", :label="`泵-${item}`", :value="`ceramic_pump_${item}`")
  195. el-form-item
  196. ft-button(size="small", type="primary", :click-handle="() => commandHandle('ceramic_pump_move', { ...debugStore.formData.peristalticPumpData.ceramicPump})")
  197. | 移动
  198. ft-button(size="small", type="primary", :click-handle="() => commandHandle('ceramic_pump_open', { ...debugStore.formData.peristalticPumpData.ceramicPump, direction: 'forward' })")
  199. | 正转
  200. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('ceramic_pump_close', debugStore.formData.peristalticPumpData.ceramicPump)")
  201. | 停止
  202. ft-button(size="small", type="primary", class="stop-button", :click-handle="() => commandHandle('ceramic_pump_open', { ...debugStore.formData.peristalticPumpData.ceramicPump, direction: 'backward' })")
  203. | 反转
  204. el-divider 无刷蠕动泵
  205. div.card-box
  206. el-form
  207. el-form-item(label="距离")
  208. el-input(v-model="debugStore.formData.peristalticPumpData.brushlessPump.distance", type="number", placeholder="请输入距离")
  209. template(#append)
  210. | mL
  211. el-form-item(label="速度")
  212. el-input(v-model="debugStore.formData.peristalticPumpData.brushlessPump.speed", type="number", placeholder="请输入速度")
  213. template(#append)
  214. | rpm/min
  215. el-form-item(label="泵")
  216. el-select(v-model="debugStore.formData.peristalticPumpData.brushlessPump.pumpCode", placeholder="请选择泵")
  217. el-option(v-for="item in 10", :key="item", :label="`泵-${item}`", :value="`brushless_pump_${item}`")
  218. el-form-item
  219. ft-button(size="small", type="primary", :click-handle="() => commandHandle('brushless_pump_move', { ...debugStore.formData.peristalticPumpData.brushlessPump})")
  220. | 正转
  221. ft-button(size="small", type="primary", :click-handle="() => commandHandle('brushless_pump_open', { ...debugStore.formData.peristalticPumpData.brushlessPump, direction: 'forward' })")
  222. | 正转
  223. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('brushless_pump_close',{ ...debugStore.formData.peristalticPumpData.brushlessPump})")
  224. | 停止
  225. ft-button(size="small", type="primary", class="stop-button", :click-handle="() => commandHandle('brushless_pump_open', { ...debugStore.formData.peristalticPumpData.brushlessPump, direction: 'backward' })")
  226. | 反转
  227. el-divider 步进蠕动泵
  228. div.card-box
  229. el-form
  230. el-form-item(label="距离")
  231. el-input(v-model="debugStore.formData.peristalticPumpData.stepPump.distance", type="number", placeholder="请输入距离")
  232. template(#append)
  233. | mL
  234. el-form-item(label="速度")
  235. el-input(v-model="debugStore.formData.peristalticPumpData.stepPump.speed", type="number", placeholder="请输入速度")
  236. template(#append)
  237. | rpm/min
  238. el-form-item(label="泵")
  239. el-select(v-model="debugStore.formData.peristalticPumpData.stepPump.pumpCode", type="number", placeholder="请选择泵")
  240. el-option(v-for="item in 3", :key="item", :label="`泵-${item}`", :value="`step_pump_${item}`")
  241. el-form-item
  242. ft-button(size="small", type="primary", :click-handle="() => commandHandle('step_pump_move', { ...debugStore.formData.peristalticPumpData.stepPump})")
  243. | 移动
  244. ft-button(size="small", type="primary", :click-handle="() => commandHandle('step_pump_open', { ...debugStore.formData.peristalticPumpData.stepPump, direction: 'forward' })")
  245. | 正转
  246. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('step_pump_close',{ ...debugStore.formData.peristalticPumpData.stepPump})")
  247. | 停止
  248. ft-button(size="small", type="primary", class="stop-button", :click-handle="() => commandHandle('step_pump_open', { ...debugStore.formData.peristalticPumpData.stepPump, direction: 'backward' })")
  249. | 反转
  250. el-card
  251. template(#header)
  252. div.card-header
  253. span 滴定移动电机
  254. div.card-box
  255. el-form
  256. el-form-item(label="距离")
  257. el-input(v-model="debugStore.formData.titrationModule.relative.distance", type="number", placeholder="请输入距离")
  258. template(#append)
  259. | mm
  260. el-form-item(label="速度")
  261. el-input(v-model="debugStore.formData.titrationModule.relative.speed", type="number", placeholder="请输入速度")
  262. template(#append)
  263. | rpm/min
  264. el-form-item(label="循环")
  265. el-input(v-model="debugStore.formData.titrationModule.relative.times", type="number", placeholder="请输入次数")
  266. template(#append)
  267. |
  268. el-form-item(label="电机")
  269. el-select(v-model="debugStore.formData.titrationModule.relative.motorCode", placeholder="请选择电机")
  270. el-option(v-for="item in 2", :key="item", :label="`电机${item}`", :value="`titration_motor_${item}`")
  271. el-form-item
  272. ft-button(size="small", type="primary", :click-handle="() => commandHandle('titration_motor_move_by', { ...debugStore.formData.titrationModule.relative, distance: debugStore.formData.titrationModule.relative.distance })")
  273. | 相对移动
  274. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('titration_motor_stop', { motorCode: debugStore.formData.titrationModule.relative.motorCode })")
  275. | 停止
  276. ft-button(size="small", type="primary", :click-handle="() => commandHandle('titration_motor_move_to', { ...debugStore.formData.titrationModule.relative, position: -(debugStore.formData.titrationModule.relative.distance ?? 0) })")
  277. | 绝对移动
  278. ft-button(type="primary", size="small", :click-handle="() => commandHandle('titration_motor_origin', { motorCode: debugStore.formData.titrationModule.relative.motorCode })")
  279. | 回原点
  280. ft-button(size="small", type="primary", :click-handle="() => commandHandle('titration_motor_enable', { motorCode: debugStore.formData.titrationModule.relative.motorCode })")
  281. | 电机使能
  282. ft-button(size="small", :click-handle="() => commandHandle('titration_motor_disable', { motorCode: debugStore.formData.titrationModule.relative.motorCode })")
  283. | 电机失能
  284. el-col(:span="8")
  285. el-card
  286. template(#header)
  287. div.card-header
  288. span 加热模组
  289. el-divider 加热棒
  290. div.card-box
  291. el-form
  292. el-form-item(label="温度")
  293. el-input(v-model="debugStore.formData.heatArea.temperature", type="number", placeholder="请输入温度")
  294. template(#append)
  295. |
  296. el-form-item(label="区域")
  297. el-select(v-model="debugStore.formData.heatArea.heatModuleCode", placeholder="请选择区域")
  298. el-option(v-for="item in 2", :key="item", :label="`加热区${item}`", :value="`heat_module_${item}`")
  299. el-form-item
  300. ft-button(size="small", type="primary", :click-handle="() => commandHandle('heater_start', debugStore.formData.heatArea)")
  301. | 开始加热
  302. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('heater_stop', debugStore.formData.heatArea)")
  303. | 停止加热
  304. el-card
  305. template(#header)
  306. div.card-header
  307. span 指示灯
  308. div.card-box
  309. el-form
  310. el-form-item(label="颜色")
  311. el-select(v-model="debugStore.formData.lightModule.color", placeholder="请选择颜色")
  312. el-option(v-for="item in [{ value: 'red', label: '红色' }, { value: 'yellow', label: '黄色' }, { value: 'green', label: '绿色' }]", :key="item.value", :label="item.label", :value="item.value")
  313. el-form-item
  314. ft-button(size="small", type="primary", :click-handle="() => commandHandle('light_open', { ...debugStore.formData.lightModule })")
  315. | 开启
  316. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('light_close')")
  317. | 关闭
  318. el-card
  319. template(#header)
  320. div.card-header
  321. span 磁子搅拌电机
  322. div.card-box
  323. el-form
  324. el-form-item(label="距离")
  325. el-input(v-model="debugStore.formData.stirMotor.relative.distance", type="number", placeholder="请输入距离")
  326. template(#append)
  327. | mm
  328. el-form-item(label="速度")
  329. el-input(v-model="debugStore.formData.stirMotor.relative.speed", type="number", placeholder="请输入速度")
  330. template(#append)
  331. | rpm/min
  332. el-form-item(label="循环")
  333. el-input(v-model="debugStore.formData.stirMotor.relative.times", type="number", placeholder="请输入次数")
  334. template(#append)
  335. |
  336. el-form-item(label="电机")
  337. el-select(v-model="debugStore.formData.stirMotor.relative.motorCode", placeholder="请选择电机")
  338. el-option(v-for="item in 2", :key="item", :label="`电机${item}`", :value="`stir_motor_${item}`")
  339. el-form-item
  340. ft-button(size="small", type="primary", :click-handle="() => commandHandle('stir_motor_move_by', { ...debugStore.formData.stirMotor.relative, distance: debugStore.formData.stirMotor.relative.distance })")
  341. | 前进
  342. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('stir_motor_stop', { motorCode: debugStore.formData.stirMotor.relative.motorCode })")
  343. | 停止
  344. ft-button(size="small", type="primary", :click-handle="() => commandHandle('stir_motor_move_by', { ...debugStore.formData.stirMotor.relative, distance: -(debugStore.formData.stirMotor.relative.distance ?? 0) })")
  345. | 后退
  346. ft-button(type="primary", size="small", :click-handle="() => commandHandle('stir_motor_origin', { motorCode: debugStore.formData.stirMotor.relative.motorCode })")
  347. | 回原点
  348. ft-button(size="small", type="primary", :click-handle="() => commandHandle('stir_motor_enable', { motorCode: debugStore.formData.stirMotor.relative.motorCode })")
  349. | 电机使能
  350. ft-button(size="small", :click-handle="() => commandHandle('stir_motor_disable', { motorCode: debugStore.formData.stirMotor.relative.motorCode })")
  351. | 电机失能
  352. el-divider 磁子投放
  353. ft-button(size="small", type="primary", :click-handle="() => commandHandle('magnet_open')")
  354. | 打开磁子投放开关
  355. ft-button(size="small", :click-handle="() => commandHandle('magnet_close')")
  356. | 关闭磁子投放开关
  357. SavePosition(v-if="savePositionVisible", @ok="savePositionVisible = false", @cancel="savePositionVisible = false")
  358. </template>
  359. <style lang="stylus" scoped>
  360. .debug-content
  361. overflow hidden
  362. max-height 100%
  363. .button-content
  364. height 40px
  365. .card-content
  366. height calc(100% - 40px)
  367. overflow auto
  368. .el-card
  369. margin-bottom 10px
  370. :deep(.el-card__header)
  371. padding 5px 10px
  372. background rgba(0, 0, 0, 0.03)
  373. .el-input, .el-select
  374. width 100%
  375. .el-form-item
  376. margin-bottom 10px
  377. margin-right 0
  378. .card-header
  379. display flex
  380. align-items center
  381. justify-content space-between
  382. .select-label
  383. margin-right 10px
  384. :deep(.el-card__body)
  385. padding 10px 5px
  386. .el-form-item__content
  387. .ft-button
  388. margin-bottom 10px
  389. .button-box
  390. display flex
  391. justify-content center
  392. :deep(.el-form-item).button-center
  393. .el-form-item__content
  394. width 100%
  395. display flex
  396. justify-content center
  397. .stop-button
  398. margin-right 8px
  399. font-weight 900
  400. margin-left 3px
  401. .el-divider
  402. margin 15px 0
  403. </style>