|
@@ -4,6 +4,7 @@ import android.app.Activity; |
|
|
import android.content.Context; |
|
|
import android.content.Context; |
|
|
import android.content.ContextWrapper; |
|
|
import android.content.ContextWrapper; |
|
|
import android.os.Handler; |
|
|
import android.os.Handler; |
|
|
|
|
|
import android.util.Log; |
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
import androidx.annotation.NonNull; |
|
|
|
|
|
|
|
@@ -147,12 +148,33 @@ public class ExecuteTheRecipe { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//endregion |
|
|
//endregion |
|
|
//写入PLC |
|
|
|
|
|
|
|
|
//写入PLC,直接出料,不用等待 |
|
|
for (Map.Entry<Integer, Integer> entry : formulation.entrySet()) { |
|
|
for (Map.Entry<Integer, Integer> entry : formulation.entrySet()) { |
|
|
Integer key = entry.getKey(); |
|
|
Integer key = entry.getKey(); |
|
|
Integer value = entry.getValue(); |
|
|
Integer value = entry.getValue(); |
|
|
Write_PLC_Material(key, value); |
|
|
Write_PLC_Material(key, value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//一直等待下料完成 否则就一直等待 6s超时 |
|
|
|
|
|
for (Map.Entry<Integer, Integer> entry : formulation.entrySet()) { |
|
|
|
|
|
Integer num = entry.getKey(); |
|
|
|
|
|
Integer val = entry.getValue(); |
|
|
|
|
|
String name = "料仓" + num + "下料完成"; |
|
|
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
|
|
long a = System.currentTimeMillis(); |
|
|
|
|
|
while (!IsComplete[0]) { |
|
|
|
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
|
|
|
break; |
|
|
|
|
|
} else { |
|
|
|
|
|
Object sb = ReadPLC(name);// ListeningValue.get(name); |
|
|
|
|
|
if (sb != null) { |
|
|
|
|
|
IsComplete[0] = (boolean) (sb); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
|
|
} |
|
|
|
|
|
ToastUtils.info(name); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (Exception ex) { |
|
|
} catch (Exception ex) { |
|
|
ToastUtils.error("异常信息:" + ex.getMessage()); |
|
|
ToastUtils.error("异常信息:" + ex.getMessage()); |
|
@@ -230,6 +252,8 @@ public class ExecuteTheRecipe { |
|
|
*/ |
|
|
*/ |
|
|
private static void Write_PLC_Material(int num, int val) { |
|
|
private static void Write_PLC_Material(int num, int val) { |
|
|
try { |
|
|
try { |
|
|
|
|
|
String name = "料仓" + num + "下料完成"; |
|
|
|
|
|
ExecuteTheRecipe.WritePLC(name, false, null); |
|
|
WritePLC("料仓" + num + "需求值", val, new IWriteCallBack() { |
|
|
WritePLC("料仓" + num + "需求值", val, new IWriteCallBack() { |
|
|
@Override |
|
|
@Override |
|
|
public void onSuccess() { |
|
|
public void onSuccess() { |
|
@@ -240,24 +264,7 @@ public class ExecuteTheRecipe { |
|
|
public void onFailure(String ErrorMsg) { |
|
|
public void onFailure(String ErrorMsg) { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
//一直等待下料完成 否则就一直等待 6s超时 |
|
|
|
|
|
String name = "料仓" + num + "下料完成"; |
|
|
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
|
|
long a = System.currentTimeMillis(); |
|
|
|
|
|
while (!IsComplete[0]) { |
|
|
|
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
|
|
|
break; |
|
|
|
|
|
} else { |
|
|
|
|
|
Object sb = ListeningValue.get(name); |
|
|
|
|
|
if (sb != null) { |
|
|
|
|
|
IsComplete[0] = (boolean) (sb); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
Thread.sleep(100);//10 *6 |
|
|
|
|
|
} |
|
|
|
|
|
ToastUtils.info("写入PLC仓号需求:" + num + "," + val); |
|
|
ToastUtils.info("写入PLC仓号需求:" + num + "," + val); |
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
} catch (Exception ex) { |
|
|
ToastUtils.error("异常信息:" + ex.getMessage()); |
|
|
ToastUtils.error("异常信息:" + ex.getMessage()); |
|
|
} |
|
|
} |
|
@@ -333,7 +340,7 @@ public class ExecuteTheRecipe { |
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
break; |
|
|
break; |
|
|
} else { |
|
|
} else { |
|
|
Object sb = ListeningValue.get(name); |
|
|
|
|
|
|
|
|
Object sb = ReadPLC(name);//ListeningValue.get(name); |
|
|
if (sb != null) { |
|
|
if (sb != null) { |
|
|
IsComplete[0] = (boolean) (sb); |
|
|
IsComplete[0] = (boolean) (sb); |
|
|
} |
|
|
} |
|
@@ -441,6 +448,7 @@ public class ExecuteTheRecipe { |
|
|
|
|
|
|
|
|
//1.去某一个位置 |
|
|
//1.去某一个位置 |
|
|
BottomClick("平移-去"+writeValue); |
|
|
BottomClick("平移-去"+writeValue); |
|
|
|
|
|
Log.d("平移", "平移-去"+writeValue); |
|
|
//一直等待机器移动到该位置,否则就一直等待 6s超时 |
|
|
//一直等待机器移动到该位置,否则就一直等待 6s超时 |
|
|
String name = "平移轴在"+writeValue; |
|
|
String name = "平移轴在"+writeValue; |
|
|
final boolean[] IsComplete = {false}; |
|
|
final boolean[] IsComplete = {false}; |
|
@@ -449,13 +457,14 @@ public class ExecuteTheRecipe { |
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
break; |
|
|
break; |
|
|
} else { |
|
|
} else { |
|
|
Object sb = ListeningValue.get(name); |
|
|
|
|
|
|
|
|
Object sb =ReadPLC(name);// ListeningValue.get(name); |
|
|
if (sb != null) { |
|
|
if (sb != null) { |
|
|
IsComplete[0] = (boolean) (sb); |
|
|
IsComplete[0] = (boolean) (sb); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Thread.sleep(100);//10 *6 |
|
|
Thread.sleep(100);//10 *6 |
|
|
} |
|
|
} |
|
|
|
|
|
Log.d("平移", name+"已经就位"); |
|
|
|
|
|
|
|
|
//2.给倒菜启动 |
|
|
//2.给倒菜启动 |
|
|
BottomClick("主料"); |
|
|
BottomClick("主料"); |
|
@@ -466,16 +475,15 @@ public class ExecuteTheRecipe { |
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
break; |
|
|
break; |
|
|
} else { |
|
|
} else { |
|
|
Object sb = ListeningValue.get(name); |
|
|
|
|
|
|
|
|
Object sb =ReadPLC(name);// ListeningValue.get(name); |
|
|
if (sb != null) { |
|
|
if (sb != null) { |
|
|
IsComplete[0] = (boolean) (sb); |
|
|
IsComplete[0] = (boolean) (sb); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
Thread.sleep(100);//10 *6 |
|
|
Thread.sleep(100);//10 *6 |
|
|
} |
|
|
} |
|
|
// |
|
|
|
|
|
ToastUtils.info("主料倒入完成,继续制作!"); |
|
|
ToastUtils.info("主料倒入完成,继续制作!"); |
|
|
BottomClick("平移-去1号位"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (Exception ex) { |
|
|
} catch (Exception ex) { |
|
@@ -589,8 +597,7 @@ public class ExecuteTheRecipe { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
BottomClick("出菜"); |
|
|
BottomClick("出菜"); |
|
|
WritePLC("搅拌", false, null); |
|
|
|
|
|
WritePLC("加热", false, null); |
|
|
|
|
|
|
|
|
|
|
|
//一直等待机器移动到该位置,否则就一直等待 6s超时 |
|
|
//一直等待机器移动到该位置,否则就一直等待 6s超时 |
|
|
String name = "出餐启动反馈"; |
|
|
String name = "出餐启动反馈"; |
|
|
final boolean[] IsComplete = {false}; |
|
|
final boolean[] IsComplete = {false}; |
|
@@ -599,7 +606,7 @@ public class ExecuteTheRecipe { |
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { |
|
|
break; |
|
|
break; |
|
|
} else { |
|
|
} else { |
|
|
Object sb = ListeningValue.get(name); |
|
|
|
|
|
|
|
|
Object sb =ReadPLC(name);//ListeningValue.get(name); |
|
|
if (sb != null) { |
|
|
if (sb != null) { |
|
|
IsComplete[0] = (boolean) (sb); |
|
|
IsComplete[0] = (boolean) (sb); |
|
|
} |
|
|
} |
|
|