| | |
| | | PageContainer, |
| | | } from '@ant-design/pro-components'; |
| | | import './index.less' |
| | | import { WEBSOCKET_BASE_URL } from '@/config/setting'; |
| | | |
| | | const Main = () => { |
| | | const [deviceInfos, setDeviceInfos] = useState([]); |
| | |
| | | const [moveLocType, setMoveLocType] = useState(1); |
| | | |
| | | useEffect(() => { |
| | | var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/shuttle/websocket"); |
| | | setWs(newWs); |
| | | connect(); |
| | | |
| | | return () => { |
| | | if (ws) { |
| | |
| | | |
| | | ws.onclose = function (e) { |
| | | console.log("close"); |
| | | reconnect(); |
| | | } |
| | | |
| | | ws.onerror = function (e) { |
| | |
| | | } |
| | | } |
| | | }, [ws]); |
| | | |
| | | const connect = () => { |
| | | var newWs = new WebSocket(WEBSOCKET_BASE_URL + "/ws/shuttle/websocket"); |
| | | setWs(newWs); |
| | | } |
| | | |
| | | const reconnect = () => { |
| | | setTimeout(() => { |
| | | console.log('WebSocketClient: Attempting to reconnect...'); |
| | | connect(); |
| | | }, 3000); |
| | | } |
| | | |
| | | const sendWs = (message) => { |
| | | if (ws.readyState == WebSocket.OPEN) { |
| | |
| | | </p> |
| | | <p> |
| | | </p> |
| | | <p> |
| | | </p> |
| | | <div className="commandItem"> |
| | | <Button onClick={() => shuttleOperator('moveLoc')}>移动到目标位置</Button> |
| | | <Button onClick={() => shuttleOperator('takeMove')}>取放货作业</Button> |
| | |
| | | <Button onClick={() => shuttleOperator('palletDown')}>托盘下降</Button> |
| | | <Button onClick={() => shuttleOperator('chargeOpen')}>充电开</Button> |
| | | <Button onClick={() => shuttleOperator('chargeClose')}>充电关</Button> |
| | | <Button onClick={() => shuttleOperator('requestWaiting')}>申请确认</Button> |
| | | <Button onClick={() => shuttleOperator('reset')}>复位</Button> |
| | | </div> |
| | | </Card> |