@@ -1586,7 +1586,7 @@ public class ExecuteTheRecipe { | |||
ModbusTcpServer.get().WriteBool("M52.1", (boolean) false, null); | |||
//读取版本号 | |||
ModbusTcpServer.get().ReadInt("VD1100", 1, val -> { | |||
PlcVersion= String.valueOf(val[0]); | |||
PlcVersion= String.valueOf(val[0]+""); | |||
if(NotifyVersionNumUpdates!=null) | |||
{ | |||
NotifyVersionNumUpdates.Run(); | |||
@@ -185,9 +185,13 @@ public class ConfigName { | |||
//region PlC连接参数 | |||
/** | |||
* Plc是否连接 | |||
* 老窗体是否显示 | |||
*/ | |||
public boolean IsShow = false; | |||
/** | |||
* 新窗体是否显示 | |||
*/ | |||
public boolean IsShowNew = false; | |||
/** | |||
* Plc是否连接 | |||
*/ | |||
@@ -184,6 +184,7 @@ public class BottomNavigation2Activity extends BaseActivity { | |||
public void ReconnectModbus() { | |||
try { | |||
ConfigName.getInstance().IsShow=true; | |||
ConfigName.getInstance().IsShowNew=false; | |||
ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
@@ -195,7 +196,7 @@ public class BottomNavigation2Activity extends BaseActivity { | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
MessageLog.ShowInfo("老版本:PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} else { | |||
@@ -204,7 +205,7 @@ public class BottomNavigation2Activity extends BaseActivity { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!"); | |||
ModbusTcpServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
MessageLog.ShowInfo("老版本:PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} | |||
@@ -216,7 +217,7 @@ public class BottomNavigation2Activity extends BaseActivity { | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
MessageLog.ShowInfo("老版本:主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
} | |||
} else { | |||
@@ -225,7 +226,7 @@ public class BottomNavigation2Activity extends BaseActivity { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().MainAddress + " 主控PLC通讯正常,准备连接!"); | |||
ModbusTcpMainServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
MessageLog.ShowInfo("老版本:主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
} | |||
} | |||
@@ -106,7 +106,7 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
@Override | |||
protected void onDestroy() { | |||
ConfigData.getInstance().ColsePLC(); | |||
IsRunThread = false; | |||
ConfigName.getInstance().IsShowNew = false; | |||
if (makeThread != null) { | |||
makeThread = null; | |||
} | |||
@@ -282,18 +282,19 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
*/ | |||
public void ReconnectModbus() { | |||
try { | |||
ThreadManager.Get().StartLong("PLC断线重连线程-2", true, new IThread() { | |||
ConfigName.getInstance().IsShowNew=true; | |||
ConfigName.getInstance().IsShow=false; | |||
ThreadManager.Get().StartLong("PLC断线重连线程新界面", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
try { | |||
if(IsRunThread) | |||
{ | |||
if (ConfigName.getInstance().IsShowNew) { | |||
if (ConfigName.getInstance().PlcIsConnect) { | |||
//ping 不通 | |||
boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
MessageLog.ShowInfo("新版本:PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} else { | |||
@@ -302,7 +303,7 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!"); | |||
ModbusTcpServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("PLC状态断开,尝试连接..."); | |||
MessageLog.ShowInfo("新版本:PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
} | |||
} | |||
@@ -313,7 +314,7 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1); | |||
if (!status) //ping 不通 连接 | |||
{ | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
MessageLog.ShowInfo("新版本:主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
} | |||
} else { | |||
@@ -322,7 +323,7 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().MainAddress + " 主控PLC通讯正常,准备连接!"); | |||
ModbusTcpMainServer.ConnectPLC(); | |||
} else { | |||
MessageLog.ShowInfo("主控PLC状态断开,尝试连接..."); | |||
MessageLog.ShowInfo("新版本:主控PLC状态断开,尝试连接..."); | |||
ConfigName.getInstance().PlcMainIsConnect = false; | |||
} | |||
} | |||
@@ -354,7 +355,6 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
public Thread makeThread = null; | |||
public Thread makeThreadDC = null; | |||
public boolean IsRunThread = true; | |||
/** | |||
* 商品制作线程 | |||
@@ -364,15 +364,15 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
makeThread = new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (IsRunThread) { | |||
while (ConfigName.getInstance().IsShowNew) { | |||
try { | |||
if (ExecuteTheRecipe.IsStart && goods != null) { | |||
long startTime = System.currentTimeMillis(); //起始时间 | |||
ExecuteTheRecipe.showlog("--------------------------------------"); | |||
ExecuteTheRecipe.showlog("开始烹饪菜谱【"+goods.name+"】"); | |||
ExecuteTheRecipe.showlog("开始烹饪菜谱【" + goods.name + "】"); | |||
ModbusTcpServer.get().WriteBool("M52.0", (boolean) true, null); | |||
ExecuteTheRecipe.HandTime=0;//默认将手动操作时间复位 | |||
ExecuteTheRecipe.HandTime = 0;//默认将手动操作时间复位 | |||
try { | |||
//获取工艺 | |||
@@ -413,14 +413,14 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
long endTime = System.currentTimeMillis(); //结束时间 | |||
int time = (int) ((endTime - startTime) / 1000); | |||
Log.e("运行时长", String.format("方法使用时间 %d s", time)); | |||
ExecuteTheRecipe.showlog("结束烹饪菜谱【"+goods.name+"】,关闭搅拌、关闭加热,"+String.format("方法使用时间 %d s", time)); | |||
ExecuteTheRecipe.showlog("结束烹饪菜谱【" + goods.name + "】,关闭搅拌、关闭加热," + String.format("方法使用时间 %d s", time)); | |||
if (!ExecuteTheRecipe.IsForcedEnd) { | |||
int ztime=time-ExecuteTheRecipe.HandTime; | |||
goods.maketime=ztime>0?ztime:time; | |||
int ztime = time - ExecuteTheRecipe.HandTime; | |||
goods.maketime = ztime > 0 ? ztime : time; | |||
QueryDB.UpdateGoodsMakeTime(goods.id, goods.maketime); | |||
} | |||
ExecuteTheRecipe.HandTime=0;//默认将手动操作时间复位 | |||
ExecuteTheRecipe.HandTime = 0;//默认将手动操作时间复位 | |||
ExecuteTheRecipe.all_list = new ArrayList<>(); | |||
runOnUiThread(new Runnable() { | |||
@@ -432,7 +432,7 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
ToastUtils.info("客官,当前菜品已强制结束!!!"); | |||
//初始化 | |||
//ExecuteTheRecipe.BottomClick("初始化"); | |||
ExecuteTheRecipe.showlog("菜谱【"+goods.name+"】已强制结束..."); | |||
ExecuteTheRecipe.showlog("菜谱【" + goods.name + "】已强制结束..."); | |||
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖"))//通知任务结束 | |||
{ | |||
@@ -459,7 +459,7 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
makeThreadDC = new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (IsRunThread) { | |||
while (ConfigName.getInstance().IsShowNew) { | |||
try { | |||
if (ExecuteTheRecipe.IsStart && goods != null && gongxuIndex != 10000 && goodsrecipesL != null && MakeCipe != null) { | |||
@@ -558,41 +558,39 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
}); | |||
makeThreadDC.start(); | |||
ExecuteTheRecipe.NoticeHandSuspension=new IRunT() { | |||
ExecuteTheRecipe.NoticeHandSuspension = new IRunT() { | |||
@Override | |||
public void Run(Object o) { | |||
if(IsRunThread) | |||
{ | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
if((boolean) o) | |||
{ | |||
onRecordPause(); | |||
}else | |||
{ | |||
onRecordPauseStart(); | |||
if (ConfigName.getInstance().IsShowNew) { | |||
if (!isFinishing()) { | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
if ((boolean) o) { | |||
onRecordPause(); | |||
} else { | |||
onRecordPauseStart(); | |||
} | |||
} | |||
} | |||
}); | |||
}); | |||
} | |||
} | |||
} | |||
}; | |||
ExecuteTheRecipe.NoticeAtPresentTime=new IRunT() { | |||
ExecuteTheRecipe.NoticeAtPresentTime = new IRunT() { | |||
@Override | |||
public void Run(Object o) { | |||
if(IsRunThread) | |||
{ | |||
int k=(int) o; | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
cooking.SetMiaoShuTime(k); | |||
} | |||
}); | |||
if (ConfigName.getInstance().IsShowNew) { | |||
int k = (int) o; | |||
if (!isFinishing()) { | |||
runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
cooking.SetMiaoShuTime(k); | |||
} | |||
}); | |||
} | |||
} | |||
} | |||
}; | |||
@@ -683,14 +681,18 @@ public class BottomNavigationNewActivity extends BaseActivity { | |||
* 暂停 | |||
*/ | |||
public void onRecordPause() { | |||
countDownTimer.pause(); | |||
if (countDownTimer != null) { | |||
countDownTimer.pause(); | |||
} | |||
} | |||
/** | |||
* 继续 | |||
*/ | |||
public void onRecordPauseStart() { | |||
countDownTimer.resume(); | |||
if (countDownTimer != null) { | |||
countDownTimer.resume(); | |||
} | |||
} | |||
/** | |||
@@ -482,8 +482,7 @@ public class Home1Fragment extends BaseFragment { | |||
public boolean onTouch(View view, MotionEvent motionEvent) { | |||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { | |||
Log.e("鼠标", "按下: "); | |||
if (!IsMake(false)) | |||
{ | |||
if (!IsMake(false)) { | |||
return false; | |||
} | |||
int jd = (int) nifty_slider3.getValue(); | |||
@@ -515,8 +514,7 @@ public class Home1Fragment extends BaseFragment { | |||
public boolean onTouch(View view, MotionEvent motionEvent) { | |||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { | |||
Log.e("鼠标", "按下: "); | |||
if (!IsMake(false)) | |||
{ | |||
if (!IsMake(false)) { | |||
return false; | |||
} | |||
int jd = (int) nifty_slider3.getValue(); | |||
@@ -565,10 +563,9 @@ public class Home1Fragment extends BaseFragment { | |||
BPA_GOODSRECIPE MakeCipe = null; | |||
public Thread makeThread=null; | |||
public Thread makeThreadDC=null; | |||
public Thread makeThreadUI=null; | |||
public boolean IsRunThread=true; | |||
public Thread makeThread = null; | |||
public Thread makeThreadDC = null; | |||
public Thread makeThreadUI = null; | |||
/** | |||
* 商品制作线程 | |||
@@ -576,18 +573,18 @@ public class Home1Fragment extends BaseFragment { | |||
public void MakeThread() { | |||
ExecuteTheRecipe.context = context; | |||
makeThread=new Thread(new Runnable() { | |||
makeThread = new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (IsRunThread) { | |||
while (ConfigName.getInstance().IsShow) { | |||
try { | |||
if ( ExecuteTheRecipe.MakeStatus && good != null) { | |||
if (ExecuteTheRecipe.MakeStatus && good != null) { | |||
long startTime = System.currentTimeMillis(); //起始时间 | |||
ExecuteTheRecipe.showlog("--------------------------------------"); | |||
ExecuteTheRecipe.showlog("开始烹饪菜谱【"+good.name+"】"); | |||
ExecuteTheRecipe.showlog("开始烹饪菜谱【" + good.name + "】"); | |||
ModbusTcpServer.get().WriteBool("M52.0", (boolean) true, null); | |||
ExecuteTheRecipe.HandTime=0;//默认将手动操作时间复位 | |||
ExecuteTheRecipe.HandTime = 0;//默认将手动操作时间复位 | |||
try { | |||
//获取工艺 | |||
@@ -624,14 +621,14 @@ public class Home1Fragment extends BaseFragment { | |||
long endTime = System.currentTimeMillis(); //结束时间 | |||
int time = (int) ((endTime - startTime) / 1000); | |||
Log.e("运行时长", String.format("方法使用时间 %d s", time)); | |||
ExecuteTheRecipe.showlog("结束烹饪菜谱【"+good.name+"】,关闭搅拌、关闭加热,"+String.format("方法使用时间 %d s", time)); | |||
ExecuteTheRecipe.showlog("结束烹饪菜谱【" + good.name + "】,关闭搅拌、关闭加热," + String.format("方法使用时间 %d s", time)); | |||
if (!ExecuteTheRecipe.IsForcedEnd) { | |||
int ztime=time-ExecuteTheRecipe.HandTime; | |||
good.maketime=ztime>0?ztime:time; | |||
int ztime = time - ExecuteTheRecipe.HandTime; | |||
good.maketime = ztime > 0 ? ztime : time; | |||
QueryDB.UpdateGoodsMakeTime(good.id, good.maketime); | |||
} | |||
ExecuteTheRecipe.HandTime=0;//默认将手动操作时间复位 | |||
ExecuteTheRecipe.HandTime = 0;//默认将手动操作时间复位 | |||
ExecuteTheRecipe.all_list = new ArrayList<>(); | |||
@@ -645,8 +642,8 @@ public class Home1Fragment extends BaseFragment { | |||
{ | |||
ToastUtils.info("客官,当前菜品已强制结束!!!"); | |||
//初始化 | |||
// ExecuteTheRecipe.BottomClick("初始化"); | |||
ExecuteTheRecipe.showlog("菜谱【"+good.name+"】已强制结束..."); | |||
// ExecuteTheRecipe.BottomClick("初始化"); | |||
ExecuteTheRecipe.showlog("菜谱【" + good.name + "】已强制结束..."); | |||
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖"))//通知任务结束 | |||
{ | |||
ExecuteTheRecipe.WriteMainPLC("强制结束任务完成", true, null);//复位 | |||
@@ -669,13 +666,13 @@ public class Home1Fragment extends BaseFragment { | |||
}); | |||
makeThread.start(); | |||
makeThreadDC=new Thread(new Runnable() { | |||
makeThreadDC = new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (IsRunThread) { | |||
while (ConfigName.getInstance().IsShow) { | |||
try { | |||
if ( ExecuteTheRecipe.MakeStatus && good != null && gongxuIndex != 10000 && goodsrecipesL != null && MakeCipe != null) { | |||
if (ExecuteTheRecipe.MakeStatus && good != null && gongxuIndex != 10000 && goodsrecipesL != null && MakeCipe != null) { | |||
try { | |||
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { | |||
//获取工艺 | |||
@@ -771,10 +768,10 @@ public class Home1Fragment extends BaseFragment { | |||
}); | |||
makeThreadDC.start(); | |||
makeThreadUI=new Thread(new Runnable() { | |||
makeThreadUI = new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
while (IsRunThread) { | |||
while (ConfigName.getInstance().IsShow) { | |||
try { | |||
SxUI(); | |||
Thread.sleep(1000); | |||
@@ -786,38 +783,40 @@ public class Home1Fragment extends BaseFragment { | |||
}); | |||
makeThreadUI.start(); | |||
ExecuteTheRecipe.NoticeHandSuspension=new IRunT() { | |||
ExecuteTheRecipe.NoticeHandSuspension = new IRunT() { | |||
@Override | |||
public void Run(Object o) { | |||
if(IsRunThread) | |||
{ | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
if((boolean) o) | |||
{ | |||
onRecordPause(); | |||
}else | |||
{ | |||
onRecordPauseStart(); | |||
if (ConfigName.getInstance().IsShow) { | |||
Activity activity = getActivity(); | |||
if (activity != null) { | |||
activity.runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
if ((boolean) o) { | |||
onRecordPause(); | |||
} else { | |||
onRecordPauseStart(); | |||
} | |||
} | |||
} | |||
}); | |||
}); | |||
} | |||
} | |||
} | |||
}; | |||
ExecuteTheRecipe.NoticeAtPresentTime=new IRunT() { | |||
ExecuteTheRecipe.NoticeAtPresentTime = new IRunT() { | |||
@Override | |||
public void Run(Object o) { | |||
if(IsRunThread) | |||
{ | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
gongxutime.setText("预计等待:"+(int) o+"s"); | |||
} | |||
}); | |||
if (ConfigName.getInstance().IsShow) { | |||
Activity activity = getActivity(); | |||
if (activity != null) { | |||
activity.runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
gongxutime.setText("预计等待:" + (int) o + "s"); | |||
} | |||
}); | |||
} | |||
} | |||
} | |||
}; | |||
@@ -928,7 +927,7 @@ public class Home1Fragment extends BaseFragment { | |||
*/ | |||
public void SetBottonStatus(boolean status) { | |||
try { | |||
ExecuteTheRecipe.MakeStatus = status; | |||
ExecuteTheRecipe.MakeStatus = status; | |||
if (status) { | |||
startbutton.setImageResource(R.mipmap.tzzz); | |||
TimerCount(good.maketime, true);//开始计时器,记录进度条 | |||
@@ -984,14 +983,18 @@ public class Home1Fragment extends BaseFragment { | |||
* 暂停 | |||
*/ | |||
public void onRecordPause() { | |||
countDownTimer.pause(); | |||
if (countDownTimer != null) { | |||
countDownTimer.pause(); | |||
} | |||
} | |||
/** | |||
* 继续 | |||
*/ | |||
public void onRecordPauseStart() { | |||
countDownTimer.resume(); | |||
if (countDownTimer != null) { | |||
countDownTimer.resume(); | |||
} | |||
} | |||
/** | |||
@@ -1010,7 +1013,7 @@ public class Home1Fragment extends BaseFragment { | |||
ToastUtils.info("打开菜谱选择界面"); | |||
break; | |||
case R.id.startbutton: | |||
if ( ExecuteTheRecipe.MakeStatus ) { | |||
if (ExecuteTheRecipe.MakeStatus) { | |||
// ToastUtils.info("客官菜谱正在制作过程中,请耐心等待一下,马上就好啦!"); | |||
// return; | |||
//按钮点击 | |||
@@ -1148,7 +1151,7 @@ public class Home1Fragment extends BaseFragment { | |||
// return false; | |||
// } | |||
if (ExecuteTheRecipe.MakeStatus && k) { | |||
if (ExecuteTheRecipe.MakeStatus && k) { | |||
ToastUtils.warning("客官,商品制作未结束请勿进行其他操作.请耐心等待商品制作结束!!!"); | |||
return false; | |||
} | |||
@@ -1171,10 +1174,16 @@ public class Home1Fragment extends BaseFragment { | |||
public void onDestroy() { | |||
super.onDestroy(); | |||
Logger.d("第一页销毁"); | |||
IsRunThread=false; | |||
if(makeThread!=null){makeThread=null;} | |||
if(makeThreadDC!=null){makeThreadDC=null;} | |||
if(makeThreadUI!=null){makeThreadUI=null;} | |||
ConfigName.getInstance().IsShow=false; | |||
if (makeThread != null) { | |||
makeThread = null; | |||
} | |||
if (makeThreadDC != null) { | |||
makeThreadDC = null; | |||
} | |||
if (makeThreadUI != null) { | |||
makeThreadUI = null; | |||
} | |||
} | |||
/** | |||
@@ -1,6 +1,7 @@ | |||
package com.bonait.bnframework.modules.mine.fragment; | |||
import android.Manifest; | |||
import android.app.Activity; | |||
import android.content.Context; | |||
import android.content.Intent; | |||
import android.net.Uri; | |||
@@ -132,12 +133,16 @@ public class MyFragment extends BaseFragment { | |||
ExecuteTheRecipe.NotifyVersionNumUpdates=new IRun() { | |||
@Override | |||
public void Run() { | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
stvUpdate.setRightString(ConfigName.getInstance().Version+"|"+ ExecuteTheRecipe.PlcVersion); | |||
} | |||
}); | |||
Activity activity=getActivity(); | |||
if(activity!=null) | |||
{ | |||
activity.runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
stvUpdate.setRightString(ConfigName.getInstance().Version+"|"+ ExecuteTheRecipe.PlcVersion); | |||
} | |||
}); | |||
} | |||
} | |||
}; | |||
/* | |||