| | |
| | | import { INTERVAL_TIME } from '@/config/setting' |
| | | |
| | | let index = 0; |
| | | let coords = { x: 0, y: 0, z: 0 }; |
| | | |
| | | const Warehouse = (props) => { |
| | | |
| | | const [agvData, setAgvData] = useState([ |
| | | {} |
| | | ]); |
| | | |
| | | const [boxData, setBoxData] = useState([ |
| | | {} |
| | | ]) |
| | | |
| | | useEffect(() => { |
| | | const agvRealData = agvRealDataList[0]; |
| | | |
| | | const timer = setInterval(() => { |
| | | const agvRealData = agvRealDataList[index]; |
| | | if (agvRealData) { |
| | | setAgvData((state) => { |
| | | return agvRealData; |
| | | }); |
| | | } |
| | | coords.x++; |
| | | agvRealData[0].position = [coords.x, coords.y, coords.z]; |
| | | // console.log(agvRealData); |
| | | setAgvData(agvRealData); |
| | | index++; |
| | | }, INTERVAL_TIME); |
| | | }, 1000); |
| | | |
| | | return () => { |
| | | clearInterval(timer); |
| | | } |
| | | }, []) |
| | | |
| | | useEffect(() => { |
| | | console.log(agvData); |
| | | }, [agvData]) |
| | | |
| | | const tunnelEl = useMemo(() => { |
| | | return tunnelData.map((tunnel, index) => <Tunnel key={index} {...tunnel} />) |
| | | }, []); |