This commit is contained in:
Nalvazhuthi 2025-06-10 18:08:24 +05:30
commit c9cedaaaa3
12 changed files with 125 additions and 76 deletions

View File

@ -35,9 +35,9 @@ const ZoneProperties: React.FC = () => {
viewPortCenter: zoneTarget, viewPortCenter: zoneTarget,
}; };
let response = await zoneCameraUpdate(zonesdata, organization,projectId); let response = await zoneCameraUpdate(zonesdata, organization, projectId);
console.log('response: ', response); console.log('response: ', response);
if (response.message === "updated successfully") { if (response.message === "zone updated") {
setEdit(false); setEdit(false);
} else { } else {
// console.log(response); // console.log(response);
@ -59,10 +59,9 @@ const ZoneProperties: React.FC = () => {
zoneName: newName, zoneName: newName,
}; };
// Call your API to update the zone // Call your API to update the zone
let response = await zoneCameraUpdate(zonesdata, organization,projectId); let response = await zoneCameraUpdate(zonesdata, organization, projectId);
console.log('response: ', response); if (response.message === "zone updated") {
// console.log("response: ", response); setSelectedZone((prev) => ({ ...prev, zoneName: newName }));
if (response.message === "updated successfully") {
setZones((prevZones: any[]) => setZones((prevZones: any[]) =>
prevZones.map((zone) => prevZones.map((zone) =>
zone.zoneUuid === selectedZone.zoneUuid zone.zoneUuid === selectedZone.zoneUuid
@ -83,7 +82,7 @@ const ZoneProperties: React.FC = () => {
const checkZoneNameDuplicate = (name: string) => { const checkZoneNameDuplicate = (name: string) => {
return zones.some( return zones.some(
(zone: any) => (zone: any) =>
zone.zoneName.trim().toLowerCase() === name.trim().toLowerCase() && zone.zoneName?.trim().toLowerCase() === name?.trim().toLowerCase() &&
zone.zoneUuid !== selectedZone.zoneUuid zone.zoneUuid !== selectedZone.zoneUuid
); );
}; };

View File

@ -92,10 +92,13 @@ const ThroughputSummary: React.FC = () => {
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
useEffect(() => { useEffect(() => {
// console.log('productionCapacityData > 0: ', productionCapacityData > 0); //
if (productionCapacityData > 0) { if (productionCapacityData > 0) {
setIsLoading(false); setTimeout(() => {
console.log("productionCapacityData: ", productionCapacityData);
setIsLoading(false);
}, 3000)
} else { } else {
setIsLoading(true); setIsLoading(true);
} }

View File

@ -80,14 +80,15 @@ const ROISummary = ({
const year = now.getFullYear(); const year = now.getFullYear();
return `${day} ${month}, ${year}`; return `${day} ${month}, ${year}`;
} }
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(true);
const { roiSummary } = useROISummaryData(); const { roiSummary } = useROISummaryData();
useEffect(() => { useEffect(() => {
if (roiSummary.productName) { if (roiSummary.productName) {
// If productName is set, assume data is loaded setTimeout(() => {
setIsLoading(false); setIsLoading(false);
}, 4500)
} else { } else {
// If productName is empty, assume still loading // If productName is empty, assume still loading
setIsLoading(true); setIsLoading(true);

View File

@ -11,9 +11,6 @@ const ProductionCapacity = ({
throughputValue = 128, throughputValue = 128,
timeRange = { startTime: "08:00 AM", endTime: "09:00 AM" }, timeRange = { startTime: "08:00 AM", endTime: "09:00 AM" },
}) => { }) => {
const { machineActiveTime } = useMachineUptime(); const { machineActiveTime } = useMachineUptime();
const { materialCycleTime } = useMaterialCycle(); const { materialCycleTime } = useMaterialCycle();
const { throughputData } = useThroughPutData() const { throughputData } = useThroughPutData()
@ -26,21 +23,14 @@ const ProductionCapacity = ({
const partialFillPercent = const partialFillPercent =
((progressPercent / 100) * totalBars - barsToFill) * 100; ((progressPercent / 100) * totalBars - barsToFill) * 100;
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(true);
useEffect(() => { useEffect(() => {
console.log('typeof throughputData:', typeof throughputData);
console.log('throughputData > 0: ', throughputData > 0);
if (throughputData > 0) { if (throughputData > 0) {
// console.log('machineActiveTime: ', machineActiveTime);
// console.log('materialCycleTime: ', materialCycleTime);
// console.log('throughputData: ', throughputData);
// console.log('productionCapacityData: ', productionCapacityData);
setIsLoading(false); setIsLoading(false);
} else { } else {
setIsLoading(true); setIsLoading(true);
} }
}, [throughputData]) }, [throughputData])
return ( return (
@ -59,7 +49,7 @@ const ProductionCapacity = ({
<ThroughputSummaryIcon /> <ThroughputSummaryIcon />
</div> </div>
</div> </div>
{isLoading ? ( {!isLoading ? (
<> <>
<div className="process-container"> <div className="process-container">
<div className="throughput-value"> <div className="throughput-value">

View File

@ -18,7 +18,6 @@ import {
} from "../../../store/builder/store"; } from "../../../store/builder/store";
import { zoneCameraUpdate } from "../../../services/visulization/zone/zoneCameraUpdation"; import { zoneCameraUpdate } from "../../../services/visulization/zone/zoneCameraUpdation";
import { setFloorItemApi } from "../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi"; import { setFloorItemApi } from "../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi";
import OuterClick from "../../../utils/outerClick";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { useAssetsStore } from "../../../store/builder/useAssetStore"; import { useAssetsStore } from "../../../store/builder/useAssetStore";
@ -111,7 +110,7 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
const isDuplicate = zones.some( const isDuplicate = zones.some(
(zone: any) => (zone: any) =>
zone.zoneName.trim().toLowerCase() === newName.trim().toLowerCase() && zone.zoneName?.trim().toLowerCase() === newName?.trim().toLowerCase() &&
zone.zoneUuid !== selectedZone.zoneUuid zone.zoneUuid !== selectedZone.zoneUuid
); );
@ -119,17 +118,13 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
alert("Zone name already exists. Please choose a different name."); alert("Zone name already exists. Please choose a different name.");
return; // DO NOT update state return; // DO NOT update state
} }
const zonesdata = { const zonesdata = {
zoneUuid: selectedZone.zoneUuid, zoneUuid: selectedZone.zoneUuid,
zoneName: newName, zoneName: newName,
}; };
const response = await zoneCameraUpdate(zonesdata, organization,projectId); const response = await zoneCameraUpdate(zonesdata, organization,projectId);
console.log('response: ', response); if (response.message === "zone updated") {
if (response.message === "updated successfully") {
setSelectedZone((prev) => ({ ...prev, zoneName: newName })); setSelectedZone((prev) => ({ ...prev, zoneName: newName }));
setZones((prevZones: any[]) => setZones((prevZones: any[]) =>
prevZones.map((zone) => prevZones.map((zone) =>
zone.zoneUuid === selectedZone.zoneUuid zone.zoneUuid === selectedZone.zoneUuid
@ -158,7 +153,7 @@ const List: React.FC<ListProps> = ({ items = [], remove }) => {
const checkZoneNameDuplicate = (name: string) => { const checkZoneNameDuplicate = (name: string) => {
return zones.some( return zones.some(
(zone: any) => (zone: any) =>
zone.zoneName.trim().toLowerCase() === name.trim().toLowerCase() && zone.zoneName?.trim().toLowerCase() === name?.trim().toLowerCase() &&
zone.zoneUuid !== selectedZone.zoneUuid zone.zoneUuid !== selectedZone.zoneUuid
); );
}; };

View File

@ -176,7 +176,7 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
actionName: "Action 1", actionName: "Action 1",
actionType: "process", actionType: "process",
processTime: 10, processTime: 10,
swapMaterial: "material-id", swapMaterial: "Default Material",
triggers: [] triggers: []
} }
} }

View File

@ -36,7 +36,7 @@ function Model({ asset }: { readonly asset: Asset }) {
const { renderDistance } = useRenderDistance(); const { renderDistance } = useRenderDistance();
const [isRendered, setIsRendered] = useState(false); const [isRendered, setIsRendered] = useState(false);
const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`; const url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
const [gltfScene, setGltfScene] = useState<GLTF | null>(null); const [gltfScene, setGltfScene] = useState<GLTF["scene"] | null>(null);
const [boundingBox, setBoundingBox] = useState<THREE.Box3 | null>(null); const [boundingBox, setBoundingBox] = useState<THREE.Box3 | null>(null);
const groupRef = useRef<THREE.Group>(null); const groupRef = useRef<THREE.Group>(null);
const { projectId } = useParams(); const { projectId } = useParams();
@ -53,7 +53,7 @@ function Model({ asset }: { readonly asset: Asset }) {
const assetId = asset.assetId; const assetId = asset.assetId;
const cachedModel = THREE.Cache.get(assetId); const cachedModel = THREE.Cache.get(assetId);
if (cachedModel) { if (cachedModel) {
setGltfScene(cachedModel); setGltfScene(cachedModel.scene.clone());
calculateBoundingBox(cachedModel.scene); calculateBoundingBox(cachedModel.scene);
return; return;
} }
@ -66,7 +66,7 @@ function Model({ asset }: { readonly asset: Asset }) {
URL.revokeObjectURL(blobUrl); URL.revokeObjectURL(blobUrl);
THREE.Cache.remove(blobUrl); THREE.Cache.remove(blobUrl);
THREE.Cache.add(assetId, gltf); THREE.Cache.add(assetId, gltf);
setGltfScene(gltf); setGltfScene(gltf.scene.clone());
calculateBoundingBox(gltf.scene); calculateBoundingBox(gltf.scene);
}, },
undefined, undefined,
@ -86,7 +86,7 @@ function Model({ asset }: { readonly asset: Asset }) {
const modelBlob = await response.blob(); const modelBlob = await response.blob();
await storeGLTF(assetId, modelBlob); await storeGLTF(assetId, modelBlob);
THREE.Cache.add(assetId, gltf); THREE.Cache.add(assetId, gltf);
setGltfScene(gltf); setGltfScene(gltf.scene.clone());
calculateBoundingBox(gltf.scene); calculateBoundingBox(gltf.scene);
} catch (error) { } catch (error) {
console.error(`[Backend] Error storing/loading ${asset.modelName}:`, error); console.error(`[Backend] Error storing/loading ${asset.modelName}:`, error);
@ -285,7 +285,7 @@ function Model({ asset }: { readonly asset: Asset }) {
> >
{gltfScene && ( {gltfScene && (
isRendered ? ( isRendered ? (
<primitive object={gltfScene.scene.clone()} /> <primitive object={gltfScene} />
) : ( ) : (
<AssetBoundingBox boundingBox={boundingBox} /> <AssetBoundingBox boundingBox={boundingBox} />
) )

View File

@ -16,7 +16,7 @@ export default function ThroughPutData() {
const { machines } = machineStore(); const { machines } = machineStore();
const { conveyors } = conveyorStore(); const { conveyors } = conveyorStore();
const { storageUnits } = storageUnitStore(); const { storageUnits } = storageUnitStore();
const { materialHistory } = materialStore(); const { materialHistory, materials } = materialStore();
const { machineCount, setMachineCount } = useMachineCount(); const { machineCount, setMachineCount } = useMachineCount();
const { machineActiveTime, setMachineActiveTime } = useMachineUptime(); const { machineActiveTime, setMachineActiveTime } = useMachineUptime();
const { materialCycleTime, setMaterialCycleTime } = useMaterialCycle(); const { materialCycleTime, setMaterialCycleTime } = useMaterialCycle();
@ -49,16 +49,15 @@ export default function ThroughPutData() {
if (item.type === "roboticArm") { if (item.type === "roboticArm") {
armBots.filter(arm => arm.modelUuid === item.modelUuid) armBots.filter(arm => arm.modelUuid === item.modelUuid)
.forEach(arm => { .forEach(arm => {
if (arm.activeTime >= 0) { if (arm.activeTime > 0) {
process.push({ modelid: arm.modelUuid, modelName: arm.modelName, activeTime: arm?.activeTime }) process.push({ modelid: arm.modelUuid, modelName: arm.modelName, activeTime: arm?.activeTime })
totalActiveTime += arm.activeTime; totalActiveTime += arm.activeTime;
} }
}); });
} else if (item.type === "vehicle") { } else if (item.type === "vehicle") {
vehicles.filter(vehicle => vehicle.modelUuid === item.modelUuid) vehicles.filter(vehicle => vehicle.modelUuid === item.modelUuid)
.forEach(vehicle => { .forEach(vehicle => {
if (vehicle.activeTime >= 0) { if (vehicle.activeTime > 0) {
process.push({ modelid: vehicle.modelUuid, modelName: vehicle.modelName, activeTime: vehicle?.activeTime }) process.push({ modelid: vehicle.modelUuid, modelName: vehicle.modelName, activeTime: vehicle?.activeTime })
totalActiveTime += vehicle.activeTime; totalActiveTime += vehicle.activeTime;
@ -67,7 +66,7 @@ export default function ThroughPutData() {
} else if (item.type === "machine") { } else if (item.type === "machine") {
machines.filter(machine => machine.modelUuid === item.modelUuid) machines.filter(machine => machine.modelUuid === item.modelUuid)
.forEach(machine => { .forEach(machine => {
if (machine.activeTime >= 0) { if (machine.activeTime > 0) {
process.push({ modelid: machine.modelUuid, modelName: machine.modelName, activeTime: machine?.activeTime }) process.push({ modelid: machine.modelUuid, modelName: machine.modelName, activeTime: machine?.activeTime })
totalActiveTime += machine.activeTime; totalActiveTime += machine.activeTime;
} }
@ -75,16 +74,16 @@ export default function ThroughPutData() {
} else if (item.type === "transfer") { } else if (item.type === "transfer") {
conveyors.filter(conveyor => conveyor.modelUuid === item.modelUuid) conveyors.filter(conveyor => conveyor.modelUuid === item.modelUuid)
.forEach(conveyor => { .forEach(conveyor => {
if (conveyor.activeTime >= 0) { if (conveyor.activeTime > 0) {
totalActiveTime += conveyor.activeTime; // totalActiveTime += conveyor.activeTime;
} }
}); });
} else if (item.type === "storageUnit") { } else if (item.type === "storageUnit") {
storageUnits.filter(storage => storage.modelUuid === item.modelUuid) storageUnits.filter(storage => storage.modelUuid === item.modelUuid)
.forEach(storage => { .forEach(storage => {
if (storage.activeTime >= 0) { if (storage.activeTime > 0) {
totalActiveTime += storage.activeTime; // totalActiveTime += storage.activeTime;
//
} }
}); });
} }
@ -93,6 +92,7 @@ export default function ThroughPutData() {
totalItems += sequence.length; totalItems += sequence.length;
}); });
setMachineCount(totalItems); setMachineCount(totalItems);
setMachineActiveTime(totalActiveTime); setMachineActiveTime(totalActiveTime);
let arr = process.map((item: any) => ({ let arr = process.map((item: any) => ({
@ -109,39 +109,98 @@ export default function ThroughPutData() {
// if (materialCycleTime <= 0) return // if (materialCycleTime <= 0) return
}, [products, selectedProduct, getProductById, setMachineCount, materialCycleTime, armBots, vehicles, machines]); }, [products, selectedProduct, getProductById, setMachineCount, materialCycleTime, armBots, vehicles, machines]);
// Setting material cycle time
useEffect(() => { useEffect(() => {
materialHistory.forEach((material) => { async function getMachineActive() {
const start = material.material.startTime ?? 0; const productData = getProductById(selectedProduct.productUuid);
const end = material.material.endTime ?? 0; let anyArmActive;
if (start === 0 || end === 0) return; let anyVehicleActive;
const totalCycleTime = (end - start) / 1000; // Convert milliseconds to seconds let anyMachineActive;
setMaterialCycleTime(Number(totalCycleTime.toFixed(2))); // Set the material cycle time in the store
});
}, [materialHistory]);
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) {
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)));
}
}
}
if (isPlaying) {
setTimeout(() => {
getMachineActive();
}, 500)
}
}, [armBots, materials, materialHistory, machines, vehicles, selectedProduct])
useEffect(() => { useEffect(() => {
if (machineActiveTime > 0 && materialCycleTime > 0 && machineCount > 0) { if (machineActiveTime > 0 && materialCycleTime > 0 && machineCount > 0) {
const utilization = machineActiveTime / 3600; // Active time per hour const utilization = machineActiveTime / 3600; // Active time per hour
const unitsPerMachinePerHour = 3600 / materialCycleTime; const unitsPerMachinePerHour = 3600 / materialCycleTime;
const throughput = unitsPerMachinePerHour * machineCount * utilization; const throughput = unitsPerMachinePerHour * machineCount * utilization;
setThroughputData(Number(throughput.toFixed(2))); // Keep as number
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);
} }
}, [machineActiveTime, materialCycleTime, machineCount]); }, [machineActiveTime, materialCycleTime, machineCount]);
return ( return (
<> <>
</> </>

View File

@ -32,7 +32,7 @@ function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetai
useEffect(() => { useEffect(() => {
if (currentPhase === 'stationed-pickup' && path.length > 0) { if (currentPhase === 'stationed-pickup' && path.length > 0) {
console.log('path: ', path); // console.log('path: ', path);
setCurrentPath(path); setCurrentPath(path);
setObjectRotation(agvDetail.point.action?.pickUpPoint?.rotation) setObjectRotation(agvDetail.point.action?.pickUpPoint?.rotation)
} else if (currentPhase === 'pickup-drop' && path.length > 0) { } else if (currentPhase === 'pickup-drop' && path.length > 0) {

View File

@ -5,8 +5,8 @@ import { useSceneContext } from "../../../scene/sceneContext";
import { useViewSceneStore } from "../../../../store/builder/store"; import { useViewSceneStore } from "../../../../store/builder/store";
function VehicleInstances() { function VehicleInstances() {
const { vehicleStore } = useSceneContext(); const { vehicleStore } = useSceneContext();
const { vehicles } = vehicleStore(); const { vehicles } = vehicleStore();
const { viewSceneLabels } = useViewSceneStore(); const { viewSceneLabels } = useViewSceneStore();
return ( return (

View File

@ -38,13 +38,12 @@ const UserAuth: React.FC = () => {
const { userId, organization } = getUserData(); const { userId, organization } = getUserData();
const handleLogin = async (e: FormEvent<HTMLFormElement>) => { const handleLogin = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault(); e.preventDefault();
const organization = email.split("@")[1].split(".")[0]; const organization = email.split("@")[1].split(".")[0];
try { try {
const res = await signInApi(email, password, organization, fingerprint); const res = await signInApi(email, password, organization, fingerprint);
console.log('res: ', res);
if (res.message.message === "login successfull") { if (res.message.message === "login successfull") {
setError(""); setError("");
setOrganization(organization); setOrganization(organization);
@ -57,7 +56,10 @@ const UserAuth: React.FC = () => {
localStorage.setItem("refreshToken", res.message.refreshToken); localStorage.setItem("refreshToken", res.message.refreshToken);
try { try {
console.log('res.message.userId: ', res.message.userId);
console.log('organization: ', organization);
const projects = await recentlyViewed(organization, res.message.userId); const projects = await recentlyViewed(organization, res.message.userId);
console.log('projects: ', projects);
if (Object.values(projects.RecentlyViewed).length > 0) { if (Object.values(projects.RecentlyViewed).length > 0) {
const firstId = (Object.values(projects?.RecentlyViewed || {})[0] as any)?._id; const firstId = (Object.values(projects?.RecentlyViewed || {})[0] as any)?._id;

View File

@ -11,7 +11,7 @@ export const zoneCameraUpdate = async (zoneData: {}, organization: string, proje
token: localStorage.getItem("token") || "", token: localStorage.getItem("token") || "",
refresh_token: localStorage.getItem("refreshToken") || "", refresh_token: localStorage.getItem("refreshToken") || "",
}, },
body: JSON.stringify({ zoneData,projectId }), body: JSON.stringify({ zoneData, projectId }),
}); });
if (!response.ok) { if (!response.ok) {