@@ -60,6 +60,9 @@ public class ExecuteTheRecipe { | |||
//public static int whileTime = 40; | |||
public static int whileTime = 100; | |||
//手动操作耗时时长 | |||
public static int HandTime=0; | |||
/** | |||
* 监听变量值 | |||
*/ | |||
@@ -110,6 +113,11 @@ public class ExecuteTheRecipe { | |||
* 通知版本号更新显示 | |||
*/ | |||
public static IRun NotifyVersionNumUpdates = null; | |||
/** | |||
* 通知手动暂停 | |||
*/ | |||
public static IRunT NoticeHandSuspension = null; | |||
//endregion | |||
//region 强制结束 | |||
@@ -541,6 +549,8 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.WritePLC("暂停开关", true, null); | |||
} | |||
ModbusTcpServer.get().WriteBool("M52.1", (boolean) true, null); | |||
long startTime = System.currentTimeMillis(); //起始时间 | |||
if(NoticeHandSuspension!=null){NoticeHandSuspension.Run(true);} | |||
final boolean[] IsComplete = {false}; | |||
Activity activity = findActivity(context); | |||
@@ -573,6 +583,11 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.WritePLC("暂停开关", false, null); | |||
} | |||
ModbusTcpServer.get().WriteBool("M52.1", (boolean) false, null); | |||
long endTime = System.currentTimeMillis(); //结束时间 | |||
int time = (int) ((endTime - startTime) / 1000); | |||
HandTime=HandTime+time; | |||
if(NoticeHandSuspension!=null){NoticeHandSuspension.Run(false);} | |||
ExecuteTheRecipe.showlog("手动已确认投入主料:" + name + "-继续流程"); | |||
} else { | |||
@@ -948,7 +963,14 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.showlog("工序:手动投料," + name + "," + zl); | |||
String title = "手动投料-温馨提示!"; | |||
String message = "客官请投入主料,[" + name + "]重量" + zl + "g,投入后点击[确定]继续流程!"; | |||
ExecuteTheRecipe.WritePLC("暂停开关", true, null); | |||
if (ConfigName.getInstance().WhetherManualFeedingSuspended.contains("是")) { | |||
ExecuteTheRecipe.WritePLC("暂停开关", true, null); | |||
} | |||
ModbusTcpServer.get().WriteBool("M52.1", (boolean) true, null); | |||
long startTime = System.currentTimeMillis(); //起始时间 | |||
if(NoticeHandSuspension!=null){NoticeHandSuspension.Run(true);} | |||
final boolean[] IsComplete = {false}; | |||
Activity activity = findActivity(context); | |||
@@ -974,7 +996,17 @@ public class ExecuteTheRecipe { | |||
while (!IsComplete[0]) { | |||
Thread.sleep(100);//10 *6 | |||
} | |||
ExecuteTheRecipe.WritePLC("暂停开关", false, null); | |||
if (ConfigName.getInstance().WhetherManualFeedingSuspended.contains("是")) { | |||
ExecuteTheRecipe.WritePLC("暂停开关", false, null); | |||
} | |||
ModbusTcpServer.get().WriteBool("M52.1", (boolean) false, null); | |||
long endTime = System.currentTimeMillis(); //结束时间 | |||
int time = (int) ((endTime - startTime) / 1000); | |||
HandTime=HandTime+time; | |||
if(NoticeHandSuspension!=null){NoticeHandSuspension.Run(false);} | |||
ExecuteTheRecipe.showlog("确定完成,继续制作!"); | |||
} else { | |||
//自动投料 | |||
@@ -1075,7 +1107,12 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.showlog("工序:手动投料," + name + "," + zl); | |||
String title = "手动投料-温馨提示!"; | |||
String message = "客官请投入主料,[" + name + "]重量" + zl + "g,投入后点击[确定]继续流程!"; | |||
ExecuteTheRecipe.WritePLC("暂停开关", true, null); | |||
if (ConfigName.getInstance().WhetherManualFeedingSuspended.contains("是")) { | |||
ExecuteTheRecipe.WritePLC("暂停开关", true, null); | |||
} | |||
ModbusTcpServer.get().WriteBool("M52.1", (boolean) true, null); | |||
long startTime = System.currentTimeMillis(); //起始时间 | |||
if(NoticeHandSuspension!=null){NoticeHandSuspension.Run(true);} | |||
final boolean[] IsComplete = {false}; | |||
Activity activity = findActivity(context); | |||
@@ -1103,7 +1140,16 @@ public class ExecuteTheRecipe { | |||
while (!IsComplete[0]) { | |||
Thread.sleep(100);//10 *6 | |||
} | |||
ExecuteTheRecipe.WritePLC("暂停开关", false, null); | |||
if (ConfigName.getInstance().WhetherManualFeedingSuspended.contains("是")) { | |||
ExecuteTheRecipe.WritePLC("暂停开关", false, null); | |||
} | |||
ModbusTcpServer.get().WriteBool("M52.1", (boolean) false, null); | |||
long endTime = System.currentTimeMillis(); //结束时间 | |||
int time = (int) ((endTime - startTime) / 1000); | |||
HandTime=HandTime+time; | |||
if(NoticeHandSuspension!=null){NoticeHandSuspension.Run(false);} | |||
ExecuteTheRecipe.showlog("确定完成,继续制作!"); | |||
} else { | |||
//自动投料 | |||
@@ -1429,6 +1475,7 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.WritePLC("料仓2校准开关", false, null);//默认校准时间5秒 | |||
ExecuteTheRecipe.WritePLC("料仓3校准开关", false, null);//默认校准时间5秒 | |||
ModbusTcpServer.get().WriteBool("M52.1", (boolean) false, null); | |||
//读取版本号 | |||
ModbusTcpServer.get().ReadInt("VD1100", 1, val -> { | |||
PlcVersion= String.valueOf(val[0]); | |||
@@ -22,6 +22,7 @@ import com.bonait.bnframework.common.db.QueryDB; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; | |||
import com.bonait.bnframework.common.helper.CountDownTimerExt; | |||
import com.bonait.bnframework.common.helper.I.IRunT; | |||
import com.bonait.bnframework.common.helper.I.IThread; | |||
import com.bonait.bnframework.common.helper.I.MyClickListener; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
@@ -368,6 +369,7 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
ExecuteTheRecipe.showlog("开始烹饪菜谱【"+goods.name+"】"); | |||
ModbusTcpServer.get().WriteBool("M52.0", (boolean) true, null); | |||
ExecuteTheRecipe.HandTime=0;//默认将手动操作时间复位 | |||
try { | |||
//获取工艺 | |||
@@ -411,8 +413,10 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
ExecuteTheRecipe.showlog("结束烹饪菜谱【"+goods.name+"】,关闭搅拌、关闭加热,"+String.format("方法使用时间 %d s", time)); | |||
if (!ExecuteTheRecipe.IsForcedEnd) { | |||
QueryDB.UpdateGoodsMakeTime(goods.id, time); | |||
int ztime=time-ExecuteTheRecipe.HandTime; | |||
QueryDB.UpdateGoodsMakeTime(goods.id, ztime>0?ztime:time); | |||
} | |||
ExecuteTheRecipe.HandTime=0;//默认将手动操作时间复位 | |||
ExecuteTheRecipe.all_list = new ArrayList<>(); | |||
runOnUiThread(new Runnable() { | |||
@@ -549,6 +553,22 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
} | |||
}); | |||
makeThreadDC.start(); | |||
ExecuteTheRecipe.NoticeHandSuspension=new IRunT() { | |||
@Override | |||
public void Run(Object o) { | |||
if(IsRunThread) | |||
{ | |||
if((boolean) o) | |||
{ | |||
onRecordPause(); | |||
}else | |||
{ | |||
onRecordPauseStart(); | |||
} | |||
} | |||
} | |||
}; | |||
} | |||
/** | |||
@@ -41,6 +41,8 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODS; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; | |||
import com.bonait.bnframework.common.db.res.StatusMode; | |||
import com.bonait.bnframework.common.helper.ByteHelper; | |||
import com.bonait.bnframework.common.helper.CountDownTimerExt; | |||
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.I.MyClickListener; | |||
@@ -575,6 +577,7 @@ public class Home1Fragment extends BaseFragment { | |||
ExecuteTheRecipe.showlog("--------------------------------------"); | |||
ExecuteTheRecipe.showlog("开始烹饪菜谱【"+good.name+"】"); | |||
ModbusTcpServer.get().WriteBool("M52.0", (boolean) true, null); | |||
ExecuteTheRecipe.HandTime=0;//默认将手动操作时间复位 | |||
try { | |||
//获取工艺 | |||
@@ -608,8 +611,10 @@ public class Home1Fragment extends BaseFragment { | |||
ExecuteTheRecipe.showlog("结束烹饪菜谱【"+good.name+"】,关闭搅拌、关闭加热,"+String.format("方法使用时间 %d s", time)); | |||
if (!ExecuteTheRecipe.IsForcedEnd) { | |||
QueryDB.UpdateGoodsMakeTime(good.id, time); | |||
int ztime=time-ExecuteTheRecipe.HandTime; | |||
QueryDB.UpdateGoodsMakeTime(good.id, ztime>0?ztime:time); | |||
} | |||
ExecuteTheRecipe.HandTime=0;//默认将手动操作时间复位 | |||
ExecuteTheRecipe.all_list = new ArrayList<>(); | |||
@@ -764,6 +769,22 @@ public class Home1Fragment extends BaseFragment { | |||
} | |||
}); | |||
makeThreadUI.start(); | |||
ExecuteTheRecipe.NoticeHandSuspension=new IRunT() { | |||
@Override | |||
public void Run(Object o) { | |||
if(IsRunThread) | |||
{ | |||
if((boolean) o) | |||
{ | |||
onRecordPause(); | |||
}else | |||
{ | |||
onRecordPauseStart(); | |||
} | |||
} | |||
} | |||
}; | |||
} | |||
/** | |||
@@ -887,7 +908,7 @@ public class Home1Fragment extends BaseFragment { | |||
} | |||
} | |||
private CountDownTimer countDownTimer = null;//计时器 | |||
private CountDownTimerExt countDownTimer = null;//计时器 | |||
/** | |||
* 计时器 | |||
@@ -899,15 +920,15 @@ public class Home1Fragment extends BaseFragment { | |||
public void TimerCount(int alltime, boolean status) { | |||
if (status) { | |||
if (countDownTimer == null) { | |||
countDownTimer = new CountDownTimer(alltime * 1000, 1000) { | |||
countDownTimer = new CountDownTimerExt(alltime * 1000, 1000) { | |||
@Override | |||
public void onTick(long millisUntilFinished) { | |||
public void onTimerTick(long millisUntilFinished) { | |||
int overtime = (int) ((millisUntilFinished) / 1000);//剩余时间 | |||
SetProcesssUI(alltime, alltime - overtime); | |||
} | |||
@Override | |||
public void onFinish() { | |||
public void onTimerFinish() { | |||
SetProcesssUI(alltime, alltime);//进度条100% | |||
} | |||
}; | |||
@@ -915,12 +936,26 @@ public class Home1Fragment extends BaseFragment { | |||
countDownTimer.start(); | |||
} else { | |||
if (countDownTimer != null) { | |||
countDownTimer.cancel(); | |||
countDownTimer.stop(); | |||
countDownTimer = null; | |||
} | |||
} | |||
} | |||
/** | |||
* 暂停 | |||
*/ | |||
public void onRecordPause() { | |||
countDownTimer.pause(); | |||
} | |||
/** | |||
* 继续 | |||
*/ | |||
public void onRecordPauseStart() { | |||
countDownTimer.resume(); | |||
} | |||
/** | |||
* 点击事件 | |||
* | |||
@@ -14,8 +14,10 @@ import androidx.annotation.Nullable; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ExecuteTheRecipe; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.helper.I.MyClickListener; | |||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | |||
@@ -96,6 +98,17 @@ public class imagebuttom extends LinearLayout { | |||
}else | |||
{ | |||
if (!ConfigName.getInstance().PlcIsConnect) { | |||
ToastUtils.warning("PLC未准备就绪!!!"); | |||
return; | |||
} | |||
Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成"); | |||
if (chushiover == null || !(boolean) chushiover) { | |||
ToastUtils.warning("设备未初始化,请先手动初始化设备!!!"); | |||
return; | |||
} | |||
String title = "开始操作提示!"; | |||
String message = "请问客官确定要开始制作吗,小菠萝好开心呀,马上就有好吃的耶?"; | |||
AlertDialogUtils.showDialog(getContext(), title, message, new QMUIDialogAction.ActionListener() { | |||