folder structure change

This commit is contained in:
2025-04-21 11:53:42 +05:30
parent 31561428ef
commit 54cc3deb98
118 changed files with 3014 additions and 13419 deletions

View File

@@ -1,6 +1,5 @@
import * as THREE from "three";
import * as Types from "../types/world/worldTypes";
import * as SimulationTypes from "../types/simulationTypes";
import { create } from "zustand";
import { io } from "socket.io-client";
@@ -338,49 +337,6 @@ export const useDrieUIValue = create<any>((set: any) => ({
})),
}));
export const useDrawMaterialPath = create<any>((set: any) => ({
drawMaterialPath: false,
setDrawMaterialPath: (x: any) => set({ drawMaterialPath: x }),
}));
export const useSelectedActionSphere = create<any>((set: any) => ({
selectedActionSphere: undefined,
setSelectedActionSphere: (x: any) => set({ selectedActionSphere: x }),
}));
export const useSelectedPath = create<any>((set: any) => ({
selectedPath: undefined,
setSelectedPath: (x: any) => set({ selectedPath: x }),
}));
interface SimulationPathsStore {
simulationStates: (SimulationTypes.ConveyorEventsSchema | SimulationTypes.VehicleEventsSchema | SimulationTypes.StaticMachineEventsSchema | SimulationTypes.ArmBotEventsSchema)[];
setSimulationStates: (
paths: (| SimulationTypes.ConveyorEventsSchema | SimulationTypes.VehicleEventsSchema | SimulationTypes.StaticMachineEventsSchema | SimulationTypes.ArmBotEventsSchema)[]
| ((prev: (| SimulationTypes.ConveyorEventsSchema | SimulationTypes.VehicleEventsSchema | SimulationTypes.StaticMachineEventsSchema | SimulationTypes.ArmBotEventsSchema)[])
=> (| SimulationTypes.ConveyorEventsSchema | SimulationTypes.VehicleEventsSchema | SimulationTypes.StaticMachineEventsSchema | SimulationTypes.ArmBotEventsSchema)[])
) => void;
}
export const useSimulationStates = create<SimulationPathsStore>((set) => ({
simulationStates: [],
setSimulationStates: (paths) =>
set((state) => ({
simulationStates:
typeof paths === "function" ? paths(state.simulationStates) : paths,
})),
}));
export const useNavMesh = create<any>((set: any) => ({
navMesh: null,
setNavMesh: (x: any) => set({ navMesh: x }),
}));
export const useIsConnecting = create<any>((set: any) => ({
isConnecting: false,
setIsConnecting: (x: any) => set({ isConnecting: x }),
}));
export const useStartSimulation = create<any>((set: any) => ({
startSimulation: false,
setStartSimulation: (x: any) => set({ startSimulation: x }),
@@ -396,14 +352,6 @@ export const useEditingPoint = create<any>((set: any) => ({
setEditingPoint: (x: any) => set({ editingPoint: x }),
}));
export const usePreviewPosition = create<{
previewPosition: { x: number; y: number } | null;
setPreviewPosition: (position: { x: number; y: number } | null) => void;
}>((set) => ({
previewPosition: null,
setPreviewPosition: (position) => set({ previewPosition: position }),
}));
export const usezoneTarget = create<any>((set: any) => ({
zoneTarget: [],
setZoneTarget: (x: any) => set({ zoneTarget: x }),
@@ -421,7 +369,7 @@ interface EditPositionState {
export const useEditPosition = create<EditPositionState>((set) => ({
Edit: false,
setEdit: (value) => set({ Edit: value }), // Properly updating the state
setEdit: (value) => set({ Edit: value }),
}));
export const useAsset3dWidget = create<any>((set: any) => ({

View File

@@ -1,5 +1,5 @@
import { create } from "zustand";
import { addingFloatingWidgets } from "../services/realTimeVisulization/zoneData/addFloatingWidgets";
import { addingFloatingWidgets } from "../services/visulization/zone/addFloatingWidgets";
import { useSocketStore } from "./store";
import useChartStore from "./useChartStore";
@@ -114,7 +114,7 @@ export const useDroppedObjectsStore = create<DroppedObjectsState>((set) => ({
// Create a shallow copy of the object with a unique ID and slightly adjusted position
const duplicatedObject: DroppedObject = {
...originalObject,
Data:{
Data: {
measurements: iotMeasurements,
duration: iotDuration,
},
@@ -132,8 +132,8 @@ export const useDroppedObjectsStore = create<DroppedObjectsState>((set) => ({
: originalObject.position.left,
},
};
console.log("duplicated object",duplicatedObject);
console.log("duplicated object", duplicatedObject);
let duplicateFloatingWidget = {
organization: organization,
widget: duplicatedObject,

View File

@@ -142,7 +142,7 @@ type Store = {
removeEventFromProduct: (productId: string, modelUuid: string) => void;
updateEventInProduct: (productId: string, modelUuid: string, updates: Partial<EventsSchema>) => void;
// Point-level actions (for transfer, vehicle, etc.)
// Point-level actions
addPointToEvent: (productId: string, modelUuid: string, point: TransferPointSchema | VehiclePointSchema | RoboticArmPointSchema | MachinePointSchema | StoragePointSchema) => void;
removePointFromEvent: (productId: string, modelUuid: string, pointUuid: string) => void;
updatePointInEvent: (
@@ -153,35 +153,25 @@ type Store = {
) => void;
// Action-level actions
addActionToPoint: (
addAction: (
productId: string,
modelUuid: string,
pointUuid: string,
action: TransferPointSchema['actions'][0] | VehiclePointSchema['actions'][0] | RoboticArmPointSchema['actions'][0] | MachinePointSchema['actions'][0] | StoragePointSchema['actions'][0]
) => void;
removeActionFromPoint: (productId: string, modelUuid: string, pointUuid: string, actionUuid: string) => void;
updateActionInPoint: (
productId: string,
modelUuid: string,
pointUuid: string,
removeAction: (actionUuid: string) => void;
updateAction: (
actionUuid: string,
updates: Partial<TransferPointSchema['actions'][0] | VehiclePointSchema['actions'][0] | RoboticArmPointSchema['actions'][0] | MachinePointSchema['actions'][0] | StoragePointSchema['actions'][0]>
) => void;
// Trigger-level actions
addTriggerToAction: (
productId: string,
modelUuid: string,
pointUuid: string,
addTrigger: (
actionUuid: string,
trigger: TriggerSchema
) => void;
removeTriggerFromAction: (productId: string, modelUuid: string, pointUuid: string, actionUuid: string, triggerUuid: string) => void;
updateTriggerInAction: (
productId: string,
modelUuid: string,
pointUuid: string,
actionUuid: string,
removeTrigger: (triggerUuid: string) => void;
updateTrigger: (
triggerUuid: string,
updates: Partial<TriggerSchema>
) => void;
@@ -190,6 +180,8 @@ type Store = {
getProductById: (productId: string) => { productName: string; productId: string; eventsData: EventsSchema[] } | undefined;
getEventByModelUuid: (productId: string, modelUuid: string) => EventsSchema | undefined;
getPointByUuid: (productId: string, modelUuid: string, pointUuid: string) => TransferPointSchema | VehiclePointSchema | RoboticArmPointSchema | MachinePointSchema | StoragePointSchema | undefined;
getActionByUuid: (actionUuid: string) => (TransferPointSchema['actions'][0] | VehiclePointSchema['actions'][0] | RoboticArmPointSchema['actions'][0] | MachinePointSchema['actions'][0] | StoragePointSchema['actions'][0]) | undefined;
getTriggerByUuid: (triggerUuid: string) => TriggerSchema | undefined;
};
export const useProductStore = create<Store>()(
@@ -303,7 +295,7 @@ export const useProductStore = create<Store>()(
},
// Action-level actions
addActionToPoint: (productId, modelUuid, pointUuid, action) => {
addAction: (productId, modelUuid, pointUuid, action) => {
set((state) => {
const product = state.products.find(p => p.productId === productId);
if (product) {
@@ -320,115 +312,120 @@ export const useProductStore = create<Store>()(
});
},
removeActionFromPoint: (productId, modelUuid, pointUuid, actionUuid) => {
removeAction: (actionUuid) => {
set((state) => {
const product = state.products.find(p => p.productId === productId);
if (product) {
const event = product.eventsData.find(e => 'modelUuid' in e && e.modelUuid === modelUuid);
if (event && 'points' in event) {
const point = (event as TransferEventSchema).points.find(p => p.uuid === pointUuid);
if (point) {
point.actions = point.actions.filter(a => a.actionUuid !== actionUuid);
for (const product of state.products) {
for (const event of product.eventsData) {
if ('points' in event) {
for (const point of (event as TransferEventSchema).points) {
point.actions = point.actions.filter(a => a.actionUuid !== actionUuid);
}
} else if ('point' in event) {
(event as any).point.actions = (event as any).point.actions.filter((a: any) => a.actionUuid !== actionUuid);
}
} else if (event && 'point' in event && (event as any).point.uuid === pointUuid) {
(event as any).point.actions = (event as any).point.actions.filter((a: any) => a.actionUuid !== actionUuid);
}
}
});
},
updateActionInPoint: (productId, modelUuid, pointUuid, actionUuid, updates) => {
updateAction: (actionUuid, updates) => {
set((state) => {
const product = state.products.find(p => p.productId === productId);
if (product) {
const event = product.eventsData.find(e => 'modelUuid' in e && e.modelUuid === modelUuid);
if (event && 'points' in event) {
const point = (event as TransferEventSchema).points.find(p => p.uuid === pointUuid);
if (point) {
const action = point.actions.find(a => a.actionUuid === actionUuid);
for (const product of state.products) {
for (const event of product.eventsData) {
if ('points' in event) {
for (const point of (event as TransferEventSchema).points) {
const action = point.actions.find(a => a.actionUuid === actionUuid);
if (action) {
Object.assign(action, updates);
return;
}
}
} else if ('point' in event) {
const action = (event as any).point.actions.find((a: any) => a.actionUuid === actionUuid);
if (action) {
Object.assign(action, updates);
return;
}
}
} else if (event && 'point' in event && (event as any).point.uuid === pointUuid) {
const action = (event as any).point.actions.find((a: any) => a.actionUuid === actionUuid);
if (action) {
Object.assign(action, updates);
}
}
}
});
},
// Trigger-level actions
addTriggerToAction: (productId, modelUuid, pointUuid, actionUuid, trigger) => {
addTrigger: (actionUuid, trigger) => {
set((state) => {
const product = state.products.find(p => p.productId === productId);
if (product) {
const event = product.eventsData.find(e => 'modelUuid' in e && e.modelUuid === modelUuid);
if (event && 'points' in event) {
const point = (event as TransferEventSchema).points.find(p => p.uuid === pointUuid);
if (point) {
const action = point.actions.find(a => a.actionUuid === actionUuid);
for (const product of state.products) {
for (const event of product.eventsData) {
if ('points' in event) {
for (const point of (event as TransferEventSchema).points) {
const action = point.actions.find(a => a.actionUuid === actionUuid);
if (action && 'triggers' in action) {
action.triggers.push(trigger);
return;
}
}
} else if ('point' in event) {
const action = (event as any).point.actions.find((a: any) => a.actionUuid === actionUuid);
if (action && 'triggers' in action) {
action.triggers.push(trigger);
return;
}
}
} else if (event && 'point' in event && (event as any).point.uuid === pointUuid) {
const action = (event as any).point.actions.find((a: any) => a.actionUuid === actionUuid);
if (action && 'triggers' in action) {
action.triggers.push(trigger);
}
}
}
});
},
removeTriggerFromAction: (productId, modelUuid, pointUuid, actionUuid, triggerUuid) => {
removeTrigger: (triggerUuid) => {
set((state) => {
const product = state.products.find(p => p.productId === productId);
if (product) {
const event = product.eventsData.find(e => 'modelUuid' in e && e.modelUuid === modelUuid);
if (event && 'points' in event) {
const point = (event as TransferEventSchema).points.find(p => p.uuid === pointUuid);
if (point) {
const action = point.actions.find(a => a.actionUuid === actionUuid);
if (action && 'triggers' in action) {
action.triggers = action.triggers.filter(t => t.triggerUuid !== triggerUuid);
for (const product of state.products) {
for (const event of product.eventsData) {
if ('points' in event) {
for (const point of (event as TransferEventSchema).points) {
for (const action of point.actions) {
if ('triggers' in action) {
action.triggers = action.triggers.filter(t => t.triggerUuid !== triggerUuid);
}
}
}
}
} else if (event && 'point' in event && (event as any).point.uuid === pointUuid) {
const action = (event as any).point.actions.find((a: any) => a.actionUuid === actionUuid);
if (action && 'triggers' in action) {
action.triggers = action.triggers.filter((t: any) => t.triggerUuid !== triggerUuid);
}
}
}
});
},
updateTriggerInAction: (productId, modelUuid, pointUuid, actionUuid, triggerUuid, updates) => {
set((state) => {
const product = state.products.find(p => p.productId === productId);
if (product) {
const event = product.eventsData.find(e => 'modelUuid' in e && e.modelUuid === modelUuid);
if (event && 'points' in event) {
const point = (event as TransferEventSchema).points.find(p => p.uuid === pointUuid);
if (point) {
const action = point.actions.find(a => a.actionUuid === actionUuid);
if (action && 'triggers' in action) {
const trigger = action.triggers.find(t => t.triggerUuid === triggerUuid);
if (trigger) {
Object.assign(trigger, updates);
} else if ('point' in event) {
for (const action of (event as any).point.actions) {
if ('triggers' in action) {
action.triggers = action.triggers.filter((t: any) => t.triggerUuid !== triggerUuid);
}
}
}
} else if (event && 'point' in event && (event as any).point.uuid === pointUuid) {
const action = (event as any).point.actions.find((a: any) => a.actionUuid === actionUuid);
if (action && 'triggers' in action) {
const trigger = action.triggers.find((t: any) => t.triggerUuid === triggerUuid);
if (trigger) {
Object.assign(trigger, updates);
}
}
});
},
updateTrigger: (triggerUuid, updates) => {
set((state) => {
for (const product of state.products) {
for (const event of product.eventsData) {
if ('points' in event) {
for (const point of (event as TransferEventSchema).points) {
for (const action of point.actions) {
if ('triggers' in action) {
const trigger = action.triggers.find(t => t.triggerUuid === triggerUuid);
if (trigger) {
Object.assign(trigger, updates);
return;
}
}
}
}
} else if ('point' in event) {
for (const action of (event as any).point.actions) {
if ('triggers' in action) {
const trigger = action.triggers.find((t: any) => t.triggerUuid === triggerUuid);
if (trigger) {
Object.assign(trigger, updates);
return;
}
}
}
}
}
@@ -460,6 +457,50 @@ export const useProductStore = create<Store>()(
}
}
return undefined;
},
getActionByUuid: (actionUuid) => {
const state = get();
for (const product of state.products) {
for (const event of product.eventsData) {
if ('points' in event) {
for (const point of (event as TransferEventSchema).points) {
const action = point.actions.find(a => a.actionUuid === actionUuid);
if (action) return action;
}
} else if ('point' in event) {
const action = (event as any).point.actions.find((a: any) => a.actionUuid === actionUuid);
if (action) return action;
}
}
}
return undefined;
},
getTriggerByUuid: (triggerUuid) => {
const state = get();
for (const product of state.products) {
for (const event of product.eventsData) {
if ('points' in event) {
for (const point of (event as TransferEventSchema).points) {
for (const action of point.actions) {
if ('triggers' in action) {
const trigger = action.triggers.find(t => t.triggerUuid === triggerUuid);
if (trigger) return trigger;
}
}
}
} else if ('point' in event) {
for (const action of (event as any).point.actions) {
if ('triggers' in action) {
const trigger = action.triggers.find((t: any) => t.triggerUuid === triggerUuid);
if (trigger) return trigger;
}
}
}
}
}
return undefined;
}
}))
);