| | |
| | | // 数据显示页面 |
| | | Item item = itemList.get(position); |
| | | holder.ip.setText("设备IP: " + item.getIp()); |
| | | holder.title.setText("设备编号: " + item.getText()); |
| | | holder.title.setText("设备编号: " + item.getAgvNo()); |
| | | holder.itemView.setTag(position); |
| | | |
| | | } |
| | |
| | | |
| | | private Button bodySwitchBtn; // 底盘/货叉切换 |
| | | private Socket socket; |
| | | private String AgvNo = "12"; |
| | | private String AgvNo = "1"; |
| | | private RelativeLayout layout_bottom; |
| | | private RelativeLayout layout_top; |
| | | private RelativeLayout layout_single; |
| | |
| | | .setAgvNo(AgvNo) |
| | | .setSerialNo(substring) |
| | | .setVal(1) |
| | | .bodySync((action) -> action.setPwd((short) 10)); |
| | | .bodySync((action) -> action.setPwd((short) 50)); |
| | | nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端 |
| | | handler.sendEmptyMessageDelayed(0, 100); // 100ms 后发送下一条消息 |
| | | } |
| | |
| | | .setAgvNo(AgvNo) |
| | | .setSerialNo(substring) |
| | | .setVal(1) |
| | | .bodySync((action) -> action.setPwd((short) -10)); |
| | | .bodySync((action) -> action.setPwd((short) -50)); |
| | | nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端 |
| | | handler.sendEmptyMessageDelayed(0, 100); |
| | | } |
| | |
| | | .setAgvNo(AgvNo) |
| | | .setSerialNo(substring) |
| | | .setVal(1) |
| | | .bodySync((action) -> action.setPwd((short) 10)); |
| | | .bodySync((action) -> action.setPwd((short) 50)); |
| | | nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端 |
| | | handler.sendEmptyMessageDelayed(0, 100); |
| | | } |
| | |
| | | .setAgvNo(AgvNo) |
| | | .setSerialNo(substring) |
| | | .setVal(1) |
| | | .bodySync((action) -> action.setPwd((short) -10)); |
| | | .bodySync((action) -> action.setPwd((short) -50 )); |
| | | nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端 |
| | | handler.sendEmptyMessageDelayed(0, 100); |
| | | } |
| | |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onDeviceConnected(Item deviceAddress) { |
| | | Log.i("EventBus", "Received device connected: " + deviceAddress); |
| | | items.add(new Item("1",deviceAddress.getIp(),"3")); |
| | | |
| | | |
| | | if (items.size() > 0) { |
| | | int sameIp = 0; |
| | | for (Item item : items) { |
| | | if (item.getIp().equals(deviceAddress.getIp())) { |
| | | sameIp++; |
| | | } |
| | | Log.i("Item",item.getIp()); |
| | | } |
| | | if (sameIp == 0) { |
| | | items.add(new Item(deviceAddress.getText(),deviceAddress.getIp(),deviceAddress.getAgvNo())); |
| | | } |
| | | } else { |
| | | items.add(new Item(deviceAddress.getText(),deviceAddress.getIp(),deviceAddress.getAgvNo())); |
| | | } |
| | | adapter.notifyDataSetChanged(); |
| | | } |
New file |
| | |
| | | package com.example.agvcontroller.protocol; |
| | | |
| | | |
| | | import com.example.agvcontroller.action.CommonConstant; |
| | | import com.example.agvcontroller.socket.RadixTools; |
| | | |
| | | import java.io.Serializable; |
| | | import java.nio.ByteBuffer; |
| | | |
| | | /** |
| | | * 实时数据包1 |
| | | * Created by vincent on 2023/3/16 |
| | | */ |
| | | public class AGV_12_UP implements IMessageBody, Serializable { |
| | | |
| | | private static final long serialVersionUID = 7485846034848121068L; |
| | | |
| | | @Override |
| | | public byte[] writeToBytes() { |
| | | return new byte[0]; |
| | | } |
| | | |
| | | @Override |
| | | public void readFromBytes(byte[] bytes) { |
| | | //地面码ID |
| | | this.qrCode = Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 0, 4))), CommonConstant.QR_CODE_LEN);; |
| | | //地面码偏移x |
| | | this.offsetX = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 4 , 2)); |
| | | //地面码偏移y |
| | | this.offsetY = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 6, 2)); |
| | | //地面码偏移θ |
| | | this.groundCodeOffset0 = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 8, 4)); |
| | | //当前状态 |
| | | this.status = Utils.slice(bytes, 12, 1)[0]; |
| | | //直行方向坐标 |
| | | this.straightDirectionPosition = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 13, 4)); |
| | | //AGV当前角度 |
| | | // this.AGVCurrentAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 17, 4)); |
| | | this.AGVCurrentAngle = ByteBuffer.wrap(Utils.sliceWithReverse(bytes, 17, 4)).getFloat(); |
| | | //陀螺仪角度 |
| | | this.gyroAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 21, 4)); |
| | | //编码器角度 |
| | | this.encoderAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 25, 4)); |
| | | //当前高度 |
| | | this.currentAltitude = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 29, 2)); |
| | | //货叉伸出距离 |
| | | this.forkLength = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 31, 2)); |
| | | //载货台旋转角度 |
| | | this.loaderTheta = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 33, 2)); |
| | | //传感器状态标志 |
| | | // this.sensorStatusFlags = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 35, 4)); |
| | | |
| | | // byte[] sensorStatusBytes = Utils.slice(bytes, 35, 4); |
| | | // parseSensorStatue(sensorStatusBytes); |
| | | } |
| | | |
| | | @Override |
| | | public String getSerialNo() { |
| | | return ""; |
| | | } |
| | | |
| | | //地面码ID |
| | | private String qrCode; |
| | | |
| | | //地面码偏移x |
| | | private int offsetX; |
| | | |
| | | //地面码偏移y |
| | | private int offsetY; |
| | | |
| | | //地面码偏移θ |
| | | private int groundCodeOffset0; |
| | | |
| | | //当前状态 |
| | | private int status; |
| | | |
| | | //直行方向坐标-单位:mm |
| | | private int straightDirectionPosition; |
| | | |
| | | //AGV当前角度-单位:° |
| | | private float AGVCurrentAngle; |
| | | |
| | | //陀螺仪角度-单位:° |
| | | private int gyroAngle; |
| | | |
| | | //编码器角度-单位:° |
| | | private int encoderAngle; |
| | | |
| | | //当前高度 |
| | | private int currentAltitude; |
| | | |
| | | // 货叉伸出距离 |
| | | private int forkLength; |
| | | |
| | | // 载货台旋转角度 |
| | | private int loaderTheta; |
| | | |
| | | //传感器状态标志 |
| | | private int sensorStatusFlags; |
| | | |
| | | // 取放货状态 |
| | | private byte inOutFlag; |
| | | |
| | | private void parseSensorStatue(byte[] bytes) { |
| | | this.tempLoc1 = Utils.getBit(bytes[0], 0); |
| | | this.tempLoc2 = Utils.getBit(bytes[0], 1); |
| | | this.tempLoc3 = Utils.getBit(bytes[0], 2); |
| | | this.tempLoc4 = Utils.getBit(bytes[0], 3); |
| | | this.tempLoc5 = Utils.getBit(bytes[0], 4); |
| | | this.tempLoc6 = Utils.getBit(bytes[0], 5); |
| | | this.tempLoc7 = Utils.getBit(bytes[0], 6); |
| | | this.tempLoc8 = Utils.getBit(bytes[0], 7); |
| | | |
| | | this.inOutFlag = bytes[1]; |
| | | |
| | | // this.tempLoc9 = Utils.getBit(bytes[1], 0); |
| | | // this.tempLoc10 = Utils.getBit(bytes[1], 1); |
| | | // this.tempLoc11 = Utils.getBit(bytes[1], 2); |
| | | // this.tempLoc12 = Utils.getBit(bytes[1], 3); |
| | | // this.tempLoc13 = Utils.getBit(bytes[1], 4); |
| | | // this.tempLoc14 = Utils.getBit(bytes[1], 5); |
| | | // this.tempLoc15 = Utils.getBit(bytes[1], 6); |
| | | // this.tempLoc16 = Utils.getBit(bytes[1], 7); |
| | | |
| | | this.expandFront = Utils.getBit(bytes[2], 0); |
| | | this.expandBack = Utils.getBit(bytes[2], 1); |
| | | this.expandLeft = Utils.getBit(bytes[2], 2); |
| | | this.expandRight = Utils.getBit(bytes[2], 3); |
| | | this.finger1 = Utils.getBit(bytes[2], 4); |
| | | this.finger2 = Utils.getBit(bytes[2], 5); |
| | | this.finger3 = Utils.getBit(bytes[2], 6); |
| | | this.finger4 = Utils.getBit(bytes[2], 7); |
| | | |
| | | this.rotaLeft = Utils.getBit(bytes[3], 0); |
| | | this.rotaRight = Utils.getBit(bytes[3], 1); |
| | | this.loaderFront = Utils.getBit(bytes[3], 2); |
| | | this.loaderBack = Utils.getBit(bytes[3], 3); |
| | | this.loaderMid = Utils.getBit(bytes[3], 4); |
| | | this.liftMid = Utils.getBit(bytes[3], 5); |
| | | this.liftUp = Utils.getBit(bytes[3], 6); |
| | | this.liftBottom = Utils.getBit(bytes[3], 7); |
| | | } |
| | | |
| | | |
| | | // 暂存货位1检测 |
| | | private boolean tempLoc1; |
| | | |
| | | // 暂存货位2检测 |
| | | private boolean tempLoc2; |
| | | |
| | | // 暂存货位3检测 |
| | | private boolean tempLoc3; |
| | | |
| | | // 暂存货位4检测 |
| | | private boolean tempLoc4; |
| | | |
| | | // 暂存货位5检测 |
| | | private boolean tempLoc5; |
| | | |
| | | // 暂存货位6检测 |
| | | private boolean tempLoc6; |
| | | |
| | | // 暂存货位7检测 |
| | | private boolean tempLoc7; |
| | | |
| | | // 暂存货位8检测 |
| | | private boolean tempLoc8; |
| | | |
| | | // 暂存货位9检测 |
| | | private boolean tempLoc9; |
| | | |
| | | // 暂存货位10检测 |
| | | private boolean tempLoc10; |
| | | |
| | | // 暂存货位11检测 |
| | | private boolean tempLoc11; |
| | | |
| | | // 暂存货位12检测 |
| | | private boolean tempLoc12; |
| | | |
| | | // 暂存货位13检测 |
| | | private boolean tempLoc13; |
| | | |
| | | // 暂存货位14检测 |
| | | private boolean tempLoc14; |
| | | |
| | | // 暂存货位15检测 |
| | | private boolean tempLoc15; |
| | | |
| | | // 暂存货位16检测 |
| | | private boolean tempLoc16; |
| | | |
| | | // 伸缩前限位 |
| | | private boolean expandFront; |
| | | |
| | | // 伸缩后限位 |
| | | private boolean expandBack; |
| | | |
| | | // 伸缩左零位 |
| | | private boolean expandLeft; |
| | | |
| | | // 伸缩右零位 |
| | | private boolean expandRight; |
| | | |
| | | // 拨指1位置 |
| | | private boolean finger1; |
| | | |
| | | // 拨指2位置 |
| | | private boolean finger2; |
| | | |
| | | // 拨指3位置 |
| | | private boolean finger3; |
| | | |
| | | // 拨指4位置 |
| | | private boolean finger4; |
| | | |
| | | // 回转左到位 |
| | | private boolean rotaLeft; |
| | | |
| | | // 回转右到位 |
| | | private boolean rotaRight; |
| | | |
| | | // 载货台前探货 |
| | | private boolean loaderFront; |
| | | |
| | | // 载货台后探货 |
| | | private boolean loaderBack; |
| | | |
| | | // 载货台货物检测 |
| | | private boolean loaderMid; |
| | | |
| | | // 升降零位 |
| | | private boolean liftMid; |
| | | |
| | | // 升降上限位 |
| | | private boolean liftUp; |
| | | |
| | | // 升降下限位 |
| | | private boolean liftBottom; |
| | | |
| | | } |
New file |
| | |
| | | package com.example.agvcontroller.protocol; |
| | | |
| | | |
| | | import com.example.agvcontroller.action.CommonConstant; |
| | | import com.example.agvcontroller.socket.RadixTools; |
| | | |
| | | import java.io.Serializable; |
| | | import java.nio.ByteBuffer; |
| | | |
| | | /** |
| | | * 实时数据包2 |
| | | * Created by vincent on 2023/3/16 |
| | | */ |
| | | public class AGV_13_UP implements IMessageBody, Serializable { |
| | | |
| | | private static final long serialVersionUID = 6993991304425938465L; |
| | | |
| | | @Override |
| | | public byte[] writeToBytes() { |
| | | return new byte[0]; |
| | | } |
| | | |
| | | @Override |
| | | public void readFromBytes(byte[] bytes) { |
| | | //地面码ID |
| | | this.qrCode = Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 0, 4))), CommonConstant.QR_CODE_LEN);; |
| | | //当前状态 |
| | | this.status = Utils.slice(bytes, 4, 1)[0]; |
| | | //直行方向坐标 |
| | | this.straightDirectionPosition = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 5, 4)); |
| | | //AGV当前角度 |
| | | // this.AGVCurrentAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 9, 4)); |
| | | this.AGVCurrentAngle = ByteBuffer.wrap(Utils.sliceWithReverse(bytes, 9, 4)).getFloat(); |
| | | //陀螺仪角度 |
| | | this.gyroAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 13, 4)); |
| | | //编码器角度 |
| | | this.encoderAngle = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 17, 4)); |
| | | //当前高度 |
| | | this.currentAltitude = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 21, 2)); |
| | | //货叉伸出距离 |
| | | this.forkLength = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 23, 2)); |
| | | //载货台旋转角度 |
| | | this.loaderTheta = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 25, 2)); |
| | | //传感器状态标志 |
| | | // this.sensorStatusFlags = RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 27, 4)); |
| | | |
| | | byte[] sensorStatusBytes = Utils.slice(bytes, 27, 4); |
| | | parseSensorStatue(sensorStatusBytes); |
| | | } |
| | | |
| | | @Override |
| | | public String getSerialNo() { |
| | | return ""; |
| | | } |
| | | |
| | | //地面码ID |
| | | private String qrCode; |
| | | |
| | | //当前状态 |
| | | private int status; |
| | | |
| | | //直行方向坐标-单位:mm |
| | | private int straightDirectionPosition; |
| | | |
| | | //AGV当前角度-单位:° |
| | | private float AGVCurrentAngle; |
| | | |
| | | //陀螺仪角度-单位:° |
| | | private int gyroAngle; |
| | | |
| | | //编码器角度-单位:° |
| | | private int encoderAngle; |
| | | |
| | | //当前高度 |
| | | private int currentAltitude; |
| | | |
| | | // 货叉伸出距离 |
| | | private int forkLength; |
| | | |
| | | // 载货台旋转角度 |
| | | private int loaderTheta; |
| | | |
| | | //传感器状态标志 |
| | | private int sensorStatusFlags; |
| | | |
| | | // 取放货状态 |
| | | private byte inOutFlag; |
| | | |
| | | private void parseSensorStatue(byte[] bytes) { |
| | | this.tempLoc1 = Utils.getBit(bytes[0], 0); |
| | | this.tempLoc2 = Utils.getBit(bytes[0], 1); |
| | | this.tempLoc3 = Utils.getBit(bytes[0], 2); |
| | | this.tempLoc4 = Utils.getBit(bytes[0], 3); |
| | | this.tempLoc5 = Utils.getBit(bytes[0], 4); |
| | | this.tempLoc6 = Utils.getBit(bytes[0], 5); |
| | | this.tempLoc7 = Utils.getBit(bytes[0], 6); |
| | | this.tempLoc8 = Utils.getBit(bytes[0], 7); |
| | | |
| | | this.inOutFlag = bytes[1]; |
| | | |
| | | // this.tempLoc9 = Utils.getBit(bytes[1], 0); |
| | | // this.tempLoc10 = Utils.getBit(bytes[1], 1); |
| | | // this.tempLoc11 = Utils.getBit(bytes[1], 2); |
| | | // this.tempLoc12 = Utils.getBit(bytes[1], 3); |
| | | // this.tempLoc13 = Utils.getBit(bytes[1], 4); |
| | | // this.tempLoc14 = Utils.getBit(bytes[1], 5); |
| | | // this.tempLoc15 = Utils.getBit(bytes[1], 6); |
| | | // this.tempLoc16 = Utils.getBit(bytes[1], 7); |
| | | |
| | | this.expandFront = Utils.getBit(bytes[2], 0); |
| | | this.expandBack = Utils.getBit(bytes[2], 1); |
| | | this.expandLeft = Utils.getBit(bytes[2], 2); |
| | | this.expandRight = Utils.getBit(bytes[2], 3); |
| | | this.finger1 = Utils.getBit(bytes[2], 4); |
| | | this.finger2 = Utils.getBit(bytes[2], 5); |
| | | this.finger3 = Utils.getBit(bytes[2], 6); |
| | | this.finger4 = Utils.getBit(bytes[2], 7); |
| | | |
| | | this.rotaLeft = Utils.getBit(bytes[3], 0); |
| | | this.rotaRight = Utils.getBit(bytes[3], 1); |
| | | this.loaderFront = Utils.getBit(bytes[3], 2); |
| | | this.loaderBack = Utils.getBit(bytes[3], 3); |
| | | this.loaderMid = Utils.getBit(bytes[3], 4); |
| | | this.liftMid = Utils.getBit(bytes[3], 5); |
| | | this.liftUp = Utils.getBit(bytes[3], 6); |
| | | this.liftBottom = Utils.getBit(bytes[3], 7); |
| | | } |
| | | |
| | | |
| | | // 暂存货位1检测 |
| | | private boolean tempLoc1; |
| | | |
| | | // 暂存货位2检测 |
| | | private boolean tempLoc2; |
| | | |
| | | // 暂存货位3检测 |
| | | private boolean tempLoc3; |
| | | |
| | | // 暂存货位4检测 |
| | | private boolean tempLoc4; |
| | | |
| | | // 暂存货位5检测 |
| | | private boolean tempLoc5; |
| | | |
| | | // 暂存货位6检测 |
| | | private boolean tempLoc6; |
| | | |
| | | // 暂存货位7检测 |
| | | private boolean tempLoc7; |
| | | |
| | | // 暂存货位8检测 |
| | | private boolean tempLoc8; |
| | | |
| | | // 暂存货位9检测 |
| | | private boolean tempLoc9; |
| | | |
| | | // 暂存货位10检测 |
| | | private boolean tempLoc10; |
| | | |
| | | // 暂存货位11检测 |
| | | private boolean tempLoc11; |
| | | |
| | | // 暂存货位12检测 |
| | | private boolean tempLoc12; |
| | | |
| | | // 暂存货位13检测 |
| | | private boolean tempLoc13; |
| | | |
| | | // 暂存货位14检测 |
| | | private boolean tempLoc14; |
| | | |
| | | // 暂存货位15检测 |
| | | private boolean tempLoc15; |
| | | |
| | | // 暂存货位16检测 |
| | | private boolean tempLoc16; |
| | | |
| | | // 伸缩前限位 |
| | | private boolean expandFront; |
| | | |
| | | // 伸缩后限位 |
| | | private boolean expandBack; |
| | | |
| | | // 伸缩左零位 |
| | | private boolean expandLeft; |
| | | |
| | | // 伸缩右零位 |
| | | private boolean expandRight; |
| | | |
| | | // 拨指1位置 |
| | | private boolean finger1; |
| | | |
| | | // 拨指2位置 |
| | | private boolean finger2; |
| | | |
| | | // 拨指3位置 |
| | | private boolean finger3; |
| | | |
| | | // 拨指4位置 |
| | | private boolean finger4; |
| | | |
| | | // 回转左到位 |
| | | private boolean rotaLeft; |
| | | |
| | | // 回转右到位 |
| | | private boolean rotaRight; |
| | | |
| | | // 载货台前探货 |
| | | private boolean loaderFront; |
| | | |
| | | // 载货台后探货 |
| | | private boolean loaderBack; |
| | | |
| | | // 载货台货物检测 |
| | | private boolean loaderMid; |
| | | |
| | | // 升降零位 |
| | | private boolean liftMid; |
| | | |
| | | // 升降上限位 |
| | | private boolean liftUp; |
| | | |
| | | // 升降下限位 |
| | | private boolean liftBottom; |
| | | |
| | | } |
New file |
| | |
| | | package com.example.agvcontroller.protocol; |
| | | |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class AGV_F0_UP implements IMessageBody, Serializable { |
| | | |
| | | private static final long serialVersionUID = 8403019742104020004L; |
| | | |
| | | @Override |
| | | public byte[] writeToBytes() { |
| | | return new byte[0]; |
| | | } |
| | | |
| | | @Override |
| | | public void readFromBytes(byte[] bytes) { |
| | | this.password = ""; |
| | | this.carType = 0; |
| | | this.baseVersion = ""; |
| | | this.bothData = ""; |
| | | this.softwareVersion = ""; |
| | | this.optData = ""; |
| | | this.totalTime = 0; |
| | | this.totalDistance = 0; |
| | | this.batteryType = 0; |
| | | this.maxChargeCurrent = 0; |
| | | this.batteryVoltage = 0; |
| | | this.remainingBattery = 0; |
| | | this.soh = 0; |
| | | this.groundCode = ""; |
| | | this.qrCode = ""; |
| | | this.offsetX = 0; |
| | | this.offsetY = 0; |
| | | this.groundCodeOffset0 = 0; |
| | | this.status = 0; |
| | | this.faultFlag = 0; |
| | | this.intrusionCount = 0; |
| | | this.spareSpaceCount = 0; |
| | | } |
| | | |
| | | @Override |
| | | public String getSerialNo() { |
| | | return ""; |
| | | } |
| | | |
| | | // 密码 |
| | | private String password; |
| | | |
| | | // 设备类型 |
| | | private int carType; |
| | | |
| | | // 硬件版本 |
| | | private String baseVersion; |
| | | |
| | | // 出厂日期 |
| | | private String bothData; |
| | | |
| | | // 软件版本 |
| | | private String softwareVersion; |
| | | |
| | | // 发布日期 |
| | | private String optData; |
| | | |
| | | // 累计工作时间 |
| | | private int totalTime; |
| | | |
| | | // 累计行走距离 |
| | | private int totalDistance; |
| | | // 电池类型 |
| | | private int batteryType; |
| | | |
| | | // 最大充电电流 |
| | | private int maxChargeCurrent; |
| | | |
| | | // 电池电压 |
| | | private int batteryVoltage; |
| | | |
| | | // 剩余电量 |
| | | private int remainingBattery; |
| | | |
| | | // soh |
| | | private int soh; |
| | | |
| | | // 地面码 |
| | | private String groundCode; |
| | | |
| | | //地面码ID |
| | | private String qrCode; |
| | | |
| | | //地面码偏移x |
| | | private int offsetX; |
| | | |
| | | //地面码偏移y |
| | | private int offsetY; |
| | | |
| | | //地面码偏移θ |
| | | private int groundCodeOffset0; |
| | | |
| | | //当前状态 |
| | | private int status; |
| | | |
| | | // 故障标志 |
| | | private int faultFlag; |
| | | |
| | | // 入侵检测次数 |
| | | private int intrusionCount; |
| | | |
| | | // 暂存货位数量 |
| | | private int spareSpaceCount; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | byte valByte = (byte) val; // 属性值 |
| | | |
| | | byte[] bytes = actionBody.writeToBytes(); // 命令参数 |
| | | byte[] bytes = Utils.reverse(actionBody.writeToBytes()); // 命令参数 |
| | | |
| | | return Utils.merge(serialNoBytes,cmdCode, valByte, bytes); |
| | | } |
| | |
| | | import com.example.agvcontroller.action.AGV_11_UP; |
| | | import com.example.agvcontroller.action.AckMsgBuilder; |
| | | import com.example.agvcontroller.met.AbstractInboundHandler; |
| | | import com.example.agvcontroller.protocol.AGV_12_UP; |
| | | import com.example.agvcontroller.protocol.AGV_13_UP; |
| | | import com.example.agvcontroller.protocol.AGV_A1_DOWN; |
| | | import com.example.agvcontroller.protocol.AGV_F0_UP; |
| | | import com.example.agvcontroller.protocol.AgvAction; |
| | | import com.example.agvcontroller.protocol.AgvPackage; |
| | | import com.example.agvcontroller.protocol.ProtocolType; |
| | |
| | | |
| | | @Override |
| | | public void channelActive(ChannelHandlerContext ctx) throws Exception { |
| | | String clientId = ctx.channel().remoteAddress().toString(); |
| | | channelMap.put(clientId, ctx.channel()); |
| | | EventBus.getDefault().post(new Item("1",clientId,"3")); |
| | | Log.d(TAG, "Client connected: " + clientId); |
| | | // String clientId = ctx.channel().remoteAddress().toString(); |
| | | // channelMap.put(clientId, ctx.channel()); |
| | | // EventBus.getDefault().post(new Item("",clientId,"3")); |
| | | // Log.d(TAG, "Client connected: " + clientId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | protected boolean channelRead0(ChannelHandlerContext ctx, AgvPackage pac) throws Exception { |
| | | |
| | | String clientId = ctx.channel().remoteAddress().toString(); |
| | | Log.i("clientId--->",clientId); |
| | | Log.i("substring",pac.toString()); |
| | | String serialNum = pac.getBody().getMessageBody().getSerialNo(); |
| | | Log.i("substring",serialNum); |
| | | MainActivity.map.put(serialNum, Boolean.TRUE); |
| | | // ack |
| | | ProtocolType ackType = isNeedAck(pac); |
| | | final String uniqueNo = pac.getHeader().getUniqueNo(); |
| | | String agvNo; |
| | | label : switch (pac.getHeader().getProtocolType()){ |
| | | case ACTION_COMPLETE: // 动作完成数据包 |
| | | |
| | | |
| | | AGV_11_UP agv_11_up = (AGV_11_UP) pac.getBody().getMessageBody(); |
| | | // redis.push(RedisConstant.AGV_COMPLETE_FLAG, AgvProtocol.build(uniqueNo).setMessageBody(agv_11_up)); |
| | | |
| | | // 动作完成应答 |
| | | if (null != ackType) { |
| | | AgvPackage ackPac = AckMsgBuilder.ofSuccess(pac, ackType); |
| | | |
| | | AGV_A1_DOWN agv_a1_down = (AGV_A1_DOWN) ackPac.getBody().getMessageBody(); |
| | | agv_a1_down.setAckSign((byte) agv_11_up.getCompleteCode()); |
| | | |
| | | ctx.writeAndFlush(ackPac); |
| | | } |
| | | |
| | | |
| | | |
| | | break label; |
| | | case DATA_CODE_REPORT: |
| | | AGV_12_UP agv_12_up = (AGV_12_UP) pac.getBody().getMessageBody(); |
| | | agvNo = pac.getHeader().getUniqueNo(); |
| | | EventBus.getDefault().post(new Item("",clientId,agvNo)); |
| | | break label; |
| | | case DATA_WITHOUT_CODE_REPORT: |
| | | AGV_13_UP agv_13_up = (AGV_13_UP) pac.getBody().getMessageBody(); |
| | | break label; |
| | | case LOGIN_REPORT: |
| | | AGV_F0_UP agv_f0_up = (AGV_F0_UP) pac.getBody().getMessageBody(); |
| | | agvNo = pac.getHeader().getUniqueNo(); |
| | | EventBus.getDefault().post(new Item("",clientId,agvNo)); |
| | | break label; |
| | | |
| | | } |
| | | return false; |
| | | } |
| | |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | | android:layout_weight="6" |
| | | android:visibility="gone"> |
| | | android:visibility="visible"> |
| | | |
| | | <Button |
| | | android:id="@+id/btn_stop2" |
| | |
| | | <!-- **************** 18轴 **************** --> |
| | | <GridLayout |
| | | android:id="@+id/layout_18" |
| | | android:visibility="visible" |
| | | android:visibility="gone" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | | android:layout_weight="6" |