Browse Source

7

tags/old_version_1
fyf 1 year ago
parent
commit
4829b93c59
3 changed files with 37 additions and 5 deletions
  1. +2
    -0
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  2. +23
    -4
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  3. +12
    -1
      app/src/main/java/com/bonait/bnframework/business/MainInit.java

+ 2
- 0
app/src/main/java/com/bonait/bnframework/business/ConfigData.java View File

@@ -10,6 +10,7 @@ import androidx.annotation.NonNull;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_CLOUDDATA;
@@ -947,6 +948,7 @@ public class ConfigData {
*/
public void ColsePLC() {
ModbusTcpHelper.get().release();//释放modbus
ConfigName.getInstance().PlcIsConnect=false;
}
/**
* PLC初始化完成时,需要注册的服务


+ 23
- 4
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -280,13 +280,14 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_Stir(HashMap<String, String> data) {
try {
int val=0;

for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)")) {
int val = Integer.parseInt(value);
val = Integer.parseInt(value);
Thread.sleep(val * 1000);
} else {
int writeValue = GetMXValue(key, value);
@@ -306,6 +307,11 @@ public class ExecuteTheRecipe {
});
}
}

if(val>0)
{
Thread.sleep(val * 1000);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
@@ -318,12 +324,14 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_Location(HashMap<String, String> data) {
try {
int val=0;

for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)")) {
int val = Integer.parseInt(value);
val = Integer.parseInt(value);
Thread.sleep(val * 1000);
} else if (key.contains("速度")) {
int writeValue = GetMXValue(key, value);
@@ -350,6 +358,11 @@ public class ExecuteTheRecipe {
ToastUtils.info("炒锅到达"+value+",继续制作!!!");
}
}

if(val>0)
{
Thread.sleep(val * 1000);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
@@ -545,13 +558,13 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_Heating(HashMap<String, String> data) {
try {
int val=0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)")) {
int val = Integer.parseInt(value);
Thread.sleep(val * 1000);
val = Integer.parseInt(value);
} else {
int writeValue = GetMXValue(key, value);
WritePLC(key, writeValue, new IWriteCallBack() {
@@ -570,6 +583,12 @@ public class ExecuteTheRecipe {
});
}
}

if(val>0)
{
Thread.sleep(val * 1000);
}

} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}


+ 12
- 1
app/src/main/java/com/bonait/bnframework/business/MainInit.java View File

@@ -23,6 +23,7 @@ import com.bonait.bnframework.common.helper.CrashHandler;
import com.bonait.bnframework.common.helper.I.IMessageLogNotify;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.SdCart;
import com.bonait.bnframework.common.modbus.ModbusTcpHelper;
import com.bonait.bnframework.common.notification.MainNotification;
import com.bonait.bnframework.common.utils.AppUtils;
import com.bonait.bnframework.common.utils.NetworkUtils;
@@ -154,7 +155,17 @@ public class MainInit {
MessageLog.MsgNotify = new IMessageLogNotify() {
@Override
public void ErrorMsg(String msg) {
Log.e("Error", msg);
if(msg.contains("msg:com.serotonin.modbus4j.exception"))
{
ModbusTcpHelper.get().release();//释放modbus
ConfigName.getInstance().PlcIsConnect=false;

BPA_ALERTLOG log = new BPA_ALERTLOG();
log.userID = ConfigName.getInstance().user.userID;
log.type=4;
log.text = msg+"程序断开PLC,准备重连机制...";
QueryDB.AddAlertlog(log);
}
}
@Override
public void InfoMsg(String msg) {


Loading…
Cancel
Save