From da407d4525cd6ea211d952fc2fd96f5ba30510e8 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 27 十一月 2024 15:43:28 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/map/insight/agv/AgvMain.jsx | 189 ++++++++++++++++++++++++++++------------------
1 files changed, 114 insertions(+), 75 deletions(-)
diff --git a/zy-acs-flow/src/map/insight/agv/AgvMain.jsx b/zy-acs-flow/src/map/insight/agv/AgvMain.jsx
index 566e2ce..3e1880c 100644
--- a/zy-acs-flow/src/map/insight/agv/AgvMain.jsx
+++ b/zy-acs-flow/src/map/insight/agv/AgvMain.jsx
@@ -14,68 +14,10 @@
} from '@mui/material';
import { useNotification } from '../../Notification';
import AgvThree from './AgvThree';
-import { handleRestoreAgvAll } from '../../http';
+import { handleRestoreAgvAll, handleAgvPatrol } from '../../http';
import BoolValueIcon from '../BoolValueIcon';
import ConfirmButton from '../../../page/components/ConfirmButton';
-
-let three;
-
-const startThree = (dom) => {
- three = new AgvThree(dom);
- three.startup();
-}
-
-const endThree = () => {
- if (three) {
- three.destroy();
- three = null;
- }
-}
-
-const renderThree = (curAgvNo) => {
- if (curAgvNo && three) {
- three.generateMesh((loader, addObject) => {
- const loadModel = (path) => {
- return new Promise((resolve, reject) => {
- loader.load(path, (mesh) => {
- resolve(mesh);
- }, undefined, (error) => {
- reject(error);
- });
- });
- };
-
- Promise.all([
- loadModel('model/agv/body.fbx'),
- loadModel('model/agv/loader.fbx'),
- loadModel('model/agv/fork.fbx'),
- ]).then(([bodyMesh, loaderMesh, forkMesh]) => {
- const scaleVal = 1;
- bodyMesh.scale.set(scaleVal, scaleVal, scaleVal);
- loaderMesh.scale.set(scaleVal, scaleVal, scaleVal);
- forkMesh.scale.set(scaleVal, scaleVal, scaleVal);
-
- bodyMesh.position.set(55, 0, 0);;
- loaderMesh.position.set(55, 150, 0);;
- forkMesh.position.set(55, 165, 0);;
-
- const agvGroup = new THREE.Group();
- agvGroup.add(bodyMesh);
- agvGroup.add(loaderMesh);
- agvGroup.add(forkMesh);
-
- agvGroup.name = curAgvNo;
-
- addObject(agvGroup);
-
- three?.rePerspective(350, 450);
-
- }).catch((error) => {
- console.error(error);
- });
- });
- }
-}
+import { grey } from '@mui/material/colors';
const AgvMain = (props) => {
const { curAgvNo, curAgvInfo: info, fetchAgvInfo } = props;
@@ -87,9 +29,70 @@
const containerRef = useRef();
const [loading, setLoading] = useState(true);
+ const threeRef = useRef(null);
+
+ const startThree = (dom) => {
+ if (threeRef.current) {
+ threeRef.current.destroy();
+ }
+ threeRef.current = new AgvThree(dom);
+ threeRef.current.startup();
+ }
+
+ const endThree = () => {
+ if (threeRef.current) {
+ threeRef.current.destroy();
+ threeRef.current = null;
+ }
+ }
+
+ const renderThree = (curAgvNo) => {
+ if (curAgvNo && threeRef.current) {
+ threeRef.current.generateMesh((loader, addObject) => {
+ const loadModel = (path) => {
+ return new Promise((resolve, reject) => {
+ loader.load(path, (mesh) => {
+ resolve(mesh);
+ }, undefined, (error) => {
+ reject(error);
+ });
+ });
+ };
+
+ Promise.all([
+ loadModel('model/agv/body.fbx'),
+ loadModel('model/agv/loader.fbx'),
+ loadModel('model/agv/fork.fbx'),
+ ]).then(([bodyMesh, loaderMesh, forkMesh]) => {
+ const scaleVal = 1;
+ bodyMesh.scale.set(scaleVal, scaleVal, scaleVal);
+ loaderMesh.scale.set(scaleVal, scaleVal, scaleVal);
+ forkMesh.scale.set(scaleVal, scaleVal, scaleVal);
+
+ bodyMesh.position.set(55, 0, 0);;
+ loaderMesh.position.set(55, 150, 0);;
+ forkMesh.position.set(55, 165, 0);;
+
+ const agvGroup = new THREE.Group();
+ agvGroup.add(bodyMesh);
+ agvGroup.add(loaderMesh);
+ agvGroup.add(forkMesh);
+
+ agvGroup.name = curAgvNo;
+
+ addObject(agvGroup);
+
+ threeRef.current?.rePerspective(350, 450);
+
+ }).catch((error) => {
+ console.error(error);
+ });
+ });
+ }
+ }
+
useEffect(() => {
if (info) {
- endThree();
setLoading(true);
setTimeout(() => {
startThree(containerRef.current);
@@ -119,6 +122,13 @@
});
}
+ const patrolControl = async () => {
+ const res = await handleAgvPatrol({ agvNo: info.agvNo })
+ if (res) {
+ fetchAgvInfo(curAgvNo);
+ }
+ }
+
return (
<Box display="flex" height="100%">
<Box
@@ -135,7 +145,7 @@
left="50%"
style={{ transform: 'translate(-50%, -50%)' }}
>
- <CircularProgress />
+ <CircularProgress sx={{ color: grey[50] }} />
</Box>
)}
</Box>
@@ -162,14 +172,17 @@
<KeyValuePair label={translate('table.field.agvDetail.pos')} value={info?.pos} bool />
</Grid>
<Grid item xs={12}>
+ <KeyValuePair label={translate('table.field.agvDetail.code')} value={info?.code} />
+ </Grid>
+ <Grid item xs={12}>
<KeyValuePair label={translate('common.field.status')} value={info?.agvStatus} />
</Grid>
<Grid item xs={12}>
<KeyValuePair label={translate('table.field.agvDetail.vol')} value={info?.vol} />
</Grid>
- <Grid item xs={12}>
+ {/* <Grid item xs={12}>
<KeyValuePair label={translate('table.field.agvDetail.soc')} value={info?.soc} />
- </Grid>
+ </Grid> */}
<Grid item xs={12}>
<KeyValuePair label={translate('table.field.agvDetail.agvAngle')} value={info?.direction} />
</Grid>
@@ -190,7 +203,8 @@
}}>
<Grid container spacing={2} style={{ marginTop: '0px' }}>
<Grid item xs={12}>
- <Stack spacing={2} mt={2}>
+ <Stack spacing={1} mt={2}>
+ {/* more */}
<Button
color="primary"
variant="contained"
@@ -200,17 +214,33 @@
>
{translate('page.map.settings.map.more.title')}
</Button>
-
- <ConfirmButton
- label="page.map.action.restoreALl"
- color="primary"
- variant="contained"
- onConfirm={() => {
- handleRestoreAll();
- }}
- />
+ {/* patrol */}
{info && (
- info.status === 1
+ info.patrol
+ ?
+ <Button variant="contained" color="error" fullWidth onClick={() => {
+ patrolControl();
+ }}>
+ {translate('page.map.action.stopPatrol')}
+ </Button>
+ :
+ // <Button variant="contained" fullWidth onClick={() => {
+ // patrolControl();
+ // }}>
+ // {translate('page.map.action.startPatrol')}
+ // </Button>
+ <ConfirmButton
+ label="page.map.action.startPatrol"
+ color="primary"
+ variant="contained"
+ onConfirm={() => {
+ patrolControl();
+ }}
+ />
+ )}
+ {/* status */}
+ {info && (
+ info.status === 0
? <Button variant="contained" color="error" fullWidth onClick={() => {
updateStatus();
}}>
@@ -222,6 +252,15 @@
{translate('page.map.action.enable')}
</Button>
)}
+ {/* restore all */}
+ <ConfirmButton
+ label="page.map.action.restoreALl"
+ color="inherit"
+ // variant="contained"
+ onConfirm={() => {
+ handleRestoreAll();
+ }}
+ />
</Stack>
</Grid>
</Grid>
--
Gitblit v1.9.1