code optimization
This commit is contained in:
@@ -17,7 +17,6 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
||||
const pauseTimeRef = useRef<number | null>(null);
|
||||
const isPausedRef = useRef<boolean>(false);
|
||||
const isSpeedRef = useRef<any>(null);
|
||||
let startTime: number;
|
||||
|
||||
const { selectedProductStore } = useProductContext();
|
||||
const { materialStore, armBotStore, vehicleStore, storageUnitStore, productStore, assetStore } = useSceneContext();
|
||||
@@ -45,9 +44,9 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
||||
const action = getActionByUuid(selectedProduct.productUuid, armBot.currentAction?.actionUuid || '');
|
||||
|
||||
const handlePickUpTrigger = () => {
|
||||
if (armBot.currentAction && armBot.currentAction.materialId) {
|
||||
if (armBot?.currentAction?.materialId) {
|
||||
const material = getMaterialById(armBot.currentAction.materialId);
|
||||
if (material && material.previous && material.previous.modelUuid) {
|
||||
if (material?.previous?.modelUuid) {
|
||||
const previousModel = getEventByActionUuid(selectedProduct.productUuid, material.previous.actionUuid);
|
||||
if (previousModel) {
|
||||
if (previousModel.type === 'transfer') {
|
||||
@@ -77,7 +76,7 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
||||
if (armBot.currentAction) {
|
||||
const action = getActionByUuid(selectedProduct.productUuid, armBot.currentAction.actionUuid);
|
||||
const model = getEventByModelUuid(selectedProduct.productUuid, action?.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid || '');
|
||||
if (action && action.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid) {
|
||||
if (action?.triggers[0]?.triggeredAsset?.triggeredModel.modelUuid) {
|
||||
if (!model) return;
|
||||
if (model.type === 'transfer') {
|
||||
setIsVisible(armBot.currentAction.materialId || '', true);
|
||||
@@ -124,7 +123,6 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
||||
resetAsset(armBot.modelUuid);
|
||||
isPausedRef.current = false
|
||||
pauseTimeRef.current = null
|
||||
startTime = 0
|
||||
activeSecondsElapsed.current = 0;
|
||||
idleSecondsElapsed.current = 0;
|
||||
previousTimeRef.current = null;
|
||||
@@ -235,7 +233,6 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
||||
setArmBotActive(armBot.modelUuid, true);
|
||||
setArmBotState(armBot.modelUuid, "running");
|
||||
setCurrentPhase("start-to-end");
|
||||
startTime = 0
|
||||
if (!action) return;
|
||||
const startPoint = (action as RoboticArmAction).process.startPoint;
|
||||
const endPoint = (action as RoboticArmAction).process.endPoint;
|
||||
@@ -254,7 +251,6 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
||||
setArmBotActive(armBot.modelUuid, true);
|
||||
setArmBotState(armBot.modelUuid, "running");
|
||||
setCurrentPhase("end-to-rest");
|
||||
startTime = 0;
|
||||
if (!action) return;
|
||||
const endPoint = (action as RoboticArmAction).process.endPoint;
|
||||
if (endPoint) {
|
||||
@@ -280,7 +276,6 @@ function RoboticArmInstance({ armBot }: { readonly armBot: ArmBotStatus }) {
|
||||
isPausedRef.current = false
|
||||
pauseTimeRef.current = null
|
||||
isPausedRef.current = false
|
||||
startTime = 0
|
||||
activeSecondsElapsed.current = 0;
|
||||
idleSecondsElapsed.current = 0;
|
||||
previousTimeRef.current = null;
|
||||
|
||||
Reference in New Issue
Block a user