|
|
@@ -24,6 +24,7 @@ import com.bonait.bnframework.common.helper.I.IRun; |
|
|
|
import com.bonait.bnframework.common.helper.I.IRunT; |
|
|
|
import com.bonait.bnframework.common.helper.I.IThread; |
|
|
|
import com.bonait.bnframework.common.helper.I.IWriteCallBack; |
|
|
|
import com.bonait.bnframework.common.helper.LogcatHelper; |
|
|
|
import com.bonait.bnframework.common.helper.ThreadManager; |
|
|
|
import com.bonait.bnframework.common.message.MessageManager; |
|
|
|
import com.bonait.bnframework.common.modbus.ModbusTcpMainServer; |
|
|
@@ -137,9 +138,12 @@ public class ExecuteTheRecipe { |
|
|
|
//1.解析 |
|
|
|
if (IsForcedEnd) { |
|
|
|
ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); |
|
|
|
ExecuteTheRecipe.showlog("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
ToastUtils.info("开始执行:" + recipe.sort + "、" + recipe.processms); |
|
|
|
ExecuteTheRecipe.showlog("开始执行:" + recipe.sort + "、" + recipe.processms); |
|
|
|
|
|
|
|
if (recipe.materialType == 0)//正常物料 |
|
|
|
{ |
|
|
|
//先到达抽料位 |
|
|
@@ -231,6 +235,8 @@ public class ExecuteTheRecipe { |
|
|
|
BPA_SILOS silos = entry.getKey(); |
|
|
|
Integer val = entry.getValue(); |
|
|
|
String name = "料仓" + silos.num + "下料完成"; |
|
|
|
ExecuteTheRecipe.showlog("等待"+name); |
|
|
|
|
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
long a = System.currentTimeMillis(); |
|
|
|
while (!IsComplete[0] && !IsForcedEnd) { |
|
|
@@ -240,11 +246,14 @@ public class ExecuteTheRecipe { |
|
|
|
Object sb = ReadPLC(name);// ListeningValue.get(name); |
|
|
|
if (sb != null) { |
|
|
|
IsComplete[0] = (boolean) (sb); |
|
|
|
ExecuteTheRecipe.showlog("正常等待结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
} |
|
|
|
ToastUtils.info(name); |
|
|
|
ExecuteTheRecipe.showlog(name); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception ex) { |
|
|
@@ -351,6 +360,7 @@ public class ExecuteTheRecipe { |
|
|
|
ExecuteCurrentOperation.Run("液体料|" + silos.num); |
|
|
|
} |
|
|
|
ToastUtils.info("准备写入PLC仓号需求:" + silos.num + "," + val / 10.0); |
|
|
|
ExecuteTheRecipe.showlog("准备写入PLC仓号需求:" + silos.num + "," + val / 10.0); |
|
|
|
|
|
|
|
String name = "料仓" + silos.num + "下料完成"; |
|
|
|
ExecuteTheRecipe.WritePLC(name, false, null); |
|
|
@@ -360,12 +370,15 @@ public class ExecuteTheRecipe { |
|
|
|
WritePLC("料仓" + silos.num + "需求值", val, new IWriteCallBack() { |
|
|
|
@Override |
|
|
|
public void onSuccess() { |
|
|
|
BottomClick("料仓" + silos.num + "下料"); |
|
|
|
ExecuteTheRecipe.showlog("需求值写入成功!"); |
|
|
|
IsComplete[0] = true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
ExecuteTheRecipe.showlog("需求值写入失败!尝试再次写入...错误原因:"+ErrorMsg); |
|
|
|
WritePLC("料仓" + silos.num + "需求值", val,null); |
|
|
|
IsComplete[0] = true; |
|
|
|
} |
|
|
|
}); |
|
|
|
long a = System.currentTimeMillis(); |
|
|
@@ -376,6 +389,9 @@ public class ExecuteTheRecipe { |
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
} |
|
|
|
|
|
|
|
BottomClick("料仓" + silos.num + "下料"); |
|
|
|
ExecuteTheRecipe.showlog("料仓" + silos.num + "下料"); |
|
|
|
|
|
|
|
//減去料仓数量 |
|
|
|
int otherG = silos.silosmargin - (val / 10); |
|
|
|
QueryDB.UpdateYL(silos.id, otherG >= 0 ? otherG : 0); |
|
|
@@ -396,6 +412,7 @@ public class ExecuteTheRecipe { |
|
|
|
private static void Write_PLC_Stir(HashMap<String, String> data) { |
|
|
|
try { |
|
|
|
int val = 0; |
|
|
|
ExecuteTheRecipe.showlog( "准备写入工序-------搅拌"); |
|
|
|
|
|
|
|
for (HashMap.Entry<String, String> entry : data.entrySet()) { |
|
|
|
String key = entry.getKey(); |
|
|
@@ -411,10 +428,13 @@ public class ExecuteTheRecipe { |
|
|
|
WritePLC(key, writeValue, new IWriteCallBack() { |
|
|
|
@Override |
|
|
|
public void onSuccess() { |
|
|
|
ExecuteTheRecipe.showlog( "成功写入工序-------搅拌,挡位-"+writeValue); |
|
|
|
if (writeValue == 0) { |
|
|
|
WritePLC("搅拌", false, null); |
|
|
|
ExecuteTheRecipe.showlog( "成功写入工序-------搅拌,开关-false"); |
|
|
|
} else { |
|
|
|
WritePLC("搅拌", true, null); |
|
|
|
ExecuteTheRecipe.showlog( "成功写入工序-------搅拌,开关-true"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -441,6 +461,8 @@ public class ExecuteTheRecipe { |
|
|
|
*/ |
|
|
|
private static void Write_PLC_Location(HashMap<String, String> data) { |
|
|
|
try { |
|
|
|
ExecuteTheRecipe.showlog( "准备写入工序-------锅口朝向"); |
|
|
|
|
|
|
|
int val = 0; |
|
|
|
for (HashMap.Entry<String, String> entry : data.entrySet()) { |
|
|
|
String key = entry.getKey(); |
|
|
@@ -465,11 +487,14 @@ public class ExecuteTheRecipe { |
|
|
|
} |
|
|
|
//原点位,等待机器移动倒响应位置 |
|
|
|
BottomClick1(value); |
|
|
|
ExecuteTheRecipe.showlog( "成功写入工序-------锅口朝向-"+value+"-等待锅口移动中..."); |
|
|
|
|
|
|
|
//一直等待机器移动到该位置,否则就一直等待 6s超时 |
|
|
|
String name = value + "反馈"; |
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
long a = System.currentTimeMillis(); |
|
|
|
Log.e("等待反馈", name + ",等待中"); |
|
|
|
ExecuteTheRecipe.showlog( name + ",等待中"); |
|
|
|
|
|
|
|
while (!IsComplete[0] && !IsForcedEnd) { |
|
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
|
break; |
|
|
@@ -477,12 +502,12 @@ public class ExecuteTheRecipe { |
|
|
|
Object sb = ReadPLC(name);//ListeningValue.get(name); |
|
|
|
if (sb != null) { |
|
|
|
IsComplete[0] = (boolean) (sb); |
|
|
|
ExecuteTheRecipe.showlog( "正常等待反馈信号结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
} |
|
|
|
Log.e("等待反馈", name + ",等待结束"); |
|
|
|
|
|
|
|
ExecuteTheRecipe.showlog( name + ",等待结束。"+"炒锅到达" + value + ",继续制作!!!"); |
|
|
|
ToastUtils.info("炒锅到达" + value + ",继续制作!!!"); |
|
|
|
} |
|
|
|
} |
|
|
@@ -503,6 +528,8 @@ public class ExecuteTheRecipe { |
|
|
|
*/ |
|
|
|
private static void Write_PLC_Ingredients(HashMap<String, String> data) { |
|
|
|
try { |
|
|
|
ExecuteTheRecipe.showlog( "准备写入工序-------主料"); |
|
|
|
|
|
|
|
//是否手动 |
|
|
|
boolean ishand = true; |
|
|
|
ToastUtils.info("准备倒入主料!"); |
|
|
@@ -546,6 +573,7 @@ public class ExecuteTheRecipe { |
|
|
|
String title = "手动投料-温馨提示!"; |
|
|
|
String message = "客官请投入主料,[" + name + "]重量" + zl + "g,投入后点击[确定]继续流程!"; |
|
|
|
//ExecuteTheRecipe.WritePLC("暂停开关", true, null); |
|
|
|
ExecuteTheRecipe.showlog( "等待手动投入主料:"+name); |
|
|
|
|
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
Activity activity = findActivity(context); |
|
|
@@ -575,6 +603,7 @@ public class ExecuteTheRecipe { |
|
|
|
} |
|
|
|
//ExecuteTheRecipe.WritePLC("暂停开关", false, null); |
|
|
|
ToastUtils.info("确定完成,继续制作!"); |
|
|
|
ExecuteTheRecipe.showlog( "手动已确认投入主料:"+name+"-继续流程"); |
|
|
|
} else { |
|
|
|
//自动投料 |
|
|
|
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { |
|
|
@@ -593,9 +622,12 @@ public class ExecuteTheRecipe { |
|
|
|
|
|
|
|
//1.去某一个位置 |
|
|
|
BottomClick1("平移-去" + writeValue); |
|
|
|
ExecuteTheRecipe.showlog( "平移-去" + writeValue); |
|
|
|
|
|
|
|
|
|
|
|
Log.d("平移", "平移-去" + writeValue); |
|
|
|
ExecuteTheRecipe.showlog( "等待:" + "平移轴在" + writeValue); |
|
|
|
|
|
|
|
//一直等待机器移动到该位置,否则就一直等待 6s超时 |
|
|
|
String name = "平移轴在" + writeValue; |
|
|
|
final boolean[] IsComplete = {false}; |
|
|
@@ -607,14 +639,19 @@ public class ExecuteTheRecipe { |
|
|
|
Object sb = ReadPLC(name);// ListeningValue.get(name); |
|
|
|
if (sb != null) { |
|
|
|
IsComplete[0] = (boolean) (sb); |
|
|
|
ExecuteTheRecipe.showlog( "正常等待反馈信号结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
} |
|
|
|
Log.d("平移", name + "已经就位"); |
|
|
|
ExecuteTheRecipe.showlog( name + "已经就位"); |
|
|
|
|
|
|
|
//2.给倒菜启动 |
|
|
|
BottomClick1("主料"); |
|
|
|
ExecuteTheRecipe.showlog( "到菜启动"); |
|
|
|
ExecuteTheRecipe.showlog( "等待:" + "倒菜完成"); |
|
|
|
|
|
|
|
name = "倒菜完成"; |
|
|
|
IsComplete[0] = false; |
|
|
|
a = System.currentTimeMillis(); |
|
|
@@ -625,10 +662,14 @@ public class ExecuteTheRecipe { |
|
|
|
Object sb = ReadPLC(name);// ListeningValue.get(name); |
|
|
|
if (sb != null) { |
|
|
|
IsComplete[0] = (boolean) (sb); |
|
|
|
ExecuteTheRecipe.showlog( "正常等待反馈信号结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
} |
|
|
|
|
|
|
|
ExecuteTheRecipe.showlog( "主料倒入完成,继续制作!"); |
|
|
|
|
|
|
|
ToastUtils.info("主料倒入完成,继续制作!"); |
|
|
|
|
|
|
|
} |
|
|
@@ -671,7 +712,7 @@ public class ExecuteTheRecipe { |
|
|
|
} |
|
|
|
|
|
|
|
Log.d("烹饪时间", "烹饪时间完成了"); |
|
|
|
|
|
|
|
ExecuteTheRecipe.showlog( "烹饪时间完成了"); |
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
ToastUtils.error("异常信息:" + ex.getMessage()); |
|
|
@@ -734,6 +775,8 @@ public class ExecuteTheRecipe { |
|
|
|
*/ |
|
|
|
private static void Write_PLC_Heating(HashMap<String, String> data) { |
|
|
|
try { |
|
|
|
ExecuteTheRecipe.showlog( "准备写入工序-------加热"); |
|
|
|
|
|
|
|
int val = 0; |
|
|
|
for (HashMap.Entry<String, String> entry : data.entrySet()) { |
|
|
|
String key = entry.getKey(); |
|
|
@@ -747,14 +790,32 @@ public class ExecuteTheRecipe { |
|
|
|
ExecuteCurrentOperation.Run("加热" + "|" + writeValue); |
|
|
|
} |
|
|
|
//写加热挡位 |
|
|
|
WritePLC(key, writeValue, null); |
|
|
|
if (writeValue == 0) { |
|
|
|
ConfigName.getInstance().IsOpenHuoLi = false; |
|
|
|
WritePLC("加热", false, null); |
|
|
|
} else { |
|
|
|
ConfigName.getInstance().IsOpenHuoLi = true; |
|
|
|
WritePLC("加热", true, null); |
|
|
|
} |
|
|
|
WritePLC(key, writeValue, new IWriteCallBack() { |
|
|
|
@Override |
|
|
|
public void onSuccess() { |
|
|
|
ExecuteTheRecipe.showlog( "写加热挡位:"+writeValue+"成功"); |
|
|
|
if (writeValue == 0) { |
|
|
|
ConfigName.getInstance().IsOpenHuoLi = false; |
|
|
|
WritePLC("加热", false, null); |
|
|
|
} else { |
|
|
|
ConfigName.getInstance().IsOpenHuoLi = true; |
|
|
|
WritePLC("加热", true, null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
ExecuteTheRecipe.showlog( "写加热挡位:"+writeValue+"失败,错误原因:"+ErrorMsg); |
|
|
|
if (writeValue == 0) { |
|
|
|
ConfigName.getInstance().IsOpenHuoLi = false; |
|
|
|
WritePLC("加热", false, null); |
|
|
|
} else { |
|
|
|
ConfigName.getInstance().IsOpenHuoLi = true; |
|
|
|
WritePLC("加热", true, null); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -818,6 +879,8 @@ public class ExecuteTheRecipe { |
|
|
|
*/ |
|
|
|
private static void Write_PLC_ParallelDischarge(HashMap<String, String> data) { |
|
|
|
try { |
|
|
|
ExecuteTheRecipe.showlog( "准备写入工序-------并行出料"); |
|
|
|
|
|
|
|
int val = 0;int cl_value=0; |
|
|
|
for (HashMap.Entry<String, String> entry : data.entrySet()) { |
|
|
|
String key = entry.getKey(); |
|
|
@@ -854,10 +917,14 @@ public class ExecuteTheRecipe { |
|
|
|
|
|
|
|
Thread.sleep(200);//等待写入完成 |
|
|
|
|
|
|
|
|
|
|
|
//一直等待下料完成 否则就一直等待 40s超时 |
|
|
|
for (Map.Entry<BPA_SILOS, Integer> entry : formulation.entrySet()) { |
|
|
|
BPA_SILOS silos = entry.getKey(); |
|
|
|
|
|
|
|
String name = "料仓" + silos.num + "下料完成"; |
|
|
|
ExecuteTheRecipe.showlog( "等待:"+name); |
|
|
|
|
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
long a = System.currentTimeMillis(); |
|
|
|
while (!IsComplete[0] && !IsForcedEnd) { |
|
|
@@ -867,10 +934,12 @@ public class ExecuteTheRecipe { |
|
|
|
Object sb = ReadPLC(name);// ListeningValue.get(name); |
|
|
|
if (sb != null) { |
|
|
|
IsComplete[0] = (boolean) (sb); |
|
|
|
ExecuteTheRecipe.showlog( "正常等待反馈信号结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
} |
|
|
|
ExecuteTheRecipe.showlog( name); |
|
|
|
ToastUtils.info(name); |
|
|
|
} |
|
|
|
|
|
|
@@ -914,6 +983,7 @@ public class ExecuteTheRecipe { |
|
|
|
private static void Write_PLC_Outdishes(HashMap<String, String> data) { |
|
|
|
try { |
|
|
|
ToastUtils.info("准备出菜!"); |
|
|
|
ExecuteTheRecipe.showlog("准备出菜!"); |
|
|
|
|
|
|
|
//先延迟 |
|
|
|
for (HashMap.Entry<String, String> entry : data.entrySet()) { |
|
|
@@ -935,6 +1005,8 @@ public class ExecuteTheRecipe { |
|
|
|
|
|
|
|
//一直等待机器移动到该位置,否则就一直等待 6s超时 |
|
|
|
String name = "出餐启动反馈"; |
|
|
|
ExecuteTheRecipe.showlog("等待:出餐启动反馈"); |
|
|
|
|
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
long a = System.currentTimeMillis(); |
|
|
|
while (!IsComplete[0] && !IsForcedEnd) { |
|
|
@@ -944,12 +1016,13 @@ public class ExecuteTheRecipe { |
|
|
|
Object sb = ReadPLC(name);//ListeningValue.get(name); |
|
|
|
if (sb != null) { |
|
|
|
IsComplete[0] = (boolean) (sb); |
|
|
|
ExecuteTheRecipe.showlog( "正常等待反馈信号结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
} |
|
|
|
|
|
|
|
ToastUtils.info("出菜完成,锅体准备回到原位!"); |
|
|
|
ExecuteTheRecipe.showlog("出菜完成,锅体准备回到原位!"); |
|
|
|
} catch (Exception ex) { |
|
|
|
ToastUtils.error("异常信息:" + ex.getMessage()); |
|
|
|
} |
|
|
@@ -963,6 +1036,7 @@ public class ExecuteTheRecipe { |
|
|
|
private static void Write_PLC_CleanPan(HashMap<String, String> data) { |
|
|
|
try { |
|
|
|
ToastUtils.info("准备清洗!"); |
|
|
|
ExecuteTheRecipe.showlog("准备清洗!"); |
|
|
|
//先延迟 |
|
|
|
for (HashMap.Entry<String, String> entry : data.entrySet()) { |
|
|
|
String key = entry.getKey(); |
|
|
@@ -982,6 +1056,7 @@ public class ExecuteTheRecipe { |
|
|
|
ExecuteTheRecipe.WritePLC(name,false,null); |
|
|
|
|
|
|
|
BottomClick1("炒锅清洗"); |
|
|
|
ExecuteTheRecipe.showlog("等待:炒锅清洗反馈!"); |
|
|
|
|
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
long a = System.currentTimeMillis(); |
|
|
@@ -992,11 +1067,13 @@ public class ExecuteTheRecipe { |
|
|
|
Object sb = ReadPLC(name);//ListeningValue.get(name); |
|
|
|
if (sb != null) { |
|
|
|
IsComplete[0] = (boolean) (sb); |
|
|
|
ExecuteTheRecipe.showlog( "正常等待反馈信号结束"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
} |
|
|
|
|
|
|
|
ExecuteTheRecipe.showlog("炒锅清洗完成!"); |
|
|
|
ToastUtils.info("炒锅清洗完成!"); |
|
|
|
} catch (Exception ex) { |
|
|
|
ToastUtils.error("异常信息:" + ex.getMessage()); |
|
|
@@ -2066,6 +2143,8 @@ public class ExecuteTheRecipe { |
|
|
|
* @param delay |
|
|
|
*/ |
|
|
|
public static void ThreadDelay(int delay) { |
|
|
|
ExecuteTheRecipe.showlog( "工序线程等待-------时长:"+delay+"秒,请耐心等待,开始计时!"); |
|
|
|
|
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd) // |
|
|
|
{ |
|
|
@@ -2074,6 +2153,20 @@ public class ExecuteTheRecipe { |
|
|
|
} catch (InterruptedException ex) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
long endTime = System.currentTimeMillis(); //结束时间 |
|
|
|
int time = (int) ((endTime - startTime) / 1000); |
|
|
|
ExecuteTheRecipe.showlog( "工序线程等待结束-------总耗时:"+time); |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
|
//region 显示日志 |
|
|
|
/** |
|
|
|
* 显示日志 |
|
|
|
*/ |
|
|
|
public static void showlog(String msg) |
|
|
|
{ |
|
|
|
Log.e("hbl", msg); |
|
|
|
} |
|
|
|
//endregion |
|
|
|
} |