Browse Source

Merge remote-tracking branch 'origin/master'

master
liupeng 6 months ago
parent
commit
5d9d817419
  1. 2
      src/core/manager/EnvManager.ts
  2. 42
      src/editor/widgets/task/TaskView2.vue
  3. 42
      src/modules/amr/ptr/PtrObject.ts
  4. 4
      src/modules/amr/ptr/cl2/Cl23dObject.ts
  5. 5
      src/modules/amr/ptr/clx/Clx3dObject.ts
  6. 2
      src/router/index.ts

2
src/core/manager/EnvManager.ts

@ -17,7 +17,7 @@ export default class EnvManager {
}
onMqttMessage = (topic: string, payload: Buffer, packet: IPublishPacket) => {
console.log(`[${topic}]-> ${payload.toString()}`)
// console.log(`[${topic}]-> ${payload.toString()}`)
if (topic.startsWith('/wcs_server/')) {
const message: AmrMsg<any> = JSON.parse(payload.toString())
this.amrMessageManager.handleMessage(topic, message)

42
src/editor/widgets/task/TaskView2.vue

@ -5,6 +5,8 @@ import { localeText as localeTextCn } from "@/components/yvTable/yv-aggrid-cn.lo
import { Request } from "@ease-forge/shared";
import type { GridOptions } from "ag-grid-enterprise";
import type { GridApi, GridReadyEvent } from "ag-grid-community";
import { Refresh } from "@element-plus/icons-vue";
import { ElButton, ElInput, ElSwitch } from "element-plus";
defineOptions({
name: 'TaskView',
@ -20,12 +22,14 @@ const props = withDefaults(defineProps<TaskViewProps>(), {});
// State
interface TaskViewState {
loading: boolean;
automaticTracking: boolean;
grid1Data: Array<any>;
}
// state
const state = reactive<TaskViewState>({
loading: false,
automaticTracking: false,
grid1Data: [],
});
@ -50,6 +54,7 @@ const data: TaskViewData = {
{ field: 'type', headerName: '类型', width: 120 },
{ field: 'status', headerName: '状态', width: 120 },
{ field: 'err', headerName: '异常' },
{ field: 'progress', headerName: '进度' },
{ field: 'payload', headerName: '任务负载', width: 600 },
{ field: 'priority', headerName: '优先级', width: 120 },
{ field: 'info', headerName: '任务明细', width: 800 },
@ -65,7 +70,7 @@ const data: TaskViewData = {
field: 'title',
width: 300,
},
groupDefaultExpanded: -1,
// groupDefaultExpanded: -1,
onGridReady(event: GridReadyEvent) {
data.api = event.api;
},
@ -160,12 +165,13 @@ function toTreeData(data: Array<any>) {
info: `报文类型: ${device.packetType}, 报文目标点: ${device.packetEndPoint}, 报文内容: ${device.packetPayload}, 执行器ID: ${device.deviceItemId}`,
children: [],
};
// planNode.children.push(deviceNode);
planNode.children.push(deviceNode);
tree.push(deviceNode);
}
// bizNode.children.push(planNode);
bizNode.children.push(planNode);
tree.push(planNode);
}
bizNode.progress = `${bizNode.children.filter(item => item.status === PlanTaskStatus.FINISHED).length}/${bizNode.children.length}`;
tree.push(bizNode);
}
return tree;
@ -190,10 +196,27 @@ export type {
</script>
<template>
<div class="task-view">
<div class="task-view flex-column-container">
<div class="tools flex-item-fixed flex-row-container">
<ElButton :icon="Refresh" :loading="state.loading" @click="reload">刷新</ElButton>
<div class="flex-row-container flex-align-items-center">
<div class="flex-item-fixed" style="padding-right: 4px;">自动追踪:</div>
<ElSwitch
class="flex-item-fixed"
v-model="state.automaticTracking"
inline-prompt
active-text="开启"
inactive-text="关闭"
/>
</div>
<div class="flex-row-container flex-align-items-center">
<div class="flex-item-fixed" style="padding-right: 4px;">筛选过滤:</div>
<ElInput class="flex-item-fixed" placeholder="关键字"/>
</div>
</div>
<AgGridVue
ref="gridRef"
:class="['ag-theme-alpine', 'yv-table', 'hi-light-selected-row','allow-vertical-line', 'grid1']"
:class="['ag-theme-alpine', 'yv-table', 'hi-light-selected-row','allow-vertical-line', 'flex-item-fill','grid1']"
v-bind="{...data.gridSetting}"
:modelValue="state.grid1Data"
>
@ -206,7 +229,12 @@ export type {
height: 100%;
}
.task-view > .grid1 {
height: 100%;
.tools {
padding: 8px;
column-gap: 8px;
}
.task-view .grid1 {
}
</style>

42
src/modules/amr/ptr/PtrObject.ts

@ -62,7 +62,12 @@ export default class PtrObject extends THREE.Object3D {
private runningStepTask: StepTask = null
public runningStepTaskList: StepTask[] = []
// 移动动画
public travelAnimation: core.Tween = null
// 旋转动画
public rotationAnimation: core.Tween = null
// 动作动画
public actionAnimation: core.Tween = null
// 心跳间隔 UInt32 单位: s
private heartBeatInterval: number = 0
@ -345,7 +350,7 @@ export default class PtrObject extends THREE.Object3D {
if (!worldModel.state.runState.isVirtual) {
return
}
console.log('send message:', JSON.stringify(msg))
// console.log('send message:', JSON.stringify(msg))
if (this.sendMessageQueue.indexOf(msg) < 0) {
this.sendMessageQueue.push(msg)
}
@ -428,17 +433,17 @@ export default class PtrObject extends THREE.Object3D {
while (ra < 0) {
ra += Math.PI * 2
}
const ddra = Math.PI / 8
if (ra >= ddra * 7 || ra < ddra) {
const ddra = Math.PI / 180
if (ra >= Math.PI * 2 - ddra || ra <= ddra) {
this.currentDirection = 0;
} else if (ra >= ddra && ra < ddra * 3) {
} else if (ra >= Math.PI/2 - ddra && ra <= Math.PI/2 + ddra) {
this.currentDirection = 3;
} else if (ra >= ddra * 3 && ra < ddra * 5) {
} else if (ra >= Math.PI - ddra && ra <= Math.PI + ddra) {
this.currentDirection = 2;
} else if (ra >= ddra * 5 && ra < ddra * 7) {
} else if (ra >= Math.PI/2*3 - ddra && ra <= Math.PI/2*3 + ddra) {
this.currentDirection = 1;
} else {
this.currentDirection = 15;
@ -477,11 +482,13 @@ export default class PtrObject extends THREE.Object3D {
}
let endDirection = currentStepTask.EndDirection
if (data.Link.length > 0) {
const linkCount = data.Link?.length || 0
if (linkCount > 0) {
for (let i = 0; i < data.Link.length; i++) {
const link = data.Link[i]
if ((currentStepTask.X == link.X && currentStepTask.Y == link.Y)
|| (currentStepTask.X != link.X && currentStepTask.Y != link.Y)) {
debugger
continue
} else if (currentStepTask.X < link.X) {
if (link.Speed > 0) {
@ -547,6 +554,9 @@ export default class PtrObject extends THREE.Object3D {
}
}
// 如果没有link 或者当前link的XY是任务结束点位
if (linkCount <= 0
|| (linkCount > 0 && data.Link[linkCount - 1].X == data.EndX && data.Link[linkCount - 1].Y == data.EndY)) {
if (data.OperationType == 0 && data.EndDirection >= 0 && data.EndDirection <= 3) {
endDirection = data.EndDirection;
@ -615,6 +625,10 @@ export default class PtrObject extends THREE.Object3D {
} else {
}
}
console.log(JSON.stringify(this.currentStepTaskList))
}
@ -624,6 +638,7 @@ export default class PtrObject extends THREE.Object3D {
const stepTask = this.currentStepTaskList[0]
if (this.runningStepTask) {
if ((stepTask.StepTaskType == "MOVE" || stepTask.StepTaskType == "MOVE_BACKWARD")
&& this.rotationAnimation == null && this.actionAnimation == null
&& stepTask.EndDirection == this.runningStepTask.EndDirection
&& (stepTask.Speed > 0) == (this.runningStepTask.Speed > 0)) {
this.runningStepTask = stepTask
@ -693,12 +708,13 @@ export default class PtrObject extends THREE.Object3D {
const duration = time
return new Promise(resolve => {
gsap.to(this.rotation, {
this.rotationAnimation = gsap.to(this.rotation, {
y: tr,
duration,
ease: 'none',
onComplete: ()=>{
resolve()
this.rotationAnimation = null
this.onActionCompleted()
}
})
@ -718,11 +734,7 @@ export default class PtrObject extends THREE.Object3D {
if (!this.travelAnimation) {
return new Promise(resolve => {
this.travelAnimation = gsap.fromTo(this.position, {
x: fromPos.x,
y: fromPos.y,
z: fromPos.z,
}, {
this.travelAnimation = gsap.to(this.position, {
x: toPos.x,
y: toPos.y,
z: toPos.z,
@ -776,6 +788,7 @@ export default class PtrObject extends THREE.Object3D {
()=>this.animationUpFork(height + 0.2).then(
()=>this.animationHideFork().then(
()=>this.animationDownFork().then(()=>{
this.actionAnimation = null
this.onActionCompleted()
})
)
@ -792,6 +805,7 @@ export default class PtrObject extends THREE.Object3D {
()=>this.animationUpFork(height).then(
()=>this.animationHideFork().then(
()=>this.animationDownFork().then(()=>{
this.actionAnimation = null
this.onActionCompleted()
})
)
@ -815,13 +829,13 @@ export default class PtrObject extends THREE.Object3D {
//获取ptr的角度朝向
getAmrOrientation(radY: number) {
radY = radY + Math.PI
while (radY < 0) {
radY += Math.PI * 2
}
while (radY > Math.PI * 2) {
radY -= Math.PI * 2
}
radY = (Math.PI * 2 - radY)%(Math.PI * 2)
return THREE.MathUtils.radToDeg(radY)
}

4
src/modules/amr/ptr/cl2/Cl23dObject.ts

@ -83,7 +83,7 @@ export default class Cl23dObject extends PtrObject {
const ptrPillar = this.getObjectByName('ptrPillar')
const time = 3
return new Promise(resolve => {
gsap.to(ptrPillar.position, {
this.actionAnimation = gsap.to(ptrPillar.position, {
z: -z,
duration: time,
repeat: 0,
@ -106,7 +106,7 @@ export default class Cl23dObject extends PtrObject {
const bh = 0.22
const children = ptrFork.children
gsap.to(ptrFork.position, {
this.actionAnimation = gsap.to(ptrFork.position, {
y: y,
duration: time,
repeat: 0,

5
src/modules/amr/ptr/clx/Clx3dObject.ts

@ -184,7 +184,7 @@ export default class Clx3dObject extends PtrObject {
})
return new Promise(resolve => {
gsap.to(clxFork.position, {
this.actionAnimation = gsap.to(clxFork.position, {
z: -z,
duration: time,
repeat: 0,
@ -243,7 +243,7 @@ export default class Clx3dObject extends PtrObject {
const bh = 0.22
const children = clxFork.children
gsap.to(clxFork.position, {
this.actionAnimation = gsap.to(clxFork.position, {
y: y,
duration: time,
repeat: 0,
@ -252,7 +252,6 @@ export default class Clx3dObject extends PtrObject {
onUpdate: function() {
const a = this.targets()[0]
if (a.y < bh) {
console.log(a.z)
if (a.z > -1) {
for (let i = 0; i < children.length; i++) {
const child = children[i]

2
src/router/index.ts

@ -32,7 +32,7 @@ const router = createRouter({
meta: {
title: '任务查询'
},
component: () => import('@/views/taskManagement/taskQuery.vue')
component: () => import('@/editor/widgets/task/TaskView2.vue')
},
{
path: '/automatedPresentation',

Loading…
Cancel
Save