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.

314 lines
8.8 KiB

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