Merge pull request 'Refactor logging in simulation handlers to use echo for improved status reporting; update Project component to reflect successful login with success message; enhance sidebar styles with text transformation.' (#85) from v2-ui into main
Reviewed-on: http://185.100.212.76:7776/Dwinzo-Beta/Dwinzo_dev/pulls/85
This commit is contained in:
commit
f38fb4a174
|
@ -42,19 +42,21 @@ const SimulationPlayer: React.FC = () => {
|
||||||
if (isReset) {
|
if (isReset) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setReset(false);
|
setReset(false);
|
||||||
}, 0)
|
}, 0);
|
||||||
}
|
}
|
||||||
}, [isReset, setReset])
|
}, [isReset, setReset]);
|
||||||
|
|
||||||
// Button functions
|
// Button functions
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
setReset(true);
|
setReset(true);
|
||||||
setIsPaused(false);
|
setIsPaused(false);
|
||||||
setSpeed(1);
|
setSpeed(1);
|
||||||
|
echo.info("Simulation RESET.....");
|
||||||
setPlaySimulation(false); // local state reset
|
setPlaySimulation(false); // local state reset
|
||||||
};
|
};
|
||||||
const handlePlayStop = () => {
|
const handlePlayStop = () => {
|
||||||
setIsPaused(!isPaused);
|
setIsPaused(!isPaused);
|
||||||
|
echo.warn(`Simulation is ${isPaused ? "Resumed" : "Paused"}`);
|
||||||
setPlaySimulation(!playSimulation);
|
setPlaySimulation(!playSimulation);
|
||||||
};
|
};
|
||||||
const handleExit = () => {
|
const handleExit = () => {
|
||||||
|
@ -62,6 +64,7 @@ const SimulationPlayer: React.FC = () => {
|
||||||
setIsPlaying(false);
|
setIsPlaying(false);
|
||||||
setIsPaused(false);
|
setIsPaused(false);
|
||||||
setActiveTool("cursor");
|
setActiveTool("cursor");
|
||||||
|
echo.info("Exit Simulation");
|
||||||
};
|
};
|
||||||
|
|
||||||
// Slider functions starts
|
// Slider functions starts
|
||||||
|
@ -282,7 +285,8 @@ const SimulationPlayer: React.FC = () => {
|
||||||
</div>
|
</div>
|
||||||
{index < intervals.length - 1 && (
|
{index < intervals.length - 1 && (
|
||||||
<div
|
<div
|
||||||
className={`line ${progress >= ((index + 1) / totalSegments) * 100
|
className={`line ${
|
||||||
|
progress >= ((index + 1) / totalSegments) * 100
|
||||||
? "filled"
|
? "filled"
|
||||||
: ""
|
: ""
|
||||||
}`}
|
}`}
|
||||||
|
@ -324,7 +328,8 @@ const SimulationPlayer: React.FC = () => {
|
||||||
<div className="custom-slider-wrapper">
|
<div className="custom-slider-wrapper">
|
||||||
<div className="custom-slider">
|
<div className="custom-slider">
|
||||||
<button
|
<button
|
||||||
className={`slider-handle ${isDragging ? "dragging" : ""
|
className={`slider-handle ${
|
||||||
|
isDragging ? "dragging" : ""
|
||||||
}`}
|
}`}
|
||||||
style={{ left: `${calculateHandlePosition()}%` }}
|
style={{ left: `${calculateHandlePosition()}%` }}
|
||||||
onMouseDown={handleMouseDown}
|
onMouseDown={handleMouseDown}
|
||||||
|
|
|
@ -5,7 +5,7 @@ export function useDefaultHandler() {
|
||||||
const { getMaterialById } = useMaterialStore();
|
const { getMaterialById } = useMaterialStore();
|
||||||
|
|
||||||
const defaultLogStatus = (materialUuid: string, status: string) => {
|
const defaultLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.info(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDefault = useCallback((action: ConveyorAction, materialId?: string) => {
|
const handleDefault = useCallback((action: ConveyorAction, materialId?: string) => {
|
||||||
|
|
|
@ -34,7 +34,7 @@ export function useDelayHandler() {
|
||||||
}, [isReset, cleanupDelay]);
|
}, [isReset, cleanupDelay]);
|
||||||
|
|
||||||
const delayLogStatus = (materialUuid: string, status: string) => {
|
const delayLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.info(`${materialUuid}, ${status}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
useFrame(() => {
|
useFrame(() => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ export function useDespawnHandler() {
|
||||||
const { getMaterialById, removeMaterial } = useMaterialStore();
|
const { getMaterialById, removeMaterial } = useMaterialStore();
|
||||||
|
|
||||||
const deSpawnLogStatus = (materialUuid: string, status: string) => {
|
const deSpawnLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.info(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDespawn = useCallback((action: ConveyorAction, materialId?: string) => {
|
const handleDespawn = useCallback((action: ConveyorAction, materialId?: string) => {
|
||||||
|
|
|
@ -58,7 +58,7 @@ export function useSpawnHandler() {
|
||||||
}, [isReset, clearAllSpawns]);
|
}, [isReset, clearAllSpawns]);
|
||||||
|
|
||||||
const spawnLogStatus = (materialUuid: string, status: string) => {
|
const spawnLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.info(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const createNewMaterial = useCallback((materialType: string, action: ConveyorAction) => {
|
const createNewMaterial = useCallback((materialType: string, action: ConveyorAction) => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ export function useSwapHandler() {
|
||||||
const { getMaterialById, setMaterial } = useMaterialStore();
|
const { getMaterialById, setMaterial } = useMaterialStore();
|
||||||
|
|
||||||
const swapLogStatus = (materialUuid: string, status: string) => {
|
const swapLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.info(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSwap = useCallback((action: ConveyorAction, materialId?: string) => {
|
const handleSwap = useCallback((action: ConveyorAction, materialId?: string) => {
|
||||||
|
|
|
@ -11,7 +11,7 @@ export function useProcessHandler() {
|
||||||
const { selectedProduct } = useSelectedProduct();
|
const { selectedProduct } = useSelectedProduct();
|
||||||
|
|
||||||
const processLogStatus = (materialUuid: string, status: string) => {
|
const processLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.log(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleProcess = useCallback((action: MachineAction, materialId?: string) => {
|
const handleProcess = useCallback((action: MachineAction, materialId?: string) => {
|
||||||
|
|
|
@ -11,7 +11,7 @@ export function usePickAndPlaceHandler() {
|
||||||
const { selectedProduct } = useSelectedProduct();
|
const { selectedProduct } = useSelectedProduct();
|
||||||
|
|
||||||
const pickAndPlaceLogStatus = (materialUuid: string, status: string) => {
|
const pickAndPlaceLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.warn(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlePickAndPlace = useCallback((action: RoboticArmAction, materialId?: string) => {
|
const handlePickAndPlace = useCallback((action: RoboticArmAction, materialId?: string) => {
|
||||||
|
@ -33,7 +33,7 @@ export function usePickAndPlaceHandler() {
|
||||||
|
|
||||||
pickAndPlaceLogStatus(material.materialId, `is going to be picked by armBot ${modelUuid}`);
|
pickAndPlaceLogStatus(material.materialId, `is going to be picked by armBot ${modelUuid}`);
|
||||||
|
|
||||||
}, [getMaterialById, getModelUuidByActionUuid, addCurrentAction]);
|
}, [getMaterialById, getModelUuidByActionUuid, selectedProduct.productId, addCurrentAction]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handlePickAndPlace,
|
handlePickAndPlace,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { useCallback, useState, useEffect, useRef } from "react";
|
import { useCallback, useState, useEffect, useRef } from "react";
|
||||||
import * as THREE from 'three';
|
|
||||||
import { useFrame } from "@react-three/fiber";
|
import { useFrame } from "@react-three/fiber";
|
||||||
import { useMaterialStore } from "../../../../../store/simulation/useMaterialStore";
|
import { useMaterialStore } from "../../../../../store/simulation/useMaterialStore";
|
||||||
import { useProductStore } from "../../../../../store/simulation/useProductStore";
|
import { useProductStore } from "../../../../../store/simulation/useProductStore";
|
||||||
|
@ -26,7 +25,7 @@ export function useRetrieveHandler() {
|
||||||
const delayTimerRef = useRef<NodeJS.Timeout | null>(null);
|
const delayTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
|
||||||
const retrieveLogStatus = (materialUuid: string, status: string) => {
|
const retrieveLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.info(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const createNewMaterial = useCallback((materialId: string, materialType: string, action: StorageAction) => {
|
const createNewMaterial = useCallback((materialId: string, materialType: string, action: StorageAction) => {
|
||||||
|
@ -100,7 +99,7 @@ export function useRetrieveHandler() {
|
||||||
if (retrieval.isProcessing) return;
|
if (retrieval.isProcessing) return;
|
||||||
|
|
||||||
const storageUnit = getStorageUnitById(
|
const storageUnit = getStorageUnitById(
|
||||||
getModelUuidByActionUuid(selectedProduct.productId, retrieval.action.actionUuid) || ''
|
getModelUuidByActionUuid(selectedProduct.productId, retrieval.action.actionUuid) ?? ''
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!storageUnit || storageUnit.currentLoad <= 0) {
|
if (!storageUnit || storageUnit.currentLoad <= 0) {
|
||||||
|
@ -124,7 +123,7 @@ export function useRetrieveHandler() {
|
||||||
|
|
||||||
if (triggeredModel.type === 'roboticArm') {
|
if (triggeredModel.type === 'roboticArm') {
|
||||||
const armBot = getArmBotById(triggeredModel.modelUuid);
|
const armBot = getArmBotById(triggeredModel.modelUuid);
|
||||||
isIdle = armBot && !armBot.isActive && armBot.state === 'idle' && !armBot.currentAction || false;
|
isIdle = (armBot && !armBot.isActive && armBot.state === 'idle' && !armBot.currentAction) || false;
|
||||||
|
|
||||||
if (isIdle) {
|
if (isIdle) {
|
||||||
setActiveRetrievals(prev => {
|
setActiveRetrievals(prev => {
|
||||||
|
@ -148,10 +147,11 @@ export function useRetrieveHandler() {
|
||||||
if (material) {
|
if (material) {
|
||||||
addCurrentAction(
|
addCurrentAction(
|
||||||
triggeredModel.modelUuid,
|
triggeredModel.modelUuid,
|
||||||
retrieval.action.triggers[0].triggeredAsset.triggeredAction?.actionUuid || '',
|
retrieval.action.triggers[0].triggeredAsset.triggeredAction?.actionUuid ?? '',
|
||||||
material.materialType,
|
material.materialType,
|
||||||
material.materialId
|
material.materialId
|
||||||
);
|
);
|
||||||
|
retrieveLogStatus(material.materialName, `is being picked by ${armBot?.modelName}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,10 +168,10 @@ export function useRetrieveHandler() {
|
||||||
|
|
||||||
} else if (triggeredModel.type === 'vehicle') {
|
} else if (triggeredModel.type === 'vehicle') {
|
||||||
const vehicle = getVehicleById(triggeredModel.modelUuid);
|
const vehicle = getVehicleById(triggeredModel.modelUuid);
|
||||||
isIdle = vehicle && !vehicle.isActive && vehicle.state === 'idle' && vehicle.isPicking || false;
|
isIdle = (vehicle && !vehicle.isActive && vehicle.state === 'idle' && vehicle.isPicking) || false;
|
||||||
|
|
||||||
if (!vehicle) return;
|
if (!vehicle) return;
|
||||||
const loadDuration = vehicle.point.action.unLoadDuration;
|
// const loadDuration = vehicle.point.action.unLoadDuration;
|
||||||
|
|
||||||
if (isIdle) {
|
if (isIdle) {
|
||||||
setActiveRetrievals(prev => {
|
setActiveRetrievals(prev => {
|
||||||
|
@ -198,6 +198,7 @@ export function useRetrieveHandler() {
|
||||||
updateCurrentLoad(storageUnit.modelUuid, -1)
|
updateCurrentLoad(storageUnit.modelUuid, -1)
|
||||||
incrementVehicleLoad(vehicle.modelUuid, 1);
|
incrementVehicleLoad(vehicle.modelUuid, 1);
|
||||||
addCurrentMaterial(vehicle.modelUuid, material.materialType, material.materialId);
|
addCurrentMaterial(vehicle.modelUuid, material.materialType, material.materialId);
|
||||||
|
retrieveLogStatus(material.materialName, `is picked by ${vehicle.modelName}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ export function useStoreHandler() {
|
||||||
const { selectedProduct } = useSelectedProduct();
|
const { selectedProduct } = useSelectedProduct();
|
||||||
|
|
||||||
const storeLogStatus = (materialUuid: string, status: string) => {
|
const storeLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.info(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleStore = useCallback((action: StorageAction, materialId?: string) => {
|
const handleStore = useCallback((action: StorageAction, materialId?: string) => {
|
||||||
|
|
|
@ -11,7 +11,7 @@ export function useTravelHandler() {
|
||||||
const { incrementVehicleLoad, addCurrentMaterial } = useVehicleStore();
|
const { incrementVehicleLoad, addCurrentMaterial } = useVehicleStore();
|
||||||
|
|
||||||
const travelLogStatus = (materialUuid: string, status: string) => {
|
const travelLogStatus = (materialUuid: string, status: string) => {
|
||||||
// console.log(`${materialUuid}, ${status}`);
|
echo.info(`${materialUuid}, ${status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTravel = useCallback((action: VehicleAction, materialId?: string) => {
|
const handleTravel = useCallback((action: VehicleAction, materialId?: string) => {
|
||||||
|
@ -29,7 +29,7 @@ export function useTravelHandler() {
|
||||||
|
|
||||||
travelLogStatus(material.materialId, `is triggering travel from ${modelUuid}`);
|
travelLogStatus(material.materialId, `is triggering travel from ${modelUuid}`);
|
||||||
|
|
||||||
}, [getMaterialById, getModelUuidByActionUuid]);
|
}, [addCurrentMaterial, getMaterialById, getModelUuidByActionUuid, incrementVehicleLoad, selectedProduct.productId]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handleTravel,
|
handleTravel,
|
||||||
|
|
|
@ -58,7 +58,7 @@ const Project: React.FC = () => {
|
||||||
setOrganization(Organization);
|
setOrganization(Organization);
|
||||||
setUserName(name);
|
setUserName(name);
|
||||||
}
|
}
|
||||||
echo.warn("Log in successful");
|
echo.success("Log in successful");
|
||||||
} else {
|
} else {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
}
|
}
|
||||||
|
|
|
@ -789,6 +789,7 @@
|
||||||
@include flex-space-between;
|
@include flex-space-between;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
padding-right: 6px;
|
padding-right: 6px;
|
||||||
|
text-transform: capitalize;
|
||||||
|
|
||||||
.add-button {
|
.add-button {
|
||||||
@include flex-center;
|
@include flex-center;
|
||||||
|
|
Loading…
Reference in New Issue