Browse Source

添加日志

炒锅机器人_一拖多
liup 2 months ago
parent
commit
cfc43e2350
7 changed files with 41 additions and 8 deletions
  1. +10
    -2
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  2. +12
    -5
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe2.java
  3. +4
    -0
      app/src/main/java/com/bonait/bnframework/modbus/RackModbusTcpServer.java
  4. +4
    -1
      app/src/main/java/com/bonait/bnframework/modbus/RobotModbusTcpServer.java
  5. +4
    -0
      app/src/main/java/com/bonait/bnframework/modbus/Wok2ModbusTcpServer.java
  6. +4
    -0
      app/src/main/java/com/bonait/bnframework/modbus/WokModbusTcpServer.java
  7. +3
    -0
      app/src/main/java/com/bonait/bnframework/newui/fragment/cooking/CookingFragment.java

+ 10
- 2
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -200,6 +200,7 @@ public class ExecuteTheRecipe {
if ((!WokModbusTcpServer.get().plcIsConnect||!RobotModbusTcpServer.get().plcIsConnect) && !ConfigName.TEST) {
showlog("客官,检测到硬件已经断开连接,主动停止炒制!!!");
IsForcedEnd = true;
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-检测到硬件已经断开连接,主动停止炒制");
return false;
}

@@ -572,11 +573,13 @@ public class ExecuteTheRecipe {
try {
Log.e("按钮按下", name);
WritePLC(name, true, null);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-"+"BottomClick "+name+":true");
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
Log.e("按钮复位", name);
WritePLC(name, false, null);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-"+"BottomClick "+name+":false");
}
}, 500);
} catch (Exception ex) {
@@ -594,8 +597,9 @@ public class ExecuteTheRecipe {
try {
Log.e("按钮按下", name);
WritePLC(name, true, null);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-BottomClick1-"+name+":true");
Thread.sleep(500);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-BottomClick1-"+name);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-BottomClick1-"+name+":false");
WritePLC(name, false, null);
Log.e("按钮复位", name);
} catch (Exception ex) {
@@ -625,6 +629,7 @@ public class ExecuteTheRecipe {
WritePLC(key, writeValue, new IWriteCallBack() {
@Override
public void onSuccess() {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-档位-"+finalWriteValue+":成功");
if (finalWriteValue == 0) {
ConfigName.getInstance().IsOpenHuoLi = false;
WritePLC("加热", false, null);
@@ -636,6 +641,7 @@ public class ExecuteTheRecipe {

@Override
public void onFailure(String ErrorMsg) {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-档位-"+finalWriteValue+":失败");
WritePLC(key, finalWriteValue, null);
if (finalWriteValue == 0) {
ConfigName.getInstance().IsOpenHuoLi = false;
@@ -1131,7 +1137,7 @@ public class ExecuteTheRecipe {
index = 23;
}
}
Thread.sleep(100);
}
if(IsForcedEnd){
return;
@@ -1160,6 +1166,8 @@ public class ExecuteTheRecipe {
IsComplete = (boolean) (sb);
}
Object jsw = ReadPLC("炒锅倒菜减速位");//ListeningValue.get(name);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",炒锅倒菜减速位:"+jsw);
LogUtils.d(" 炒锅倒菜减速位:"+jsw);
if (jsw != null) {
ModbusCenter.robotWritePlc(false,deviceNum+"号炒锅出餐减速到位",jsw,null);
}


+ 12
- 5
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe2.java View File

@@ -35,7 +35,7 @@ import java.util.Map;
*/
public class ExecuteTheRecipe2 {

private static final String TAG = "ExecuteTheRecipe==>";
private static final String TAG = "ExecuteTheRecipe2==>";
private static int deviceNum = 2;
/**
@@ -88,8 +88,8 @@ public class ExecuteTheRecipe2 {
if (MakeStatus && orderDetail != null) {
boolean isError = false;
long startTime = System.currentTimeMillis(); //起始时间
RobotIsWorking = false;
showlog("开始烹饪菜谱【" + orderDetail.goodsName + "】");
RobotIsWorking = false;
Wok2ModbusTcpServer.get().WriteBool("M52.0", (boolean) true, null);
try {
//获取工艺
@@ -354,7 +354,7 @@ public class ExecuteTheRecipe2 {
case "主料":
case "辅料":
case "出菜":
while (!IsForcedEnd && ExecuteTheRecipe.RobotIsWorking) {
while (!IsForcedEnd && ExecuteTheRecipe2.RobotIsWorking) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
@@ -571,11 +571,13 @@ public class ExecuteTheRecipe2 {
try {
Log.e("按钮按下", name);
WritePLC(name, true, null);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-"+"BottomClick "+name+":true");
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
Log.e("按钮复位", name);
WritePLC(name, false, null);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-"+"BottomClick "+name+":false");
}
}, 500);
} catch (Exception ex) {
@@ -593,8 +595,9 @@ public class ExecuteTheRecipe2 {
try {
Log.e("按钮按下", name);
WritePLC(name, true, null);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-BottomClick1-"+name+":true");
Thread.sleep(500);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-BottomClick1-"+name);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-BottomClick1-"+name+":false");
WritePLC(name, false, null);
Log.e("按钮复位", name);
} catch (Exception ex) {
@@ -624,6 +627,7 @@ public class ExecuteTheRecipe2 {
WritePLC(key, writeValue, new IWriteCallBack() {
@Override
public void onSuccess() {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-档位-"+finalWriteValue+":成功");
if (finalWriteValue == 0) {
ConfigName.getInstance().IsOpenHuoLi = false;
WritePLC("加热", false, null);
@@ -635,6 +639,7 @@ public class ExecuteTheRecipe2 {

@Override
public void onFailure(String ErrorMsg) {
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅("+deviceNum+")-档位-"+finalWriteValue+":失败");
WritePLC(key, finalWriteValue, null);
if (finalWriteValue == 0) {
ConfigName.getInstance().IsOpenHuoLi = false;
@@ -1130,7 +1135,7 @@ public class ExecuteTheRecipe2 {
index = 23;
}
}
Thread.sleep(100);
}
if(IsForcedEnd){
return;
@@ -1159,6 +1164,8 @@ public class ExecuteTheRecipe2 {
IsComplete = (boolean) (sb);
}
Object jsw = ReadPLC("炒锅倒菜减速位");//ListeningValue.get(name);
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",炒锅倒菜减速位:"+jsw);
LogUtils.d(" 炒锅倒菜减速位:"+jsw);
if (jsw != null) {
ModbusCenter.robotWritePlc(false,deviceNum+"号炒锅出餐减速到位",jsw,null);
}


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

@@ -6,6 +6,7 @@ import android.util.Log;
import com.bonait.bnframework.HBL.Logs.MessageLog;
import com.bonait.bnframework.HBL.Thread.ThreadManager;
import com.bonait.bnframework.Service.ModbusTcpHelper;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.helper.DataFormat;
import com.bonait.bnframework.common.helper.I.IReadCallBack;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
@@ -200,6 +201,7 @@ public class RackModbusTcpServer {
public void ReConnect(String error){
if(error.contains("Connection refused")||error.contains("SocketException")){
plcIsConnect = false;
RecordManager.getInstance().addLogRecord("设备异常日志","货架plc-重连");
ConnectPLC();
}
}
@@ -225,6 +227,7 @@ public class RackModbusTcpServer {
MessageLog.ShowInfo("设备 " + ModbusCenter.rackAddress + " 连接成功");
RackModbusTcpServer.get().plcIsConnect = true;
Log.e("设备PLC", "设备PLC: 连接成功");
RecordManager.getInstance().addLogRecord("设备异常日志","货架plc-连接成功");
}

@Override
@@ -233,6 +236,7 @@ public class RackModbusTcpServer {
// NewToastUtil.getInstance().showToastError("设备 " + ModbusCenter.Address + " 连接失败:" + tr.getMessage());
MessageLog.ShowError("PLC设备 " + ModbusCenter.rackAddress + " 连接失败:" + tr.getMessage());
Log.e("设备PLC", "设备PLC: 连接断开");
RecordManager.getInstance().addLogRecord("设备异常日志","货架plc-连接失败");
}

@Override


+ 4
- 1
app/src/main/java/com/bonait/bnframework/modbus/RobotModbusTcpServer.java View File

@@ -5,6 +5,7 @@ import android.util.Log;
import com.bonait.bnframework.HBL.Logs.MessageLog;
import com.bonait.bnframework.HBL.Thread.IThread;
import com.bonait.bnframework.HBL.Thread.ThreadManager;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.helper.DataFormat;
import com.bonait.bnframework.common.helper.I.IReadCallBack;
@@ -110,6 +111,7 @@ public class RobotModbusTcpServer {
}
plcIsConnect = false;
if(error.contains("Connection refused")||error.contains("SocketException")){
RecordManager.getInstance().addLogRecord("设备异常日志","机器人plc-重连");
ConnectPLC();
}
}
@@ -139,6 +141,7 @@ public class RobotModbusTcpServer {
Log.e("机器人PLC", "机器人PLC: 连接成功");
ThreadManager.get().Stop("机器人设备重连");
ModbusCenter.Listening();
RecordManager.getInstance().addLogRecord("设备异常日志","机器人PLC-连接成功");
}

@Override
@@ -146,7 +149,7 @@ public class RobotModbusTcpServer {
RobotModbusTcpServer.get().plcIsConnect = false;
MessageLog.ShowError("机器人设备 " + ModbusCenter.robotAddress + " 连接失败:" + tr.getMessage());
Log.e("机器人PLC", "机器人PLC: 连接断开");
RecordManager.getInstance().addLogRecord("设备异常日志","机器人PLC-连接失败");
}
@Override
public void onFinally() {


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

@@ -6,6 +6,7 @@ import android.util.Log;
import com.bonait.bnframework.HBL.Logs.MessageLog;
import com.bonait.bnframework.HBL.Thread.IThread;
import com.bonait.bnframework.HBL.Thread.ThreadManager;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.helper.DataFormat;
import com.bonait.bnframework.common.helper.I.IReadCallBack;
@@ -69,6 +70,7 @@ public class Wok2ModbusTcpServer {
}
plcIsConnect = false;
if(error.contains("Connection refused")||error.contains("SocketException")){
RecordManager.getInstance().addLogRecord("设备异常日志","2号炒锅plc-重连");
ConnectPLC();
}
}
@@ -116,6 +118,7 @@ public class Wok2ModbusTcpServer {
ThreadManager.get().Stop("炒锅设备重连");
ModbusCenter.Listening();
init();
RecordManager.getInstance().addLogRecord("设备异常日志",2+"号炒锅-连接成功");
}

@Override
@@ -123,6 +126,7 @@ public class Wok2ModbusTcpServer {
Wok2ModbusTcpServer.get().plcIsConnect = false;
MessageLog.ShowError("炒锅PLC设备 " + ModbusCenter.wokAddress + " 连接失败:" + tr.getMessage());
Log.e("炒锅设备PLC", "炒锅设备PLC: 连接断开");
RecordManager.getInstance().addLogRecord("设备异常日志",2+"号炒锅-连接失败");
}

@Override


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

@@ -6,6 +6,7 @@ import android.util.Log;
import com.bonait.bnframework.HBL.Logs.MessageLog;
import com.bonait.bnframework.HBL.Thread.IThread;
import com.bonait.bnframework.HBL.Thread.ThreadManager;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.helper.DataFormat;
import com.bonait.bnframework.common.helper.I.IReadCallBack;
@@ -73,6 +74,7 @@ public class WokModbusTcpServer {
}
plcIsConnect = false;
if(error.contains("Connection refused")||error.contains("SocketException")){
RecordManager.getInstance().addLogRecord("设备异常日志","1号炒锅plc-重连");
ConnectPLC();
}
}
@@ -119,6 +121,7 @@ public class WokModbusTcpServer {
Log.e("炒锅设备PLC", "炒锅设备PLC: 连接成功");
ThreadManager.get().Stop("炒锅设备重连");
ModbusCenter.Listening();
RecordManager.getInstance().addLogRecord("设备异常日志",1+"号炒锅-连接成功");
init();
}

@@ -127,6 +130,7 @@ public class WokModbusTcpServer {
WokModbusTcpServer.get().plcIsConnect = false;
MessageLog.ShowError("炒锅PLC设备 " + ModbusCenter.wokAddress + " 连接失败:" + tr.getMessage());
Log.e("炒锅设备PLC", "炒锅设备PLC: 连接断开");
RecordManager.getInstance().addLogRecord("设备异常日志",1+"号炒锅-连接失败");
}

@Override


+ 3
- 0
app/src/main/java/com/bonait/bnframework/newui/fragment/cooking/CookingFragment.java View File

@@ -21,6 +21,7 @@ import com.bonait.bnframework.R;
import com.bonait.bnframework.Service.ModbusHelper;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.business.ExecuteTheRecipe2;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
@@ -238,12 +239,14 @@ public class CookingFragment extends BaseFragment {
switch (deviceNum){
case 1:
ExecuteTheRecipe.IsForcedEnd = true;
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",强行停止");
ExecuteTheRecipe.IsPause = false;
ExecuteTheRecipe.MakeStatus = false;
ExecuteTheRecipe.IsStart = false;
break;
case 2:
ExecuteTheRecipe2.IsForcedEnd = true;
RecordManager.getInstance().addLogRecord("订单处理日志",deviceNum+"号炒锅-" + ",强行停止");
ExecuteTheRecipe2.IsPause = false;
ExecuteTheRecipe2.MakeStatus = false;
ExecuteTheRecipe2.IsStart = false;


Loading…
Cancel
Save