Browse Source

大炒调整

燃气自翻炒锅
pry 1 year ago
parent
commit
9069846c21
2 changed files with 63 additions and 33 deletions
  1. +62
    -33
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  2. +1
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java

+ 62
- 33
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -420,7 +420,8 @@ public class ExecuteTheRecipe {
}

if (val > 0) {
Thread.sleep(val * 1000);
ThreadDelay(val);
//Thread.sleep(val * 1000);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -463,7 +464,7 @@ public class ExecuteTheRecipe {
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
Log.e("等待反馈", name + ",等待中");
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
} else {
@@ -480,8 +481,9 @@ public class ExecuteTheRecipe {
}
}

if (val > 0) {
Thread.sleep(val * 1000);
if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
//Thread.sleep(val * 1000);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -592,7 +594,7 @@ public class ExecuteTheRecipe {
String name = "平移轴在" + writeValue;
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
} else {
@@ -610,7 +612,7 @@ public class ExecuteTheRecipe {
name = "倒菜完成";
IsComplete[0] = false;
a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
} else {
@@ -647,8 +649,9 @@ public class ExecuteTheRecipe {
val = Integer.parseInt(value);
}
}
if (val > 0) {
Thread.sleep(val * 1000);
if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
//Thread.sleep(val * 1000);
}

Log.d("烹饪时间", "烹饪时间完成了");
@@ -739,8 +742,9 @@ public class ExecuteTheRecipe {
}
}

if (val > 0) {
Thread.sleep(val * 1000);
if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
//Thread.sleep(val * 1000);
}

} catch (Exception ex) {
@@ -767,7 +771,7 @@ public class ExecuteTheRecipe {
if (ExecuteCurrentOperation != null) {
ExecuteCurrentOperation.Run("加水" + "|" + val);
}
if (val > 0) {
if (val > 0 && !IsForcedEnd) {
WritePLC("炒锅抽水", true, null);
final boolean[] IsComplete = {false};
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@@ -802,9 +806,10 @@ public class ExecuteTheRecipe {
String key = entry.getKey();
String value = entry.getValue();
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)")) {
if (key.contains("(秒)") && !IsForcedEnd) {
int val = Integer.parseInt(value);
Thread.sleep(val * 1000);
ThreadDelay(val);
//Thread.sleep(val * 1000);
}
}
} catch (Exception ex) {
@@ -828,8 +833,9 @@ public class ExecuteTheRecipe {
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)")) {
int val = Integer.parseInt(value);
if (all_list.size() > 0) {
Thread.sleep(val * 1000);
if (all_list.size() > 0 && !IsForcedEnd) {
ThreadDelay(val);
//Thread.sleep(val * 1000);
}
}
}
@@ -842,7 +848,7 @@ public class ExecuteTheRecipe {
String name = "出餐启动反馈";
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 3)) {
break;
} else {
@@ -873,9 +879,10 @@ public class ExecuteTheRecipe {
String key = entry.getKey();
String value = entry.getValue();
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)")) {
if (key.contains("(秒)") && !IsForcedEnd) {
int val = Integer.parseInt(value);
Thread.sleep(val * 1000);
ThreadDelay(val);
//Thread.sleep(val * 1000);
}
}

@@ -885,7 +892,7 @@ public class ExecuteTheRecipe {
String name = "炒锅清洗反馈";
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 5)) {
break;
} else {
@@ -1003,7 +1010,7 @@ public class ExecuteTheRecipe {
String name = writeValue + "倒菜完成";
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
} else {
@@ -1035,8 +1042,9 @@ public class ExecuteTheRecipe {
val = Integer.parseInt(value);
}
}
if (val > 0) {
Thread.sleep(val * 1000);
if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
//Thread.sleep(val * 1000);
}

Log.d("烹饪时间", "烹饪时间完成了");
@@ -1141,7 +1149,7 @@ public class ExecuteTheRecipe {

final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 10)) {
break;
} else {
@@ -1176,8 +1184,9 @@ public class ExecuteTheRecipe {
val = Integer.parseInt(value);
}
}
if (val > 0) {
Thread.sleep(val * 1000);
if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
//Thread.sleep(val * 1000);
}

Log.d("烹饪时间", "烹饪时间完成了");
@@ -1220,7 +1229,7 @@ public class ExecuteTheRecipe {

final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 10)) {
break;
} else {
@@ -1240,8 +1249,9 @@ public class ExecuteTheRecipe {
BPA_GOODSRECIPE data3 = Get位置("高速", "炒菜位1");
ExecuteOperationSteps(data3.processname, data3.processvalue);

if (val > 0) {
Thread.sleep(val * 1000);
if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
//Thread.sleep(val * 1000);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -1264,7 +1274,8 @@ public class ExecuteTheRecipe {
if (key.contains("(秒)")) {
int val = Integer.parseInt(value);
if (all_list.size() > 0) {
Thread.sleep(val * 1000);
ThreadDelay(val);
//Thread.sleep(val * 1000);
}
}
}
@@ -1277,7 +1288,7 @@ public class ExecuteTheRecipe {
//等待机器人就位
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 10)) {
break;
} else {
@@ -1297,7 +1308,7 @@ public class ExecuteTheRecipe {
String name = "出餐启动反馈";
IsComplete[0] = false;
a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 3)) {
break;
} else {
@@ -1867,8 +1878,7 @@ public class ExecuteTheRecipe {
//强制结束任务
Object IsStop = ReadMainPLC("强制结束任务");
if (IsStop != null) {
if ((boolean) IsStop)
{
if ((boolean) IsStop) {
WriteMainPLC("强制结束任务", false, null);//复位

ExecuteTheRecipe.IsPause = false;
@@ -1930,4 +1940,23 @@ public class ExecuteTheRecipe {
}
}
//endregion

//region 延迟函数

/**
* 线程延迟函数(避免线程阻塞等待)
*
* @param delay
*/
public static void ThreadDelay(int delay) {
long startTime = System.currentTimeMillis();
while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd) //
{
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
}
}
}
//endregion
}

+ 1
- 0
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java View File

@@ -173,6 +173,7 @@ public class BottomNavigationNewActivity extends BaseActivity {
runOnUiThread(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.StopForcedEnd();
cooking.SetStartStaus(true);
ExecuteTheRecipe.IsPause = false;
ExecuteTheRecipe.WritePLC("暂停开关", false, null);


Loading…
Cancel
Save