From 52cbfeb0c93770530965955ca861f3d0a2bedd66 Mon Sep 17 00:00:00 2001
From: dubin <bindu_bean@163.com>
Date: 星期一, 12 一月 2026 11:01:27 +0800
Subject: [PATCH] 添加重量信息

---
 src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java |  203 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 128 insertions(+), 75 deletions(-)

diff --git a/src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java b/src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java
index 1cdd5bd..d529843 100644
--- a/src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyDualCrnFakeConnect.java
@@ -16,7 +16,10 @@
 
     private ZyDualCrnStatusEntity crnStatus;
     private DeviceConfig deviceConfig;
-    private final ExecutorService executor = Executors.newSingleThreadExecutor();
+    // 鍏佽骞惰鎵ц澶氫釜鍛戒护浠诲姟锛堝浐瀹氱嚎绋嬫睜锛夈�傚闇�鏇撮珮骞跺彂鍙皟鏁村ぇ灏忋��
+    private final ExecutorService executor = Executors
+            .newFixedThreadPool(9999);
+    private int taskExecuteStation = 0;
 
     public ZyDualCrnFakeConnect(DeviceConfig deviceConfig) {
         this.deviceConfig = deviceConfig;
@@ -64,53 +67,86 @@
 
     private void commandTaskComplete(DualCrnCommand command) {
         if(command.getStation() == 1) {
-            this.crnStatus.setTaskNo(0);
+            if (crnStatus.getLoaded() == 0) {
+                this.crnStatus.setTaskNo(0);
+            }
+            this.crnStatus.setTaskReceive(0);
             this.crnStatus.setStatus(CrnStatusType.IDLE.id);
         }else {
-            this.crnStatus.setTaskNoTwo(0);
+            if (crnStatus.getLoadedTwo() == 0) {
+                this.crnStatus.setTaskNoTwo(0);
+            }
+            this.crnStatus.setTaskReceiveTwo(0);
             this.crnStatus.setStatusTwo(CrnStatusType.IDLE.id);
         }
     }
 
     private void commandMove(DualCrnCommand command) {
-        int destinationPosX = command.getDestinationPosX().intValue();
-        int destinationPosY = command.getDestinationPosY().intValue();
-        int destinationPosZ = command.getDestinationPosZ().intValue();
-        int taskMode = command.getTaskMode().intValue();
-        int taskNo = command.getTaskNo().intValue();
+        int destinationPosX = command.getDestinationPosX();
+        int destinationPosY = command.getDestinationPosY();
+        int destinationPosZ = command.getDestinationPosZ();
+        int taskMode = command.getTaskMode();
+        int taskNo = command.getTaskNo();
+        int station = command.getStation();
+
+        while (true) {
+            if (taskExecuteStation == 0) {
+                taskExecuteStation = station;
+            }
+
+            if (taskExecuteStation == station) {
+                break;
+            }
+
+            sleep(200);
+        }
 
         if(command.getStation() == 1) {
             this.crnStatus.setTaskNo(taskNo);
             this.crnStatus.setStatus(CrnStatusType.MOVING.id);
-            moveY(this.crnStatus.getBay(), destinationPosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevel(), destinationPosZ, command.getStation().intValue());
+            this.crnStatus.setTaskReceive(1);
+            moveYZ(this.crnStatus.getBay(), destinationPosY, this.crnStatus.getLevel(), destinationPosZ, command.getStation());
             this.crnStatus.setStatus(CrnStatusType.WAITING.id);
         }else {
             this.crnStatus.setTaskNoTwo(taskNo);
             this.crnStatus.setStatusTwo(CrnStatusType.MOVING.id);
-            moveY(this.crnStatus.getBayTwo(), destinationPosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevelTwo(), destinationPosZ, command.getStation().intValue());
+            this.crnStatus.setTaskReceive(1);
+            moveYZ(this.crnStatus.getBay(), destinationPosY, this.crnStatus.getLevel(), destinationPosZ, command.getStation());
             this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id);
         }
+
+        taskExecuteStation = 0;
     }
 
     private void commandTake(DualCrnCommand command) {
-        int sourcePosX = command.getSourcePosX().intValue();
-        int sourcePosY = command.getSourcePosY().intValue();
-        int sourcePosZ = command.getSourcePosZ().intValue();
-        int destinationPosX = command.getDestinationPosX().intValue();
-        int destinationPosY = command.getDestinationPosY().intValue();
-        int destinationPosZ = command.getDestinationPosZ().intValue();
-        int taskMode = command.getTaskMode().intValue();
-        int taskNo = command.getTaskNo().intValue();
+        int sourcePosX = command.getSourcePosX();
+        int sourcePosY = command.getSourcePosY();
+        int sourcePosZ = command.getSourcePosZ();
+        int destinationPosX = command.getDestinationPosX();
+        int destinationPosY = command.getDestinationPosY();
+        int destinationPosZ = command.getDestinationPosZ();
+        int taskMode = command.getTaskMode();
+        int taskNo = command.getTaskNo();
+        int station = command.getStation();
 
-        this.crnStatus.setMode(taskMode);
+        while (true) {
+            if (taskExecuteStation == 0) {
+                taskExecuteStation = station;
+            }
+
+            if (taskExecuteStation == station) {
+                break;
+            }
+
+            sleep(200);
+        }
+
         if(command.getStation() == 1) {
             this.crnStatus.setTaskNo(taskNo);
             this.crnStatus.setStatus(CrnStatusType.FETCH_MOVING.id);
+            this.crnStatus.setTaskReceive(1);
 
-            moveY(this.crnStatus.getBay(), sourcePosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevel(), sourcePosZ, command.getStation().intValue());
+            moveYZ(this.crnStatus.getBay(), sourcePosY,this.crnStatus.getLevel(), sourcePosZ,command.getStation());
             this.crnStatus.setStatus(CrnStatusType.FETCHING.id);
             sleep(2000);
             if (Thread.currentThread().isInterrupted()) {
@@ -119,8 +155,7 @@
 
             this.crnStatus.setLoaded(1);
             this.crnStatus.setStatus(CrnStatusType.PUT_MOVING.id);
-            moveY(this.crnStatus.getBay(), destinationPosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevel(), destinationPosZ, command.getStation().intValue());
+            moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
             this.crnStatus.setStatus(CrnStatusType.PUTTING.id);
             sleep(2000);
             if (Thread.currentThread().isInterrupted()) {
@@ -131,9 +166,9 @@
         }else {
             this.crnStatus.setTaskNoTwo(taskNo);
             this.crnStatus.setStatusTwo(CrnStatusType.FETCH_MOVING.id);
+            this.crnStatus.setTaskReceiveTwo(1);
 
-            moveY(this.crnStatus.getBayTwo(), sourcePosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevelTwo(), sourcePosZ, command.getStation().intValue());
+            moveYZ(this.crnStatus.getBay(), sourcePosY,this.crnStatus.getLevel(), sourcePosZ, command.getStation());
             this.crnStatus.setStatusTwo(CrnStatusType.FETCHING.id);
             sleep(2000);
             if (Thread.currentThread().isInterrupted()) {
@@ -142,8 +177,7 @@
 
             this.crnStatus.setLoadedTwo(1);
             this.crnStatus.setStatusTwo(CrnStatusType.PUT_MOVING.id);
-            moveY(this.crnStatus.getBayTwo(), destinationPosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevelTwo(), destinationPosZ, command.getStation().intValue());
+            moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
             this.crnStatus.setStatusTwo(CrnStatusType.PUTTING.id);
             sleep(2000);
             if (Thread.currentThread().isInterrupted()) {
@@ -152,24 +186,38 @@
             this.crnStatus.setLoadedTwo(0);
             this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id);
         }
+
+        taskExecuteStation = 0;
     }
 
     private void commandPick(DualCrnCommand command) {
-        int destinationPosX = command.getDestinationPosX().intValue();
-        int destinationPosY = command.getDestinationPosY().intValue();
-        int destinationPosZ = command.getDestinationPosZ().intValue();
-        int taskMode = command.getTaskMode().intValue();
-        int taskNo = command.getTaskNo().intValue();
+        int destinationPosX = command.getDestinationPosX();
+        int destinationPosY = command.getDestinationPosY();
+        int destinationPosZ = command.getDestinationPosZ();
+        int taskMode = command.getTaskMode();
+        int taskNo = command.getTaskNo();
+        int station = command.getStation();
 
-        this.crnStatus.setMode(taskMode);
+        while (true) {
+            if (taskExecuteStation == 0) {
+                taskExecuteStation = station;
+            }
+
+            if (taskExecuteStation == station) {
+                break;
+            }
+
+            sleep(200);
+        }
+
         if(command.getStation() == 1) {
             this.crnStatus.setTaskNo(taskNo);
             this.crnStatus.setStatus(CrnStatusType.FETCH_MOVING.id);
+            this.crnStatus.setTaskReceive(1);
 
-            moveY(this.crnStatus.getBay(), destinationPosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevel(), destinationPosZ, command.getStation().intValue());
+            moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
             this.crnStatus.setStatus(CrnStatusType.FETCHING.id);
-            sleep(2000);
+            sleep(3000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
@@ -178,35 +226,49 @@
         }else {
             this.crnStatus.setTaskNoTwo(taskNo);
             this.crnStatus.setStatusTwo(CrnStatusType.FETCH_MOVING.id);
+            this.crnStatus.setTaskReceiveTwo(1);
 
-            moveY(this.crnStatus.getBayTwo(), destinationPosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevelTwo(), destinationPosZ, command.getStation().intValue());
+            moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
             this.crnStatus.setStatusTwo(CrnStatusType.FETCHING.id);
-            sleep(2000);
+            sleep(3000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
             this.crnStatus.setLoadedTwo(1);
             this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id);
         }
+
+        taskExecuteStation = 0;
     }
 
     private void commandPut(DualCrnCommand command) {
-        int destinationPosX = command.getDestinationPosX().intValue();
-        int destinationPosY = command.getDestinationPosY().intValue();
-        int destinationPosZ = command.getDestinationPosZ().intValue();
-        int taskMode = command.getTaskMode().intValue();
-        int taskNo = command.getTaskNo().intValue();
+        int destinationPosX = command.getDestinationPosX();
+        int destinationPosY = command.getDestinationPosY();
+        int destinationPosZ = command.getDestinationPosZ();
+        int taskMode = command.getTaskMode();
+        int taskNo = command.getTaskNo();
+        int station = command.getStation();
 
-        this.crnStatus.setMode(taskMode);
+        while (true) {
+            if (taskExecuteStation == 0) {
+                taskExecuteStation = station;
+            }
+
+            if (taskExecuteStation == station) {
+                break;
+            }
+
+            sleep(200);
+        }
+
         if(command.getStation() == 1) {
             this.crnStatus.setTaskNo(taskNo);
             this.crnStatus.setStatus(CrnStatusType.PUT_MOVING.id);
+            this.crnStatus.setTaskReceive(1);
 
-            moveY(this.crnStatus.getBay(), destinationPosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevel(), destinationPosZ, command.getStation().intValue());
+            moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
             this.crnStatus.setStatus(CrnStatusType.PUTTING.id);
-            sleep(2000);
+            sleep(3000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
@@ -215,17 +277,19 @@
         }else {
             this.crnStatus.setTaskNoTwo(taskNo);
             this.crnStatus.setStatusTwo(CrnStatusType.PUT_MOVING.id);
+            this.crnStatus.setTaskReceiveTwo(1);
 
-            moveY(this.crnStatus.getBayTwo(), destinationPosY, command.getStation().intValue());
-            moveZ(this.crnStatus.getLevelTwo(), destinationPosZ, command.getStation().intValue());
+            moveYZ(this.crnStatus.getBay(), destinationPosY,this.crnStatus.getLevel(), destinationPosZ, command.getStation());
             this.crnStatus.setStatusTwo(CrnStatusType.PUTTING.id);
-            sleep(2000);
+            sleep(3000);
             if (Thread.currentThread().isInterrupted()) {
                 return;
             }
             this.crnStatus.setLoadedTwo(0);
             this.crnStatus.setStatusTwo(CrnStatusType.WAITING.id);
         }
+
+        taskExecuteStation = 0;
     }
 
     private void moveZ(int sourcePosZ, int destinationPosZ, int station) {
@@ -234,11 +298,7 @@
             int initSourcePosZ = sourcePosZ;
             for(int i = 0; i < moveLength; i++) {
                 initSourcePosZ++;
-                if(station == 1) {
-                    this.crnStatus.setLevel(initSourcePosZ);
-                }else {
-                    this.crnStatus.setLevelTwo(initSourcePosZ);
-                }
+                this.crnStatus.setLevel(initSourcePosZ);
                 sleep(1000);
                 if (Thread.currentThread().isInterrupted()) {
                     return;
@@ -249,11 +309,7 @@
             int initSourcePosZ = sourcePosZ;
             for(int i = 0; i < moveLength; i++) {
                 initSourcePosZ--;
-                if(station == 1) {
-                    this.crnStatus.setLevel(initSourcePosZ);
-                }else {
-                    this.crnStatus.setLevelTwo(initSourcePosZ);
-                }
+                this.crnStatus.setLevel(initSourcePosZ);
                 this.crnStatus.setLevel(initSourcePosZ);
                 sleep(1000);
                 if (Thread.currentThread().isInterrupted()) {
@@ -269,12 +325,8 @@
             int initSourcePosY = sourcePosY;
             for(int i = 0; i < moveLength; i++) {
                 initSourcePosY++;
-                if(station == 1) {
-                    this.crnStatus.setBay(initSourcePosY);
-                }else {
-                    this.crnStatus.setBayTwo(initSourcePosY);
-                }
-                sleep(1000);
+                this.crnStatus.setBay(initSourcePosY);
+                sleep(500);
                 if (Thread.currentThread().isInterrupted()) {
                     return;
                 }
@@ -284,12 +336,8 @@
             int initSourcePosY = sourcePosY;
             for(int i = 0; i < moveLength; i++) {
                 initSourcePosY--;
-                if(station == 1) {
-                    this.crnStatus.setBay(initSourcePosY);
-                }else {
-                    this.crnStatus.setBayTwo(initSourcePosY);
-                }
-                sleep(1000);
+                this.crnStatus.setBay(initSourcePosY);
+                sleep(500);
                 if (Thread.currentThread().isInterrupted()) {
                     return;
                 }
@@ -297,6 +345,11 @@
         }
     }
 
+    private void moveYZ(int sourcePosY, int destinationPosY, int sourcePosZ, int destinationPosZ, int station) {
+        moveY(sourcePosY, destinationPosY, station);
+        moveZ(sourcePosZ, destinationPosZ, station);
+    }
+
     private void sleep(long ms) {
         try {
             Thread.sleep(ms);

--
Gitblit v1.9.1