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.

329 lines
10 KiB

2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <script lang="ts" setup>
  2. import { getSelfFinish, getSelfStatus } from 'apis/self'
  3. import { requireOutTray } from 'apis/system'
  4. import { ElMessageBox } from 'element-plus'
  5. import { socket } from 'libs/socket'
  6. import { useHomeStore } from 'stores/homeStore'
  7. import { useSystemStore } from 'stores/systemStore'
  8. import { onMounted, ref, watch } from 'vue'
  9. const emits = defineEmits(['close'])
  10. const homeStore = useHomeStore()
  11. const systemStore = useSystemStore()
  12. const checkMap = ref(new Map([
  13. ['gantryZOrigin', { status: '', name: '龙门架z轴回原点', params: { commandId: '', command: `gantry_z_origin`, params: {} } }],
  14. ['gantryXOrigin', { status: '', name: '龙门架x轴回原点', params: { commandId: '', command: `gantry_x_origin`, params: {} } }],
  15. ['gantryYOrigin', { status: '', name: '龙门架y轴回原点', params: { commandId: '', command: `gantry_y_origin`, params: {} } }],
  16. ['trayLifting01Origin', { status: '', name: 'A-1托盘升降电机回原点', params: { commandId: '', command: `tray_lifting_origin`, params: { heatId: 'heat_module_01' } } }],
  17. ['trayLifting02Origin', { status: '', name: 'A-2托盘升降电机回原点', params: { commandId: '', command: `tray_lifting_origin`, params: { heatId: 'heat_module_02' } } }],
  18. ['trayLifting03Origin', { status: '', name: 'A-3托盘升降电机回原点', params: { commandId: '', command: `tray_lifting_origin`, params: { heatId: 'heat_module_03' } } }],
  19. ['trayLifting04Origin', { status: '', name: 'A-4托盘升降电机回原点', params: { commandId: '', command: `tray_lifting_origin`, params: { heatId: 'heat_module_04' } } }],
  20. ['trayLifting05Origin', { status: '', name: 'A-5托盘升降电机回原点', params: { commandId: '', command: `tray_lifting_origin`, params: { heatId: 'heat_module_05' } } }],
  21. ['trayLifting06Origin', { status: '', name: 'A-6托盘升降电机回原点', params: { commandId: '', command: `tray_lifting_origin`, params: { heatId: 'heat_module_06' } } }],
  22. ['capLiftingOrigin', { status: '', name: '拍子升降电机回原点', params: { commandId: '', command: `cap_lifting_origin` } }],
  23. ['doorOrigin', { status: '', name: '门电机回原点', params: { commandId: '', command: `door_origin`, params: {} } }],
  24. ['shakeOrigin', { status: '', name: '摇匀电机回原点', params: { commandId: '', command: `shake_origin`, params: {} } }],
  25. ['dualRobotOrigin', { status: '', name: '加液机械臂回原点', params: { commandId: '', command: `dual_robot_origin`, params: {} } }],
  26. ]))
  27. const checkList = ref<any[]>([])
  28. onMounted(async () => {
  29. socket.init(receiveMessage1, 'cmd_debug')
  30. socket.init(receiveMessage2, 'cmd_response')
  31. socket.init(receiveMessageSelfMove, 'self_move_test')
  32. const res = await getSelfStatus()
  33. for (const key in res) {
  34. const entry = checkMap.value.get(key)
  35. if (entry) {
  36. entry.status = res[key] ? 'success' : 'error'
  37. }
  38. }
  39. await ElMessageBox.confirm(
  40. '设备转运机械臂x、y、z需进行初始化,请确认机械臂行进路径无杂物,夹爪没有在夹取物品',
  41. '提示',
  42. {
  43. confirmButtonText: '确认',
  44. showClose: false,
  45. showCancelButton: false,
  46. closeOnClickModal: false,
  47. closeOnPressEscape: false,
  48. type: 'warning',
  49. customClass: 'init-message',
  50. },
  51. )
  52. const keys = [...checkMap.value.keys()]
  53. checkList.value.push(checkMap.value.get(keys[0]), checkMap.value.get(keys[1]), checkMap.value.get(keys[2]))
  54. })
  55. watch(() => checkList.value, async (newVal) => {
  56. console.log('checkList', newVal)
  57. if (newVal.length === 3 && newVal.every(item => item.status === 'success')) {
  58. await ElMessageBox.confirm(
  59. '加热模组升降、拍子存放模组升降、电动门升降、摇匀模组、加液机械臂需进行初始化,请确认升降范围无杂物',
  60. '提示',
  61. {
  62. confirmButtonText: '确认',
  63. showClose: false,
  64. showCancelButton: false,
  65. closeOnClickModal: false,
  66. closeOnPressEscape: false,
  67. type: 'warning',
  68. customClass: 'init-message',
  69. },
  70. )
  71. const keys = [...checkMap.value.keys()]
  72. for (let i = 3; i < keys.length; i++) {
  73. checkList.value.push(checkMap.value.get(keys[i]))
  74. }
  75. }
  76. }, { deep: true })
  77. let currentCommandId = ''
  78. const receiveMessage1 = (data: Socket.cmdData) => {
  79. data.commandId === currentCommandId && systemStore.pushSystemList(data)
  80. }
  81. const receiveMessage2 = (data: Socket.cmdData) => {
  82. data.commandId === currentCommandId && systemStore.pushSystemList(data)
  83. const item = checkList.value.find(item => item.params.commandId === data.commandId)
  84. if (item && data.commandId === item.params.commandId && ['success', 'error'].includes(data.status)) {
  85. item.status = data.status
  86. }
  87. const item1 = heatList.value.find(item => item.params.commandId === data.commandId)
  88. if (item1 && data.commandId === item1.params.commandId && ['success', 'error'].includes(data.status)) {
  89. item.status = data.status
  90. }
  91. }
  92. const commandHandle = async (data: any) => {
  93. data.params.commandId = currentCommandId = Date.now().toString()
  94. await homeStore.sendControl(data!.params)
  95. }
  96. const onConfirm = async () => {
  97. await getSelfFinish(true)
  98. emits('close')
  99. }
  100. const percentage = ref(0)
  101. const checkHandle = async () => {
  102. activeStep.value = 1
  103. await ElMessageBox.confirm(
  104. '设备即将开始自检',
  105. '提示',
  106. {
  107. confirmButtonText: '确认',
  108. showClose: false,
  109. showCancelButton: false,
  110. closeOnClickModal: false,
  111. closeOnPressEscape: false,
  112. type: 'warning',
  113. customClass: 'init-message',
  114. },
  115. )
  116. currentCommandId = Date.now().toString()
  117. const params = {
  118. commandId: currentCommandId,
  119. command: 'move_test',
  120. params: {},
  121. }
  122. await homeStore.sendControl(params)
  123. }
  124. const checkTextList = ref<string[]>([])
  125. const receiveMessageSelfMove = (data: any) => {
  126. checkTextList.value.push(data.title)
  127. percentage.value = data.schedule
  128. }
  129. const activeStep = ref(0)
  130. const heatList = ref([
  131. {
  132. name: 'A-1',
  133. status: 'success',
  134. command: 'heat_module_01',
  135. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_01' } },
  136. },
  137. {
  138. name: 'A-2',
  139. status: 'success',
  140. command: 'heat_module_02',
  141. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_02' } },
  142. },
  143. {
  144. name: 'A-3',
  145. status: 'success',
  146. command: 'heat_module_03',
  147. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_03' } },
  148. },
  149. {
  150. name: 'A-4',
  151. status: 'success',
  152. command: 'heat_module_04',
  153. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_04' } },
  154. },
  155. {
  156. name: 'A-5',
  157. status: 'success',
  158. command: 'heat_module_05',
  159. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_05' } },
  160. },
  161. {
  162. name: 'A-6',
  163. status: 'success',
  164. command: 'heat_module_06',
  165. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_06' } },
  166. },
  167. ])
  168. const checkHandle1 = async () => {
  169. const res = await requireOutTray()
  170. res.forEach((item) => {
  171. const heatItem = heatList.value.find(heatItem => heatItem.command === item.moduleCode)
  172. heatItem!.status = item.trayExist ? 'error' : 'success'
  173. })
  174. activeStep.value = 2
  175. }
  176. </script>
  177. <template>
  178. <FtDialog visible title="设备初始化" width="60%">
  179. <el-steps style="max-width: 600px" :active="activeStep" finish-status="success">
  180. <el-step title="初始化" />
  181. <el-step title="自检" />
  182. <el-step title="设备状态" />
  183. </el-steps>
  184. <div v-if="activeStep === 0" class="check-main">
  185. <div v-for="item in checkList" :key="item.name" class="check-item">
  186. <el-tag>{{ item.name }}</el-tag>
  187. <el-icon v-if="item.status === 'success'" color="#26D574">
  188. <CircleCheckFilled />
  189. </el-icon>
  190. <el-icon v-else-if="item.status === 'error'" color="#FE0A0A">
  191. <CircleCloseFilled />
  192. </el-icon>
  193. <el-icon v-else-if="item.status === ''" class="el-icon--loading">
  194. <Loading />
  195. </el-icon>
  196. <ft-button v-if="item.status !== 'success'" size="small" type="primary" :click-handle="() => commandHandle(item)">
  197. 回原点
  198. </ft-button>
  199. </div>
  200. </div>
  201. <div v-if="activeStep === 1" class="check-box">
  202. <div class="progress-box">
  203. <p>自检进度: </p>
  204. <el-progress
  205. :stroke-width="20"
  206. :percentage="percentage"
  207. />
  208. </div>
  209. <ul>
  210. <li v-for="item in checkTextList" :key="item">
  211. {{ item }}
  212. </li>
  213. </ul>
  214. </div>
  215. <div v-if="activeStep === 2" class="check-box">
  216. <div v-for="item in heatList" :key="item.name" class="check-item">
  217. <el-tag>{{ item.name }}</el-tag>
  218. <el-icon v-if="item.status === 'success'" color="#26D574">
  219. <CircleCheckFilled />
  220. </el-icon>
  221. <el-icon v-else-if="item.status === 'error'" color="#FE0A0A">
  222. <CircleCloseFilled />
  223. </el-icon>
  224. <el-icon v-else-if="item.status === ''" class="el-icon--loading">
  225. <Loading />
  226. </el-icon>
  227. <ft-button v-if="item.status !== 'success'" size="small" type="primary" :click-handle="() => commandHandle(item)">
  228. 移出托盘
  229. </ft-button>
  230. </div>
  231. </div>
  232. <template #footer>
  233. <div style="height: 40px">
  234. <FtButton v-if="activeStep === 0 && checkList.length === 13 && checkList.every(item => item.status === 'success')" type="primary" :click-handle="checkHandle">
  235. 下一步
  236. </FtButton>
  237. <FtButton v-if="activeStep === 1 && percentage === 100" type="primary" :click-handle="checkHandle1">
  238. 下一步
  239. </FtButton>
  240. <FtButton v-if="activeStep === 2" :click-handle="onConfirm">
  241. 关闭
  242. </FtButton>
  243. </div>
  244. </template>
  245. </FtDialog>
  246. </template>
  247. <style scoped>
  248. .check-box {
  249. height: 45vh;
  250. ul {
  251. li {
  252. margin: 3px 0;
  253. }
  254. }
  255. }
  256. .progress-box {
  257. width: 100%;
  258. display: flex;
  259. align-items: center;
  260. p {
  261. margin-right: 10px;
  262. }
  263. span {
  264. margin-left: 10px;
  265. }
  266. .el-progress {
  267. flex: 1;
  268. }
  269. }
  270. .check-main{
  271. height: 65vh;
  272. overflow: auto;
  273. }
  274. .check-item {
  275. width: 100%;
  276. display: flex;
  277. align-items: center;
  278. margin-bottom: 10px;
  279. .el-tag {
  280. flex: 1;
  281. }
  282. .el-icon {
  283. margin: 0 10px;
  284. font-size: 18px;
  285. }
  286. }
  287. .check-status{
  288. display: grid;
  289. grid-template-columns: 2fr 1fr 1fr;
  290. margin-top: 5px;
  291. height: 30px;
  292. }
  293. @keyframes spin {
  294. 0% {
  295. transform: rotate(0deg);
  296. }
  297. 100% {
  298. transform: rotate(360deg);
  299. }
  300. }
  301. .el-icon.el-icon--loading {
  302. animation: spin 1s linear infinite;
  303. }
  304. </style>