#
whycq
2025-01-16 6f1275502e0d7be1b919f9d6eb308436cc8958fa
app/src/main/java/com/example/agvcontroller/MainActivity.java
@@ -38,6 +38,7 @@
import com.example.agvcontroller.action.LoadResetAction;
import com.example.agvcontroller.action.RotatopnLeftRight;
import com.example.agvcontroller.action.SingleSwitchAction;
import com.example.agvcontroller.action.SingleSwitchRunAction;
import com.example.agvcontroller.protocol.AgvAction;
import com.example.agvcontroller.action.HandOutAction;
import com.example.agvcontroller.socket.NettyServerHandler;
@@ -140,19 +141,24 @@
    private boolean isGoBackward = false;
    private boolean isRotatopnRight = false;
    private boolean isRotatopnLeft = false;
    private boolean isFrontPaddleExtendBtn = false;
    private boolean isFrontPaddleCollectBtn = false;
    private boolean isBackPaddleExtendBtn = false;
    private boolean isBackPaddleCollectBtn = false;
    private boolean isRiseBtn = false;
    private boolean isDropBtn = false;
    private boolean isExtendForkBtn = false;
    private boolean isCollectForkBtn = false;
    private boolean isTurnLeftBtn = false;
    private boolean isTurnRightBtn = false;
    private boolean isFront1 = false;
    private boolean isBack1 = false;
    private boolean isFront2 = false;
    private boolean isBack2 = false;
    private boolean isFront3 = false;
    private boolean isBack3 = false;
    private boolean isFront4 = false;
    private boolean isBack4 = false;
    private boolean isFront5 = false;
    private boolean isBack5 = false;
    private boolean isFront6 = false;
    private boolean isBack6 = false;
    private boolean isFront7 = false;
    private boolean isBack7 = false;
    private boolean isFront8 = false;
    private boolean isBack8 = false;
    private boolean isFront9 = false;
    private boolean isBack9 = false;
