Browse Source

增加自检功能

master
王梦远 1 week ago
parent
commit
cc2690efb0
  1. 1
      src/apis/self.ts
  2. 155
      src/components/system/Check/index.vue

1
src/apis/self.ts

@ -1,4 +1,3 @@
import http from 'libs/http'
export const getSelfStatus = (): Promise<Record<string, boolean>> => http.get('/self-test/status')
export const getSelfFinish = (params: boolean): Promise<Record<string, boolean>> => http.post('/self-test/finish', { params: { mode: params } })

155
src/components/system/Check/index.vue

@ -1,6 +1,5 @@
<script lang="ts" setup>
import { getSelfFinish, getSelfStatus } from 'apis/self'
import { requireOutTray, setIgnoreItem } from 'apis/system'
import { getSelfFinish } from 'apis/self'
import { ElMessageBox } from 'element-plus'
import { socket } from 'libs/socket'
import { useHomeStore } from 'stores/homeStore'
@ -12,10 +11,11 @@ const homeStore = useHomeStore()
const systemStore = useSystemStore()
const checkMap = ref(new Map([
['dualRobotOrigin', { status: '', ignoreKey: 'dualRobotOriginIsIgnore', name: '加液机械臂回原点', params: { commandId: '', command: `dual_robot_origin`, params: {} } }],
['transferZOrigin', { status: '', ignoreKey: 'transferZOriginIsIgnore', name: 'z轴回原点', params: { commandId: '', command: `transfer_z_origin`, params: {} } }],
['transferXOrigin', { status: '', ignoreKey: 'transferXOriginIsIgnore', name: 'x轴回原点', params: { commandId: '', command: `transfer_x_origin`, params: {} } }],
['doorOrigin', { status: '', ignoreKey: 'doorOriginIsIgnore', name: '门电机回原点', params: { commandId: '', command: `door_origin`, params: {} } }],
['zOrigin', { status: '', ignoreKey: 'zOriginIsIgnore', name: 'Z轴回原点', params: { commandId: '', command: `check_z_origin`, params: {} } }],
['xyOrigin', { status: '', ignoreKey: 'xyOriginIsIgnore', name: '机械臂回原点', params: { commandId: '', command: `check_xy_origin`, params: {} } }],
['titrationOrigin', { status: '', ignoreKey: 'titrationOriginIsIgnore', name: '滴定电机回原点', params: { commandId: '', command: `check_titration_motor_origin`, params: {} } }],
['shakeOrigin', { status: '', ignoreKey: 'shakeOriginIsIgnore', name: '摇匀电机回原点', params: { commandId: '', command: `check_shake_motor_origin`, params: {} } }],
['stirOrigin', { status: '', ignoreKey: 'stirOriginIsIgnore', name: '磁子投放电机回原点', params: { commandId: '', command: `check_stir_motor_origin`, params: {} } }],
]))
const checkList = ref<any[]>([])
@ -24,21 +24,8 @@ onMounted(async () => {
socket.init(receiveMessage1, 'cmd_debug')
socket.init(receiveMessage2, 'cmd_response')
socket.init(receiveMessageSelfMove, 'self_move_test')
const res = await getSelfStatus()
for (const key in res) {
const entry = checkMap.value.get(key)
if (entry) {
entry.status = res[key] ? 'success' : 'error'
}
for (const [checkKey] of checkMap.value) {
const data = checkMap.value.get(checkKey)
if (key === data?.ignoreKey) {
res[key] && (data.status = 'ignore')
}
}
}
await ElMessageBox.confirm(
'设备转运机械臂x、z, 加液机械臂, 门等需进行初始化,请确认机械臂行进路径无杂物',
'设备转运机械臂、滴定电机、摇匀电机、磁子投放电机,请确认机械臂行进路径无杂物',
'提示',
{
confirmButtonText: '确认',
@ -67,11 +54,6 @@ const receiveMessage2 = (data: Socket.cmdData) => {
if (item && data.commandId === item.params.commandId && ['success', 'error'].includes(data.status)) {
item.status = data.status
}
const item1 = heatList.value.find(item => item.params.commandId === data.commandId)
if (item1 && data.commandId === item1.params.commandId && ['success', 'error'].includes(data.status)) {
item.status = data.status
}
}
const commandHandle = async (data: any) => {
@ -81,28 +63,7 @@ const commandHandle = async (data: any) => {
const onConfirm = async () => {
await getSelfFinish(true)
ElMessageBox.confirm(
'是否预充管路',
'提示',
{
confirmButtonText: '确认',
showClose: false,
closeOnClickModal: false,
closeOnPressEscape: false,
type: 'warning',
},
).then(async () => {
currentCommandId = Date.now().toString()
const params = {
commandId: currentCommandId,
command: 'liquid_pre_fill_when_launch',
params: {},
}
await homeStore.sendControl(params)
emits('close')
}).catch(() => {
emits('close')
})
emits('close')
}
const percentage = ref(0)
@ -125,7 +86,7 @@ const checkHandle = async () => {
currentCommandId = Date.now().toString()
const params = {
commandId: currentCommandId,
command: 'move_test',
command: 'check_move_test',
params: {},
}
await homeStore.sendControl(params)
@ -133,7 +94,7 @@ const checkHandle = async () => {
const checkTextList = ref<{ title: string, type: 'success' | 'error' }[]>([])
const selfAgain = ref(false)
const selfAgain = ref(true)
const receiveMessageSelfMove = (data: any) => {
checkTextList.value.push(data)
percentage.value = data.schedule
@ -141,81 +102,30 @@ const receiveMessageSelfMove = (data: any) => {
selfAgain.value = true
}
}
const activeStep = ref(0)
const heatList = ref([
{
name: '加热区1',
status: 'success',
command: 'heat_module_01',
params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_01' } },
},
{
name: '加热区2',
status: 'success',
command: 'heat_module_02',
params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_02' } },
},
{
name: '加热区3',
status: 'success',
command: 'heat_module_03',
params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_03' } },
},
{
name: '退火区',
status: 'success',
command: 'heat_module_04',
params: { commandId: '', command: `tray_out`, params: { heatId: 'heat_module_04' } },
},
])
const checkHandle1 = async () => {
const res = await requireOutTray()
res.forEach((item) => {
const heatItem = heatList.value.find(heatItem => heatItem.command === item.moduleCode)
heatItem!.status = item.trayExist ? 'error' : 'success'
})
activeStep.value = 2
}
const ignore = async (item: any) => {
await setIgnoreItem({
ignoreSelfTestType: 'door_origin_is_ignore',
ignore: true,
})
item.status = 'ignore'
}
const ignoreFalse = async (item: any) => {
await setIgnoreItem({
ignoreSelfTestType: 'door_origin_is_ignore',
ignore: false,
})
item.status = 'error'
}
const checkAgain = async () => {
selfAgain.value = false
checkTextList.value = []
percentage.value = 0
currentCommandId = Date.now().toString()
const params = {
commandId: currentCommandId,
command: 'move_test',
command: 'check_move_test',
params: {},
}
await homeStore.sendControl(params)
selfAgain.value = true
}
</script>
<template>
<FtDialog visible title="设备初始化" width="60%">
<el-steps style="max-width: 600px" :active="activeStep" finish-status="success">
<!-- <el-steps style="max-width: 600px" :active="activeStep" finish-status="success">
<el-step title="初始化" />
<el-step title="自检" />
<el-step title="设备状态" />
</el-steps>
</el-steps> -->
<div v-if="activeStep === 0" class="check-main">
<div v-for="item in checkList" :key="item.name" class="check-item">
<el-tag>{{ item.name }}</el-tag>
@ -234,12 +144,12 @@ const checkAgain = async () => {
<ft-button v-if="!['ignore', 'success'].includes(item.status)" type="primary" size="small" :click-handle="() => commandHandle(item)">
回原点
</ft-button>
<ft-button v-if="!['ignore', 'success'].includes(item.status) && item.name === '门电机回原点'" size="small" type="primary" :click-handle="() => ignore(item)">
<!-- <ft-button v-if="!['ignore', 'success'].includes(item.status) && item.name === '门电机回原点'" size="small" type="primary" :click-handle="() => ignore(item)">
忽略
</ft-button>
<ft-button v-if="item.status === 'ignore' && item.name === '门电机回原点'" size="small" type="danger" :click-handle="() => ignoreFalse(item)">
取消忽略
</ft-button>
</ft-button> -->
</div>
</div>
<div v-if="activeStep === 1" class="check-box">
@ -257,36 +167,15 @@ const checkAgain = async () => {
</ul>
</div>
<div v-if="activeStep === 2" class="check-box">
<div v-for="item in heatList" :key="item.name" class="check-item">
<el-tag>{{ item.name }}</el-tag>
<el-icon v-if="item.status === 'success'" color="#26D574">
<CircleCheckFilled />
</el-icon>
<el-icon v-else-if="item.status === 'error'" color="#FE0A0A">
<CircleCloseFilled />
</el-icon>
<el-icon v-else-if="item.status === ''" class="el-icon--loading">
<Loading />
</el-icon>
<ft-button v-if="item.status !== 'success'" size="small" type="primary" :click-handle="() => commandHandle(item)">
移出托盘
</ft-button>
</div>
</div>
<template #footer>
<div style="height: 40px">
<FtButton v-if="activeStep === 0 && checkList.every(item => ['success', 'ignore'].includes(item.status))" type="primary" :click-handle="checkHandle">
下一步
</FtButton>
<FtButton v-if="activeStep === 1 && percentage === 100" type="primary" :click-handle="checkHandle1">
下一步
</FtButton>
<FtButton v-if="activeStep === 1 && selfAgain" type="primary" :click-handle="checkAgain">
重新自检
</FtButton>
<FtButton v-if="activeStep === 2" :click-handle="onConfirm">
<FtButton v-if="activeStep === 1" :click-handle="onConfirm">
关闭
</FtButton>
</div>
@ -319,15 +208,19 @@ const checkAgain = async () => {
}
}
.check-main{
height: 30vh;
height: 25vh;
overflow: auto;
display: flex;
flex-direction: column;
justify-content: flex-start;
margin-top: 20px;
}
.check-item {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 10px;
.el-tag {
width: 50%;

Loading…
Cancel
Save