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.

362 lines
10 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
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. ['dualRobotOrigin', { status: '', ignoreKey: 'dualRobotOriginIsIgnore', name: '加液机械臂回原点', params: { commandId: '', command: `dual_robot_origin`, params: {} } }],
  14. ['transferZOrigin', { status: '', ignoreKey: 'transferZOriginIsIgnore', name: 'z轴回原点', params: { commandId: '', command: `transfer_z_origin`, params: {} } }],
  15. ['transferXOrigin', { status: '', ignoreKey: 'transferXOriginIsIgnore', name: 'x轴回原点', params: { commandId: '', command: `transfer_x_origin`, params: {} } }],
  16. ['doorOrigin', { status: '', ignoreKey: 'doorOriginIsIgnore', name: '门电机回原点', params: { commandId: '', command: `door_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. ElMessageBox.confirm(
  76. '是否预充管路',
  77. '提示',
  78. {
  79. confirmButtonText: '确认',
  80. showClose: false,
  81. closeOnClickModal: false,
  82. closeOnPressEscape: false,
  83. type: 'warning',
  84. },
  85. ).then(async () => {
  86. currentCommandId = Date.now().toString()
  87. const params = {
  88. commandId: currentCommandId,
  89. command: 'liquid_pre_fill_when_launch',
  90. params: {},
  91. }
  92. await homeStore.sendControl(params)
  93. emits('close')
  94. }).catch(() => {
  95. emits('close')
  96. })
  97. }
  98. const percentage = ref(0)
  99. const checkHandle = async () => {
  100. activeStep.value = 1
  101. await ElMessageBox.confirm(
  102. '设备即将开始自检',
  103. '提示',
  104. {
  105. confirmButtonText: '确认',
  106. showClose: false,
  107. showCancelButton: false,
  108. closeOnClickModal: false,
  109. closeOnPressEscape: false,
  110. type: 'warning',
  111. customClass: 'init-message',
  112. },
  113. )
  114. currentCommandId = Date.now().toString()
  115. const params = {
  116. commandId: currentCommandId,
  117. command: 'move_test',
  118. params: {},
  119. }
  120. await homeStore.sendControl(params)
  121. }
  122. const checkTextList = ref<{ title: string, type: 'success' | 'error' }[]>([])
  123. const selfAgain = ref(false)
  124. const receiveMessageSelfMove = (data: any) => {
  125. checkTextList.value.push(data)
  126. percentage.value = data.schedule
  127. if (data.type === 'error') {
  128. selfAgain.value = true
  129. }
  130. }
  131. const activeStep = ref(0)
  132. const heatList = ref([
  133. {
  134. name: '加热区1',
  135. status: 'success',
  136. command: 'heat_module_01',
  137. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_01' } },
  138. },
  139. {
  140. name: '加热区2',
  141. status: 'success',
  142. command: 'heat_module_02',
  143. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_02' } },
  144. },
  145. {
  146. name: '加热区23',
  147. status: 'success',
  148. command: 'heat_module_03',
  149. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_03' } },
  150. },
  151. {
  152. name: '退火区',
  153. status: 'success',
  154. command: 'heat_module_04',
  155. params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_04' } },
  156. },
  157. ])
  158. const checkHandle1 = async () => {
  159. const res = await requireOutTray()
  160. res.forEach((item) => {
  161. const heatItem = heatList.value.find(heatItem => heatItem.command === item.moduleCode)
  162. heatItem!.status = item.trayExist ? 'error' : 'success'
  163. })
  164. activeStep.value = 2
  165. }
  166. const ignore = async (item: any) => {
  167. await setIgnoreItem({
  168. ignoreSelfTestType: '\'door_origin_is_ignore',
  169. ignore: true,
  170. })
  171. item.status = 'ignore'
  172. }
  173. const ignoreFalse = async (item: any) => {
  174. await setIgnoreItem({
  175. ignoreSelfTestType: 'door_origin_is_ignore',
  176. ignore: false,
  177. })
  178. item.status = 'error'
  179. }
  180. const checkAgain = async () => {
  181. selfAgain.value = false
  182. checkTextList.value = []
  183. currentCommandId = Date.now().toString()
  184. const params = {
  185. commandId: currentCommandId,
  186. command: 'move_test',
  187. params: {},
  188. }
  189. await homeStore.sendControl(params)
  190. }
  191. </script>
  192. <template>
  193. <FtDialog visible title="设备初始化" width="60%">
  194. <el-steps style="max-width: 600px" :active="activeStep" finish-status="success">
  195. <el-step title="初始化" />
  196. <el-step title="自检" />
  197. <el-step title="设备状态" />
  198. </el-steps>
  199. <div v-if="activeStep === 0" class="check-main">
  200. <div v-for="item in checkList" :key="item.name" class="check-item">
  201. <el-tag>{{ item.name }}</el-tag>
  202. <el-icon v-if="item.status === 'success'" color="#26D574">
  203. <CircleCheckFilled />
  204. </el-icon>
  205. <el-icon v-else-if="item.status === 'error'" color="#FE0A0A">
  206. <CircleCloseFilled />
  207. </el-icon>
  208. <el-icon v-else-if="item.status === ''" class="el-icon--loading">
  209. <Loading />
  210. </el-icon>
  211. <el-icon v-else-if="item.status === 'ignore'">
  212. <More />
  213. </el-icon>
  214. <ft-button v-if="!['ignore', 'success'].includes(item.status)" type="primary" size="small" :click-handle="() => commandHandle(item)">
  215. 回原点
  216. </ft-button>
  217. <ft-button v-if="!['ignore', 'success'].includes(item.status) && item.name === '门电机回原点'" size="small" type="primary" :click-handle="() => ignore(item)">
  218. 忽略
  219. </ft-button>
  220. <ft-button v-if="item.status === 'ignore' && item.name === '门电机回原点'" size="small" type="danger" :click-handle="() => ignoreFalse(item)">
  221. 取消忽略
  222. </ft-button>
  223. </div>
  224. </div>
  225. <div v-if="activeStep === 1" class="check-box">
  226. <div class="progress-box">
  227. <p>自检进度: </p>
  228. <el-progress
  229. :stroke-width="20"
  230. :percentage="percentage"
  231. />
  232. </div>
  233. <ul>
  234. <li v-for="(item, index) in checkTextList" :key="index">
  235. <span :style="{ color: item.type === 'success' ? '#14A656' : '#DF1515' }">{{ item.title }}</span>
  236. </li>
  237. </ul>
  238. </div>
  239. <div v-if="activeStep === 2" class="check-box">
  240. <div v-for="item in heatList" :key="item.name" class="check-item">
  241. <el-tag>{{ item.name }}</el-tag>
  242. <el-icon v-if="item.status === 'success'" color="#26D574">
  243. <CircleCheckFilled />
  244. </el-icon>
  245. <el-icon v-else-if="item.status === 'error'" color="#FE0A0A">
  246. <CircleCloseFilled />
  247. </el-icon>
  248. <el-icon v-else-if="item.status === ''" class="el-icon--loading">
  249. <Loading />
  250. </el-icon>
  251. <ft-button v-if="item.status !== 'success'" size="small" type="primary" :click-handle="() => commandHandle(item)">
  252. 移出托盘
  253. </ft-button>
  254. </div>
  255. </div>
  256. <template #footer>
  257. <div style="height: 40px">
  258. <FtButton v-if="activeStep === 0 && checkList.every(item => ['success', 'ignore'].includes(item.status))" type="primary" :click-handle="checkHandle">
  259. 下一步
  260. </FtButton>
  261. <FtButton v-if="activeStep === 1 && percentage === 100" type="primary" :click-handle="checkHandle1">
  262. 下一步
  263. </FtButton>
  264. <FtButton v-if="activeStep === 1 && selfAgain" type="primary" :click-handle="checkAgain">
  265. 重新自检
  266. </FtButton>
  267. <FtButton v-if="activeStep === 2" :click-handle="onConfirm">
  268. 关闭
  269. </FtButton>
  270. </div>
  271. </template>
  272. </FtDialog>
  273. </template>
  274. <style scoped>
  275. .check-box {
  276. height: 30vh;
  277. ul {
  278. li {
  279. margin: 3px 0;
  280. }
  281. }
  282. }
  283. .progress-box {
  284. width: 100%;
  285. height: 40px;
  286. display: flex;
  287. align-items: center;
  288. p {
  289. margin-right: 10px;
  290. }
  291. span {
  292. margin-left: 10px;
  293. }
  294. .el-progress {
  295. width: 80%;
  296. }
  297. }
  298. .check-main{
  299. height: 30vh;
  300. overflow: auto;
  301. }
  302. .check-item {
  303. width: 100%;
  304. display: flex;
  305. align-items: center;
  306. margin-bottom: 10px;
  307. .el-tag {
  308. width: 50%;
  309. }
  310. .el-icon {
  311. margin: 0 10px;
  312. font-size: 18px;
  313. }
  314. }
  315. .check-status{
  316. display: grid;
  317. grid-template-columns: 2fr 1fr 1fr;
  318. margin-top: 5px;
  319. height: 30px;
  320. }
  321. @keyframes spin {
  322. 0% {
  323. transform: rotate(0deg);
  324. }
  325. 100% {
  326. transform: rotate(360deg);
  327. }
  328. }
  329. .el-icon.el-icon--loading {
  330. animation: spin 1s linear infinite;
  331. }
  332. .ft-button {
  333. width:120px
  334. }
  335. </style>