@@ -161,8 +167,9 @@
    private Handler handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
            short pwd = 0;
            if (isGoForward) {
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(ForwardBackAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
@@ -172,7 +179,6 @@
                handler.sendEmptyMessageDelayed(0, 100);  //  100ms 后发送下一条消息
            }
            if (isGoBackward) {
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(ForwardBackAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
@@ -182,7 +188,6 @@
                handler.sendEmptyMessageDelayed(0, 100);
            }
            if (isRotatopnRight) {
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(RotatopnLeftRight.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
@@ -192,7 +197,6 @@
                handler.sendEmptyMessageDelayed(0, 100);
            }
            if (isRotatopnLeft) {
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(RotatopnLeftRight.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
@@ -202,116 +206,24 @@
                handler.sendEmptyMessageDelayed(0, 100);
            }
//            // 前拨杆伸
//            if (isFrontPaddleExtendBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(FrontPaddle.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) 1));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
//            // 前拨杆收
//            if (isFrontPaddleCollectBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(FrontPaddle.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) 0));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
//            // 后拨杆伸
//            if (isBackPaddleExtendBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(BackPaddle.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) 1));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
//            // 后拨杆收
//            if (isBackPaddleCollectBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(BackPaddle.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) 0));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
//            // 上升
//            if (isRiseBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(HandLift.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) -10));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
//            // 下降
//            if (isDropBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(HandLift.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) -10));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
//            // 伸叉
//            if (isExtendForkBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(HandExtendCollect.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) -10));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
//            // 收叉
//            if (isCollectForkBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(HandExtendCollect.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) -10));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
//            // 货叉左旋
//            if (isTurnLeftBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) -10));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
//            // 货叉右旋
//            if (isTurnRightBtn) {
//                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
//                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
//                        .setAgvNo(AgvNo)
//                        .setSerialNo(substring)
//                        .setVal(1)
//                        .bodySync((action) -> action.setPwd((short) -10));
//                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
//                handler.sendEmptyMessageDelayed(0, 100);
//            }
            if (isRotatopnRight) {
                AgvAction agvAction = new AgvAction<>(RotatopnLeftRight.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(1)
                        .bodySync((action) -> action.setPwd((short) 50));
                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
                handler.sendEmptyMessageDelayed(0, 100);
            }
            if (isRotatopnLeft) {
                AgvAction agvAction = new AgvAction<>(RotatopnLeftRight.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(1)
                        .bodySync((action) -> action.setPwd((short) -50 ));
                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
                handler.sendEmptyMessageDelayed(0, 100);
            }
            return false;
        }
    });
@@ -525,7 +437,7 @@
                            .setAgvNo(AgvNo)
                            .setSerialNo(substring)
                            .setVal(1)
                            .bodySync((action) -> action.setPwd((short) 21));
                            .bodySync((action) -> action.setPwd((short) extendWidth));
                    nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
                    extendWidth += 50;
                } else {
@@ -548,7 +460,7 @@
                            .setAgvNo(AgvNo)
                            .setSerialNo(substring)
                            .setVal(1)
                            .bodySync((action) -> action.setPwd((short) 21));
                            .bodySync((action) -> action.setPwd((short) extendWidth));
                    nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端户端
                    extendWidth -= 50;
                } else {
@@ -711,6 +623,7 @@
                if (vibrator != null && vibrator.hasVibrator()) {
                    vibrator.vibrate(500);
                }
                boolean result = false;
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                if (isAuto) {
                    AgvAction agvAction = new AgvAction<>(HandInAction.class)
@@ -719,6 +632,8 @@
                            .setVal(autoVal)
                            .bodySync((action) -> action.setPwd((short) 21));
                    nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
                    result = true;
                    isAuto = !isAuto;
                } else {
                    AgvAction agvAction = new AgvAction<>(HandOutAction.class)
                            .setAgvNo(AgvNo)
@@ -726,21 +641,23 @@
                            .setVal(autoVal)
                            .bodySync((action) -> action.setPwd((short) 21));
                    nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
                    result = true;
                    isAuto = !isAuto;
                }
                boolean result = false;
                long timestamp = System.currentTimeMillis();
                while (System.currentTimeMillis() - timestamp < 5000) {
                    Object o = map.get(substring);
                    if (null != o) {
                        result = true;
                        isAuto = !isAuto;
                        map.remove(o);
                        break;
                    }
                }
//                long timestamp = System.currentTimeMillis();
//                while (System.currentTimeMillis() - timestamp < 5000) {
//
//                    Object o = map.get(substring);
//
//                    if (null != o) {
//                        result = true;
//                        isAuto = !isAuto;
//                        map.remove(o);
//                        break;
//                    }
//                }
                if (result) {
                    // alert ok  修改按钮样式 名称
@@ -881,15 +798,19 @@
                            .setAgvNo(AgvNo)
                            .setSerialNo(substring)
                            .setVal(5)
                            .bodySync((action) -> action.setPwd((short) 0));
                            .bodySync((action) -> action.setPwd((short) 1));
                    nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
                    axleFrontBtn5.setVisibility(View.VISIBLE);
                    axleBackBtn5.setVisibility(View.VISIBLE);
                } else {
                    AgvAction agvAction = new AgvAction<>(SingleSwitchAction.class)
                            .setAgvNo(AgvNo)
                            .setSerialNo(substring)
                            .setVal(5)
                            .bodySync((action) -> action.setPwd((short) 1));
                            .bodySync((action) -> action.setPwd((short) 0));
                    nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
                    axleFrontBtn5.setVisibility(View.GONE);
                    axleBackBtn5.setVisibility(View.GONE);
                }
            }
        });
@@ -999,23 +920,6 @@
        });
        axleFrontBtn2 =findViewById(R.id.btn_axle_2_front);
        axleBackBtn2 =findViewById(R.id.btn_axle_2_back);
        axleFrontBtn3 =findViewById(R.id.btn_axle_3_front);
        axleBackBtn3 =findViewById(R.id.btn_axle_3_back);
        axleFrontBtn4 =findViewById(R.id.btn_axle_4_front);
        axleBackBtn4 =findViewById(R.id.btn_axle_4_back);
        axleFrontBtn5 =findViewById(R.id.btn_axle_5_front);
        axleBackBtn5 =findViewById(R.id.btn_axle_5_back);
        axleFrontBtn6 =findViewById(R.id.btn_axle_6_front);
        axleBackBtn6 =findViewById(R.id.btn_axle_6_back);
        axleFrontBtn7 =findViewById(R.id.btn_axle_7_front);
        axleBackBtn7 =findViewById(R.id.btn_axle_7_back);
        axleFrontBtn8 =findViewById(R.id.btn_axle_8_front);
        axleBackBtn8 =findViewById(R.id.btn_axle_8_back);
        axleFrontBtn9 =findViewById(R.id.btn_axle_9_front);
        axleBackBtn9 =findViewById(R.id.btn_axle_9_back);
        axleFrontBtn1.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
@@ -1023,7 +927,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(1)
@@ -1039,7 +943,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(1)
@@ -1055,7 +959,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(2)
@@ -1071,7 +975,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(2)
@@ -1087,7 +991,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(3)
@@ -1103,7 +1007,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(3)
@@ -1119,7 +1023,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(4)
@@ -1135,7 +1039,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(4)
@@ -1151,11 +1055,11 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(5)
                        .bodySync((action) -> action.setPwd((short) 100));
                        .bodySync((action) -> action.setPwd((short) 99));
                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
            }
        });
@@ -1167,11 +1071,11 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(5)
                        .bodySync((action) -> action.setPwd((short) -100));
                        .bodySync((action) -> action.setPwd((short) -99));
                nettyServerHandler.sendMessageToClient(clientId, agvAction); // 发送消息到客户端
            }
        });
@@ -1183,7 +1087,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(6)
@@ -1199,7 +1103,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(6)
@@ -1215,7 +1119,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(7)
@@ -1231,7 +1135,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(7)
@@ -1247,7 +1151,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(8)
@@ -1263,7 +1167,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(8)
@@ -1279,7 +1183,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(9)
@@ -1295,7 +1199,7 @@
                    vibrator.vibrate(500);
                }
                String substring = String.valueOf(new SnowflakeIdWorker().nextId()).substring(0,16);
                AgvAction agvAction = new AgvAction<>(HandForkRotatopn.class)
                AgvAction agvAction = new AgvAction<>(SingleSwitchRunAction.class)
                        .setAgvNo(AgvNo)
                        .setSerialNo(substring)
                        .setVal(9)
@@ -1311,16 +1215,25 @@
        rotatopnLeftBtn.setOnTouchListener(new CarTouchButton());
        rotatopnRightBtn.setOnTouchListener(new CarTouchButton());
//        frontPaddleExtendBtn.setOnTouchListener(new CarTouchButton());
//        frontPaddleCollectBtn.setOnTouchListener(new CarTouchButton());
//        backPaddleExtendBtn.setOnTouchListener(new CarTouchButton());
//        backPaddleCollectBtn.setOnTouchListener(new CarTouchButton());
//        riseBtn.setOnTouchListener(new CarTouchButton());
//        dropBtn.setOnTouchListener(new CarTouchButton());
//        extendForkBtn.setOnTouchListener(new CarTouchButton());
//        collectForkBtn.setOnTouchListener(new CarTouchButton());
//        turnLeftBtn.setOnTouchListener(new CarTouchButton());
//        turnRightBtn.setOnTouchListener(new CarTouchButton());
        axleFrontBtn1.setOnTouchListener(new CarTouchButton());
        axleBackBtn1.setOnTouchListener(new CarTouchButton());
        axleFrontBtn2.setOnTouchListener(new CarTouchButton());
        axleBackBtn2.setOnTouchListener(new CarTouchButton());
        axleFrontBtn3.setOnTouchListener(new CarTouchButton());
        axleBackBtn3.setOnTouchListener(new CarTouchButton());
        axleFrontBtn4.setOnTouchListener(new CarTouchButton());
        axleBackBtn4.setOnTouchListener(new CarTouchButton());
        axleFrontBtn5.setOnTouchListener(new CarTouchButton());
        axleBackBtn5.setOnTouchListener(new CarTouchButton());
        axleFrontBtn6.setOnTouchListener(new CarTouchButton());
        axleBackBtn6.setOnTouchListener(new CarTouchButton());
        axleFrontBtn7.setOnTouchListener(new CarTouchButton());
        axleBackBtn7.setOnTouchListener(new CarTouchButton());
        axleFrontBtn8.setOnTouchListener(new CarTouchButton());
        axleBackBtn8.setOnTouchListener(new CarTouchButton());
        axleFrontBtn9.setOnTouchListener(new CarTouchButton());
        axleBackBtn9.setOnTouchListener(new CarTouchButton());
    }
@@ -1328,7 +1241,6 @@
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (view.getId() == R.id.btn_go_forward) {
                // 前进
                if (motionEvent.getAction() == KeyEvent.ACTION_DOWN) {
@@ -1337,7 +1249,6 @@
                } else if (motionEvent.getAction() == KeyEvent.ACTION_UP) {
                    isGoForward = false;
                }
            } else if (view.getId() == R.id.btn_go_backward) {
                // 后退
                if (motionEvent.getAction() == KeyEvent.ACTION_DOWN) {
@@ -1364,6 +1275,14 @@
                } else if (motionEvent.getAction() == KeyEvent.ACTION_UP) {
                    isRotatopnRight = false;
                }
            } else if (view.getId() == R.id.btn_rotatopn_right) {
                // 轴动按钮
                if (motionEvent.getAction() == KeyEvent.ACTION_DOWN) {
                    isRotatopnRight = true;
                    handler.sendEmptyMessage(0);
                } else if (motionEvent.getAction() == KeyEvent.ACTION_UP) {
                    isRotatopnRight = false;
                }
            }