diff --git a/app/src/components/ui/analysis/ROISummary.tsx b/app/src/components/ui/analysis/ROISummary.tsx
index a03b15c..0de3c4a 100644
--- a/app/src/components/ui/analysis/ROISummary.tsx
+++ b/app/src/components/ui/analysis/ROISummary.tsx
@@ -86,8 +86,9 @@ const ROISummary = ({
useEffect(() => {
if (roiSummary.productName) {
- // If productName is set, assume data is loaded
- setIsLoading(false);
+ setTimeout(() => {
+ setIsLoading(false);
+ }, 4000)
} else {
// If productName is empty, assume still loading
setIsLoading(true);
diff --git a/app/src/components/ui/analysis/ThroughputSummary.tsx b/app/src/components/ui/analysis/ThroughputSummary.tsx
index a01ac61..6660e90 100644
--- a/app/src/components/ui/analysis/ThroughputSummary.tsx
+++ b/app/src/components/ui/analysis/ThroughputSummary.tsx
@@ -11,9 +11,6 @@ const ProductionCapacity = ({
throughputValue = 128,
timeRange = { startTime: "08:00 AM", endTime: "09:00 AM" },
}) => {
-
-
-
const { machineActiveTime } = useMachineUptime();
const { materialCycleTime } = useMaterialCycle();
const { throughputData } = useThroughPutData()
@@ -30,14 +27,10 @@ const ProductionCapacity = ({
const [isLoading, setIsLoading] = useState(false);
useEffect(() => {
- console.log('typeof throughputData:', typeof throughputData);
- console.log('throughputData > 0: ', throughputData > 0);
if (throughputData > 0) {
- // console.log('machineActiveTime: ', machineActiveTime);
- // console.log('materialCycleTime: ', materialCycleTime);
- // console.log('throughputData: ', throughputData);
- // console.log('productionCapacityData: ', productionCapacityData);
- setIsLoading(false);
+ setTimeout(() => {
+ setIsLoading(false);
+ }, 3000)
} else {
setIsLoading(true);
}
@@ -60,7 +53,7 @@ const ProductionCapacity = ({
- {isLoading ? (
+ {!isLoading ? (
<>
diff --git a/app/src/modules/simulation/analysis/throughPut/throughPutData.tsx b/app/src/modules/simulation/analysis/throughPut/throughPutData.tsx
index aa7fc19..6efc814 100644
--- a/app/src/modules/simulation/analysis/throughPut/throughPutData.tsx
+++ b/app/src/modules/simulation/analysis/throughPut/throughPutData.tsx
@@ -16,7 +16,7 @@ export default function ThroughPutData() {
const { machines } = machineStore();
const { conveyors } = conveyorStore();
const { storageUnits } = storageUnitStore();
- const { materialHistory } = materialStore();
+ const { materialHistory, materials } = materialStore();
const { machineCount, setMachineCount } = useMachineCount();
const { machineActiveTime, setMachineActiveTime } = useMachineUptime();
const { materialCycleTime, setMaterialCycleTime } = useMaterialCycle();
@@ -109,39 +109,92 @@ export default function ThroughPutData() {
// if (materialCycleTime <= 0) return
}, [products, selectedProduct, getProductById, setMachineCount, materialCycleTime, armBots, vehicles, machines]);
- // Setting material cycle time
useEffect(() => {
- materialHistory.forEach((material) => {
- const start = material.material.startTime ?? 0;
- const end = material.material.endTime ?? 0;
- if (start === 0 || end === 0) return;
- const totalCycleTime = (end - start) / 1000; // Convert milliseconds to seconds
- setMaterialCycleTime(Number(totalCycleTime.toFixed(2))); // Set the material cycle time in the store
- });
- }, [materialHistory]);
+ async function getMachineActive() {
+ const productData = getProductById(selectedProduct.productUuid);
+ let anyArmActive;
+ let anyVehicleActive;
+ let anyMachineActive;
+ if (productData) {
+ const productSequenceData = await determineExecutionMachineSequences([productData]);
+ if (productSequenceData?.length > 0) {
+ productSequenceData.forEach(sequence => {
+ sequence.forEach(item => {
+ if (item.type === "roboticArm") {
+ armBots
+ .filter(arm => arm.modelUuid === item.modelUuid)
+ .forEach(arm => {
+ if (arm.isActive) {
+ anyArmActive = true;
+ } else {
+ anyArmActive = false;
+ }
+ });
+ }
+ if (item.type === "vehicle") {
+ vehicles
+ .filter(vehicle => vehicle.modelUuid === item.modelUuid)
+ .forEach(vehicle => {
+ if (vehicle.isActive) {
+ anyVehicleActive = true;
+ } else {
+ anyVehicleActive = false;
+ }
+ });
+ }
+ if (item.type === "machine") {
+ machines
+ .filter(machine => machine.modelUuid === item.modelUuid)
+ .forEach(machine => {
+ if (machine.isActive) {
+ anyMachineActive = true;
+ } else {
+ anyMachineActive = false;
+ }
+ });
+ }
+ });
+ });
+ }
+ }
+ const allInactive = !anyArmActive && !anyVehicleActive && !anyMachineActive;
+ if (allInactive && materials.length === 0 && materialHistory.length > 0) {
+ console.log("inside allInactive condition");
+ let totalCycleTimeSum = 0;
+ let cycleCount = 0;
+
+ materialHistory.forEach((material) => {
+ const start = material.material.startTime ?? 0;
+ const end = material.material.endTime ?? 0;
+ if (start === 0 || end === 0) return;
+
+ const totalCycleTime = (end - start) / 1000; // Convert milliseconds to seconds
+ totalCycleTimeSum += totalCycleTime;
+ cycleCount++;
+ });
+
+ if (cycleCount > 0) {
+ const averageCycleTime = totalCycleTimeSum / cycleCount;
+ setMaterialCycleTime(Number(averageCycleTime.toFixed(2)));
+ }
+ }
+ }
+
+ getMachineActive();
+ }, [armBots, materials, materialHistory, machines, vehicles, selectedProduct])
useEffect(() => {
if (machineActiveTime > 0 && materialCycleTime > 0 && machineCount > 0) {
const utilization = machineActiveTime / 3600; // Active time per hour
const unitsPerMachinePerHour = 3600 / materialCycleTime;
const throughput = unitsPerMachinePerHour * machineCount * utilization;
-
- setThroughputData(throughput.toFixed(2)); // Set throughput to state/store
-
- // console.log('---Throughput Results---');
- // console.log('Machine Active Time (s):', machineActiveTime);
- // console.log('Material Cycle Time (s):', materialCycleTime);
- // console.log('Machine Count:', machineCount);
- // console.log('Utilization:', utilization);
- // console.log('Throughput (units/hr):', throughput);
+ setThroughputData(Number(throughput.toFixed(2))); // Keep as number
+ // console.log('throughput ', Number(throughput.toFixed(2)));
}
}, [machineActiveTime, materialCycleTime, machineCount]);
-
-
-
return (
<>
>