feat: Add simulation storage unit instance animation and comprehensive dashboard element design panel.
This commit is contained in:
@@ -82,9 +82,11 @@ const ElementDesign: React.FC<ElementDesignProps> = ({
|
|||||||
<div className="design-section">
|
<div className="design-section">
|
||||||
<InputWithDropDown
|
<InputWithDropDown
|
||||||
label="Text Value"
|
label="Text Value"
|
||||||
|
type="string"
|
||||||
value={currentElement.textValue || ""}
|
value={currentElement.textValue || ""}
|
||||||
placeholder={"Enter text..."}
|
placeholder={"Enter text..."}
|
||||||
onChange={(newValue: string) => {
|
onChange={(newValue) => {
|
||||||
|
console.log("newValue: ", newValue);
|
||||||
updateTextValue(selectedBlock, selectedElement, newValue);
|
updateTextValue(selectedBlock, selectedElement, newValue);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -190,6 +190,9 @@ function Analyzer() {
|
|||||||
// Track previous actions for Machines to detect cycle completion
|
// Track previous actions for Machines to detect cycle completion
|
||||||
const previousMachineActionsRef = useRef<Record<string, string | undefined>>({});
|
const previousMachineActionsRef = useRef<Record<string, string | undefined>>({});
|
||||||
|
|
||||||
|
// Track previous storage loads to detect store/retrieve operations
|
||||||
|
const previousStorageLoadsRef = useRef<Record<string, number>>({});
|
||||||
|
|
||||||
// Track previous action counts for Humans to detect completion from EventManager
|
// Track previous action counts for Humans to detect completion from EventManager
|
||||||
const previousHumanCountsRef = useRef<Record<string, Record<string, number>>>({});
|
const previousHumanCountsRef = useRef<Record<string, Record<string, number>>>({});
|
||||||
|
|
||||||
@@ -232,6 +235,7 @@ function Analyzer() {
|
|||||||
previousAssetStatesRef.current = {};
|
previousAssetStatesRef.current = {};
|
||||||
previousArmBotActionsRef.current = {};
|
previousArmBotActionsRef.current = {};
|
||||||
previousMachineActionsRef.current = {};
|
previousMachineActionsRef.current = {};
|
||||||
|
previousStorageLoadsRef.current = {};
|
||||||
previousHumanCountsRef.current = {};
|
previousHumanCountsRef.current = {};
|
||||||
previousVehiclePhasesRef.current = {};
|
previousVehiclePhasesRef.current = {};
|
||||||
previousCranePhasesRef.current = {};
|
previousCranePhasesRef.current = {};
|
||||||
@@ -1475,8 +1479,8 @@ function Analyzer() {
|
|||||||
|
|
||||||
currentStatus: {
|
currentStatus: {
|
||||||
isActive: storage.isActive,
|
isActive: storage.isActive,
|
||||||
state: storage.state,
|
state: storage.state || "idle",
|
||||||
currentLoad,
|
currentLoad: currentLoad,
|
||||||
storageCapacity: capacity,
|
storageCapacity: capacity,
|
||||||
currentMaterials: storage.currentMaterials,
|
currentMaterials: storage.currentMaterials,
|
||||||
},
|
},
|
||||||
@@ -1530,7 +1534,7 @@ function Analyzer() {
|
|||||||
roi: costMetrics.roi,
|
roi: costMetrics.roi,
|
||||||
valueAdded: costMetrics.valueAdded,
|
valueAdded: costMetrics.valueAdded,
|
||||||
costPerUnit: totalOps > 0 ? costMetrics.totalCost / totalOps : 0,
|
costPerUnit: totalOps > 0 ? costMetrics.totalCost / totalOps : 0,
|
||||||
costPerStorageHour: capacity > 0 ? costMetrics.totalCost / (capacity * (timeMetrics.totalTime / 3600)) : 0,
|
costPerStorageHour: capacity * timeMetrics.totalTime > 0 ? costMetrics.totalCost / (capacity * (timeMetrics.totalTime / 3600)) : 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Add energy metrics
|
// Add energy metrics
|
||||||
@@ -2426,6 +2430,34 @@ function Analyzer() {
|
|||||||
});
|
});
|
||||||
}, [machines, isPlaying]);
|
}, [machines, isPlaying]);
|
||||||
|
|
||||||
|
// Monitor Storage load changes to track store/retrieve operations
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isPlaying) return;
|
||||||
|
|
||||||
|
storageUnits.forEach((storage) => {
|
||||||
|
const previousLoad = previousStorageLoadsRef.current[storage.modelUuid] || 0;
|
||||||
|
const currentLoad = storage.currentLoad || 0;
|
||||||
|
|
||||||
|
if (currentLoad !== previousLoad) {
|
||||||
|
if (currentLoad > previousLoad) {
|
||||||
|
// Store operation
|
||||||
|
if (!completedActionsRef.current[`${storage.modelUuid}_store`]) {
|
||||||
|
completedActionsRef.current[`${storage.modelUuid}_store`] = 0;
|
||||||
|
}
|
||||||
|
completedActionsRef.current[`${storage.modelUuid}_store`] += currentLoad - previousLoad;
|
||||||
|
} else {
|
||||||
|
// Retrieve operation
|
||||||
|
if (!completedActionsRef.current[`${storage.modelUuid}_retrieve`]) {
|
||||||
|
completedActionsRef.current[`${storage.modelUuid}_retrieve`] = 0;
|
||||||
|
}
|
||||||
|
completedActionsRef.current[`${storage.modelUuid}_retrieve`] += previousLoad - currentLoad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
previousStorageLoadsRef.current[storage.modelUuid] = currentLoad;
|
||||||
|
});
|
||||||
|
}, [storageUnits, isPlaying]);
|
||||||
|
|
||||||
// Monitor Human action changes from EventManager
|
// Monitor Human action changes from EventManager
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isPlaying || !humanEventManagerRef.current) return;
|
if (!isPlaying || !humanEventManagerRef.current) return;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useAnimationPlaySpeed, usePauseButtonStore, usePlayButtonStore } from "
|
|||||||
|
|
||||||
function StorageUnitInstance({ storageUnit }: Readonly<{ storageUnit: StorageUnitStatus }>) {
|
function StorageUnitInstance({ storageUnit }: Readonly<{ storageUnit: StorageUnitStatus }>) {
|
||||||
const { storageUnitStore } = useSceneContext();
|
const { storageUnitStore } = useSceneContext();
|
||||||
const { storageUnits, incrementActiveTime, incrementIdleTime } = storageUnitStore();
|
const { storageUnits, incrementActiveTime, incrementIdleTime, setStorageUnitActive } = storageUnitStore();
|
||||||
const { isPlaying } = usePlayButtonStore();
|
const { isPlaying } = usePlayButtonStore();
|
||||||
|
|
||||||
const idleTimeRef = useRef<number>(0);
|
const idleTimeRef = useRef<number>(0);
|
||||||
@@ -18,6 +18,10 @@ function StorageUnitInstance({ storageUnit }: Readonly<{ storageUnit: StorageUni
|
|||||||
const { speed } = useAnimationPlaySpeed();
|
const { speed } = useAnimationPlaySpeed();
|
||||||
const { isPaused } = usePauseButtonStore();
|
const { isPaused } = usePauseButtonStore();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setStorageUnitActive(storageUnit.modelUuid, isPlaying);
|
||||||
|
}, [isPlaying]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
isPausedRef.current = isPaused;
|
isPausedRef.current = isPaused;
|
||||||
}, [isPaused]);
|
}, [isPaused]);
|
||||||
|
|||||||
Reference in New Issue
Block a user