Browse Source

优化

炒锅机器人_一拖多
liup 2 months ago
parent
commit
510a009c7a
3 changed files with 84 additions and 27 deletions
  1. +79
    -26
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  2. +1
    -1
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  3. +4
    -0
      app/src/main/java/com/bonait/bnframework/modbus/ModbusTcpHelper.java

+ 79
- 26
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -891,9 +891,8 @@ public class ExecuteTheRecipe {
return;
}
ModbusCenter.robotWritePlc(true,foodPosition+"#库取原料倒至炒锅",true,null);
if (RobotModbusTcpServer.get().plcIsConnect) {
RobotModbusTcpServer.get().WriteShort("GI1", (short) deviceNum, null);
}
RobotModbusTcpServer.get().WriteShort("GI1", (short) deviceNum, null);

Thread.sleep(2000);
ThreadWhile(deviceNum,deviceNum+"炒锅倒原料完成");

@@ -1018,9 +1017,7 @@ public class ExecuteTheRecipe {
return;
}
ModbusCenter.robotWritePlc(true,foodPosition+"#库取调料倒至炒锅",true,null);
if (RobotModbusTcpServer.get().plcIsConnect) {
RobotModbusTcpServer.get().WriteShort("GI2", (short) deviceNum, null);
}
RobotModbusTcpServer.get().WriteShort("GI2", (short) deviceNum, null);
Thread.sleep(2000);
ThreadWhile(deviceNum,deviceNum+"炒锅倒调料完成");

@@ -1127,28 +1124,33 @@ public class ExecuteTheRecipe {
ThreadWhileFalse(deviceNum,"输送线进料菜盆检测");

Wait_Robot_No_Working();//等待机器人空闲
// ModbusCenter.robotWritePlc(true,"机器人取空盆接菜出餐",null,null);

boolean isCheck = false;
int index = 0;
long b = System.currentTimeMillis();
while (!isCheck && !ConfigName.IsForcedEnd[deviceNum-1] && RackModbusTcpServer.get().plcIsConnect){
while (!isCheck && !ConfigName.IsForcedEnd[deviceNum-1]){
if ((System.currentTimeMillis() - b) > 1000 * (whileTime * 3)) {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-制作取消-检测空盆超时");
ConfigName.IsForcedEnd[deviceNum-1] = true;
break;
}else{
boolean pan1 = (Boolean) ModbusCenter.ReadPlc(1,"1#空盆库位检测有无");
boolean pan2 = (Boolean) ModbusCenter.ReadPlc(1,"2#空盆库位检测有无");
boolean pan3 = (Boolean) ModbusCenter.ReadPlc(1,"3#空盆库位检测有无");
isCheck = pan1||pan2||pan3;
if(pan1){
index = 21;
}else if(pan2){
index = 22;
}else if(pan3){
index = 23;
Object pan1 = ModbusCenter.ReadPlc(1,"1#空盆库位检测有无");
Object pan2 = ModbusCenter.ReadPlc(1,"2#空盆库位检测有无");
Object pan3 = ModbusCenter.ReadPlc(1,"3#空盆库位检测有无");
if(pan1 !=null){
isCheck = (Boolean) pan1|| (Boolean)pan2|| (Boolean)pan3;
if( (Boolean)pan1){
index = 21;
}else if( (Boolean)pan2){
index = 22;
}else if( (Boolean)pan3){
index = 23;
}
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",空盆库位检测有无:"+isCheck);
}else{
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",空盆库位检测有无:异常");
}

}
Thread.sleep(100);
}
@@ -1156,10 +1158,28 @@ public class ExecuteTheRecipe {
return;
}

if (RobotModbusTcpServer.get().plcIsConnect) {
RobotModbusTcpServer.get().WriteShort("GI0", (short) index, null);
RobotModbusTcpServer.get().WriteShort("GI3", (short) deviceNum, null);
}
RobotModbusTcpServer.get().WriteShort("GI0", (short) index, new IWriteCallBack() {
@Override
public void onSuccess() {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",取空盆写入成功");
}

@Override
public void onFailure(String ErrorMsg) {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",取空盆写入失败");
}
});
RobotModbusTcpServer.get().WriteShort("GI3", (short) deviceNum, new IWriteCallBack() {
@Override
public void onSuccess() {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",取空盆到炒锅写入成功");
}

@Override
public void onFailure(String ErrorMsg) {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",取空盆到炒锅写入失败");
}
});

