diff --git a/app/src/main/java/com/bonait/bnframework/business/AddressData.java b/app/src/main/java/com/bonait/bnframework/business/AddressData.java index 0e34a0fd..71bb2098 100644 --- a/app/src/main/java/com/bonait/bnframework/business/AddressData.java +++ b/app/src/main/java/com/bonait/bnframework/business/AddressData.java @@ -53,7 +53,7 @@ public class AddressData { public static int AddIngredientsRequest=10; /** - * 炒锅强制结束信号 + * 炒锅强制结束完成信号 */ public static int FryingpanForceEnd=11; diff --git a/app/src/main/java/com/bonait/bnframework/business/ControlBase.java b/app/src/main/java/com/bonait/bnframework/business/ControlBase.java index 4817acd1..7d2e34b1 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ControlBase.java +++ b/app/src/main/java/com/bonait/bnframework/business/ControlBase.java @@ -212,6 +212,8 @@ public abstract class ControlBase { MbSlave.WriteBoolean(GetAddress(num,AddressData.PutMainMaterial),false);//复位放主料完成 MbSlave.WriteBoolean(GetAddress(num,AddressData.PutAccessories),false);//复位放辅料完成 MbSlave.WriteBoolean(GetAddress(num,AddressData.RobotServingSpace),false);//复位机器人到达出餐位 + MbSlave.WriteBoolean(GetAddress(num,AddressData.FryingpanForceEnd),false);//复位强制结束信号 + MbSlave.WriteBoolean(GetAddress(num,AddressData.ForceEnd),false);//复位强制结束控制 MbSlave.WriteString(id,GetHoldAdd(num,0));//写入商品ID MbSlave.WriteBoolean(GetAddress(num,AddressData.GoodDown),true);//写入商品下发 MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"写入的商品id"+id); @@ -224,8 +226,23 @@ public abstract class ControlBase { */ protected boolean EndProcess(int num){ if(ForceEnd[num-1]||MbSlave.ReadBoolean(GetAddress(num,AddressData.FryingpanForceEnd))){ - MbSlave.WriteBoolean(GetAddress(num,AddressData.ForceEnd),true);//强制结束 - MbSlave.WriteBoolean(GetAddress(num,AddressData.FryingpanForceEnd),false);//复位炒锅强制结束信号 + if( ForceEnd[num-1]){ + MbSlave.WriteBoolean(GetAddress(num,AddressData.ForceEnd),true);//强制结束 + } + + long startTime=System.currentTimeMillis(); + while(!MbSlave.ReadBoolean(GetAddress(num,AddressData.FryingpanForceEnd))&&(System.currentTimeMillis()-startTime)<=4000){ + try { + Thread.sleep(100); + }catch (InterruptedException ex){ + + } + } + + if(MbSlave.ReadBoolean(GetAddress(num,AddressData.FryingpanForceEnd))){ + MbSlave.WriteBoolean(GetAddress(num,AddressData.FryingpanForceEnd),false);//复位强制结束信号 + } + MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,num+" 号炒锅取消任务"); if(FryingPan.containsKey(num)) RemoveId.add(num); @@ -298,14 +315,16 @@ public abstract class ControlBase { protected void RobotFeedingMainMaterials(short IngredientsLocs,short FryingPanNum){ try { - MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从"+IngredientsLocs+"号主料位,放主料到"+FryingPanNum + "号锅"); - ModbusMaster.get().WriteShort("GI0",IngredientsLocs,1,null);//写入机器人主任务,指定主料位置 - ModbusMaster.get().WriteShort("GI1",FryingPanNum,1,null);//写入机器人子任务,指定炒锅位置 - ModbusMaster.get().WriteBool(GetRobotAdd(FryingPanNum,0).toString(),true,1,null);//写入机器人允许放料信号 - MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人放菜完成"); - while(!RobotData.FryingStatus.get(FryingPanNum).PutMaterialComplete&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100); }//等待放主料完成 - if(EndProcess(FryingPanNum))return; - MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人放菜完成"); + if(IngredientsLocs>0){ + MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从"+IngredientsLocs+"号主料位,放主料到"+FryingPanNum + "号锅"); + ModbusMaster.get().WriteShort("GI0",IngredientsLocs,1,null);//写入机器人主任务,指定主料位置 + ModbusMaster.get().WriteShort("GI1",FryingPanNum,1,null);//写入机器人子任务,指定炒锅位置 + ModbusMaster.get().WriteBool(GetRobotAdd(FryingPanNum,0).toString(),true,1,null);//写入机器人允许放料信号 + MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人放菜完成"); + while(!RobotData.FryingStatus.get((int)FryingPanNum).PutMaterialComplete&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100); }//等待放主料完成 + if(EndProcess(FryingPanNum))return; + MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人放菜完成"); + } MbSlave.WriteBoolean(GetAddress(FryingPanNum,AddressData.RobotPutIngredientsComplete),true);//机器人放主料完成 } catch(InterruptedException ex){ @@ -323,10 +342,12 @@ public abstract class ControlBase { { MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从" +AccessoriesLoc+"号辅料位,放辅料到"+FryingPanNum + "号锅"); MbSlave.WriteBoolean(GetAddress(FryingPanNum,AddressData.FryingPanRequestAccessories),false);//复位投辅料请求信号 - ModbusMaster.get().WriteShort("GI0",AccessoriesLoc,1,null);//写入机器人主任务,设置辅料位置 - ModbusMaster.get().WriteShort("GI2",FryingPanNum,1,null);//写入机器人子任务,设置炒锅位置 - MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人倒调料完成"); - while(!RobotData.FryingStatus.get(FryingPanNum).FallSeasoningComplete&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100);}//等待机器人倒调料完成 + if(AccessoriesLoc-10>0){ + ModbusMaster.get().WriteShort("GI0",AccessoriesLoc,1,null);//写入机器人主任务,设置辅料位置 + ModbusMaster.get().WriteShort("GI2",FryingPanNum,1,null);//写入机器人子任务,设置炒锅位置 + MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人倒调料完成"); + while(!RobotData.FryingStatus.get((int)FryingPanNum).FallSeasoningComplete&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100);}//等待机器人倒调料完成 + } MbSlave.WriteString(GetHoldAdd(FryingPanNum,0));//复位商品id if(EndProcess(FryingPanNum))return; MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人倒调料完成"); @@ -363,7 +384,7 @@ public abstract class ControlBase { { MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人到"+FryingPanNum+"号炒锅位置"); //等待机器人到达炒锅位置 - while(!RobotData.FryingStatus.get(FryingPanNum).RequestDiningOut&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100);} + while(!RobotData.FryingStatus.get((int)FryingPanNum).RequestDiningOut&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100);} if(EndProcess(FryingPanNum))return; MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人到"+FryingPanNum+"号炒锅位置"); MbSlave.WriteBoolean(GetAddress(FryingPanNum,AddressData.RobotServingSpace),true);//通知炒锅,机器人到达出餐位 @@ -385,7 +406,7 @@ public abstract class ControlBase { ModbusMaster.get().WriteBool(GetRobotAdd(FryingPanNum,2).toString(),true,1,null); MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人出餐完成"); //等待机器人出餐完成 - while(!RobotData.FryingStatus.get(FryingPanNum).DiningOutComplete&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100);} + while(!RobotData.FryingStatus.get((int)FryingPanNum).DiningOutComplete&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100);} if(EndProcess(FryingPanNum)) return; MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人出餐完成"); MbSlave.WriteBoolean(GetAddress(FryingPanNum,AddressData.RequestingMeaDelivery),false);; //复位炒菜完成,出餐请求 diff --git a/app/src/main/java/com/bonait/bnframework/business/DoubleFryingpanControl.java b/app/src/main/java/com/bonait/bnframework/business/DoubleFryingpanControl.java index e5ca0afa..eb70886b 100644 --- a/app/src/main/java/com/bonait/bnframework/business/DoubleFryingpanControl.java +++ b/app/src/main/java/com/bonait/bnframework/business/DoubleFryingpanControl.java @@ -73,8 +73,15 @@ public class DoubleFryingpanControl extends ControlBase { RobotData.FryingStatus.get(2).DiningOutComplete=value[3]; }); -// RobotData.RobotIdle=RobotData.RobotHome&&RobotData.RobotTaskFeedback==0;//机器人空闲状态 - RobotData.RobotIdle=true;//机器人空闲状态 + RobotData.RobotIdle=RobotData.RobotHome&&RobotData.RobotTaskFeedback==0;//机器人空闲状态 +// RobotData.RobotIdle=true;//机器人空闲状态 + +// for(int i=1;i<=2;i++){ +// if(!ForceEnd[i-1]&& MbSlave.ReadBoolean(GetAddress(i,AddressData.FryingpanForceEnd)) ) { +// SetForceEnd(i); +// MbSlave.WriteBoolean(GetAddress(i,AddressData.FryingpanForceEnd),false); +// } +// } } diff --git a/app/src/main/java/com/bonait/bnframework/common/modbus/ModbusMaster.java b/app/src/main/java/com/bonait/bnframework/common/modbus/ModbusMaster.java index 8c0efe68..11c120a7 100644 --- a/app/src/main/java/com/bonait/bnframework/common/modbus/ModbusMaster.java +++ b/app/src/main/java/com/bonait/bnframework/common/modbus/ModbusMaster.java @@ -115,7 +115,7 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { private void ReConnect(String error){ if(ConnectionType==1){ - if(error.contains("Connection refused")){ + if(error.contains("Connection refused")||error.contains("SocketException")){ IsConnected=false; TcpConnect(TempIp,TempPort,null); } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DoubleFryingpanFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DoubleFryingpanFragment.java index 720bf487..b55efa5c 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DoubleFryingpanFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DoubleFryingpanFragment.java @@ -156,25 +156,6 @@ public class DoubleFryingpanFragment extends BaseFragment { if (msg.obj.toString()== "MSG_REFRESH") { if(ConfigName.getInstance().cloudGoods!=null && ConfigName.getInstance().cloudGoods.size()>0) { -// getActivity().runOnUiThread(new Runnable() { -// @Override -// public void run(){ -// ArrayList goods= QueryDB.GetGoodsALL(); -// ArrayList rec= QueryDB.GetGoodsSrecipeALL(); -// for (BPA_GOODS good:goods) -// { -// QueryDB.DeleteGoods(good); -// } -// for (BPA_GOODSRECIPE pf:rec) -// { -// QueryDB.DeleteGoodsSrecipe(pf); -// } -// for (CloudGood item : ConfigName.getInstance().cloudGoods) { -// ConfigData.getInstance().GetGoodProcess(getContext(),item.id,false); -// } -// } -// }); - ArrayList goods= QueryDB.GetGoodsALL(); ArrayList rec= QueryDB.GetGoodsSrecipeALL(); for (BPA_GOODS good:goods) @@ -334,15 +315,16 @@ public class DoubleFryingpanFragment extends BaseFragment { if (msg != null) { BPA_GOODS goods = (BPA_GOODS) msg; fry.GoodID= goods.id; - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - if(!getActivity().isFinishing()){ - OpenParSet(); - } - - } - }); + OpenParSet(); +// getActivity().runOnUiThread(new Runnable() { +// @Override +// public void run() { +// if(!getActivity().isFinishing()){ +// +// } +// +// } +// }); } }