| | |
| | | PageContainer, |
| | | } from '@ant-design/pro-components'; |
| | | import './index.less' |
| | | import { WEBSOCKET_BASE_URL } from '@/config/setting'; |
| | | |
| | | const Main = () => { |
| | | const [deviceInfos, setDeviceInfos] = useState([]); |
| | | const [ws, setWs] = useState(null); |
| | | const [openOpera, setOpenOpera] = useState(false); |
| | | const [currentData, setCurrentData] = useState(null); |
| | | const [sourceLoc, setSourceLoc] = useState(""); |
| | | const [targetLoc, setTargetLoc] = useState(""); |
| | | const [xStart, setXStart] = useState(1); |
| | | const [xTarget, setXTarget] = useState(1); |
| | |
| | | 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) { |
| | |
| | | setOpenOpera(false); |
| | | }; |
| | | |
| | | const sourceLocChange = (e) => { |
| | | setSourceLoc(e.target.value) |
| | | } |
| | | |
| | | const targetLocChange = (e) => { |
| | | setTargetLoc(e.target.value) |
| | | } |
| | |
| | | message.warning('请输入目标位置'); |
| | | return; |
| | | } |
| | | }else if(type == 'takeMove') { |
| | | if (targetLoc == '') { |
| | | message.warning('请输入目标位置'); |
| | | return; |
| | | } |
| | | |
| | | if (sourceLoc == '') { |
| | | message.warning('请输入起始位置'); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | try { |
| | | const resp = await Http.doPost('api/basShuttle/operator/shuttle', { |
| | | shuttleNo: currentData.shuttleNo, |
| | | shuttleTaskMode: type, |
| | | sourceLocNo: sourceLoc, |
| | | targetLocNo: targetLoc |
| | | }); |
| | | if (resp.code === 200) { |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | const shuttleMoveLocClose = async () => { |
| | | try { |
| | | const resp = await Http.doPost('api/basShuttle/moveLocClose', { |
| | | shuttleNo: currentData.shuttleNo, |
| | | }); |
| | | if (resp.code === 200) { |
| | | message.success("请求成功"); |
| | | return true; |
| | | } else { |
| | | message.warning(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.warning("请求失败"); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | const xStartChange = (e) => { |
| | | setXStart(e.target.value) |
| | |
| | | { |
| | | key: '6', |
| | | label: '错误码', |
| | | children: '0', |
| | | children: item.errorCode$, |
| | | }, |
| | | { |
| | | key: '7', |
| | |
| | | label: '是否有托盘', |
| | | children: item.hasPallet ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '13', |
| | | label: '自动', |
| | | children: item.mode ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '14', |
| | | label: '库位号', |
| | | children: item.currentLocNo, |
| | | }, |
| | | ]; |
| | | return <div key={item.id} style={{ width: '45%' }}> |
| | | <div style={{ marginBottom: '10px' }}> |
| | |
| | | <div style={{ marginBottom: '15px' }}> |
| | | <Card title="移动指令" style={{ width: 300 }}> |
| | | <p> |
| | | <Input addonBefore="起始位置" onChange={sourceLocChange} /> |
| | | </p> |
| | | <p> |
| | | <Input addonBefore="目标位置" onChange={targetLocChange} /> |
| | | </p> |
| | | <p> |
| | | <Button onClick={() => shuttleOperator('moveLoc')}>移动到目标位置</Button> |
| | | </p> |
| | | <div className="commandItem"> |
| | | <Button onClick={() => shuttleOperator('moveLoc')}>移动到目标位置</Button> |
| | | <Button onClick={() => shuttleOperator('takeMove')}>取放货作业</Button> |
| | | </div> |
| | | </Card> |
| | | </div> |
| | | |
| | |
| | | <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> |
| | |
| | | defaultValue="0" |
| | | onChange={moveLocTypeChange} |
| | | style={{ width: 120 }} |
| | | options={[{ value: '0', label: '跑轨道' }, { value: '1', label: '跑库位' }, { value: '2', label: '母轨道循环跑' }, { value: '3', label: '子轨道循环跑' }]} |
| | | options={[{ value: '0', label: '跑轨道' }, { value: '1', label: '跑库位' }, { value: '2', label: '母轨道循环跑' }, { value: '3', label: '子轨道循环跑' }, { value: '4', label: '取放货' }]} |
| | | /> |
| | | </div> |
| | | <Button onClick={() => shuttleMoveLoc()}>跑库</Button> |
| | | <Button onClick={() => shuttleMoveLocClose()}>跑库关闭</Button> |
| | | </div> |
| | | </Card> |
| | | </div> |