Thread.sleep(100);
ThreadWhile(deviceNum,deviceNum+"机器人到位请求炒锅出餐倒菜");
@@ -1167,7 +1187,18 @@ public class ExecuteTheRecipe {
Thread.sleep(100);
return;
}
ModbusCenter.robotWritePlc(false,deviceNum+"号炒锅出餐减速到位",false,null);
Thread.sleep(100);
ModbusCenter.robotWritePlc(false, deviceNum + "号炒锅出餐减速到位", false, new IWriteCallBack() {
@Override
public void onSuccess() {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",号炒锅出餐减速到位 写入成功");
}

@Override
public void onFailure(String ErrorMsg) {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",号炒锅出餐减速到位 写入失败");
}
});
Thread.sleep(100);
BottomClick1(deviceNum,"出菜");//自动去倒菜位
//一直等待机器移动到该位置,否则就一直等待 6s超时
@@ -1183,17 +1214,39 @@ public class ExecuteTheRecipe {
IsComplete = (boolean) (sb);
}
Object jsw = ReadPLC(deviceNum,"炒锅倒菜减速位");//ListeningValue.get(name);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",炒锅倒菜减速位:"+jsw);
LogUtils.d(" 炒锅倒菜减速位:"+jsw);
if (jsw != null) {
ModbusCenter.robotWritePlc(false,deviceNum+"号炒锅出餐减速到位",jsw,null);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",炒锅倒菜减速位:"+jsw);
ModbusCenter.robotWritePlc(false,deviceNum+"号炒锅出餐减速到位",jsw, new IWriteCallBack() {
@Override
public void onSuccess() {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",号炒锅出餐减速到位 写入成功");
}

@Override
public void onFailure(String ErrorMsg) {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",号炒锅出餐减速到位 写入失败");
}
});
}else {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",炒锅倒菜减速位:null");
}
}
Thread.sleep(100);//10 *6
}
ThreadWhile(deviceNum,"出餐启动反馈");
Thread.sleep(100);
ModbusCenter.robotWritePlc(false,deviceNum+"号炒锅出餐倒菜完成",true,null);
ModbusCenter.robotWritePlc(false,deviceNum+"号炒锅出餐倒菜完成",true, new IWriteCallBack() {
@Override
public void onSuccess() {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",号炒锅出餐倒菜完成 写入成功");
}

@Override
public void onFailure(String ErrorMsg) {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",号炒锅出餐倒菜完成 写入失败");
}
});
Thread.sleep(500);
Make位置(deviceNum,"原点位");
if(hasClear){


+ 1
- 1
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java View File

@@ -32,7 +32,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class ConfigName {
//是否是测试模式
public final static boolean TEST = false;
public final static boolean TEST = true;
//崩溃重启
public final static boolean ERROR_ROOT = false;
//日志打印


+ 4
- 0
app/src/main/java/com/bonait/bnframework/modbus/ModbusTcpHelper.java View File

@@ -559,6 +559,7 @@ public abstract class ModbusTcpHelper {
callback.onSuccess();
} catch (InterruptedException | ExecutionException | ModbusTransportException |
ModbusInitException | ModbusRespException e) {
ReConnect(e.toString());
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
}
@@ -577,6 +578,7 @@ public abstract class ModbusTcpHelper {
} catch (InterruptedException | ExecutionException | ModbusTransportException |
ModbusInitException | ModbusRespException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
ReConnect(e.toString());
if (callback != null) callback.onFailure(e.toString());
}
}
@@ -596,6 +598,7 @@ public abstract class ModbusTcpHelper {
} catch (InterruptedException | ExecutionException | ModbusTransportException |
ModbusInitException | ModbusRespException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
ReConnect(e.toString());
if (callback != null) callback.onFailure(e.toString());
}
}
@@ -610,6 +613,7 @@ public abstract class ModbusTcpHelper {
} catch (InterruptedException | ExecutionException | ModbusTransportException |
ModbusInitException | ModbusRespException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
ReConnect(e.toString());
if (callback != null) callback.onFailure(e.toString());
}
}


Loading…
Cancel
Save