|
|
@ -63,6 +63,7 @@ const getSpraying = async () => { |
|
|
|
const res = await getSprayStatus() |
|
|
|
const sprayTaskSprayedList = res.sprayTaskSprayedList |
|
|
|
form.value = res.sprayParams |
|
|
|
cmdId = res.cmdId |
|
|
|
form.value.position = [{ select: false }, { select: false }, { select: false }, { select: false }] |
|
|
|
sprayTaskSprayedList.forEach((item: any) => { |
|
|
|
form.value.position[item.index] = { |
|
|
@ -82,6 +83,7 @@ const getSpraying = async () => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
socket.init(sprayPointReceiveMessage, 'spray_point') |
|
|
|
socket.init(finishMessage, 'cmd_response') |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
@ -143,6 +145,7 @@ const checkPosition = () => { |
|
|
|
return position |
|
|
|
} |
|
|
|
|
|
|
|
const maskVisible = ref(false) |
|
|
|
const startWork = async () => { |
|
|
|
formRef.value.validate(async (valid: boolean) => { |
|
|
|
console.log('valid', valid) |
|
|
@ -155,10 +158,10 @@ const startWork = async () => { |
|
|
|
if (!position) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
cmdId = Date.now().toString() |
|
|
|
const params = { |
|
|
|
cmdCode: 'matrix_spray_start', |
|
|
|
cmdId: Date.now().toString(), |
|
|
|
cmdId, |
|
|
|
params: { |
|
|
|
...form.value, |
|
|
|
position, |
|
|
@ -166,16 +169,8 @@ const startWork = async () => { |
|
|
|
} |
|
|
|
console.log(params) |
|
|
|
socket.init(sprayPointReceiveMessage, 'spray_point') |
|
|
|
socket.init((data: any) => { |
|
|
|
console.log(data) |
|
|
|
if (data.cmdId === params.cmdId && data.status === 'spray_task_finish') { |
|
|
|
form.value.position.forEach((item, index) => { |
|
|
|
if (item.select) { |
|
|
|
sprayRefs.value[index].clearLines() |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}, 'cmd_response') |
|
|
|
socket.init(finishMessage, 'cmd_response') |
|
|
|
maskVisible.value = true |
|
|
|
await sendControl(params) |
|
|
|
currentSpeed = Number(form.value.movingSpeed) |
|
|
|
}) |
|
|
@ -186,9 +181,12 @@ let currentSpeed = 0 |
|
|
|
console.log(currentSpeed) |
|
|
|
const colors = ['#FAF0E6', '#191970', '#2E8B57', '#C0FF3E', '#8B658B', '#EE7942', '#EE1289', '#FF00FF', '#C6E2FF', '#556B2F', '#00BFFF', '#7B68EE'] |
|
|
|
const sprayPointReceiveMessage = (data: any) => { |
|
|
|
const { currentPoint, nextPoint, index, number } = data |
|
|
|
drawLine(index, { x: currentPoint.x * 5, y: currentPoint.y * 5 }, number) |
|
|
|
drawLine(index, { x: nextPoint.x * 5, y: nextPoint.y * 5 }, number) |
|
|
|
if (data.cmdId === cmdId) { |
|
|
|
const { currentPoint, nextPoint, index, number } = data |
|
|
|
drawLine(index, { x: currentPoint.x * 5, y: currentPoint.y * 5 }, number) |
|
|
|
drawLine(index, { x: nextPoint.x * 5, y: nextPoint.y * 5 }, number) |
|
|
|
} |
|
|
|
|
|
|
|
// if (poll) { |
|
|
|
// clearInterval(poll) |
|
|
|
// } |
|
|
@ -218,6 +216,18 @@ const sprayPointReceiveMessage = (data: any) => { |
|
|
|
// }, 500) |
|
|
|
// } |
|
|
|
} |
|
|
|
let cmdId = '' |
|
|
|
const finishMessage = (data: any) => { |
|
|
|
console.log(data) |
|
|
|
if (data.cmdId === cmdId && data.status === 'spray_task_finish') { |
|
|
|
form.value.position.forEach((item, index) => { |
|
|
|
if (item.select) { |
|
|
|
sprayRefs.value[index].clearLines() |
|
|
|
} |
|
|
|
}) |
|
|
|
maskVisible.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const drawLine = async (index: number, point: { x: number, y: number }, number: number) => { |
|
|
|
await nextTick(() => { |
|
|
@ -383,7 +393,7 @@ const addCraft = () => { |
|
|
|
<div class="select-box" /> |
|
|
|
</div> |
|
|
|
<div style="display: flex; position: relative"> |
|
|
|
<div v-show="false" class="mask-box" /> |
|
|
|
<div v-show="maskVisible" class="mask-box" /> |
|
|
|
<div |
|
|
|
v-for="(p, index) in form.position" |
|
|
|
:key="index" |
|
|
|