feat: Implement conveyor material spawning, storage unit retrieval actions, and a new simulation analyzer.
This commit is contained in:
@@ -75,7 +75,7 @@ export function useSpawnHandler() {
|
||||
materialId: THREE.MathUtils.generateUUID(),
|
||||
materialName: `${materialType}-${Date.now()}`,
|
||||
materialType: materialType,
|
||||
isActive: false,
|
||||
isActive: true,
|
||||
isVisible: true,
|
||||
isPaused: false,
|
||||
isRendered: true,
|
||||
@@ -87,7 +87,11 @@ export function useSpawnHandler() {
|
||||
},
|
||||
};
|
||||
|
||||
if (action.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid && action.triggers[0]?.triggeredAsset?.triggeredPoint?.pointUuid && action.triggers[0]?.triggeredAsset?.triggeredAction?.actionUuid) {
|
||||
if (
|
||||
action.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid &&
|
||||
action.triggers[0]?.triggeredAsset?.triggeredPoint?.pointUuid &&
|
||||
action.triggers[0]?.triggeredAsset?.triggeredAction?.actionUuid
|
||||
) {
|
||||
newMaterial.next = {
|
||||
modelUuid: action.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid,
|
||||
pointUuid: action.triggers[0]?.triggeredAsset?.triggeredPoint?.pointUuid,
|
||||
|
||||
@@ -46,7 +46,7 @@ export function useRetrieveHandler() {
|
||||
materialId: materialId,
|
||||
materialName: `${materialType}-${Date.now()}`,
|
||||
materialType: materialType,
|
||||
isActive: false,
|
||||
isActive: true,
|
||||
isVisible: false,
|
||||
isPaused: false,
|
||||
isRendered: true,
|
||||
|
||||
@@ -13,7 +13,7 @@ function Analyzer() {
|
||||
const { vehicles } = vehicleStore();
|
||||
const { cranes } = craneStore();
|
||||
const { storageUnits } = storageUnitStore();
|
||||
const { materials, getMaterialsByModel } = materialStore();
|
||||
const { materials, materialHistory, getMaterialsByModel } = materialStore();
|
||||
const { speed } = useAnimationPlaySpeed();
|
||||
|
||||
const { setAnalysis, setAnalyzing, analysis } = analysisStore();
|
||||
@@ -240,6 +240,7 @@ function Analyzer() {
|
||||
previousVehiclePhasesRef.current = {};
|
||||
previousCranePhasesRef.current = {};
|
||||
materialLifecycleRef.current = {};
|
||||
materialHistoryRef.current = [];
|
||||
setAnalysis(null);
|
||||
setAnalyzing(false);
|
||||
};
|
||||
@@ -1860,6 +1861,7 @@ function Analyzer() {
|
||||
const totalAssets = allAssets.length;
|
||||
const activeAssets = allAssets.filter((a) => a.currentStatus.isActive).length;
|
||||
const assetsInError = allAssets.filter((a) => a.currentStatus.state === "error").length;
|
||||
|
||||
const assetsIdle = allAssets.filter((a) => !a.currentStatus.isActive && a.currentStatus.state === "idle").length;
|
||||
|
||||
// Calculate system OEE (weighted average by throughput)
|
||||
@@ -1973,15 +1975,30 @@ function Analyzer() {
|
||||
};
|
||||
});
|
||||
|
||||
// Material Flow Analysis
|
||||
// Material Flow Analysis
|
||||
const totalMaterialsInSystem = materials.filter((m) => m.isActive).length;
|
||||
const completedMaterials = materialHistoryRef.current.length;
|
||||
|
||||
// Combine store history (removed materials) with current inactive materials (completed but not removed)
|
||||
const inactiveMaterials = materials.filter((m) => !m.isActive && m.endTime);
|
||||
const allCompletedUpdates = [
|
||||
...materialHistory.map((entry) => ({
|
||||
startTime: entry.material.startTime || 0,
|
||||
endTime: new Date(entry.removedAt).getTime(),
|
||||
})),
|
||||
...inactiveMaterials.map((m) => ({
|
||||
startTime: m.startTime || 0,
|
||||
endTime: m.endTime || Date.now(),
|
||||
})),
|
||||
];
|
||||
|
||||
const completedMaterials = allCompletedUpdates.length;
|
||||
const averageResidenceTime =
|
||||
materialHistoryRef.current.length > 0
|
||||
? materialHistoryRef.current.reduce((sum, entry) => {
|
||||
const residenceTime = new Date(entry.removedAt).getTime() - (entry.material.startTime || 0);
|
||||
return sum + (residenceTime || 0);
|
||||
}, 0) / materialHistoryRef.current.length
|
||||
allCompletedUpdates.length > 0
|
||||
? allCompletedUpdates.reduce((sum, entry) => {
|
||||
const residenceTime = entry.endTime - entry.startTime;
|
||||
return sum + Math.max(0, residenceTime);
|
||||
}, 0) / allCompletedUpdates.length
|
||||
: 0;
|
||||
|
||||
// Bottleneck Identification
|
||||
@@ -2232,6 +2249,7 @@ function Analyzer() {
|
||||
machines,
|
||||
humans,
|
||||
cranes,
|
||||
materials,
|
||||
analyzeConveyor,
|
||||
analyzeVehicle,
|
||||
analyzeRoboticArm,
|
||||
|
||||
Reference in New Issue
Block a user