10 changed files with 514 additions and 313 deletions
-
17src/assets/styles/element.scss
-
0src/components/Stop/index.vue
-
375src/components/check/index.vue
-
318src/components/check1/index.vue
-
26src/layouts/default.vue
-
2src/libs/utils.ts
-
3src/router/index.ts
-
4src/views/container/liquidItem.vue
-
2tsconfig.json
@ -0,0 +1,318 @@ |
|||||
|
<script lang="ts" setup> |
||||
|
import { getSelfFinish, getSelfStatus } from '@/apis/self' |
||||
|
import { ElMessage } from 'element-plus' |
||||
|
import { socket } from 'libs/socket' |
||||
|
import { useHomeStore } from 'stores/homeStore' |
||||
|
import { useSystemStore } from 'stores/systemStore' |
||||
|
import { onMounted, onUnmounted, ref } from 'vue' |
||||
|
|
||||
|
interface SelfStatus { |
||||
|
name: string |
||||
|
isOrign: boolean |
||||
|
value: string |
||||
|
type: string |
||||
|
} |
||||
|
const emits = defineEmits(['close']) |
||||
|
const homeStore = useHomeStore() |
||||
|
const systemStore = useSystemStore() |
||||
|
|
||||
|
const loading = ref(false) |
||||
|
|
||||
|
onMounted(() => { |
||||
|
socket.init(receiveMessage, 'cmd_debug') |
||||
|
socket.init(receiveMessage, 'cmd_response') |
||||
|
onStartSelfTest() |
||||
|
}) |
||||
|
onUnmounted(() => { |
||||
|
clearInterval(patrolTimes.value) |
||||
|
socket.unregisterCallback(receiveMessage, 'cmd_debug') |
||||
|
socket.unregisterCallback(receiveMessage, 'cmd_response') |
||||
|
}) |
||||
|
|
||||
|
const receiveMessage = (data: Socket.cmdData) => { |
||||
|
data.commandId === currentCommandId && systemStore.pushSystemList(data) |
||||
|
} |
||||
|
|
||||
|
const onStartSelfTest = () => { |
||||
|
patrolSelfStatus() |
||||
|
} |
||||
|
const statusMap: Record<string, Record<string, string>> = { |
||||
|
doorOrigin: { |
||||
|
name: '门', |
||||
|
value: '', |
||||
|
type: 'door', |
||||
|
}, |
||||
|
shakeOrigin: { |
||||
|
name: '摇匀电机', |
||||
|
value: '', |
||||
|
type: 'shake', |
||||
|
}, |
||||
|
gantryXOrigin: { |
||||
|
name: '机械臂x轴', |
||||
|
value: 'x', |
||||
|
type: 'axis', |
||||
|
}, |
||||
|
gantryYOrigin: { |
||||
|
name: '机械臂y轴', |
||||
|
value: 'y', |
||||
|
type: 'axis', |
||||
|
}, |
||||
|
gantryZOrigin: { |
||||
|
name: '机械臂z轴', |
||||
|
value: 'z', |
||||
|
type: 'axis', |
||||
|
}, |
||||
|
dualRobotOrigin: { |
||||
|
name: '加液机械臂', |
||||
|
value: '', |
||||
|
type: 'liquid', |
||||
|
}, |
||||
|
// dualRobotJoint2Origin: { |
||||
|
// name: '机械臂02', |
||||
|
// value: 'smallArm', |
||||
|
// type: 'liquid', |
||||
|
// }, |
||||
|
capLiftingOrigin: { |
||||
|
name: '拍子电机升降', |
||||
|
value: '', |
||||
|
type: 'cap', |
||||
|
}, |
||||
|
trayLifting01Origin: { |
||||
|
name: '加热区01托盘升降', |
||||
|
value: 'heat_module_01', |
||||
|
type: 'heat', |
||||
|
}, |
||||
|
trayLifting02Origin: { |
||||
|
name: '加热区02托盘升降', |
||||
|
value: 'heat_module_02', |
||||
|
type: 'heat', |
||||
|
}, |
||||
|
trayLifting03Origin: { |
||||
|
name: '加热区03托盘升降', |
||||
|
value: 'heat_module_03', |
||||
|
type: 'heat', |
||||
|
}, |
||||
|
trayLifting04Origin: { |
||||
|
name: '加热区04托盘升降', |
||||
|
value: 'heat_module_04', |
||||
|
type: 'heat', |
||||
|
}, |
||||
|
trayLifting05Origin: { |
||||
|
name: '加热区05托盘升降', |
||||
|
value: 'heat_module_05', |
||||
|
type: 'heat', |
||||
|
}, |
||||
|
trayLifting06Origin: { |
||||
|
name: '加热区06托盘升降', |
||||
|
value: 'heat_module_06', |
||||
|
type: 'heat', |
||||
|
}, |
||||
|
} |
||||
|
|
||||
|
const patrolTimes = ref() |
||||
|
const patrolSelfStatus = () => { |
||||
|
loading.value = true |
||||
|
patrolTimes.value = setInterval(() => { |
||||
|
querySelfStatus() |
||||
|
}, 1000) |
||||
|
} |
||||
|
|
||||
|
const deviceStatusList = ref<SelfStatus[]>([]) |
||||
|
const selfStateComplete = ref(false) |
||||
|
const querySelfStatus = () => { |
||||
|
const orignStatusList = [] |
||||
|
getSelfStatus().then((res) => { |
||||
|
console.log('res', res) |
||||
|
loading.value = false |
||||
|
if (res) { |
||||
|
try { |
||||
|
const list: SelfStatus[] = [] |
||||
|
const keys = Object.keys(res) |
||||
|
keys.forEach((item) => { |
||||
|
list.push({ |
||||
|
name: statusMap[item].name, |
||||
|
isOrign: res[item], |
||||
|
value: statusMap[item].value, |
||||
|
type: statusMap[item].type, |
||||
|
}) |
||||
|
if (res[item]) { |
||||
|
orignStatusList.push(item) |
||||
|
} |
||||
|
if (orignStatusList.length === keys.length) { |
||||
|
clearInterval(patrolTimes.value) |
||||
|
selfStateComplete.value = true |
||||
|
} |
||||
|
}) |
||||
|
deviceStatusList.value = list |
||||
|
console.log('deviceStatusList', list) |
||||
|
} |
||||
|
catch (e) { |
||||
|
console.log('error', e) |
||||
|
} |
||||
|
} |
||||
|
}).catch(() => { |
||||
|
loading.value = false |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
const resetOrign = (item: SelfStatus) => { |
||||
|
if (item.type === 'door') { |
||||
|
door_origin() |
||||
|
} |
||||
|
if (item.type === 'shake') { |
||||
|
shake_origin() |
||||
|
} |
||||
|
else if (item.value === 'x' || item.value === 'y' || item.value === 'z') { |
||||
|
gantry_origin(item.value) |
||||
|
} |
||||
|
else if (item.type === 'liquid') { |
||||
|
dual_robot_origin() |
||||
|
} |
||||
|
else if (item.type === 'heat') { |
||||
|
tray_lifting_origin(item.value) |
||||
|
} |
||||
|
else if (item.type === 'cap') { |
||||
|
cap_lifting_origin() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const shake_origin = async () => { |
||||
|
currentCommandId = Date.now().toString() |
||||
|
|
||||
|
const params = { |
||||
|
commandId: currentCommandId, |
||||
|
command: `shake_origin`, |
||||
|
params: {}, |
||||
|
} |
||||
|
await homeStore.sendControl(params) |
||||
|
} |
||||
|
|
||||
|
const door_origin = async () => { |
||||
|
currentCommandId = Date.now().toString() |
||||
|
|
||||
|
const params = { |
||||
|
commandId: currentCommandId, |
||||
|
command: `door_origin`, |
||||
|
params: {}, |
||||
|
} |
||||
|
await homeStore.sendControl(params) |
||||
|
} |
||||
|
|
||||
|
// 先注释 TODO |
||||
|
// const currentPumpId = ref() |
||||
|
// const onPumpChange = (value: string) => { |
||||
|
// currentPumpId.value = value |
||||
|
// } |
||||
|
// const onPumpEmpty = () => { |
||||
|
// console.log('===currentPumpId===', currentPumpId.value) |
||||
|
// } |
||||
|
|
||||
|
let currentCommandId = '' |
||||
|
const gantry_origin = async (motor: 'x' | 'y' | 'z') => { |
||||
|
currentCommandId = Date.now().toString() |
||||
|
|
||||
|
const params = { |
||||
|
commandId: currentCommandId, |
||||
|
command: `gantry_${motor}_origin`, |
||||
|
params: {}, |
||||
|
} |
||||
|
await homeStore.sendControl(params) |
||||
|
} |
||||
|
|
||||
|
const dual_robot_origin = async () => { |
||||
|
currentCommandId = Date.now().toString() |
||||
|
const params = { |
||||
|
commandId: currentCommandId, |
||||
|
command: 'dual_robot_origin', |
||||
|
params: {}, |
||||
|
} |
||||
|
await homeStore.sendControl(params) |
||||
|
} |
||||
|
|
||||
|
const cap_lifting_origin = async () => { |
||||
|
currentCommandId = Date.now().toString() |
||||
|
const params = { |
||||
|
commandId: currentCommandId, |
||||
|
command: 'cap_lifting_origin', |
||||
|
params: {}, |
||||
|
} |
||||
|
await homeStore.sendControl(params) |
||||
|
} |
||||
|
|
||||
|
const tray_lifting_origin = async (heatId: string) => { |
||||
|
currentCommandId = Date.now().toString() |
||||
|
const params = { |
||||
|
commandId: currentCommandId, |
||||
|
command: 'tray_lifting_origin', |
||||
|
params: { |
||||
|
heatId, |
||||
|
}, |
||||
|
} |
||||
|
await homeStore.sendControl(params) |
||||
|
} |
||||
|
|
||||
|
const onComplete = () => { |
||||
|
getSelfFinish().then(() => { |
||||
|
ElMessage.success('自检完成') |
||||
|
emits('close') |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// const cancel = () => { |
||||
|
// emits('update:checking', false) |
||||
|
// visible.value = false |
||||
|
// } |
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<FtDialog visible title="自检" width="50%"> |
||||
|
<div v-loading="loading" class="check-main"> |
||||
|
<!-- <div v-if="type !== 'cancel'"> --> |
||||
|
<!-- <span style="color: red">所有电机回原点后才可操作</span> --> |
||||
|
<!-- </div> --> |
||||
|
<div class="check-status"> |
||||
|
<h3>名称</h3> |
||||
|
<h3>是否在原点</h3> |
||||
|
<h3 style="text-align: center;"> |
||||
|
操作 |
||||
|
</h3> |
||||
|
</div> |
||||
|
<div v-for="(item) in deviceStatusList" :key="item.name" class="check-status"> |
||||
|
<div> |
||||
|
{{ item.name }} |
||||
|
</div> |
||||
|
<div style="margin-left: 2rem;"> |
||||
|
<el-icon v-if="!item.isOrign" style="color:red;font-size: 25px;"> |
||||
|
<CloseBold /> |
||||
|
</el-icon> |
||||
|
<el-icon v-else style="color:#25be25;font-size: 25px;"> |
||||
|
<Select /> |
||||
|
</el-icon> |
||||
|
</div> |
||||
|
<div v-if="!item.isOrign" style="text-align: center;"> |
||||
|
<ft-button type="primary" :click-handle="() => resetOrign(item)"> |
||||
|
回原点 |
||||
|
</ft-button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<template #footer> |
||||
|
<FtButton :disabled="!selfStateComplete" :click-handle="onComplete"> |
||||
|
关闭 |
||||
|
</FtButton> |
||||
|
</template> |
||||
|
</FtDialog> |
||||
|
</template> |
||||
|
|
||||
|
<style scoped> |
||||
|
.check-main{ |
||||
|
height: 70vh; |
||||
|
overflow: auto; |
||||
|
} |
||||
|
.check-status{ |
||||
|
display: grid; |
||||
|
grid-template-columns: 2fr 1fr 1fr; |
||||
|
margin-top: 5px; |
||||
|
height: 30px; |
||||
|
} |
||||
|
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue