Przeglądaj źródła

生物防控人员2

523096025 3 dni temu
rodzic
commit
297d934fc3

+ 4 - 1
huimv-admin/src/main/java/com/huimv/admin/jinghongtimer/ProtTimer.java

@@ -47,12 +47,13 @@ public class ProtTimer {
                 protData.setFarmId(getFarmId(jinghongWater.getDeviceId()));
                 protData.setFlow(jinghongWater.getValueA());
 
-                if ("861213058872158".equals(jinghongWater.getDeviceId())){
+                if ("861213058872158".equals(jinghongWater.getDeviceId())||"865661077850256".equals(jinghongWater.getDeviceId())){
                     protData.setLoctionType(2);
                 }else {
                     protData.setLoctionType(1);
                 }
 
+
                 protData.setCod("0");
                 protData.setNh3n("0");
                 protData.setPh("0");
@@ -77,6 +78,8 @@ public class ProtTimer {
                 return 29;
             case "861213058846640":
                 return 30;
+            case "865661077850256":
+                return 30;
             default: //"861213058872158":
                 return 28;
         }

+ 11 - 0
huimv-receive/src/main/java/com/huimv/receive/timer/test/FixedGameController.java

@@ -0,0 +1,11 @@
+package com.huimv.receive.timer.test;
+
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.event.KeyEvent;
+
+public class FixedGameController {
+
+
+    // 其他方法保持不变...
+}

+ 101 - 0
huimv-receive/src/main/java/com/huimv/receive/timer/test/GameController.java

@@ -0,0 +1,101 @@
+package com.huimv.receive.timer.test;
+
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.util.Scanner;
+
+public class GameController {
+
+    private static Robot robot;
+
+    static {
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(10); // 设置自动事件间隔
+            wait(3000);
+        } catch (AWTException e) {
+            throw new RuntimeException("初始化Robot失败", e);
+        }
+    }
+
+    public static void main(String[] args) {
+        for (int i = 0; i < 100; i++) {
+            runPresetScript();
+
+        }
+//        runPresetScript2();
+    }
+
+    private static void runPresetScript2() {
+        wait(2000);
+        for (int i = 0; i < 6000; i++) {
+            tapKey(KeyEvent.VK_2);
+        }
+
+    }
+
+    private static void runPresetScript() {
+        System.out.println("执行改进版预定义脚本...");
+        holdKey(KeyEvent.VK_P,300);
+        wait(1000);
+        tapKey(KeyEvent.VK_SPACE);
+        wait(4000);
+        // 新版脚本测试:
+        holdKey(KeyEvent.VK_P, 400); // 正确保持2秒
+        holdKey(KeyEvent.VK_L, 500);
+        wait(800);
+        holdKey(KeyEvent.VK_L, 1000);
+        wait(500);
+        tapKey(KeyEvent.VK_A);
+        wait(500);
+        tapKey(KeyEvent.VK_A);
+        wait(1000);
+        tapKey(KeyEvent.VK_ESCAPE);
+
+        wait(2000);
+        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        wait(500);
+        // 模拟鼠标左键释放lllllllllllllllllllllllllllllll
+        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+        wait(3 *1000);
+
+    }
+
+    // 改进的按键保持方法
+    private static void holdKey(int keyCode, int duration) {
+        System.out.printf("按住 %s 键 %d 毫秒%n", KeyEvent.getKeyText(keyCode), duration);
+
+        long startTime = System.currentTimeMillis();
+        robot.keyPress(keyCode);
+
+        // 持续保持按键状态
+        while (System.currentTimeMillis() - startTime < duration) {
+            robot.delay(10); // 使用Robot内置延迟
+            robot.keyPress(keyCode); // 持续发送按键信号
+        }
+
+        robot.keyRelease(keyCode);
+        System.out.println("释放按键");
+
+    }
+
+
+
+
+    // 快速点击
+    private static void tapKey(int keyCode) {
+        robot.keyPress(keyCode);
+        robot.keyRelease(keyCode);
+    }
+
+    // 等待方法
+    private static void wait(int milliseconds) {
+        try {
+            Thread.sleep(milliseconds);
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }
+    }
+}