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.

417 lines
23 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_close', { ...debugStore.formData.transferModule.clawMotorData, distance: -(debugStore.formData.transferModule.clawMotorData.distance ?? 0) })")
  173. | 闭合
  174. el-col(:span="8")
  175. el-card
  176. template(#header)
  177. div.card-header
  178. span 蠕动泵
  179. el-divider 陶瓷蠕动泵
  180. div.card-box
  181. el-form
  182. el-form-item(label="容量")
  183. el-input(v-model="debugStore.formData.peristalticPumpData.ceramicPump.volume", type="number", placeholder="请输入容量")
  184. template(#append)
  185. | mL
  186. el-form-item(label="速度")
  187. el-input(v-model="debugStore.formData.peristalticPumpData.ceramicPump.speed", type="number", placeholder="请输入速度")
  188. template(#append)
  189. | rpm/min
  190. el-form-item(label="泵")
  191. el-select(v-model="debugStore.formData.peristalticPumpData.ceramicPump.pumpCode", placeholder="请选择泵")
  192. el-option(v-for="item in 2", :key="item", :label="`泵-${item}`", :value="`ceramic_pump_${item}`")
  193. el-form-item
  194. ft-button(size="small", type="primary", :click-handle="() => commandHandle('ceramic_pump_open', { ...debugStore.formData.peristalticPumpData.ceramicPump, direction: 'forward' })")
  195. | 正转
  196. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('ceramic_pump_close')")
  197. | 停止
  198. ft-button(size="small", type="primary", class="stop-button", :click-handle="() => commandHandle('ceramic_pump_open', { ...debugStore.formData.peristalticPumpData.ceramicPump, direction: 'backward' })")
  199. | 反转
  200. el-divider 无刷蠕动泵
  201. div.card-box
  202. el-form
  203. el-form-item(label="容量")
  204. el-input(v-model="debugStore.formData.peristalticPumpData.brushlessPump.volume", type="number", placeholder="请输入容量")
  205. template(#append)
  206. | mL
  207. el-form-item(label="速度")
  208. el-input(v-model="debugStore.formData.peristalticPumpData.brushlessPump.speed", type="number", placeholder="请输入速度")
  209. template(#append)
  210. | rpm/min
  211. el-form-item(label="泵")
  212. el-select(v-model="debugStore.formData.peristalticPumpData.brushlessPump.pumpCode", placeholder="请选择泵")
  213. el-option(v-for="item in 10", :key="item", :label="`泵-${item}`", :value="`brushless_pump_${item}`")
  214. el-form-item
  215. ft-button(size="small", type="primary", :click-handle="() => commandHandle('brushless_pump_open', { ...debugStore.formData.peristalticPumpData.brushlessPump, direction: 'forward' })")
  216. | 正转
  217. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('brushless_pump_close')")
  218. | 停止
  219. ft-button(size="small", type="primary", class="stop-button", :click-handle="() => commandHandle('brushless_pump_open', { ...debugStore.formData.peristalticPumpData.brushlessPump, direction: 'backward' })")
  220. | 反转
  221. el-divider 步进蠕动泵
  222. div.card-box
  223. el-form
  224. el-form-item(label="容量")
  225. el-input(v-model="debugStore.formData.peristalticPumpData.stepPump.volume", type="number", placeholder="请输入容量")
  226. template(#append)
  227. | mL
  228. el-form-item(label="速度")
  229. el-input(v-model="debugStore.formData.peristalticPumpData.stepPump.speed", type="number", placeholder="请输入速度")
  230. template(#append)
  231. | rpm/min
  232. el-form-item(label="泵")
  233. el-select(v-model="debugStore.formData.peristalticPumpData.stepPump.pumpCode", type="number", placeholder="请选择泵")
  234. el-option(v-for="item in 3", :key="item", :label="`泵-${item}`", :value="`step_pump_${item}`")
  235. el-form-item
  236. ft-button(size="small", type="primary", :click-handle="() => commandHandle('brushless_pump_open', { ...debugStore.formData.peristalticPumpData.stepPump, direction: 'forward' })")
  237. | 正转
  238. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('brushless_pump_close')")
  239. | 停止
  240. ft-button(size="small", type="primary", class="stop-button", :click-handle="() => commandHandle('brushless_pump_open', { ...debugStore.formData.peristalticPumpData.stepPump, direction: 'backward' })")
  241. | 反转
  242. el-card
  243. template(#header)
  244. div.card-header
  245. span 滴定移动电机
  246. div.card-box
  247. el-form
  248. el-form-item(label="距离")
  249. el-input(v-model="debugStore.formData.titrationModule.relative.distance", type="number", placeholder="请输入距离")
  250. template(#append)
  251. | mm
  252. el-form-item(label="速度")
  253. el-input(v-model="debugStore.formData.titrationModule.relative.speed", type="number", placeholder="请输入速度")
  254. template(#append)
  255. | rpm/min
  256. el-form-item(label="循环")
  257. el-input(v-model="debugStore.formData.titrationModule.relative.times", type="number", placeholder="请输入次数")
  258. template(#append)
  259. |
  260. el-form-item(label="电机")
  261. el-select(v-model="debugStore.formData.titrationModule.relative.motorCode", placeholder="请选择电机")
  262. el-option(v-for="item in 2", :key="item", :label="`电机${item}`", :value="`titration_motor_${item}`")
  263. el-form-item
  264. ft-button(size="small", type="primary", :click-handle="() => commandHandle('titration_motor_move_by', { ...debugStore.formData.titrationModule.relative, distance: debugStore.formData.titrationModule.relative.distance })")
  265. | 前进
  266. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('titration_motor_stop', { motorCode: debugStore.formData.titrationModule.relative.motorCode })")
  267. | 停止
  268. ft-button(size="small", type="primary", :click-handle="() => commandHandle('z_move_by', { ...debugStore.formData.titrationModule.relative, distance: -(debugStore.formData.titrationModule.relative.distance ?? 0) })")
  269. | 后退
  270. ft-button(type="primary", size="small", :click-handle="() => commandHandle('titration_motor_origin', { motorCode: debugStore.formData.titrationModule.relative.motorCode })")
  271. | 回原点
  272. ft-button(size="small", type="primary", :click-handle="() => commandHandle('z_enable', { motorCode: debugStore.formData.titrationModule.relative.motorCode })")
  273. | 电机使能
  274. ft-button(size="small", :click-handle="() => commandHandle('z_disable', { motorCode: debugStore.formData.titrationModule.relative.motorCode })")
  275. | 电机失能
  276. el-col(:span="8")
  277. el-card
  278. template(#header)
  279. div.card-header
  280. span 加热模组
  281. el-divider 加热棒
  282. div.card-box
  283. el-form
  284. el-form-item(label="温度")
  285. el-input(v-model="debugStore.formData.heatArea.temperature", type="number", placeholder="请输入温度")
  286. template(#append)
  287. |
  288. el-form-item(label="区域")
  289. el-select(v-model="debugStore.formData.heatArea.heatModuleCode", placeholder="请选择区域")
  290. el-option(v-for="item in 2", :key="item", :label="`加热区${item}`", :value="`heat_module_${item}`")
  291. el-form-item
  292. ft-button(size="small", type="primary", :click-handle="() => commandHandle('heater_start', debugStore.formData.heatArea)")
  293. | 开始加热
  294. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('heater_stop', debugStore.formData.heatArea)")
  295. | 停止加热
  296. el-card
  297. template(#header)
  298. div.card-header
  299. span 指示灯
  300. div.card-box
  301. el-form
  302. el-form-item(label="颜色")
  303. el-select(v-model="debugStore.formData.lightModule.color", placeholder="请选择颜色")
  304. el-option(v-for="item in [{ value: 'red', label: '红色' }, { value: 'yellow', label: '黄色' }, { value: 'green', label: '绿色' }]", :key="item.value", :label="item.label", :value="item.value")
  305. el-form-item
  306. ft-button(size="small", type="primary", :click-handle="() => commandHandle('door_open', { ...debugStore.formData.door })")
  307. | 开启
  308. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('door_stop')")
  309. | 关闭
  310. el-card
  311. template(#header)
  312. div.card-header
  313. span 磁子搅拌电机
  314. div.card-box
  315. el-form
  316. el-form-item(label="距离")
  317. el-input(v-model="debugStore.formData.magnetStirMotor.relative.distance", type="number", placeholder="请输入距离")
  318. template(#append)
  319. | mm
  320. el-form-item(label="速度")
  321. el-input(v-model="debugStore.formData.magnetStirMotor.relative.speed", type="number", placeholder="请输入速度")
  322. template(#append)
  323. | rpm/min
  324. el-form-item(label="循环")
  325. el-input(v-model="debugStore.formData.magnetStirMotor.relative.times", type="number", placeholder="请输入次数")
  326. template(#append)
  327. |
  328. el-form-item(label="电机")
  329. el-select(v-model="debugStore.formData.magnetStirMotor.relative.motorCode", placeholder="请选择电机")
  330. el-option(v-for="item in 2", :key="item", :label="`电机${item}`", :value="`magnet_stir_motor_${item}`")
  331. el-form-item
  332. ft-button(size="small", type="primary", :click-handle="() => commandHandle('magnet_stir_motor_move_by', { ...debugStore.formData.magnetStirMotor.relative, distance: debugStore.formData.magnetStirMotor.relative.distance })")
  333. | 前进
  334. ft-button(size="small", class="stop-button", :click-handle="() => commandHandle('magnet_stir_motor_stop', { motorCode: debugStore.formData.magnetStirMotor.relative.motorCode })")
  335. | 停止
  336. ft-button(size="small", type="primary", :click-handle="() => commandHandle('magnet_stir_motor_move_by', { ...debugStore.formData.magnetStirMotor.relative, distance: -(debugStore.formData.magnetStirMotor.relative.distance ?? 0) })")
  337. | 后退
  338. ft-button(type="primary", size="small", :click-handle="() => commandHandle('magnet_stir_motor_origin', { motorCode: debugStore.formData.magnetStirMotor.relative.motorCode })")
  339. | 回原点
  340. ft-button(size="small", type="primary", :click-handle="() => commandHandle('magnet_stir_motor_enable', { motorCode: debugStore.formData.magnetStirMotor.relative.motorCode })")
  341. | 电机使能
  342. ft-button(size="small", :click-handle="() => commandHandle('magnet_stir_motor_disable', { motorCode: debugStore.formData.magnetStirMotor.relative.motorCode })")
  343. | 电机失能
  344. el-divider 磁子投放
  345. ft-button(size="small", type="primary", :click-handle="() => commandHandle('magnet_open')")
  346. | 打开磁子投放开关
  347. ft-button(size="small", :click-handle="() => commandHandle('magnet_close')")
  348. | 关闭磁子投放开关
  349. SavePosition(v-if="savePositionVisible", @ok="savePositionVisible = false", @cancel="savePositionVisible = false")
  350. </template>
  351. <style lang="stylus" scoped>
  352. .debug-content
  353. overflow hidden
  354. max-height 100%
  355. .button-content
  356. height 40px
  357. .card-content
  358. height calc(100% - 40px)
  359. overflow auto
  360. .el-card
  361. margin-bottom 10px
  362. :deep(.el-card__header)
  363. padding 5px 10px
  364. background rgba(0, 0, 0, 0.03)
  365. .el-input, .el-select
  366. width 100%
  367. .el-form-item
  368. margin-bottom 10px
  369. margin-right 0
  370. .card-header
  371. display flex
  372. align-items center
  373. justify-content space-between
  374. .select-label
  375. margin-right 10px
  376. :deep(.el-card__body)
  377. padding 10px 5px
  378. .el-form-item__content
  379. .ft-button
  380. margin-bottom 10px
  381. .button-box
  382. display flex
  383. justify-content center
  384. :deep(.el-form-item).button-center
  385. .el-form-item__content
  386. width 100%
  387. display flex
  388. justify-content center
  389. .stop-button
  390. margin-right 8px
  391. font-weight 900
  392. margin-left 3px
  393. .el-divider
  394. margin 15px 0
  395. </style>