Browse Source

业务流程

master
pry 1 year ago
parent
commit
4341e2d0d0
4 changed files with 110 additions and 6 deletions
  1. +5
    -0
      app/src/main/java/com/example/bpa/Model/IRunT.java
  2. +5
    -0
      app/src/main/java/com/example/bpa/Model/RunStatusModel.java
  3. +32
    -0
      app/src/main/java/com/example/bpa/app/BusinessServer.java
  4. +68
    -6
      app/src/main/java/com/example/bpa/app/DeviceData.java

+ 5
- 0
app/src/main/java/com/example/bpa/Model/IRunT.java View File

@@ -0,0 +1,5 @@
package com.example.bpa.Model;

public interface IRunT<T> {
void Run(T t);
}

+ 5
- 0
app/src/main/java/com/example/bpa/Model/RunStatusModel.java View File

@@ -0,0 +1,5 @@
package com.example.bpa.Model;

public class RunStatusModel {
public int ChNumber;
}

+ 32
- 0
app/src/main/java/com/example/bpa/app/BusinessServer.java View File

@@ -1,13 +1,16 @@
package com.example.bpa.app; package com.example.bpa.app;


import com.example.bpa.Model.IRunT;
import com.example.bpa.Model.IThread; import com.example.bpa.Model.IThread;
import com.example.bpa.db.QueryDB; 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.MessageLog;
import com.example.bpa.helper.ThreadManager; import com.example.bpa.helper.ThreadManager;
import com.example.bpa.view.mode.ResGoodsRecipe; import com.example.bpa.view.mode.ResGoodsRecipe;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;


@@ -35,6 +38,7 @@ public class BusinessServer {
} }


public void Start() { public void Start() {
DeviceData.Get().TestInit();
ThreadManager.Get().StartLong("配方执行业务流程", true, new IThread() { ThreadManager.Get().StartLong("配方执行业务流程", true, new IThread() {
@Override @Override
public void Run() throws InterruptedException { public void Run() throws InterruptedException {
@@ -50,10 +54,38 @@ public class BusinessServer {
rgrs.get(goods.get(i).sort).add(goods.get(i)); rgrs.get(goods.get(i).sort).add(goods.get(i));
} }


// rgrs.forEach((x, y) -> {
//
// });


for (int i = 0; i < rgrs.size(); i++) { for (int i = 0; i < rgrs.size(); i++) {
List<Integer> ChNums = new ArrayList<>();
for (int m = 0; m < rgrs.get(i).size(); m++) { for (int m = 0; m < rgrs.get(i).size(); m++) {
//获取料仓信息
List<BPA_SILOS> 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<Integer> 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("结束=");
} }


} }


+ 68
- 6
app/src/main/java/com/example/bpa/app/DeviceData.java View File

@@ -2,11 +2,14 @@ package com.example.bpa.app;


import com.example.bpa.Model.IReadCallBack; import com.example.bpa.Model.IReadCallBack;
import com.example.bpa.Model.IRun; import com.example.bpa.Model.IRun;
import com.example.bpa.Model.IRunT;
import com.example.bpa.Model.IThread; import com.example.bpa.Model.IThread;
import com.example.bpa.Model.IWriteCallBack; import com.example.bpa.Model.IWriteCallBack;
import com.example.bpa.helper.RTrig; import com.example.bpa.helper.RTrig;
import com.example.bpa.helper.ThreadManager; import com.example.bpa.helper.ThreadManager;


import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;


@@ -19,6 +22,37 @@ public class DeviceData {
return _instance; return _instance;
} }



//----------------------------------------------------------------Start 测试 ----------------------------------------------------------------
ConcurrentLinkedQueue<Integer> 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() { public void Init() {
ThreadManager.Get().StartLong("Plc设备数据监听", true, new IThread() { ThreadManager.Get().StartLong("Plc设备数据监听", true, new IThread() {
@Override @Override
@@ -62,14 +96,22 @@ public class DeviceData {
} }
}); });


//获取清洗参数
ModbusTcpServer.get().ReadBool("M6.5", 1, new IReadCallBack<boolean[]>() {
@Override
public void onSuccess(boolean[] booleans) {
WeightCalibrationMode = booleans[0];
}
});

//配料完成 M0.3 //配料完成 M0.3
CompleteListen("M0.3", "配料完成", ChargeMixtureCompleteNotify);
CompleteListen("M0.3", "配料完成", OnChargeMixtureCompleteNotify);


//清洗完成 M0.6 //清洗完成 M0.6
CompleteListen("M0.6", "清洗完成", CleaningCompleteNotify);
CompleteListen("M0.6", "清洗完成", OnCleaningCompleteNotify);


//去皮完成 M1.3 //去皮完成 M1.3
CompleteListen("M1.3", "去皮完成", PeelingCompleteNotify);
CompleteListen("M1.3", "去皮完成", OnPeelingCompleteNotify);


Thread.sleep(10); 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); ModbusTcpServer.get().WriteBool("M6.3", true, callback);
} }


/**
* 砝码校准模式
*/
boolean WeightCalibrationMode;

/** /**
* 砝码校准模式 * 砝码校准模式
*/ */
@@ -241,6 +294,15 @@ public class DeviceData {
ModbusTcpServer.get().WriteBool("M6.5", true, callback); ModbusTcpServer.get().WriteBool("M6.5", true, callback);
} }


/**
* 获取砝码校准模式
*
* @return
*/
public boolean getWeightCalibrationMode() {
return WeightCalibrationMode;
}

/** /**
* 启动通道校准 * 启动通道校准
*/ */


Loading…
Cancel
Save