From 4341e2d0d067fdc5b5315fc13940848ee0c3e5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Thu, 27 Apr 2023 15:04:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/bpa/Model/IRunT.java | 5 ++ .../com/example/bpa/Model/RunStatusModel.java | 5 ++ .../com/example/bpa/app/BusinessServer.java | 32 ++++++++ .../java/com/example/bpa/app/DeviceData.java | 74 +++++++++++++++++-- 4 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/com/example/bpa/Model/IRunT.java create mode 100644 app/src/main/java/com/example/bpa/Model/RunStatusModel.java diff --git a/app/src/main/java/com/example/bpa/Model/IRunT.java b/app/src/main/java/com/example/bpa/Model/IRunT.java new file mode 100644 index 0000000..1febe93 --- /dev/null +++ b/app/src/main/java/com/example/bpa/Model/IRunT.java @@ -0,0 +1,5 @@ +package com.example.bpa.Model; + +public interface IRunT { + void Run(T t); +} diff --git a/app/src/main/java/com/example/bpa/Model/RunStatusModel.java b/app/src/main/java/com/example/bpa/Model/RunStatusModel.java new file mode 100644 index 0000000..9737e21 --- /dev/null +++ b/app/src/main/java/com/example/bpa/Model/RunStatusModel.java @@ -0,0 +1,5 @@ +package com.example.bpa.Model; + +public class RunStatusModel { + public int ChNumber; +} diff --git a/app/src/main/java/com/example/bpa/app/BusinessServer.java b/app/src/main/java/com/example/bpa/app/BusinessServer.java index bbb0663..232c5bf 100644 --- a/app/src/main/java/com/example/bpa/app/BusinessServer.java +++ b/app/src/main/java/com/example/bpa/app/BusinessServer.java @@ -1,13 +1,16 @@ package com.example.bpa.app; +import com.example.bpa.Model.IRunT; import com.example.bpa.Model.IThread; import com.example.bpa.db.QueryDB; +import com.example.bpa.db.mode.BPA_SILOS; import com.example.bpa.helper.MessageLog; import com.example.bpa.helper.ThreadManager; import com.example.bpa.view.mode.ResGoodsRecipe; import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; @@ -35,6 +38,7 @@ public class BusinessServer { } public void Start() { + DeviceData.Get().TestInit(); ThreadManager.Get().StartLong("配方执行业务流程", true, new IThread() { @Override public void Run() throws InterruptedException { @@ -50,10 +54,38 @@ public class BusinessServer { rgrs.get(goods.get(i).sort).add(goods.get(i)); } +// rgrs.forEach((x, y) -> { +// +// }); + + for (int i = 0; i < rgrs.size(); i++) { + List ChNums = new ArrayList<>(); for (int m = 0; m < rgrs.get(i).size(); m++) { + //获取料仓信息 + List bss = QueryDB.GetSolisByMaterialID(rgrs.get(i).get(m).materialID); + for (int x = 0; x < bss.size(); x++) { +// if (DeviceData.Get().getCallCurrentWeight(bss.get(x).num) >= (float) rgrs.get(i).get(m).value) { + MessageLog.ShowInfo("下发" + bss.get(x).num + "号料仓PLC控制命令,需求量:=" + rgrs.get(i).get(m).value); + ChNums.add(bss.get(x).num); + DeviceData.Get().testAddComm(bss.get(x).num); +// } + } + } + + List tempComplete = new ArrayList<>(); + DeviceData.Get().OnChargeMixtureComNotPar = new IRunT() { + @Override + public void Run(Object o) { + tempComplete.add(Integer.parseInt(o.toString())); + MessageLog.ShowInfo("完成=" + o); + } + }; + while (ChNums.size() < tempComplete.size()) { + Thread.sleep(100); } + MessageLog.ShowInfo("结束="); } } diff --git a/app/src/main/java/com/example/bpa/app/DeviceData.java b/app/src/main/java/com/example/bpa/app/DeviceData.java index dc34e4b..f5ae0e3 100644 --- a/app/src/main/java/com/example/bpa/app/DeviceData.java +++ b/app/src/main/java/com/example/bpa/app/DeviceData.java @@ -2,11 +2,14 @@ package com.example.bpa.app; import com.example.bpa.Model.IReadCallBack; import com.example.bpa.Model.IRun; +import com.example.bpa.Model.IRunT; import com.example.bpa.Model.IThread; import com.example.bpa.Model.IWriteCallBack; import com.example.bpa.helper.RTrig; import com.example.bpa.helper.ThreadManager; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; @@ -19,6 +22,37 @@ public class DeviceData { return _instance; } + + //----------------------------------------------------------------Start 测试 ---------------------------------------------------------------- + ConcurrentLinkedQueue testComms = new ConcurrentLinkedQueue<>(); + + public void testAddComm(int value) { + testComms.offer(value); + } + + public void TestInit() { + ThreadManager.Get().StartLong("TestInit", true, new IThread() { + @Override + public void Run() throws InterruptedException { + while (testComms.size() > 0) { + Thread.sleep(5000); + if (OnChargeMixtureComNotPar != null) { + OnChargeMixtureComNotPar.Run(testComms.poll()); + } + } + Thread.sleep(100); + } + + @Override + public void RunComplete() throws InterruptedException { + + } + }); + ; + } + //----------------------------------------------------------------End 测试 ---------------------------------------------------------------- + + public void Init() { ThreadManager.Get().StartLong("Plc设备数据监听", true, new IThread() { @Override @@ -62,14 +96,22 @@ public class DeviceData { } }); + //获取清洗参数 + ModbusTcpServer.get().ReadBool("M6.5", 1, new IReadCallBack() { + @Override + public void onSuccess(boolean[] booleans) { + WeightCalibrationMode = booleans[0]; + } + }); + //配料完成 M0.3 - CompleteListen("M0.3", "配料完成", ChargeMixtureCompleteNotify); + CompleteListen("M0.3", "配料完成", OnChargeMixtureCompleteNotify); //清洗完成 M0.6 - CompleteListen("M0.6", "清洗完成", CleaningCompleteNotify); + CompleteListen("M0.6", "清洗完成", OnCleaningCompleteNotify); //去皮完成 M1.3 - CompleteListen("M1.3", "去皮完成", PeelingCompleteNotify); + CompleteListen("M1.3", "去皮完成", OnPeelingCompleteNotify); Thread.sleep(10); } @@ -96,20 +138,26 @@ public class DeviceData { }); } + /** * 配料完成通知 */ - public IRun ChargeMixtureCompleteNotify; + public IRun OnChargeMixtureCompleteNotify; + + /** + * 通道配料完成通知 + */ + public IRunT OnChargeMixtureComNotPar; /** * 清洗完成通知 */ - public IRun CleaningCompleteNotify; + public IRun OnCleaningCompleteNotify; /** * 去皮完成 */ - public IRun PeelingCompleteNotify; + public IRun OnPeelingCompleteNotify; /** * 校准值写入 @@ -234,6 +282,11 @@ public class DeviceData { ModbusTcpServer.get().WriteBool("M6.3", true, callback); } + /** + * 砝码校准模式 + */ + boolean WeightCalibrationMode; + /** * 砝码校准模式 */ @@ -241,6 +294,15 @@ public class DeviceData { ModbusTcpServer.get().WriteBool("M6.5", true, callback); } + /** + * 获取砝码校准模式 + * + * @return + */ + public boolean getWeightCalibrationMode() { + return WeightCalibrationMode; + } + /** * 启动通道校准 */