Refactor Machine and TriggerConnector components: enhance event handling for machine points and streamline vehicle status sample initialization
This commit is contained in:
parent
29efeab387
commit
571da0a78a
|
@ -2,6 +2,29 @@ import React from 'react'
|
||||||
import MachineInstances from './instances/machineInstances'
|
import MachineInstances from './instances/machineInstances'
|
||||||
|
|
||||||
function Machine() {
|
function Machine() {
|
||||||
|
|
||||||
|
const machineSample: MachineEventSchema = {
|
||||||
|
modelUuid: "machine-1234-5678-9012",
|
||||||
|
modelName: "CNC Milling Machine",
|
||||||
|
position: [10, 0, 5],
|
||||||
|
rotation: [0, 0, 0],
|
||||||
|
state: "idle",
|
||||||
|
type: "machine",
|
||||||
|
point: {
|
||||||
|
uuid: "machine-point-9876-5432-1098",
|
||||||
|
position: [10, 0.5, 5.2],
|
||||||
|
rotation: [0, 0, 0],
|
||||||
|
action: {
|
||||||
|
actionUuid: "machine-action-2468-1357-8024",
|
||||||
|
actionName: "Metal Processing",
|
||||||
|
actionType: "process",
|
||||||
|
processTime: 10,
|
||||||
|
swapMaterial: "steel",
|
||||||
|
triggers: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,10 @@ function TriggerConnector() {
|
||||||
if (!product || products.length === 0) return;
|
if (!product || products.length === 0) return;
|
||||||
|
|
||||||
product.eventDatas.forEach(event => {
|
product.eventDatas.forEach(event => {
|
||||||
if ('points' in event) {
|
// Handle Conveyor points
|
||||||
|
if (event.type === "transfer" && 'points' in event) {
|
||||||
event.points.forEach(point => {
|
event.points.forEach(point => {
|
||||||
if ('action' in point && point.action?.triggers) {
|
if (point.action?.triggers) {
|
||||||
point.action.triggers.forEach(trigger => {
|
point.action.triggers.forEach(trigger => {
|
||||||
if (trigger.triggeredAsset) {
|
if (trigger.triggeredAsset) {
|
||||||
newConnections.push({
|
newConnections.push({
|
||||||
|
@ -74,14 +75,53 @@ function TriggerConnector() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if ('point' in event) {
|
}
|
||||||
if ('actions' in event.point) {
|
// Handle Vehicle point
|
||||||
console.log(event);
|
else if (event.type === "vehicle" && 'point' in event) {
|
||||||
|
const point = event.point;
|
||||||
// you left here
|
if (point.action?.triggers) {
|
||||||
|
point.action.triggers.forEach(trigger => {
|
||||||
} else if ('action' in event.point) {
|
if (trigger.triggeredAsset) {
|
||||||
console.log(event);
|
newConnections.push({
|
||||||
|
id: `${point.uuid}-${trigger.triggeredAsset.triggeredPoint.pointUuid}-${trigger.triggerUuid}`,
|
||||||
|
startPointUuid: point.uuid,
|
||||||
|
endPointUuid: trigger.triggeredAsset.triggeredPoint.pointUuid,
|
||||||
|
trigger
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle Robotic Arm points
|
||||||
|
else if (event.type === "roboticArm" && 'point' in event) {
|
||||||
|
const point = event.point;
|
||||||
|
point.actions?.forEach(action => {
|
||||||
|
action.triggers?.forEach(trigger => {
|
||||||
|
if (trigger.triggeredAsset) {
|
||||||
|
newConnections.push({
|
||||||
|
id: `${point.uuid}-${trigger.triggeredAsset.triggeredPoint.pointUuid}-${trigger.triggerUuid}`,
|
||||||
|
startPointUuid: point.uuid,
|
||||||
|
endPointUuid: trigger.triggeredAsset.triggeredPoint.pointUuid,
|
||||||
|
trigger
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Handle Machine point
|
||||||
|
else if (event.type === "machine" && 'point' in event) {
|
||||||
|
const point = event.point;
|
||||||
|
if (point.action?.triggers) {
|
||||||
|
point.action.triggers.forEach(trigger => {
|
||||||
|
if (trigger.triggeredAsset) {
|
||||||
|
newConnections.push({
|
||||||
|
id: `${point.uuid}-${trigger.triggeredAsset.triggeredPoint.pointUuid}-${trigger.triggerUuid}`,
|
||||||
|
startPointUuid: point.uuid,
|
||||||
|
endPointUuid: trigger.triggeredAsset.triggeredPoint.pointUuid,
|
||||||
|
trigger
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,9 +13,7 @@ function Vehicles() {
|
||||||
const { floorItems } = useFloorItems();
|
const { floorItems } = useFloorItems();
|
||||||
const { isPlaying } = usePlayButtonStore();
|
const { isPlaying } = usePlayButtonStore();
|
||||||
|
|
||||||
const [vehicleStatusSample, setVehicleStatusSample] = useState<
|
const [vehicleStatusSample, setVehicleStatusSample] = useState<VehicleEventSchema[]>([
|
||||||
VehicleEventSchema[]
|
|
||||||
>([
|
|
||||||
{
|
{
|
||||||
modelUuid: "9356f710-4727-4b50-bdb2-9c1e747ecc74",
|
modelUuid: "9356f710-4727-4b50-bdb2-9c1e747ecc74",
|
||||||
modelName: "AGV",
|
modelName: "AGV",
|
||||||
|
@ -34,7 +32,7 @@ function Vehicles() {
|
||||||
actionType: "travel",
|
actionType: "travel",
|
||||||
unLoadDuration: 10,
|
unLoadDuration: 10,
|
||||||
loadCapacity: 2,
|
loadCapacity: 2,
|
||||||
steeringAngle:0,
|
steeringAngle: 0,
|
||||||
pickUpPoint: { position: { x: 98.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
pickUpPoint: { position: { x: 98.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
||||||
unLoadPoint: { position: { x: 105.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
unLoadPoint: { position: { x: 105.71483985219794, y: 0, z: 28.66321267938962 }, rotation: { x: 0, y: 0, z: 0 } },
|
||||||
triggers: [
|
triggers: [
|
||||||
|
@ -78,7 +76,7 @@ function Vehicles() {
|
||||||
actionType: "travel",
|
actionType: "travel",
|
||||||
unLoadDuration: 10,
|
unLoadDuration: 10,
|
||||||
loadCapacity: 2,
|
loadCapacity: 2,
|
||||||
steeringAngle:0,
|
steeringAngle: 0,
|
||||||
pickUpPoint: null,
|
pickUpPoint: null,
|
||||||
unLoadPoint: null,
|
unLoadPoint: null,
|
||||||
triggers: [
|
triggers: [
|
||||||
|
|
Loading…
Reference in New Issue