@@ -131,6 +131,9 @@ dependencies { | |||
//Modbus | |||
implementation 'com.github.licheedev:Modbus4Android:2.0.2' | |||
//Modbus server | |||
implementation 'com.github.hwx95:ModbusTCP:v1.1' | |||
//下载进度条 | |||
implementation 'com.github.Ccapton:Android-ColorfulProgressBar:1.0.5' | |||
@@ -39,9 +39,6 @@ | |||
<activity | |||
android:name=".material_view" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".MainActivity" | |||
android:exported="false" /> | |||
<activity | |||
android:name=".modules.home.fragment.mode.Silos_item_fragment" | |||
android:exported="false" | |||
@@ -1,169 +0,0 @@ | |||
package com.bonait.bnframework; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
import android.view.Gravity; | |||
import android.view.View; | |||
import android.widget.AdapterView; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.Button; | |||
import android.widget.Spinner; | |||
import com.bonait.bnframework.common.helper.I.IRun; | |||
import com.bonait.bnframework.dialog.DialogManager; | |||
import com.bonait.bnframework.dialog.DialogView; | |||
import butterknife.BindView; | |||
import butterknife.ButterKnife; | |||
public class MainActivity extends AppCompatActivity { | |||
@BindView(R.id.main_btn1) | |||
Button btn1; | |||
@BindView(R.id.main_btn2) | |||
Button btn2; | |||
@BindView(R.id.main_btn3) | |||
Button btn3; | |||
@BindView(R.id.main_btn4) | |||
Button btn4; | |||
private DialogView mDialogVisual; | |||
private DialogView mParSetVisual; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.activity_main); | |||
ButterKnife.bind(this); | |||
// btn1=this.findViewById(R.id.main_btn1); | |||
// btn2=this.findViewById(R.id.main_btn2); | |||
// btn3=this.findViewById(R.id.main_btn3); | |||
// btn4=this.findViewById(R.id.main_btn4); | |||
OpenGoodSelectDialog(); | |||
mDialogVisual= DialogManager.getInstance().initView(this, R.layout.activity_material_view, Gravity.BOTTOM); | |||
mParSetVisual = DialogManager.getInstance().initView(this,R.layout.activity_par_set,Gravity.BOTTOM); | |||
// Button btn1=this.findViewById(R.id.main_btn1); | |||
// btn1.setOnClickListener(new View.OnClickListener() { | |||
// @Override | |||
// public void onClick(View view) { | |||
// //true:点击弹框外面可取消显示 | |||
// //false:点击弹框外面不可取消显示 | |||
// mDialogVisual.setCanceledOnTouchOutside(false); | |||
// Button openSetView = mDialogVisual .findViewById(R.id.open); | |||
// openSetView.setOnClickListener(new View.OnClickListener() { | |||
// @Override | |||
// public void onClick(View view) { | |||
//// DialogView d1= DialogManager.getInstance().initView(this, R.layout.activity_par_set, Gravity.BOTTOM); | |||
// Log.i("info", "onClick: 打开设置弹框"); | |||
// } | |||
// }); | |||
// DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //显示自定义弹框 | |||
// } | |||
// }); | |||
// Button btn2=this.findViewById(R.id.main_btn2); | |||
// btn2.setOnClickListener(new View.OnClickListener() { | |||
// @Override | |||
// public void onClick(View view) { | |||
// Log.d("Debug", "选中商品二"); | |||
// } | |||
// }); | |||
// | |||
// Button btn3=this.findViewById(R.id.main_btn3); | |||
// btn3.setOnClickListener(new View.OnClickListener() { | |||
// @Override | |||
// public void onClick(View view) { | |||
// Log.d("Debug", "选中商品三"); | |||
// } | |||
// }); | |||
// | |||
// Button btn4=this.findViewById(R.id.main_btn4); | |||
// btn4.setOnClickListener(new View.OnClickListener() { | |||
// @Override | |||
// public void onClick(View view) { | |||
// Log.d("Debug", "选中商品四"); | |||
// } | |||
// }); | |||
} | |||
private void OpenGoodSelectDialog() | |||
{ | |||
btn1.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view){ | |||
mDialogVisual.setCanceledOnTouchOutside(false); | |||
Button openSetView = mDialogVisual .findViewById(R.id.open); | |||
openSetView.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
//参数配置界面确认按钮 | |||
ButtonClickBinder(mParSetVisual, R.id.parset_ok_btn,()->{ | |||
Log.i("TAG", "onClick: 确认参数配置"); | |||
DialogManager.getInstance().hide(mParSetVisual);//关闭参数设置窗口 | |||
}); | |||
//参数配置界面取消按钮 | |||
ButtonClickBinder(mParSetVisual, R.id.parset_cancel_btn, ()->{ | |||
Log.i("TAG", "onClick: 退出参数配置"); | |||
DialogManager.getInstance().hide(mParSetVisual);//关闭参数设置窗口 | |||
}); | |||
DialogManager.getInstance().hide(mDialogVisual);//关闭商品选择窗口 | |||
DialogManager.getInstance().show(mParSetVisual,R.id.parset_close_dialog); //打开参数设置窗口 | |||
ParSetInit(R.id.location_selection,new String[] {"0", "1", "2", "3", "4","5","6"}); | |||
ParSetInit(R.id.accessories_selection_1,new String[] {"0", "1", "2", "3", "4","5","6","7","8"}); | |||
ParSetInit(R.id.accessories_selection_2,new String[] {"0", "1", "2", "3", "4","5","6","7","8"}); | |||
} | |||
}); | |||
DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
} | |||
}); | |||
} | |||
private void ParSetInit(int id,String[] args) | |||
{ | |||
Spinner sp = mParSetVisual.findViewById(id); | |||
ArrayAdapter<String> starAdapter = new ArrayAdapter<String>(getBaseContext(), R.layout.select_item, args); | |||
sp.setAdapter(starAdapter); | |||
sp.setSelection(0); | |||
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | |||
@Override | |||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { | |||
} | |||
@Override | |||
public void onNothingSelected(AdapterView<?> adapterView) { | |||
} | |||
}); | |||
} | |||
/** | |||
* 弹框按钮事件绑定 | |||
* @param dv 弹框页面 | |||
* @param id 按钮id | |||
* @param action 执行委托 | |||
*/ | |||
private void ButtonClickBinder(DialogView dv,int id, IRun action){ | |||
if(dv!=null&& !dv.findViewById(id).hasOnClickListeners()){ | |||
dv.findViewById(id).setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
if(action!=null) action.Run(); | |||
} | |||
}); | |||
} | |||
} | |||
} |
@@ -0,0 +1,95 @@ | |||
package com.bonait.bnframework.business; | |||
public class AddressData { | |||
/** | |||
* 炒锅空闲状态 | |||
*/ | |||
public static int FryingPanHide=1; | |||
/** | |||
* 炒锅出餐完成 | |||
*/ | |||
public static int FryingPanDiningOut=2; | |||
/** | |||
* 炒锅投主料完成 | |||
*/ | |||
public static int FryingPnaMainMaterialComplete=3; | |||
/** | |||
* 炒锅请求投辅料 | |||
*/ | |||
public static int FryingPanRequestAccessories=4; | |||
/** | |||
* 商品数据验证 | |||
*/ | |||
public static int GoodDataVery=5; | |||
/** | |||
* 投料机构状态 | |||
*/ | |||
public static int FeedingMechanism=6; | |||
/** | |||
* 心跳状态 | |||
*/ | |||
public static int Heartbeat=7; | |||
/** | |||
* 炒菜完成,请求出餐 | |||
*/ | |||
public static int RequestingMeaDelivery=8; | |||
/** | |||
* 出餐减速到位 | |||
*/ | |||
public static int DecelerationInPlace=9; | |||
/** | |||
* 投主料请求 | |||
*/ | |||
public static int AddIngredientsRequest=10; | |||
/** | |||
* 炒锅强制结束信号 | |||
*/ | |||
public static int FryingpanForceEnd=11; | |||
/** | |||
* 机器人放主料完成 | |||
*/ | |||
public static int PutMainMaterial=51; | |||
/** | |||
* 机器人放辅料完成 | |||
*/ | |||
public static int PutAccessories=52; | |||
/** | |||
* 机器人到达出餐位 | |||
*/ | |||
public static int RobotServingSpace=53; | |||
/** | |||
* 商品下发 | |||
*/ | |||
public static int GoodDown=54; | |||
/** | |||
* 机器人急停 | |||
*/ | |||
public static int EStop=55; | |||
/** | |||
* 机器人投主料完成 | |||
*/ | |||
public static int RobotPutIngredientsComplete=56; | |||
/** | |||
* 强制结束 | |||
*/ | |||
public static int ForceEnd=57; | |||
} |
@@ -297,27 +297,55 @@ public class ConfigData { | |||
OkGo.<ResAPI<OrganizeMode>>get(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetStore + ConfigName.getInstance().ClientAutoKey) | |||
.tag(context) | |||
.execute(new JsonDialogCallback<ResAPI<OrganizeMode>>(context) { | |||
@Override | |||
public void onSuccess(Response<ResAPI<OrganizeMode>> response) { | |||
ResAPI<OrganizeMode> organize = response.body(); | |||
if (organize.isSuccess) { | |||
ConfigName.getInstance().organizeMode = organize.data; | |||
OkGo.<ResAPI<DeviceInformation>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetDeviceInformation, ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceAutoKey)).tag(context).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<DeviceInformation>>(context) { | |||
@Override | |||
public void onSuccess(Response<ResAPI<DeviceInformation>> response) { | |||
ResAPI<DeviceInformation> deviceInformation = response.body(); | |||
if (deviceInformation.succeeded) { | |||
ConfigName.getInstance().deviceInformation = deviceInformation.data; | |||
if (ConfigName.getInstance().deviceInformation != null) { | |||
ConfigName.getInstance().DeviceId = ConfigName.getInstance().deviceInformation.id; | |||
@Override | |||
public void onSuccess(Response<ResAPI<OrganizeMode>> response) { | |||
ResAPI<OrganizeMode> organize = response.body(); | |||
if (organize.isSuccess) { | |||
ConfigName.getInstance().organizeMode = organize.data; | |||
OkGo.<ResAPI<DeviceInformation>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetDeviceInformation, ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceAutoKey)).tag(context).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<DeviceInformation>>(context) { | |||
@Override | |||
public void onSuccess(Response<ResAPI<DeviceInformation>> response) { | |||
ResAPI<DeviceInformation> deviceInformation = response.body(); | |||
if (deviceInformation.succeeded) { | |||
ConfigName.getInstance().deviceInformation = deviceInformation.data; | |||
if (ConfigName.getInstance().deviceInformation != null) { | |||
ConfigName.getInstance().DeviceId = ConfigName.getInstance().deviceInformation.id; | |||
MessageManager.getInstance().sendMessage(MessageName.GetOrganize, "GetOrganize"); | |||
} | |||
} | |||
} | |||
} | |||
}); | |||
} | |||
}); | |||
} | |||
} | |||
}); | |||
} | |||
}); | |||
// //获取店铺信息 | |||
// OkGo.<ResAPI<OrganizeMode>>get(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetStore + ConfigName.getInstance().ClientAutoKey) | |||
// .tag(context) | |||
// .execute(new JsonDialogCallback<ResAPI<OrganizeMode>>(context) { | |||
// @Override | |||
// public void onSuccess(Response<ResAPI<OrganizeMode>> response) { | |||
// ResAPI<OrganizeMode> organize = response.body(); | |||
// if (organize.isSuccess) { | |||
// ConfigName.getInstance().organizeMode = organize.data; | |||
// | |||
// OkGo.<ResAPI<DeviceInformation>>get(String.format(ConfigName.getInstance().SaasAddress + ConfigName.getInstance().GetDeviceInformation, ConfigName.getInstance().organizeMode.id, ConfigName.getInstance().DeviceAutoKey)).tag(context).headers(new HttpHeaders("TenantId", ConfigName.getInstance().organizeMode.companyId)).execute(new JsonDialogCallback<ResAPI<DeviceInformation>>(context) { | |||
// @Override | |||
// public void onSuccess(Response<ResAPI<DeviceInformation>> response) { | |||
// ResAPI<DeviceInformation> deviceInformation = response.body(); | |||
// if (deviceInformation.succeeded) { | |||
// ConfigName.getInstance().deviceInformation = deviceInformation.data; | |||
// if (ConfigName.getInstance().deviceInformation != null) { | |||
// ConfigName.getInstance().DeviceId = ConfigName.getInstance().deviceInformation.id; | |||
// } | |||
// } | |||
// } | |||
// }); | |||
// } | |||
// } | |||
// }); | |||
} else { | |||
ToastUtils.warning("无网络,请先连接网络!!!"); | |||
} | |||
@@ -0,0 +1,414 @@ | |||
package com.bonait.bnframework.business; | |||
import com.bonait.bnframework.common.ModbusSlave.ModbusTcpSlave; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.db.res.UserLogEnum; | |||
import com.bonait.bnframework.common.helper.I.IThread; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.helper.ThreadManager; | |||
import com.bonait.bnframework.common.modbus.IOperateResult; | |||
import com.bonait.bnframework.common.modbus.ModbusMaster; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import java.util.ArrayList; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
public abstract class ControlBase { | |||
public void Init(){ | |||
RobotData.FryingStatus.put(1,new FryingPanData()); | |||
RobotData.FryingStatus.put(2,new FryingPanData()); | |||
RobotData.FryingStatus.put(3,new FryingPanData()); | |||
RobotData.FryingStatus.put(4,new FryingPanData()); | |||
HeartbeatStatusListen(); | |||
ConnectRobot(); | |||
ThreadManager.Get().StartLong("炒锅控制业务", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
Control(); | |||
Thread.sleep(100); | |||
} | |||
@Override | |||
public void RunComplete() throws InterruptedException { | |||
} | |||
}); | |||
MbSlave.Init(); | |||
} | |||
/** | |||
* 根据炒锅编号解析对应的炒锅控制地址 | |||
* @param num | |||
* @param offset | |||
* @return | |||
*/ | |||
protected int GetAddress(int num,int offset) | |||
{ | |||
return (num-1)*100+offset; | |||
} | |||
protected int GetHoldAdd(int num,int offset){ | |||
return (num-1)*20+offset; | |||
} | |||
protected Integer GetRobotAdd(int num,int offset){ | |||
//M500--4596 | |||
// return "M"+ 500+offset+(num-1)*10; | |||
return 4596+offset+(num-1)*10; | |||
} | |||
/** | |||
* 获取心跳状态 | |||
* @param num | |||
* @return | |||
*/ | |||
protected boolean GetHeartbeatStatus(int num){ | |||
return HeartbeatStatus[num-1]; | |||
} | |||
/** | |||
* 炒锅心跳状态 | |||
*/ | |||
protected boolean[] HeartbeatStatus=new boolean[4]; | |||
/** | |||
* 炒锅心跳时间 | |||
*/ | |||
protected long[] StartTime=new long[4]; | |||
/** | |||
* 强制结束信号 | |||
*/ | |||
protected boolean[] ForceEnd =new boolean[4];//强制结束 | |||
/** | |||
* 需要移除的任务 | |||
*/ | |||
protected List<Integer> RemoveId=new ArrayList<Integer>(); | |||
/** | |||
* 强制结束指定炒锅任务 | |||
* @param num | |||
*/ | |||
public void SetForceEnd(int num){ | |||
if(num>0){ | |||
ForceEnd[num-1]=true; | |||
} | |||
} | |||
/** | |||
* 复位强制结束信号 | |||
* @param num | |||
*/ | |||
private void resetForceEnd(int num){ | |||
if(num>0){ | |||
ForceEnd[num-1]=false; | |||
} | |||
} | |||
/** | |||
* 设备心跳超时时间 | |||
*/ | |||
protected long TimeOut=5000; | |||
public LinkedHashMap<Integer,FryingPanPar> FryingPan=new LinkedHashMap<>(); | |||
protected ModbusTcpSlave MbSlave=new ModbusTcpSlave(); | |||
/** | |||
* 机器人地址解析 | |||
* @param address | |||
* @return | |||
*/ | |||
public String RobotAddress(String address){ | |||
if (address == null) return ""; | |||
if (address.length() > 0) { | |||
address = address.trim(); | |||
if (address.toUpperCase().contains("M") &&address.length() >=2){ | |||
String res = address.substring(1); | |||
if (res != null) { | |||
try { | |||
Integer tempAdd = Integer.parseInt(res); | |||
if(tempAdd>=0){ | |||
return (tempAdd+4096)+""; | |||
} | |||
} catch (NumberFormatException e) { | |||
return ""; | |||
} | |||
} | |||
} | |||
} | |||
return ""; | |||
} | |||
protected void ConnectRobot(){ | |||
new Thread(()->{ | |||
try { | |||
ModbusMaster.get().TcpConnect(ConfigName.getInstance().Address, ConfigName.getInstance().Post, new IOperateResult() { | |||
@Override | |||
public void onSuccess() { | |||
ConfigName.getInstance().PlcIsConnect = true; | |||
ThreadManager.Get().StartLong("机器人数据监听", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
RobotDataListen(); | |||
Thread.sleep(100); | |||
} | |||
@Override | |||
public void RunComplete() throws InterruptedException { | |||
} | |||
}); | |||
} | |||
@Override | |||
public void onFailure(String message) { | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
// ToastUtils.info("设备 " + ConfigName.getInstance().Address + " 连接失败:" + message); | |||
} | |||
@Override | |||
public void onFinally() { | |||
} | |||
}); | |||
}catch (Exception e ) | |||
{ | |||
MessageLog.ShowInfo("重新连接Modbus异常," + e.getMessage()); | |||
} | |||
}).start(); | |||
} | |||
/** | |||
* 商品是否验证成功 | |||
* @param num | |||
* @return | |||
*/ | |||
public boolean GetGoodVery(int num){ | |||
return MbSlave.ReadBoolean(GetAddress(num,AddressData.GoodDataVery)); | |||
} | |||
/** | |||
* 获取指定炒锅的状态 | |||
* @param num | |||
* @return | |||
*/ | |||
public boolean GetFryingPan(int num){ | |||
return MbSlave.ReadBoolean(GetAddress(num,AddressData.FryingPanHide))&&GetHeartbeatStatus(num); | |||
} | |||
/** | |||
* 商品下发 | |||
*/ | |||
public void GoodDown(String id,int num){ | |||
MbSlave.WriteBoolean(GetAddress(num,AddressData.GoodDataVery),false);//复位商品验证 | |||
MbSlave.WriteBoolean(GetAddress(num,AddressData.PutMainMaterial),false);//复位放主料完成 | |||
MbSlave.WriteBoolean(GetAddress(num,AddressData.PutAccessories),false);//复位放辅料完成 | |||
MbSlave.WriteBoolean(GetAddress(num,AddressData.RobotServingSpace),false);//复位机器人到达出餐位 | |||
MbSlave.WriteString(id,GetHoldAdd(num,0));//写入商品ID | |||
MbSlave.WriteBoolean(GetAddress(num,AddressData.GoodDown),true);//写入商品下发 | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"写入的商品id"+id); | |||
} | |||
/** | |||
* 强制结束信号检测 | |||
* @param num | |||
* @return | |||
*/ | |||
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);//复位炒锅强制结束信号 | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,num+" 号炒锅取消任务"); | |||
if(FryingPan.containsKey(num)) | |||
RemoveId.add(num); | |||
return true; | |||
} | |||
else return false; | |||
} | |||
protected int GetBooleanIndex(boolean[] bools,boolean value){ | |||
if(bools==null)return -1; | |||
int index=-1; | |||
for(int i=0;i<bools.length;i++){ | |||
if(bools[i]==value){ | |||
index=i; | |||
break; | |||
} | |||
} | |||
return index; | |||
} | |||
public ICompleteNotify completeNotify; | |||
public IStatusNotify statusNotify; | |||
/** | |||
* 设备心跳监听 | |||
*/ | |||
protected void HeartbeatStatusListen(){ | |||
ThreadManager.Get().StartLong("设备心跳监听", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
String[] status=new String[4]; | |||
for (int i=0;i<4;i++){ | |||
if (!MbSlave.ReadBoolean(GetAddress(i+1,AddressData.Heartbeat))){ | |||
StartTime[i]=System.currentTimeMillis(); | |||
} | |||
if((System.currentTimeMillis()-StartTime[i])>=2000) | |||
MbSlave.WriteBoolean(GetAddress(i+1,AddressData.Heartbeat),true); | |||
HeartbeatStatus[i]=(System.currentTimeMillis()-StartTime[i])<=TimeOut; | |||
if ( HeartbeatStatus[i]&&MbSlave.ReadBoolean(GetAddress(i+1,AddressData.FryingPanHide))){ | |||
status[i]="空闲中"; | |||
} | |||
else{ | |||
status[i]="忙碌中"; | |||
} | |||
} | |||
if(statusNotify!=null) | |||
statusNotify.OnStatusChanged(status[0],status[1],status[2],status[3]); | |||
Thread.sleep(100); | |||
} | |||
@Override | |||
public void RunComplete() throws InterruptedException { | |||
} | |||
}); | |||
} | |||
/** | |||
* 机器人投主料控制 | |||
* @param IngredientsLocs 主料位置 | |||
* @param FryingPanNum 炒锅位置 | |||
*/ | |||
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.订单处理日志 ,"机器人放菜完成"); | |||
MbSlave.WriteBoolean(GetAddress(FryingPanNum,AddressData.RobotPutIngredientsComplete),true);//机器人放主料完成 | |||
} | |||
catch(InterruptedException ex){ | |||
} | |||
} | |||
/** | |||
* 机器人投辅料控制 | |||
* @param AccessoriesLoc 辅料位置 | |||
* @param FryingPanNum 炒锅位置 | |||
*/ | |||
protected void RobotFeedingAuxiliaryMaterials(short AccessoriesLoc,short FryingPanNum){ | |||
try | |||
{ | |||
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);}//等待机器人倒调料完成 | |||
MbSlave.WriteString(GetHoldAdd(FryingPanNum,0));//复位商品id | |||
if(EndProcess(FryingPanNum))return; | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人倒调料完成"); | |||
MbSlave.WriteBoolean(GetAddress(FryingPanNum,AddressData.PutAccessories),true);//设置机器人放辅料完成信号 | |||
} | |||
catch(InterruptedException ex){ | |||
} | |||
} | |||
/** | |||
* 移除任务检测 | |||
*/ | |||
protected void RemoveTask(){ | |||
for(Integer key:RemoveId){ | |||
if(FryingPan.containsKey(key)) | |||
{ | |||
FryingPan.remove(key); | |||
resetForceEnd(key); | |||
if (completeNotify!=null) | |||
completeNotify.onComplete(key); | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"删除"+key+"号炒锅任务"); | |||
} | |||
} | |||
RemoveId.clear(); | |||
} | |||
/** | |||
* 机器人出餐控制 | |||
* @param FryingPanNum 炒锅位置 | |||
*/ | |||
protected void RobotMealControl(int FryingPanNum){ | |||
try | |||
{ | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人到"+FryingPanNum+"号炒锅位置"); | |||
//等待机器人到达炒锅位置 | |||
while(!RobotData.FryingStatus.get(FryingPanNum).RequestDiningOut&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100);} | |||
if(EndProcess(FryingPanNum))return; | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人到"+FryingPanNum+"号炒锅位置"); | |||
MbSlave.WriteBoolean(GetAddress(FryingPanNum,AddressData.RobotServingSpace),true);//通知炒锅,机器人到达出餐位 | |||
//等待炒锅到达减速位 | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人到"+FryingPanNum+"号炒锅减速位置"); | |||
while (!MbSlave.ReadBoolean(GetAddress(FryingPanNum,AddressData.DecelerationInPlace))&&!ForceEnd[FryingPanNum-1]){Thread.sleep(50);} | |||
if(EndProcess(FryingPanNum)) return; | |||
ModbusMaster.get().WriteBool(GetRobotAdd(FryingPanNum,1).toString(),true,1,null);//设置机器人炒锅减速到位 | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人到达"+FryingPanNum+"号炒锅减速位置"); | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待"+FryingPanNum+"号炒锅出餐完成"); | |||
//等待炒锅出餐完成 | |||
while (!MbSlave.ReadBoolean(GetAddress(FryingPanNum,AddressData.FryingPanDiningOut))&&!ForceEnd[FryingPanNum-1]){Thread.sleep(100);} | |||
if(EndProcess(FryingPanNum)) return; | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,FryingPanNum+"号炒锅出餐完成"); | |||
//设置机器人出餐完成 | |||
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);} | |||
if(EndProcess(FryingPanNum)) return; | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人出餐完成"); | |||
MbSlave.WriteBoolean(GetAddress(FryingPanNum,AddressData.RequestingMeaDelivery),false);; //复位炒菜完成,出餐请求 | |||
MbSlave.WriteBoolean(GetAddress(FryingPanNum,AddressData.FryingPanDiningOut),false); //复位炒锅出餐完成信号 | |||
//通知界面可以继续下发任务 | |||
if (completeNotify!=null) | |||
{ | |||
completeNotify.onComplete(FryingPanNum); | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"通知界面"+FryingPanNum+"号炒锅执行完成"); | |||
} | |||
if(FryingPan.containsKey(FryingPanNum)) | |||
RemoveId.add(FryingPanNum); | |||
} | |||
catch(InterruptedException ex){ | |||
} | |||
} | |||
protected abstract void RobotDataListen()throws InterruptedException; | |||
protected abstract void Control()throws InterruptedException; | |||
} |
@@ -0,0 +1,321 @@ | |||
package com.bonait.bnframework.business; | |||
import android.util.Log; | |||
import com.bonait.bnframework.common.db.res.UserLogEnum; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.modbus.ModbusMaster; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class DoubleFryingpanControl extends ControlBase { | |||
private static DoubleFryingpanControl mInstance; //实例变量设置私有,防止直接通过类名访问 | |||
public static synchronized DoubleFryingpanControl getInstance() { //静态同步方法作为唯一的实例对象获取方式 | |||
if (mInstance == null) { | |||
mInstance = new DoubleFryingpanControl(); | |||
} | |||
return mInstance; | |||
} | |||
private DoubleFryingpanControl() { | |||
} | |||
@Override | |||
public void RobotDataListen()throws InterruptedException{ | |||
//机器人急停 | |||
// ModbusMaster.get().ReadBool("M640",1,1, value->{ | |||
// for (int i =0;i<4;i++){ | |||
// MbSlave.WriteBoolean(GetAddress(i+1,AddressData.EStop),value[0]); | |||
// } | |||
// }); | |||
//机器人入库完成 | |||
ModbusMaster.get().ReadBool(RobotAddress("M620"),6,1,value->{ | |||
RobotData.RobotWarehousingComplete=value; | |||
}); | |||
//指定位置有盆 | |||
ModbusMaster.get().ReadBool(RobotAddress("M630"),4,1,value->{ | |||
RobotData.WarehouseLocHavingBasin=value; | |||
}); | |||
//机器人到达维护位 | |||
ModbusMaster.get().ReadBool(RobotAddress("M640"),1,1,value->{ | |||
RobotData.RobotReachTending=value[0]; | |||
}); | |||
//机器人原点位 | |||
ModbusMaster.get().ReadBool(RobotAddress("M660"),1,1,value->{ | |||
RobotData.RobotHome=value[0]; | |||
}); | |||
//机器人任务反馈 | |||
ModbusMaster.get().ReadShort("GI5",1,1,value->{ | |||
RobotData.RobotTaskFeedback=value[0]; | |||
}); | |||
//机器人1号炒锅完成 | |||
ModbusMaster.get().ReadBool(RobotAddress("M600"),4,1,value->{ | |||
RobotData.FryingStatus.get(1).PutMaterialComplete=value[0]; | |||
RobotData.FryingStatus.get(1).FallSeasoningComplete=value[1]; | |||
RobotData.FryingStatus.get(1).RequestDiningOut=value[2]; | |||
RobotData.FryingStatus.get(1).DiningOutComplete=value[3]; | |||
}); | |||
//机器人2号炒锅完成 | |||
ModbusMaster.get().ReadBool(RobotAddress("M610"),4,1,value->{ | |||
RobotData.FryingStatus.get(2).PutMaterialComplete=value[0]; | |||
RobotData.FryingStatus.get(2).FallSeasoningComplete=value[1]; | |||
RobotData.FryingStatus.get(2).RequestDiningOut=value[2]; | |||
RobotData.FryingStatus.get(2).DiningOutComplete=value[3]; | |||
}); | |||
// RobotData.RobotIdle=RobotData.RobotHome&&RobotData.RobotTaskFeedback==0;//机器人空闲状态 | |||
RobotData.RobotIdle=true;//机器人空闲状态 | |||
} | |||
@Override | |||
public void Control()throws InterruptedException{ | |||
if (FryingPan.size()>0){ | |||
for(FryingPanPar item:FryingPan.values()){ | |||
if(RobotData.RobotIdle&&!item.IsPutIngredients ){ | |||
MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.PutMainMaterial),true);//写入商品ID | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"写入准备就绪信号给"+item.FryingPanNum+"号炒锅"); | |||
item.IsPutIngredients=true; | |||
} | |||
//准备就绪,准备投入主料 | |||
if(RobotData.RobotIdle && MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.AddIngredientsRequest))){ | |||
MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.AddIngredientsRequest),false);//复位投主料请求信号 | |||
RobotFeedingMainMaterials((short) item.IngredientsLocs[item.AddIngredientsCount],(short)item.FryingPanNum);//机器人投主料控制 | |||
item.AddIngredientsCount++; | |||
} | |||
if(EndProcess(item.FryingPanNum)) break;//强制结束检测 | |||
//投辅料请求 | |||
if(RobotData.RobotIdle&& MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanRequestAccessories))){ | |||
int tempLoc = item.AccessoriesLocs[item.AddAccessoriesCount]+10; | |||
RobotFeedingAuxiliaryMaterials((short)tempLoc,(short) item.FryingPanNum);//机器人投辅料控制 | |||
item.AddAccessoriesCount++; | |||
} | |||
if(EndProcess(item.FryingPanNum)) break;//强制结束检测 | |||
//炒菜完成请求出餐 | |||
if(RobotData.RobotIdle&&MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.RequestingMeaDelivery))){ | |||
int index = GetBooleanIndex(RobotData.WarehouseLocHavingBasin,true); | |||
if(index>=0&&index<RobotData.WarehouseLocHavingBasin.length){ | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从" +(index+1)+"号位置取空盆到"+item.FryingPanNum + "号炒锅"); | |||
ModbusMaster.get().WriteShort("GI0",(short) (index+21),1,null);//写入机器人主任务,指定取空盆位置 | |||
ModbusMaster.get().WriteShort("GI3",(short) (item.FryingPanNum),1,null);//写入机器人主任务,指定取空盆位置 | |||
RobotMealControl(item.FryingPanNum);//机器人出餐控制 | |||
} | |||
} | |||
} | |||
RemoveTask();//移除任务检测 | |||
} | |||
} | |||
// @Override | |||
// public void Control()throws InterruptedException{ | |||
// if (FryingPan.size()>0){ | |||
// | |||
//// List<Integer> RemoveId=new ArrayList<Integer>(); | |||
// | |||
// for(FryingPanPar item:FryingPan.values()){ | |||
// | |||
// if(RobotData.RobotIdle)//判断机器人是否OK | |||
// { | |||
// if(!item.IsPutIngredients ){ | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.PutMainMaterial),true);//写入商品ID | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"写入准备就绪信号给"+item.FryingPanNum+"号炒锅"); | |||
// item.IsPutIngredients=true; | |||
// } | |||
// | |||
// //准备就绪,准备投入主料 | |||
// if(RobotData.RobotIdle && MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.AddIngredientsRequest))){ | |||
// | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.AddIngredientsRequest),false);//复位投主料请求信号 | |||
//// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从"+item.IngredientsLocs[item.AddIngredientsCount]+"号主料位,放主料到"+item.FryingPanNum + "号锅"); | |||
//// ModbusMaster.get().WriteShort("GI0",(short) item.IngredientsLocs[item.AddIngredientsCount],1,null);//写入机器人主任务,指定主料位置 | |||
//// ModbusMaster.get().WriteShort("GI1",(short) item.FryingPanNum,1,null);//写入机器人子任务,指定炒锅位置 | |||
//// ModbusMaster.get().WriteBool(GetRobotAdd(item.FryingPanNum,0).toString(),true,1,null);//写入机器人允许放料信号 | |||
//// | |||
//// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人放菜完成"); | |||
// | |||
// RobotFeedingMainMaterials((short) item.IngredientsLocs[item.AddIngredientsCount],(short)item.FryingPanNum); | |||
// | |||
// //等待放主料完成 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).PutMaterialComplete&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100); } | |||
// if(EndProcess(item.FryingPanNum)) break; | |||
//// if(ForceEnd[item.FryingPanNum-1]){ | |||
//// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.ForceEnd),true);//强制结束 | |||
//// item.IsForceEnd=true; | |||
//// if(FryingPan.containsKey(item.FryingPanNum)) | |||
//// RemoveId.add(item.FryingPanNum); | |||
//// break; | |||
//// } | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人放菜完成"); | |||
// | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.RobotPutIngredientsComplete),true);//机器人放主料完成 | |||
// item.AddIngredientsCount++; | |||
// } | |||
// if(EndProcess(item.FryingPanNum)) break; | |||
//// if(ForceEnd[item.FryingPanNum-1]){ | |||
//// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.ForceEnd),true);//强制结束 | |||
//// item.IsForceEnd=true; | |||
//// if(FryingPan.containsKey(item.FryingPanNum)) | |||
//// RemoveId.add(item.FryingPanNum); | |||
//// break; | |||
//// } | |||
// | |||
// //投辅料请求 | |||
// if(RobotData.RobotIdle&& MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanRequestAccessories))){ | |||
// int tempLoc = item.AccessoriesLocs[item.AddAccessoriesCount]+10; | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从" +tempLoc+"号辅料位,放辅料到"+item.FryingPanNum + "号锅"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanRequestAccessories),false);//复位投辅料请求信号 | |||
// ModbusMaster.get().WriteShort("GI0",(short) tempLoc,1,null);//写入机器人主任务,设置辅料位置 | |||
// ModbusMaster.get().WriteShort("GI2",(short) item.FryingPanNum,1,null);//写入机器人子任务,设置炒锅位置 | |||
// item.AddAccessoriesCount++; | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人倒调料完成"); | |||
// //等待机器人倒调料完成 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).FallSeasoningComplete&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(EndProcess(item.FryingPanNum)) break; | |||
//// if(ForceEnd[item.FryingPanNum-1]){ | |||
//// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.ForceEnd),true);//强制结束 | |||
//// item.IsForceEnd=true; | |||
//// if(FryingPan.containsKey(item.FryingPanNum)) | |||
//// RemoveId.add(item.FryingPanNum); | |||
//// break; | |||
//// } | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人倒调料完成"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.PutAccessories),true);//设置机器人放辅料完成信号 | |||
// MbSlave.WriteString(GetHoldAdd(item.FryingPanNum,0));//复位商品id | |||
// } | |||
// if(EndProcess(item.FryingPanNum)) break; | |||
//// if(ForceEnd[item.FryingPanNum-1]){ | |||
//// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.ForceEnd),true);//强制结束 | |||
//// item.IsForceEnd=true; | |||
//// if(FryingPan.containsKey(item.FryingPanNum)) | |||
//// RemoveId.add(item.FryingPanNum); | |||
//// break; | |||
//// } | |||
// | |||
// //炒菜完成请求出餐 | |||
// if(RobotData.RobotIdle&&MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.RequestingMeaDelivery))){ | |||
// | |||
// int index = GetBooleanIndex(RobotData.WarehouseLocHavingBasin,true); | |||
// | |||
// if(index>=0&&index<RobotData.WarehouseLocHavingBasin.length){ | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从" +(index+1)+"号位置取空盆到"+item.FryingPanNum + "号炒锅"); | |||
// | |||
// ModbusMaster.get().WriteShort("GI0",(short) (index+21),1,null);//写入机器人主任务,指定取空盆位置 | |||
// ModbusMaster.get().WriteShort("GI3",(short) (item.FryingPanNum),1,null);//写入机器人主任务,指定取空盆位置 | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人到"+item.FryingPanNum+"号炒锅位置"); | |||
// //等待机器人到达炒锅位置 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).RequestDiningOut&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(EndProcess(item.FryingPanNum)) break; | |||
//// if(ForceEnd[item.FryingPanNum-1]){ | |||
//// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.ForceEnd),true);//强制结束 | |||
//// item.IsForceEnd=true; | |||
//// if(FryingPan.containsKey(item.FryingPanNum)) | |||
//// RemoveId.add(item.FryingPanNum); | |||
//// break; | |||
//// } | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人到"+item.FryingPanNum+"号炒锅位置"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.RobotServingSpace),true);//通知炒锅,机器人到达出餐位 | |||
// | |||
// //等待炒锅到达减速位 | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人到"+item.FryingPanNum+"号炒锅减速位置"); | |||
// while (!MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.DecelerationInPlace))&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(50);} | |||
// if(EndProcess(item.FryingPanNum)) break; | |||
//// if(ForceEnd[item.FryingPanNum-1]){ | |||
//// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.ForceEnd),true);//强制结束 | |||
//// item.IsForceEnd=true; | |||
//// if(FryingPan.containsKey(item.FryingPanNum)) | |||
//// RemoveId.add(item.FryingPanNum); | |||
//// break; | |||
//// } | |||
// | |||
// //设置机器人炒锅减速到位 | |||
// ModbusMaster.get().WriteBool(GetRobotAdd(item.FryingPanNum,1).toString(),true,1,null); | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人到"+item.FryingPanNum+"号炒锅减速位置"); | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待"+item.FryingPanNum+"号炒锅出餐完成"); | |||
// //等待炒锅出餐完成 | |||
// while (!MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanDiningOut))&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(EndProcess(item.FryingPanNum)) break; | |||
//// if(ForceEnd[item.FryingPanNum-1]){ | |||
//// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.ForceEnd),true);//强制结束 | |||
//// item.IsForceEnd=true; | |||
//// if(FryingPan.containsKey(item.FryingPanNum)) | |||
//// RemoveId.add(item.FryingPanNum); | |||
//// break; | |||
//// } | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,item.FryingPanNum+"号炒锅出餐完成"); | |||
// | |||
// //设置机器人出餐完成 | |||
// ModbusMaster.get().WriteBool(GetRobotAdd(item.FryingPanNum,2).toString(),true,1,null); | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人出餐完成"); | |||
// //等待机器人出餐完成 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).DiningOutComplete&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(EndProcess(item.FryingPanNum)) break; | |||
//// if(ForceEnd[item.FryingPanNum-1]){ | |||
//// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.ForceEnd),true);//强制结束 | |||
//// item.IsForceEnd=true; | |||
//// if(FryingPan.containsKey(item.FryingPanNum)) | |||
//// RemoveId.add(item.FryingPanNum); | |||
//// break; | |||
//// } | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人出餐完成"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.RequestingMeaDelivery),false);; //复位炒菜完成,出餐请求 | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanDiningOut),false); //复位炒锅出餐完成信号 | |||
// | |||
// //通知界面可以继续下发任务 | |||
// if (completeNotify!=null) | |||
// { | |||
// completeNotify.onComplete(item.FryingPanNum); | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"通知界面"+item.FryingPanNum+"号炒锅执行完成"); | |||
// } | |||
// | |||
// item.IsComplete=true; | |||
// if(FryingPan.containsKey(item.FryingPanNum)) | |||
// RemoveId.add(item.FryingPanNum); | |||
// } | |||
// } | |||
// } | |||
// } | |||
// | |||
// for(Integer key:RemoveId){ | |||
// if(FryingPan.containsKey(key)) | |||
// { | |||
// FryingPan.remove(key); | |||
// resetForceEnd(key); | |||
// if (completeNotify!=null) | |||
// { | |||
// completeNotify.onComplete(key); | |||
// } | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"删除"+key+"号炒锅任务"); | |||
// } | |||
// } | |||
// | |||
// } | |||
// } | |||
} |
@@ -0,0 +1,24 @@ | |||
package com.bonait.bnframework.business; | |||
public class FryingPanData { | |||
/** | |||
* 机器人放原料到炒锅完成 | |||
*/ | |||
public boolean PutMaterialComplete; | |||
/** | |||
* 机器人倒调料完成 | |||
*/ | |||
public boolean FallSeasoningComplete; | |||
/** | |||
* 机器人到位,请求出餐 | |||
*/ | |||
public boolean RequestDiningOut; | |||
/** | |||
* 机器人出餐完成 | |||
*/ | |||
public boolean DiningOutComplete; | |||
} |
@@ -0,0 +1,63 @@ | |||
package com.bonait.bnframework.business; | |||
public class FryingPanPar { | |||
/** | |||
* 炒锅编号 | |||
*/ | |||
public int FryingPanNum; | |||
/** | |||
* 商品ID | |||
*/ | |||
public String GoodID; | |||
/** | |||
* 主料位置 | |||
*/ | |||
// public int IngredientsLoc; | |||
/** | |||
* 辅料位置1 | |||
*/ | |||
// public int AccessoriesLoc1; | |||
/** | |||
* 辅料位置2 | |||
*/ | |||
// public int AccessoriesLoc2; | |||
/** | |||
* 是否放了主料 | |||
*/ | |||
public boolean IsPutIngredients; | |||
/** | |||
* 添加辅料次数 | |||
*/ | |||
public int AddAccessoriesCount=0; | |||
/** | |||
* 主料位置 | |||
*/ | |||
public int[] IngredientsLocs=new int[2]; | |||
/** | |||
* 辅料位置 | |||
*/ | |||
public int[] AccessoriesLocs=new int[2]; | |||
/** | |||
* 添加主料次数 | |||
*/ | |||
public int AddIngredientsCount=0; | |||
/** | |||
* 是否执行完成 | |||
*/ | |||
public boolean IsComplete; | |||
/** | |||
* 是否强制结束 | |||
*/ | |||
public boolean IsForceEnd; | |||
} |
@@ -0,0 +1,5 @@ | |||
package com.bonait.bnframework.business; | |||
public interface ICompleteNotify { | |||
void onComplete(int num); | |||
} |
@@ -0,0 +1,5 @@ | |||
package com.bonait.bnframework.business; | |||
public interface IStatusNotify { | |||
void OnStatusChanged(String s1,String s2,String s3,String s4); | |||
} |
@@ -186,7 +186,7 @@ public class MainInit { | |||
user.exp = "管理员"; | |||
QueryDB.AddUser(user); | |||
ConfigData.getInstance().RevertPLCProcess(); | |||
// ConfigData.getInstance().RevertPLCProcess(); | |||
} | |||
} | |||
/** | |||
@@ -230,7 +230,7 @@ public class MainInit { | |||
public void UserMsg(UserLogEnum type, String msg) { | |||
BPA_LOG log = new BPA_LOG(); | |||
log.userID = ConfigName.getInstance().user.userID; | |||
ToastUtils.info(msg); | |||
// ToastUtils.info(msg); | |||
switch (type.toString()) | |||
{ | |||
case "登录日志":log.type=1; | |||
@@ -0,0 +1,43 @@ | |||
package com.bonait.bnframework.business; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS; | |||
public class OrderData { | |||
//region 单例模式 | |||
private static OrderData mInstance; //实例变量设置私有,防止直接通过类名访问 | |||
private OrderData() { //默认构造函数私有,防止类外直接new创建对象 | |||
} | |||
public static synchronized OrderData getInstance() { //静态同步方法作为唯一的实例对象获取方式 | |||
if (mInstance == null) { | |||
mInstance = new OrderData(); | |||
} | |||
return mInstance; | |||
} | |||
/** | |||
* 商品信息 | |||
*/ | |||
public BPA_GOODS goods=new BPA_GOODS(); | |||
/** | |||
* 主料位置 | |||
*/ | |||
public int MainMaterialLoc; | |||
/** | |||
* 辅料位置1 | |||
*/ | |||
public int AccessoriesLoc1; | |||
/** | |||
* 辅料位置2 | |||
*/ | |||
public int AccessoriesLoc2; | |||
} |
@@ -0,0 +1,666 @@ | |||
package com.bonait.bnframework.business; | |||
import android.util.Log; | |||
import com.bonait.bnframework.common.db.res.UserLogEnum; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.modbus.ModbusMaster; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class RobotControl extends ControlBase { | |||
//region 私有 | |||
private static RobotControl mInstance; //实例变量设置私有,防止直接通过类名访问 | |||
public static synchronized RobotControl getInstance() { //静态同步方法作为唯一的实例对象获取方式 | |||
if (mInstance == null) { | |||
mInstance = new RobotControl(); | |||
} | |||
return mInstance; | |||
} | |||
private RobotControl() { | |||
} | |||
// private int GetAddress(int num,int offset) | |||
// { | |||
// return (num-1)*100+offset; | |||
// } | |||
// | |||
// private int GetHoldAdd(int num,int offset){ | |||
// return (num-1)*20+offset; | |||
// } | |||
// | |||
// private Integer GetRobotAdd(int num,int offset){ | |||
// //M500--4596 | |||
//// return "M"+ 500+offset+(num-1)*10; | |||
// return 4596+offset+(num-1)*10; | |||
// } | |||
// | |||
// public boolean GetHeartbeatStatus(int num){ | |||
// return HeartbeatStatus[num-1]; | |||
// } | |||
// | |||
// public boolean[] HeartbeatStatus=new boolean[4]; | |||
// public long[] StartTime=new long[4]; | |||
// | |||
// public boolean[] qzjs=new boolean[4];//强制结束 | |||
// | |||
// public long TimeOut=5000; | |||
// public LinkedHashMap<Integer,FryingPanPar> FryingPan=new LinkedHashMap<>(); | |||
// public ModbusTcpSlave MbSlave=new ModbusTcpSlave(); | |||
// public void Init(){ | |||
// | |||
// if (ConfigName.getInstance().versionSelectionEnum.equals("一拖四")){ | |||
// RobotData.FryingStatus.put(1,new FryingPanData()); | |||
// RobotData.FryingStatus.put(2,new FryingPanData()); | |||
// RobotData.FryingStatus.put(3,new FryingPanData()); | |||
// RobotData.FryingStatus.put(4,new FryingPanData()); | |||
// HeartbeatStatusListen(); | |||
// ConnectRobot(); | |||
// Control(); | |||
// MbSlave.Init(); | |||
// } | |||
// else if (ConfigName.getInstance().versionSelectionEnum.equals("一拖二")){ | |||
// MbSlave.Init(); | |||
// } | |||
// | |||
// | |||
// } | |||
// public String RobotAddress(String address){ | |||
// if (address == null) return ""; | |||
// if (address.length() > 0) { | |||
// address = address.trim(); | |||
// if (address.toUpperCase().contains("M") &&address.length() >=2){ | |||
// String res = address.substring(1); | |||
// if (res != null) { | |||
// try { | |||
// Integer tempAdd = Integer.parseInt(res); | |||
// if(tempAdd>=0){ | |||
// return (tempAdd+4096)+""; | |||
//} | |||
// } catch (NumberFormatException e) { | |||
// return ""; | |||
// } | |||
// } | |||
// } | |||
// } | |||
// return ""; | |||
// } | |||
// | |||
// public void ConnectRobot(){ | |||
// new Thread(()->{ | |||
// try { | |||
// ModbusMaster.get().TcpConnect(ConfigName.getInstance().Address, ConfigName.getInstance().Post, new IOperateResult() { | |||
// @Override | |||
// public void onSuccess() { | |||
// ConfigName.getInstance().PlcIsConnect = true; | |||
// RobotDataListen(); | |||
// } | |||
// | |||
// @Override | |||
// public void onFailure(String message) { | |||
// ConfigName.getInstance().PlcIsConnect = false; | |||
// ToastUtils.info("设备 " + ConfigName.getInstance().Address + " 连接失败:" + message); | |||
// } | |||
// | |||
// @Override | |||
// public void onFinally() { | |||
// | |||
// } | |||
// }); | |||
// }catch (Exception e ) | |||
// { | |||
// MessageLog.ShowInfo("重新连接Modbus异常," + e.getMessage()); | |||
// } | |||
// }).start(); | |||
// } | |||
// | |||
// public boolean GetGoodVery(int num){ | |||
// return MbSlave.ReadBoolean(GetAddress(num,AddressData.GoodDataVery)); | |||
// } | |||
// /** | |||
// * 获取指定炒锅的状态 | |||
// * @param num | |||
// * @return | |||
// */ | |||
// public boolean GetFryingPan(int num){ | |||
// return MbSlave.ReadBoolean(GetAddress(num,AddressData.FryingPanHide))&&GetHeartbeatStatus(num); | |||
// } | |||
// | |||
// /** | |||
// * 商品下发 | |||
// */ | |||
// public void GoodDown(String id,int num){ | |||
// MbSlave.WriteBoolean(GetAddress(num,AddressData.PutMainMaterial),false);//复位放主料完成 | |||
// MbSlave.WriteBoolean(GetAddress(num,AddressData.PutAccessories),false);//复位放辅料完成 | |||
// MbSlave.WriteBoolean(GetAddress(num,AddressData.RobotServingSpace),false);//复位机器人到达出餐位 | |||
// MbSlave.WriteString(id,GetHoldAdd(num,0));//写入商品ID | |||
// MbSlave.WriteBoolean(GetAddress(num,AddressData.GoodDown),true);//写入商品ID | |||
// } | |||
// public ICompleteNotify completeNotify; | |||
// | |||
// public IStatusNotify statusNotify; | |||
// /** | |||
// * 设备心跳监听 | |||
// */ | |||
// public void HeartbeatStatusListen(){ | |||
// ThreadManager.Get().StartLong("设备心跳监听", true, new IThread() { | |||
// @Override | |||
// public void Run() throws InterruptedException { | |||
// | |||
// String[] status=new String[4]; | |||
// | |||
// for (int i=0;i<4;i++){ | |||
// | |||
// if (!MbSlave.ReadBoolean(GetAddress(i+1,AddressData.Heartbeat))){ | |||
// StartTime[i]=System.currentTimeMillis(); | |||
// } | |||
// MbSlave.WriteBoolean(GetAddress(i+1,AddressData.Heartbeat),true); | |||
// | |||
// HeartbeatStatus[i]=(System.currentTimeMillis()-StartTime[i])<=TimeOut; | |||
// | |||
// if ( HeartbeatStatus[i]&&MbSlave.ReadBoolean(GetAddress(i+1,AddressData.FryingPanHide))){ | |||
// status[i]="空闲中"; | |||
// } | |||
// else{ | |||
// status[i]="忙碌中"; | |||
// } | |||
// } | |||
// | |||
// if(statusNotify!=null) | |||
// statusNotify.OnStatusChanged(status[0],status[1],status[2],status[3]); | |||
// Thread.sleep(100); | |||
// } | |||
// | |||
// @Override | |||
// public void RunComplete() throws InterruptedException { | |||
// | |||
// } | |||
// }); | |||
// } | |||
// @Override | |||
// public void RobotDataListen(){ | |||
// ThreadManager.Get().StartLong("机器人数据监听", true, new IThread() { | |||
// @Override | |||
// public void Run() throws InterruptedException { | |||
// | |||
// //机器人急停 | |||
// ModbusMaster.get().ReadBool("M640",1,1,value->{ | |||
// for (int i =0;i<4;i++){ | |||
// MbSlave.WriteBoolean(GetAddress(i+1,AddressData.EStop),value[0]); | |||
// } | |||
// }); | |||
// | |||
// | |||
// //M640--1280--4736 | |||
// ModbusMaster.get().ReadBool("4736",6,1,value->{ | |||
// RobotData.PutEmptyBasinComplete=value; | |||
// }); | |||
// | |||
// //M660--1294--4756 | |||
// ModbusMaster.get().ReadBool("4756",1,1,value->{ | |||
// RobotData.RobotHome=value[0]; | |||
// }); | |||
// | |||
// //GI5--5 | |||
// ModbusMaster.get().ReadShort("5",1,1,value->{ | |||
// RobotData.RobotTaskFeedback=value[0]; | |||
// }); | |||
// | |||
// //M600--1258-4696 | |||
// ModbusMaster.get().ReadBool("4696",4,1,value->{ | |||
// RobotData.FryingStatus.get(1).PutMaterialComplete=value[0]; | |||
// RobotData.FryingStatus.get(1).FallSeasoningComplete=value[1]; | |||
// RobotData.FryingStatus.get(1).RequestDiningOut=value[2]; | |||
// RobotData.FryingStatus.get(1).DiningOutComplete=value[3]; | |||
// }); | |||
// | |||
// //M610--1262-4706 | |||
// ModbusMaster.get().ReadBool("4706",4,1,value->{ | |||
// RobotData.FryingStatus.get(2).PutMaterialComplete=value[0]; | |||
// RobotData.FryingStatus.get(2).FallSeasoningComplete=value[1]; | |||
// RobotData.FryingStatus.get(2).RequestDiningOut=value[2]; | |||
// RobotData.FryingStatus.get(2).DiningOutComplete=value[3]; | |||
// }); | |||
// | |||
// //M620--126C-4716 | |||
// ModbusMaster.get().ReadBool("4716",4,1,value->{ | |||
// RobotData.FryingStatus.get(3).PutMaterialComplete=value[0]; | |||
// RobotData.FryingStatus.get(3).FallSeasoningComplete=value[1]; | |||
// RobotData.FryingStatus.get(3).RequestDiningOut=value[2]; | |||
// RobotData.FryingStatus.get(3).DiningOutComplete=value[3]; | |||
// }); | |||
// | |||
// //M630--1276-4726 | |||
// ModbusMaster.get().ReadBool("4726",4,1,value->{ | |||
// RobotData.FryingStatus.get(4).PutMaterialComplete=value[0]; | |||
// RobotData.FryingStatus.get(4).FallSeasoningComplete=value[1]; | |||
// RobotData.FryingStatus.get(4).RequestDiningOut=value[2]; | |||
// RobotData.FryingStatus.get(4).DiningOutComplete=value[3]; | |||
// }); | |||
// | |||
// Thread.sleep(100); | |||
// } | |||
// | |||
// @Override | |||
// public void RunComplete() throws InterruptedException { | |||
// | |||
// } | |||
// }); | |||
// } | |||
// | |||
// @Override | |||
// public void Control(){ | |||
// ThreadManager.Get().StartLong("炒锅控制业务", true, new IThread() { | |||
// @Override | |||
// public void Run() throws InterruptedException { | |||
// | |||
// if (FryingPan.size()>0){ | |||
// | |||
// List<Integer> RemoveId=new ArrayList<Integer>(); | |||
// | |||
// for(FryingPanPar item:FryingPan.values()){ | |||
// | |||
// if(RobotData.RobotHome&&RobotData.RobotTaskFeedback==0)//判断机器人是否OK | |||
// { | |||
// //如果没有放主料,并且投料机构OK | |||
// if(!item.IsPutIngredients && MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FeedingMechanism))){ | |||
// Log.e("TAG", "机器人从"+item.IngredientsLoc+"号主料位,放主料到"+item.FryingPanNum + "号锅"); | |||
// item.IsPutIngredients=true; | |||
// Log.e("TAG", "写入的商品id"+item.GoodID); | |||
// ModbusMaster.get().WriteShort("GI0",(short) item.IngredientsLoc,1,null);//写入机器人主任务,指定主料位置 | |||
// ModbusMaster.get().WriteShort("GI1",(short) item.FryingPanNum,1,null);//写入机器人子任务,指定炒锅位置 | |||
// ModbusMaster.get().WriteBool(GetRobotAdd(item.FryingPanNum,0).toString(),true,1,null);//写入机器人允许放料信号 | |||
// | |||
// Log.e("TAG", "等待机器人放菜完成"); | |||
// | |||
// //等待放菜完成 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).PutMaterialComplete&&!qzjs[item.FryingPanNum-1]){Thread.sleep(100); } | |||
// | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// | |||
// Log.e("TAG", "机器人放菜完成"); | |||
// | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.PutMainMaterial),true);//机器人放主料完成 | |||
// } | |||
// | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// | |||
// //投辅料请求 | |||
// boolean RobotHeid= RobotData.RobotHome&&RobotData.RobotTaskFeedback==0;//机器人空闲状态 | |||
// if(RobotHeid&& MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanRequestAccessories))){ | |||
// int tempLoc = item.AccessoriesLoc1+10; | |||
// if(item.AddAccessoriesCount==1)tempLoc=item.AccessoriesLoc2+10; | |||
// Log.e("TAG", "机器人从" +tempLoc+"号辅料位,放辅料到"+item.FryingPanNum + "号锅"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanRequestAccessories),false);//复位投辅料请求信号 | |||
// ModbusMaster.get().WriteShort("GI0",(short) tempLoc,1,null);//写入机器人主任务,设置辅料位置 | |||
// ModbusMaster.get().WriteShort("GI2",(short) item.FryingPanNum,1,null);//写入机器人子任务,设置炒锅位置 | |||
// item.AddAccessoriesCount++; | |||
// Log.e("TAG", "等待机器人倒调料完成"); | |||
// //等待机器人倒调料完成 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).FallSeasoningComplete&&!qzjs[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// Log.e("TAG", "机器人倒调料完成"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.PutAccessories),true);//设置机器人放辅料完成信号 | |||
// MbSlave.WriteString(GetHoldAdd(item.FryingPanNum,0));//复位商品id | |||
// } | |||
// | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// | |||
// //倒主料完成,放主料盒子到货架请求 | |||
// RobotHeid= RobotData.RobotHome&&RobotData.RobotTaskFeedback==0; | |||
// if(RobotHeid&&MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPnaMainMaterialComplete))) | |||
// { | |||
// Log.e("TAG", "机器人从" +item.FryingPanNum+"号炒锅取料盆到"+item.IngredientsLoc + "号货架"); | |||
// ModbusMaster.get().WriteShort("GI0",(short) (item.FryingPanNum+20),1,null);//写入机器人主任务,指定锅号 | |||
// ModbusMaster.get().WriteShort("GI3",(short) item.IngredientsLoc,1,null);//写入机器人子任务,指定货架位置 | |||
// Log.e("TAG", "等待机器人放空盆完成"); | |||
// //等待放空盆完成 | |||
// while(!RobotData.PutEmptyBasinComplete[item.IngredientsLoc-1]&&!qzjs[item.FryingPanNum-1]) { Thread.sleep(100);} | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// Log.e("TAG", "机器人放空盆完成"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPnaMainMaterialComplete),false);//复位倒主料完成信号 | |||
// } | |||
// | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// | |||
// //炒菜完成请求出餐 | |||
// RobotHeid= RobotData.RobotHome&&RobotData.RobotTaskFeedback==0; | |||
// if(RobotHeid&&MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.RequestingMeaDelivery))){ | |||
// | |||
// Log.e("TAG", "机器人从" +item.FryingPanNum+"号位置取空盆到"+item.FryingPanNum + "号炒锅"); | |||
// | |||
// ModbusMaster.get().WriteShort("GI0",(short) (item.FryingPanNum+30),1,null);//写入机器人主任务,指定出餐空盆位置 | |||
// | |||
// Log.e("TAG", "等待机器人到"+item.FryingPanNum+"号炒锅位置"); | |||
// //等待机器人到达炒锅位置 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).RequestDiningOut&&!qzjs[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// Log.e("TAG", "机器人到"+item.FryingPanNum+"号炒锅位置"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.RobotServingSpace),true);//通知炒锅,机器人到达出餐位 | |||
// | |||
// //等待炒锅到达减速位 | |||
// while (!MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.DecelerationInPlace))&&!qzjs[item.FryingPanNum-1]){Thread.sleep(50);} | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// | |||
// Log.e("TAG", "等待机器人到"+item.FryingPanNum+"号炒锅减速位置"); | |||
// //设置机器人炒锅减速到位 | |||
// ModbusMaster.get().WriteBool(GetRobotAdd(item.FryingPanNum,1).toString(),true,1,null); | |||
// Log.e("TAG", "机器人到"+item.FryingPanNum+"号炒锅减速位置"); | |||
// | |||
// Log.e("TAG", "等待"+item.FryingPanNum+"号炒锅出餐完成"); | |||
// //等待炒锅出餐完成 | |||
// while (!MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanDiningOut))&&!qzjs[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// Log.e("TAG", item.FryingPanNum+"号炒锅出餐完成"); | |||
// | |||
// //设置机器人出餐完成 | |||
// ModbusMaster.get().WriteBool(GetRobotAdd(item.FryingPanNum,2).toString(),true,1,null); | |||
// | |||
// Log.e("TAG", "等待机器人出餐完成"); | |||
// //等待机器人出餐完成 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).DiningOutComplete&&!qzjs[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(qzjs[item.FryingPanNum-1])return; | |||
// Log.e("TAG", "机器人出餐完成"); | |||
// //复位炒菜完成,出餐请求 | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.RequestingMeaDelivery),false);; | |||
// //复位炒锅出餐完成信号 | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanDiningOut),false); | |||
// | |||
// //通知界面可以继续下发任务 | |||
// if (completeNotify!=null) | |||
// { | |||
// completeNotify.onComplete(item.FryingPanNum); | |||
// Log.e("TAG", "通知界面"+item.FryingPanNum+"号炒锅执行完成"); | |||
// } | |||
// | |||
// item.IsComplete=true; | |||
// if(FryingPan.containsKey(item.FryingPanNum)) | |||
// RemoveId.add(item.FryingPanNum); | |||
// } | |||
// } | |||
// } | |||
// | |||
// for(Integer key:RemoveId){ | |||
// if(FryingPan.containsKey(key)) | |||
// { | |||
// FryingPan.remove(key); | |||
// Log.e("TAG", "删除"+key+"号炒锅任务"); | |||
// } | |||
// } | |||
// | |||
// } | |||
// Thread.sleep(100); | |||
// } | |||
// | |||
// @Override | |||
// public void RunComplete() throws InterruptedException { | |||
// | |||
// } | |||
// }); | |||
// } | |||
@Override | |||
public void RobotDataListen()throws InterruptedException{ | |||
//机器人急停 | |||
ModbusMaster.get().ReadBool("M640",1,1,value->{ | |||
for (int i =0;i<4;i++){ | |||
MbSlave.WriteBoolean(GetAddress(i+1,AddressData.EStop),value[0]); | |||
} | |||
}); | |||
//M640--1280--4736 | |||
ModbusMaster.get().ReadBool("4736",6,1,value->{ | |||
RobotData.PutEmptyBasinComplete=value; | |||
}); | |||
//M660--1294--4756 | |||
ModbusMaster.get().ReadBool("4756",1,1,value->{ | |||
RobotData.RobotHome=value[0]; | |||
}); | |||
//GI5--5 | |||
ModbusMaster.get().ReadShort("5",1,1,value->{ | |||
RobotData.RobotTaskFeedback=value[0]; | |||
}); | |||
//M600--1258-4696 | |||
ModbusMaster.get().ReadBool("4696",4,1,value->{ | |||
RobotData.FryingStatus.get(1).PutMaterialComplete=value[0]; | |||
RobotData.FryingStatus.get(1).FallSeasoningComplete=value[1]; | |||
RobotData.FryingStatus.get(1).RequestDiningOut=value[2]; | |||
RobotData.FryingStatus.get(1).DiningOutComplete=value[3]; | |||
}); | |||
//M610--1262-4706 | |||
ModbusMaster.get().ReadBool("4706",4,1,value->{ | |||
RobotData.FryingStatus.get(2).PutMaterialComplete=value[0]; | |||
RobotData.FryingStatus.get(2).FallSeasoningComplete=value[1]; | |||
RobotData.FryingStatus.get(2).RequestDiningOut=value[2]; | |||
RobotData.FryingStatus.get(2).DiningOutComplete=value[3]; | |||
}); | |||
//M620--126C-4716 | |||
ModbusMaster.get().ReadBool("4716",4,1,value->{ | |||
RobotData.FryingStatus.get(3).PutMaterialComplete=value[0]; | |||
RobotData.FryingStatus.get(3).FallSeasoningComplete=value[1]; | |||
RobotData.FryingStatus.get(3).RequestDiningOut=value[2]; | |||
RobotData.FryingStatus.get(3).DiningOutComplete=value[3]; | |||
}); | |||
//M630--1276-4726 | |||
ModbusMaster.get().ReadBool("4726",4,1,value->{ | |||
RobotData.FryingStatus.get(4).PutMaterialComplete=value[0]; | |||
RobotData.FryingStatus.get(4).FallSeasoningComplete=value[1]; | |||
RobotData.FryingStatus.get(4).RequestDiningOut=value[2]; | |||
RobotData.FryingStatus.get(4).DiningOutComplete=value[3]; | |||
}); | |||
RobotData.RobotIdle=RobotData.RobotHome&&RobotData.RobotTaskFeedback==0;//机器人空闲状态 | |||
} | |||
@Override | |||
public void Control()throws InterruptedException{ | |||
if (FryingPan.size()>0){ | |||
for(FryingPanPar item:FryingPan.values()){ | |||
//如果没有放主料,并且投料机构OK | |||
if( RobotData.RobotIdle&&!item.IsPutIngredients && MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FeedingMechanism))){ | |||
item.IsPutIngredients=true; | |||
RobotFeedingMainMaterials((short)item.IngredientsLocs[0],(short)item.FryingPanNum); | |||
} | |||
if(EndProcess(item.FryingPanNum)) break;//强制结束检测 | |||
//投辅料请求 | |||
if( RobotData.RobotIdle&& MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanRequestAccessories))){ | |||
int tempLoc = item.AccessoriesLocs[item.AddAccessoriesCount]+10; | |||
RobotFeedingAuxiliaryMaterials((short)tempLoc,(short) item.FryingPanNum);//机器人投辅料控制 | |||
item.AddAccessoriesCount++; | |||
} | |||
if(EndProcess(item.FryingPanNum)) break;//强制结束检测 | |||
//倒主料完成,放主料盒子到货架请求 | |||
if( RobotData.RobotIdle&&MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPnaMainMaterialComplete))) | |||
{ | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从" +item.FryingPanNum+"号炒锅取料盆到"+item.IngredientsLocs[0] + "号货架"); | |||
ModbusMaster.get().WriteShort("GI0",(short) (item.FryingPanNum+20),1,null);//写入机器人主任务,指定锅号 | |||
ModbusMaster.get().WriteShort("GI3",(short) item.IngredientsLocs[0],1,null);//写入机器人子任务,指定货架位置 | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人放空盆完成"); | |||
//等待放空盆完成 | |||
while(!RobotData.PutEmptyBasinComplete[item.IngredientsLocs[0]-1]&&!ForceEnd[item.FryingPanNum-1]) { Thread.sleep(100);} | |||
if(EndProcess(item.FryingPanNum)) break;//强制结束检测 | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 , "机器人放空盆完成"); | |||
MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPnaMainMaterialComplete),false);//复位倒主料完成信号 | |||
} | |||
if(EndProcess(item.FryingPanNum)) break;//强制结束检测 | |||
//炒菜完成请求出餐 | |||
if( RobotData.RobotIdle&&MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.RequestingMeaDelivery))){ | |||
MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从" +item.FryingPanNum+"号位置取空盆到"+item.FryingPanNum + "号炒锅"); | |||
ModbusMaster.get().WriteShort("GI0",(short) (item.FryingPanNum+30),1,null);//写入机器人主任务,指定出餐空盆位置 | |||
RobotMealControl(item.FryingPanNum);//机器人出餐控制 | |||
} | |||
} | |||
RemoveTask();//移除任务检测 | |||
} | |||
} | |||
// @Override | |||
// public void Control()throws InterruptedException{ | |||
// if (FryingPan.size()>0){ | |||
// | |||
// List<Integer> RemoveId=new ArrayList<Integer>(); | |||
// | |||
// for(FryingPanPar item:FryingPan.values()){ | |||
// | |||
// if(RobotData.RobotHome&&RobotData.RobotTaskFeedback==0)//判断机器人是否OK | |||
// { | |||
// //如果没有放主料,并且投料机构OK | |||
// if(!item.IsPutIngredients && MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FeedingMechanism))){ | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 , "机器人从"+item.IngredientsLoc+"号主料位,放主料到"+item.FryingPanNum + "号锅"); | |||
// item.IsPutIngredients=true; | |||
// ModbusMaster.get().WriteShort("GI0",(short) item.IngredientsLoc,1,null);//写入机器人主任务,指定主料位置 | |||
// ModbusMaster.get().WriteShort("GI1",(short) item.FryingPanNum,1,null);//写入机器人子任务,指定炒锅位置 | |||
// ModbusMaster.get().WriteBool(GetRobotAdd(item.FryingPanNum,0).toString(),true,1,null);//写入机器人允许放料信号 | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 , "等待机器人放菜完成"); | |||
// | |||
// //等待放菜完成 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).PutMaterialComplete&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100); } | |||
// | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 , "机器人放菜完成"); | |||
// | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.PutMainMaterial),true);//机器人放主料完成 | |||
// } | |||
// | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// | |||
// //投辅料请求 | |||
// boolean RobotHeid= RobotData.RobotHome&&RobotData.RobotTaskFeedback==0;//机器人空闲状态 | |||
// if(RobotHeid&& MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanRequestAccessories))){ | |||
// int tempLoc = item.AccessoriesLoc1+10; | |||
// if(item.AddAccessoriesCount==1)tempLoc=item.AccessoriesLoc2+10; | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从" +tempLoc+"号辅料位,放辅料到"+item.FryingPanNum + "号锅"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanRequestAccessories),false);//复位投辅料请求信号 | |||
// ModbusMaster.get().WriteShort("GI0",(short) tempLoc,1,null);//写入机器人主任务,设置辅料位置 | |||
// ModbusMaster.get().WriteShort("GI2",(short) item.FryingPanNum,1,null);//写入机器人子任务,设置炒锅位置 | |||
// item.AddAccessoriesCount++; | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人倒调料完成"); | |||
// //等待机器人倒调料完成 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).FallSeasoningComplete&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 , "机器人倒调料完成"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.PutAccessories),true);//设置机器人放辅料完成信号 | |||
// MbSlave.WriteString(GetHoldAdd(item.FryingPanNum,0));//复位商品id | |||
// } | |||
// | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// | |||
// //倒主料完成,放主料盒子到货架请求 | |||
// RobotHeid= RobotData.RobotHome&&RobotData.RobotTaskFeedback==0; | |||
// if(RobotHeid&&MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPnaMainMaterialComplete))) | |||
// { | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从" +item.FryingPanNum+"号炒锅取料盆到"+item.IngredientsLoc + "号货架"); | |||
// ModbusMaster.get().WriteShort("GI0",(short) (item.FryingPanNum+20),1,null);//写入机器人主任务,指定锅号 | |||
// ModbusMaster.get().WriteShort("GI3",(short) item.IngredientsLoc,1,null);//写入机器人子任务,指定货架位置 | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待机器人放空盆完成"); | |||
// //等待放空盆完成 | |||
// while(!RobotData.PutEmptyBasinComplete[item.IngredientsLoc-1]&&!ForceEnd[item.FryingPanNum-1]) { Thread.sleep(100);} | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 , "机器人放空盆完成"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPnaMainMaterialComplete),false);//复位倒主料完成信号 | |||
// } | |||
// | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// | |||
// //炒菜完成请求出餐 | |||
// RobotHeid= RobotData.RobotHome&&RobotData.RobotTaskFeedback==0; | |||
// if(RobotHeid&&MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.RequestingMeaDelivery))){ | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人从" +item.FryingPanNum+"号位置取空盆到"+item.FryingPanNum + "号炒锅"); | |||
// | |||
// ModbusMaster.get().WriteShort("GI0",(short) (item.FryingPanNum+30),1,null);//写入机器人主任务,指定出餐空盆位置 | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 , "等待机器人到"+item.FryingPanNum+"号炒锅位置"); | |||
// //等待机器人到达炒锅位置 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).RequestDiningOut&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人到"+item.FryingPanNum+"号炒锅位置"); | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.RobotServingSpace),true);//通知炒锅,机器人到达出餐位 | |||
// | |||
// //等待炒锅到达减速位 | |||
// while (!MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.DecelerationInPlace))&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(50);} | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 , "等待机器人到"+item.FryingPanNum+"号炒锅减速位置"); | |||
// //设置机器人炒锅减速到位 | |||
// ModbusMaster.get().WriteBool(GetRobotAdd(item.FryingPanNum,1).toString(),true,1,null); | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人到"+item.FryingPanNum+"号炒锅减速位置"); | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"等待"+item.FryingPanNum+"号炒锅出餐完成"); | |||
// //等待炒锅出餐完成 | |||
// while (!MbSlave.ReadBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanDiningOut))&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,item.FryingPanNum+"号炒锅出餐完成"); | |||
// | |||
// //设置机器人出餐完成 | |||
// ModbusMaster.get().WriteBool(GetRobotAdd(item.FryingPanNum,2).toString(),true,1,null); | |||
// | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 , "等待机器人出餐完成"); | |||
// //等待机器人出餐完成 | |||
// while(!RobotData.FryingStatus.get(item.FryingPanNum).DiningOutComplete&&!ForceEnd[item.FryingPanNum-1]){Thread.sleep(100);} | |||
// if(ForceEnd[item.FryingPanNum-1])return; | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"机器人出餐完成"); | |||
// //复位炒菜完成,出餐请求 | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.RequestingMeaDelivery),false);; | |||
// //复位炒锅出餐完成信号 | |||
// MbSlave.WriteBoolean(GetAddress(item.FryingPanNum,AddressData.FryingPanDiningOut),false); | |||
// | |||
// //通知界面可以继续下发任务 | |||
// if (completeNotify!=null) | |||
// { | |||
// completeNotify.onComplete(item.FryingPanNum); | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"通知界面"+item.FryingPanNum+"号炒锅执行完成"); | |||
// } | |||
// | |||
// item.IsComplete=true; | |||
// if(FryingPan.containsKey(item.FryingPanNum)) | |||
// RemoveId.add(item.FryingPanNum); | |||
// } | |||
// } | |||
// } | |||
// | |||
// for(Integer key:RemoveId){ | |||
// if(FryingPan.containsKey(key)) | |||
// { | |||
// FryingPan.remove(key); | |||
// MessageLog.ShowUserMessage( UserLogEnum.订单处理日志 ,"删除"+key+"号炒锅任务"); | |||
// } | |||
// } | |||
// | |||
// } | |||
// } | |||
} |
@@ -0,0 +1,59 @@ | |||
package com.bonait.bnframework.business; | |||
import java.util.LinkedHashMap; | |||
public class RobotData { | |||
/** | |||
* 机器人原点位置 | |||
*/ | |||
public static boolean RobotHome; | |||
/** | |||
* 机器人空闲状态 | |||
*/ | |||
public static boolean RobotHeid; | |||
/** | |||
* 原料库空盆放回完成 | |||
*/ | |||
public static boolean[] PutEmptyBasinComplete=new boolean[6]; | |||
/** | |||
* 机器人入库完成 | |||
*/ | |||
public static boolean[] RobotWarehousingComplete=new boolean[6]; | |||
/** | |||
* 指定库位有盆 | |||
*/ | |||
public static boolean[] WarehouseLocHavingBasin=new boolean[4]; | |||
/** | |||
* 机器人到达维护位置 | |||
*/ | |||
public static boolean RobotReachTending; | |||
/** | |||
* 机器人任务反馈 | |||
*/ | |||
public static short RobotTaskFeedback; | |||
/** | |||
* 机器人空闲状态 | |||
*/ | |||
public static boolean RobotIdle; | |||
/** | |||
* 炒锅状态 | |||
*/ | |||
public static LinkedHashMap<Integer,FryingPanData> FryingStatus=new LinkedHashMap<Integer,FryingPanData>(); | |||
} |
@@ -0,0 +1,165 @@ | |||
package com.bonait.bnframework.common.ModbusSlave; | |||
import android.util.Log; | |||
import com.bonait.bnframework.common.helper.DataFormat; | |||
import com.bonait.bnframework.common.modbus.ShortLib; | |||
import net.wimpi.modbus.ModbusCoupler; | |||
import net.wimpi.modbus.net.ModbusTCPListener; | |||
import net.wimpi.modbus.procimg.DigitalOut; | |||
import net.wimpi.modbus.procimg.Register; | |||
import net.wimpi.modbus.procimg.SimpleDigitalIn; | |||
import net.wimpi.modbus.procimg.SimpleDigitalOut; | |||
import net.wimpi.modbus.procimg.SimpleProcessImage; | |||
import net.wimpi.modbus.procimg.SimpleRegister; | |||
import java.net.Inet6Address; | |||
import java.net.InetAddress; | |||
import java.net.NetworkInterface; | |||
import java.net.SocketException; | |||
import java.net.UnknownHostException; | |||
import java.util.Enumeration; | |||
public class ModbusTcpSlave { | |||
SimpleProcessImage spi = new SimpleProcessImage(); | |||
ModbusTCPListener listener = null; | |||
int port = 30000;//Android 1024 以下端口属于系统端口,需要root权限 | |||
//参考连接 | |||
//https://www.geek-share.com/detail/2805846670.html | |||
/** | |||
* 寄存器地址注册,地址依次从 add 添加顺序为主 | |||
*/ | |||
public void Register(){ | |||
//线圈寄存器(DO) | |||
for (int i = 0; i <400;i++) | |||
spi.addDigitalOut(new SimpleDigitalOut(false)); | |||
//保持寄存器(AO) | |||
for (int i =0;i<100;i++) | |||
spi.addRegister(new SimpleRegister(0)); | |||
//离散输入寄存器(DI) | |||
// spi.addDigitalIn(new SimpleDigitalIn(false)); | |||
//输入寄存器(AI) | |||
// spi.addInputRegister(new SimpleInputRegister(45)); | |||
} | |||
/** | |||
* 寄存器注册 | |||
*/ | |||
public void Init(){ | |||
Register(); | |||
ModbusCoupler.getReference().setProcessImage(spi); | |||
ModbusCoupler.getReference().setMaster(false);//默认是true,这里需要设置为false | |||
ModbusCoupler.getReference().setUnitID(1);//从站地址 | |||
new Thread(networkTask).start(); | |||
Log.e("TAG", "本机的IP = " + getHostIP()); | |||
} | |||
/** | |||
* 网络操作相关的子线程 | |||
*/ | |||
Runnable networkTask = new Runnable() { | |||
@Override | |||
public void run() { | |||
// TODO | |||
// 在这里进行 http request.网络请求相关操作 | |||
// byte[] bytes =new byte[4]; | |||
// bytes[0]=(byte)192; | |||
// bytes[1]=(byte)168; | |||
// bytes[2]=(byte)6; | |||
// bytes[3]=(byte)105; | |||
// | |||
// InetAddress adder= null; | |||
// try { | |||
// adder = InetAddress.getByAddress(bytes); | |||
// } catch (UnknownHostException e) { | |||
// throw new RuntimeException(e); | |||
// } | |||
listener = new ModbusTCPListener(3 ); | |||
listener.setPort(port); | |||
listener.start(); | |||
} | |||
}; | |||
public void WriteString(String str,int add){ | |||
short[] shorts = ShortLib.ToShorts(str.getBytes(), DataFormat.ABCD); | |||
int tempAdd = add; | |||
Log.e("TAG", "写入字长度: "+shorts.length); | |||
for (int i = 0;i<shorts.length;i++) | |||
{ | |||
Register register = spi.getRegister(tempAdd); | |||
register.setValue(shorts[i]); | |||
tempAdd++; | |||
} | |||
} | |||
public void WriteString(int add){ | |||
short[] shorts = new short[18]; | |||
int tempAdd = add; | |||
for (int i = 0;i<shorts.length;i++) | |||
{ | |||
Register register = spi.getRegister(tempAdd); | |||
register.setValue(shorts[i]); | |||
tempAdd++; | |||
} | |||
} | |||
public void WriteBoolean(int add,boolean value){ | |||
DigitalOut register= spi.getDigitalOut(add); | |||
register.set(value); | |||
} | |||
public boolean ReadBoolean(int add){ | |||
DigitalOut register= spi.getDigitalOut(add); | |||
return register.isSet(); | |||
} | |||
/** | |||
* 获取ip地址 | |||
* @return | |||
*/ | |||
public String getHostIP() { | |||
String hostIp = null; | |||
try { | |||
Enumeration nis = NetworkInterface.getNetworkInterfaces(); | |||
InetAddress ia = null; | |||
while (nis.hasMoreElements()) { | |||
NetworkInterface ni = (NetworkInterface) nis.nextElement(); | |||
Enumeration<InetAddress> ias = ni.getInetAddresses(); | |||
while (ias.hasMoreElements()) { | |||
ia = ias.nextElement(); | |||
if (ia instanceof Inet6Address) { | |||
continue;// skip ipv6 | |||
} | |||
String ip = ia.getHostAddress(); | |||
if (!"127.0.0.1".equals(ip)) { | |||
hostIp = ia.getHostAddress(); | |||
break; | |||
} | |||
} | |||
} | |||
} catch (SocketException e) { | |||
Log.i("yao", "SocketException"); | |||
e.printStackTrace(); | |||
} | |||
return hostIp; | |||
} | |||
} | |||
@@ -0,0 +1,15 @@ | |||
package com.bonait.bnframework.common.UDP; | |||
public class SendUdpMode { | |||
public String ip; | |||
public int port; | |||
//数据格式 | |||
public String data; | |||
public SendUdpMode(String _IP,int _PORT,String _DATA) | |||
{ | |||
this.ip=_IP; | |||
this.port=_PORT; | |||
this.data=_DATA; | |||
} | |||
} |
@@ -0,0 +1,192 @@ | |||
package com.bonait.bnframework.common.UDP; | |||
import android.annotation.SuppressLint; | |||
import android.os.Handler; | |||
import android.os.Looper; | |||
import android.os.Message; | |||
import android.util.Log; | |||
import java.io.IOException; | |||
import java.io.UnsupportedEncodingException; | |||
import java.net.DatagramPacket; | |||
import java.net.DatagramSocket; | |||
import java.net.InetAddress; | |||
import java.net.SocketException; | |||
import java.net.UnknownHostException; | |||
import java.nio.charset.Charset; | |||
import java.util.concurrent.ExecutorService; | |||
public class UdpHelper { | |||
//region 变量 | |||
private static final String TAG = "UDP帮助"; | |||
/** | |||
* 服务端口 | |||
*/ | |||
public int ServerPort = 10000; | |||
/** | |||
* 是否启动监听 | |||
*/ | |||
private volatile boolean isRuning = false; | |||
/** | |||
* 接收数据服务端 | |||
*/ | |||
private DatagramSocket receiveSocket = null; | |||
/** | |||
* 反馈数据 | |||
*/ | |||
public Handler myHandler = null; | |||
/** | |||
* 服务端 | |||
*/ | |||
private ServerThread serverThread = new ServerThread(); | |||
/** | |||
* 客户端 | |||
*/ | |||
public ClientThread clientThread = new ClientThread(); | |||
//endregion | |||
//region 外部调用 | |||
/** | |||
* 服务启动监听 | |||
* | |||
* @param port | |||
*/ | |||
public void Start(int port) { | |||
ServerPort = port; | |||
try { | |||
receiveSocket = new DatagramSocket(port); | |||
} catch (SocketException e) { | |||
} | |||
isRuning = true; | |||
} | |||
/** | |||
* 停止监听 | |||
*/ | |||
public void Stop() { | |||
isRuning = false; | |||
if(receiveSocket!=null) | |||
{ | |||
receiveSocket.close(); | |||
} | |||
} | |||
/** | |||
* 发送数据 | |||
* | |||
* @param ip | |||
* @param port | |||
* @param data | |||
*/ | |||
public void SendData(String ip, int port, String data) { | |||
Message msg = Message.obtain(); | |||
msg.obj = new SendUdpMode(ip, port, data); | |||
msg.what = 1; | |||
clientThread.mhandler.sendMessage(msg); | |||
} | |||
//endregion | |||
//region 线程 | |||
/** | |||
* 发送数据线程 | |||
*/ | |||
public class ClientThread extends Thread { | |||
private Handler mhandler = null; | |||
@SuppressLint("HandlerLeak") | |||
@Override | |||
public void run() { | |||
Looper.prepare(); | |||
mhandler = new Handler() { | |||
@Override | |||
public void handleMessage(Message msg) { | |||
SendUdpMode message = (SendUdpMode) msg.obj; | |||
byte[] data = message.data.getBytes(Charset.forName("GBK")); | |||
DatagramPacket dpSend = null; | |||
DatagramSocket sendSocket = null; | |||
try { | |||
InetAddress inetAddress = InetAddress.getByName(message.ip.toString().trim()); | |||
dpSend = new DatagramPacket(data, data.length, inetAddress, message.port); | |||
} catch (UnknownHostException e) { | |||
} | |||
try { | |||
double start = System.currentTimeMillis(); | |||
for (int i = 0; i < 1; i++) { | |||
sendSocket = new DatagramSocket(); | |||
sendSocket.send(dpSend); | |||
sendSocket.close(); | |||
Thread.sleep(80); | |||
Log.i(TAG, "发送数据: " + new String(data)); | |||
} | |||
double end = System.currentTimeMillis(); | |||
double times = end - start; | |||
Log.i(TAG, "发送数据所用时间: " + times + "ms"); | |||
} catch (IOException e) { | |||
Log.i(TAG, "发送数据异常: " + e.getMessage()); | |||
} catch (InterruptedException e) { | |||
Log.i(TAG, "发送数据异常: " + e.getMessage()); | |||
} finally { | |||
if (sendSocket != null) { | |||
sendSocket.close(); | |||
} | |||
} | |||
} | |||
}; | |||
Looper.loop(); | |||
} | |||
} | |||
/** | |||
* 服务线程 | |||
*/ | |||
private class ServerThread extends Thread { | |||
@Override | |||
public void run() { | |||
while (true) { | |||
if (isRuning) { | |||
byte[] receiveData = new byte[1024]; | |||
DatagramPacket dpReceive = null; | |||
dpReceive = new DatagramPacket(receiveData, receiveData.length); | |||
try { | |||
receiveSocket.receive(dpReceive); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
String recIp = dpReceive.getAddress().toString().substring(1); | |||
String port = String.valueOf(dpReceive.getPort()); | |||
String content = ""; | |||
content = new String(receiveData, 0, dpReceive.getLength(), Charset.forName("GBK")); | |||
if (dpReceive != null) { | |||
Message revMessage = Message.obtain(); | |||
revMessage.what = 1; | |||
revMessage.obj = "收到来自" + recIp + ":" + port + "的信息:" + content; | |||
Log.i(TAG, "收到来自" + recIp + ":" + port + "的信息:" + content); | |||
if (myHandler != null) { | |||
myHandler.sendMessage(revMessage); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
//endregion | |||
//region 私有 | |||
// private static UdpHelper mInstance; //实例变量设置私有,防止直接通过类名访问 | |||
// | |||
// public static synchronized UdpHelper getInstance() { //静态同步方法作为唯一的实例对象获取方式 | |||
// if (mInstance == null) { | |||
// mInstance = new UdpHelper(); | |||
// } | |||
// return mInstance; | |||
// } | |||
// | |||
// private UdpHelper() { //默认构造函数私有,防止类外直接new创建对象 | |||
// clientThread.start(); | |||
// serverThread.start(); | |||
// } | |||
//endregion | |||
} |
@@ -1005,12 +1005,12 @@ public class ConfigName { | |||
/** | |||
* 版本信息 | |||
*/ | |||
public String[] versionSelectionValues = new String[]{"奶茶机", "配料吧台","味魔方","调味吧台"}; | |||
public String[] versionSelectionValues = new String[]{"一拖四", "一拖二"}; | |||
/** | |||
* 选配版本信息 | |||
*/ | |||
public String versionSelectionEnum = "调味吧台"; | |||
public String versionSelectionEnum = "一拖四"; | |||
//endregion | |||
//region 主页 | |||
@@ -21,6 +21,8 @@ public interface MessageName { | |||
String ClickImage="ClickImage";//点击图标 | |||
String GetOrganize="GetOrganize";//获取组织信息 | |||
String UpdateGood="UpdateGood";//修改商品 | |||
String DeleteGood1="DeleteGood1";//删除商品 | |||
@@ -90,7 +90,7 @@ public class MQTT { | |||
MessageLog.ShowInfo("mqtt断开连接,尝试重新连接..."); | |||
if(Disconnect!=null) | |||
{ | |||
Disconnect.Run(); | |||
Disconnect.Run(); | |||
} | |||
Reconnect(); | |||
} | |||
@@ -193,7 +193,8 @@ public class MQTT { | |||
IsConnect=true; | |||
if(ConnectOk!=null) | |||
{ | |||
ConnectOk.Run(); | |||
ConnectOk.Run(); | |||
} | |||
} catch (MqttException e) { | |||
Log.i("MQTT", "mqtt重连接失败!"+e.getMessage()); | |||
@@ -1,5 +1,7 @@ | |||
package com.bonait.bnframework.common.helper; | |||
import android.util.Log; | |||
import com.bonait.bnframework.common.db.res.AlertLogEnum; | |||
import com.bonait.bnframework.common.db.res.UserLogEnum; | |||
import com.bonait.bnframework.common.helper.I.IMessageLogNotify; | |||
@@ -41,6 +43,7 @@ public class MessageLog { | |||
} | |||
public static void ShowError(String msg) { | |||
Log.e("error", "onFailure: "+msg ); | |||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
Date date = new Date(); | |||
String tempMsg = formatter.format(date) + ":" + msg; | |||
@@ -58,6 +61,7 @@ public class MessageLog { | |||
*/ | |||
public static void ShowUserMessage(UserLogEnum type, String msg) | |||
{ | |||
Log.e(type.toString(), msg); | |||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
Date date = new Date(); | |||
String tempMsg = formatter.format(date) + ":" + msg; | |||
@@ -83,6 +87,7 @@ public class MessageLog { | |||
if (MsgNotify != null) | |||
MsgNotify.AlertMsg(type,tempMsg); | |||
if (AddNotify != null) AddNotify.Run(); | |||
} | |||
@@ -37,6 +37,7 @@ public class RTrig { | |||
setIN(IN); | |||
if (Q) | |||
callback.Run(); | |||
} | |||
} |
@@ -193,7 +193,17 @@ public class DataConvertLib { | |||
return -1; | |||
} | |||
} | |||
} else { | |||
}else if (address.toUpperCase().contains("GI") &&address.length() >=3){ | |||
String res = address.substring(2); | |||
if (res != null) { | |||
try { | |||
return Integer.parseInt(res); | |||
} catch (NumberFormatException e) { | |||
return -1; | |||
} | |||
} | |||
} | |||
else { | |||
try { | |||
return Integer.parseInt(address); | |||
} catch (NumberFormatException e) { | |||
@@ -21,20 +21,21 @@ public class ExceptionServer { | |||
} | |||
if (excpet!=null) excpet.onSuccess(add); | |||
} catch (InterruptedException e) { | |||
MessageLog.ShowError("onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); | |||
if (excpet!=null) excpet.onFailure(e.toString()); | |||
MessageLog.ShowError("InterruptedException,Address=" + Address + ",length=" + length + ",msg:" + e.getMessage()); | |||
if (excpet!=null) excpet.onFailure(e.getMessage()); | |||
} catch (ExecutionException e) { | |||
MessageLog.ShowError("onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); | |||
if (excpet!=null) excpet.onFailure(e.toString()); | |||
MessageLog.ShowError("ExecutionException,Address=" + Address + ",length=" + length + ",msg:" + e.getMessage()); | |||
if (excpet!=null) excpet.onFailure(e.getMessage()); | |||
} catch (ModbusTransportException e) { | |||
MessageLog.ShowError("onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); | |||
if (excpet!=null) excpet.onFailure(e.toString()); | |||
MessageLog.ShowError("ModbusTransportException,Address=" + Address + ",length=" + length + ",msg:" + e.getMessage()); | |||
if (excpet!=null) excpet.onFailure(e.getMessage()); | |||
} catch (ModbusInitException e) { | |||
MessageLog.ShowError("onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); | |||
if (excpet!=null) excpet.onFailure(e.toString()); | |||
MessageLog.ShowError("ModbusInitException,Address=" + Address + ",length=" + length + ",msg:" + e.getMessage()); | |||
if (excpet!=null) excpet.onFailure(e.getMessage()); | |||
} catch (ModbusRespException e) { | |||
MessageLog.ShowError("onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); | |||
if (excpet!=null) excpet.onFailure(e.toString()); | |||
MessageLog.ShowError("ModbusRespException,Address=" + Address + ",length=" + length + ",msg:" + e.getMessage()); | |||
if (excpet!=null) excpet.onFailure(e.getMessage()); | |||
} | |||
} | |||
} |
@@ -23,6 +23,7 @@ import com.licheedev.modbus4android.ModbusParam; | |||
import com.licheedev.modbus4android.ModbusRespException; | |||
import com.licheedev.modbus4android.param.SerialParam; | |||
import com.licheedev.modbus4android.param.TcpParam; | |||
import com.serotonin.modbus4j.ModbusFactory; | |||
import com.serotonin.modbus4j.exception.ModbusInitException; | |||
import com.serotonin.modbus4j.exception.ModbusTransportException; | |||
import com.serotonin.modbus4j.msg.ReadCoilsResponse; | |||
@@ -60,6 +61,10 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
private ModbusMaster() { | |||
} | |||
//https://blog.csdn.net/zgkxzx/article/details/71630301 | |||
ModbusFactory factory = new ModbusFactory();//使用该方法可以创建不同类型的modbus通讯 | |||
/** | |||
* Ping PLC地址是否通畅 | |||
* @param address | |||
@@ -98,6 +103,32 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
public boolean IsConnected=false; | |||
private String TempIp; | |||
private int TempPort; | |||
private String TempCom; | |||
private int TempBaudRate; | |||
/** | |||
* 连接类型,1=TCP,2=RUT | |||
*/ | |||
private int ConnectionType; | |||
private void ReConnect(String error){ | |||
if(ConnectionType==1){ | |||
if(error.contains("Connection refused")){ | |||
IsConnected=false; | |||
TcpConnect(TempIp,TempPort,null); | |||
} | |||
} | |||
else if (ConnectionType==2){ | |||
if(error.contains("Connection refused")){ | |||
IsConnected=false; | |||
RtuConnect(TempCom,TempBaudRate,null); | |||
} | |||
} | |||
} | |||
/** | |||
* TCP 连接,连接时请用多线程的方式,否者有可能无法连接 | |||
* @param ip | |||
@@ -106,7 +137,10 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
* @throws InterruptedException | |||
*/ | |||
@Override | |||
public void TcpConnect(String ip, int port, IOperateResult result)throws InterruptedException { | |||
public void TcpConnect(String ip, int port, IOperateResult result){ | |||
TempIp=ip; | |||
TempPort=port; | |||
ConnectionType=1; | |||
MessageLog.ShowInfo("开始验证网络:"+ip ); | |||
boolean status = false; | |||
while (!status) { | |||
@@ -128,7 +162,6 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
.setKeepAlive(true); | |||
while (IsConnected==false) | |||
{ | |||
MessageLog.ShowInfo("Modbus TCP 1111" ); | |||
ModbusBasis.get().init(param, new ModbusCallback<com.serotonin.modbus4j.ModbusMaster>() { | |||
@Override | |||
public void onSuccess(com.serotonin.modbus4j.ModbusMaster modbusMaster) { | |||
@@ -147,7 +180,12 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
if(result!=null) result.onFinally(); | |||
} | |||
}); | |||
if(IsConnected==false) Thread.sleep(5000); | |||
try | |||
{ | |||
if(IsConnected==false) Thread.sleep(5000); | |||
}catch(InterruptedException ex){ | |||
} | |||
} | |||
} | |||
@@ -159,8 +197,11 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
* @throws InterruptedException | |||
*/ | |||
@Override | |||
public void RtuConnect(String com, int baudRate, IOperateResult result)throws InterruptedException { | |||
public void RtuConnect(String com, int baudRate, IOperateResult result){ | |||
MessageLog.ShowInfo("开始连接Modbus RTU" ); | |||
TempCom=com; | |||
TempBaudRate=baudRate; | |||
ConnectionType=2; | |||
ModbusParam param=SerialParam.create(com, baudRate) // 串口地址和波特率 | |||
.setDataBits(8) // 数据位 | |||
.setParity(0) // 校验位 | |||
@@ -186,7 +227,11 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
if(result!=null) result.onFinally(); | |||
} | |||
}); | |||
if(IsConnected==false) Thread.sleep(5000); | |||
try{ | |||
if(IsConnected==false) Thread.sleep(5000); | |||
}catch (InterruptedException ex){ | |||
} | |||
} | |||
} | |||
@@ -205,7 +250,8 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -226,8 +272,8 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -259,8 +305,8 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -298,8 +344,8 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -323,8 +369,8 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -353,8 +399,8 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -384,8 +430,9 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
if (callback != null)callback.onFailure(error); | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -404,8 +451,9 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
if (callback != null)callback.onFailure(error); | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -426,8 +474,9 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
if (callback != null)callback.onFailure(error); | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -446,8 +495,9 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
if (callback != null)callback.onFailure(error); | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -467,8 +517,9 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
if (callback != null)callback.onFailure(error); | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -497,8 +548,9 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
if (callback != null)callback.onFailure(error); | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -519,8 +571,9 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
if (callback != null)callback.onFailure(error); | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -541,8 +594,9 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
if (callback != null)callback.onFailure(error); | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
@@ -572,13 +626,12 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster { | |||
} | |||
@Override | |||
public void onFailure(String error){ | |||
public void onFailure(String error) { | |||
if (callback != null)callback.onFailure(error); | |||
ReConnect(error); | |||
} | |||
}); | |||
} | |||
} |
@@ -41,7 +41,7 @@ public class MainNavigateTabBar extends LinearLayout implements View.OnClickList | |||
private ColorStateList mSelectedTextColor; | |||
private ColorStateList mNormalTextColor; | |||
private float mTabTextSize; | |||
private int mDefaultSelectedTab = 2; | |||
private int mDefaultSelectedTab = 0; | |||
private int mCurrentSelectedTab; | |||
public MainNavigateTabBar(Context context) { | |||
@@ -6,32 +6,26 @@ import androidx.viewpager.widget.ViewPager; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
import com.bonait.bnframework.MainActivity; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ConfigData; | |||
import com.bonait.bnframework.business.DoubleFryingpanControl; | |||
import com.bonait.bnframework.business.OrderServer; | |||
import com.bonait.bnframework.business.RobotControl; | |||
import com.bonait.bnframework.common.ModbusSlave.ModbusTcpSlave; | |||
import com.bonait.bnframework.common.base.BaseActivity; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.helper.DataFormat; | |||
import com.bonait.bnframework.common.helper.I.IThread; | |||
import com.bonait.bnframework.common.helper.I.IWriteCallBack; | |||
import com.bonait.bnframework.common.helper.MQTT; | |||
import com.bonait.bnframework.common.helper.MediaPlayerHelper; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.helper.ThreadManager; | |||
import com.bonait.bnframework.common.modbus.ByteLib; | |||
import com.bonait.bnframework.common.modbus.FloatLib; | |||
import com.bonait.bnframework.common.modbus.IOperateResult; | |||
import com.bonait.bnframework.common.modbus.ModbusClient; | |||
import com.bonait.bnframework.common.modbus.ModbusMaster; | |||
import com.bonait.bnframework.common.modbus.ShortLib; | |||
import com.bonait.bnframework.common.tabbar.MainNavigateTabBar; | |||
import com.bonait.bnframework.common.utils.NetworkUtils; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.bonait.bnframework.modules.home.adapter.FragmentAdapter; | |||
import com.bonait.bnframework.modules.home.fragment.DingDanfragment; | |||
import com.bonait.bnframework.modules.home.fragment.DoubleFryingpanFragment; | |||
import com.bonait.bnframework.modules.home.fragment.GongnengFragment; | |||
import com.bonait.bnframework.modules.home.fragment.MakeGoodFragment; | |||
import com.bonait.bnframework.modules.home.fragment.RobotMain; | |||
import com.bonait.bnframework.modules.home.fragment.SheZhifragment; | |||
import com.bonait.bnframework.modules.mine.fragment.MyFragment; | |||
@@ -57,17 +51,23 @@ public class BottomNavigationMainActivity extends BaseActivity { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.activity_bottom_navigation_main); | |||
ButterKnife.bind(this); | |||
MediaPlayerHelper.getInstance().SetConText(getBaseContext()); | |||
mNavigateTabBar.onRestoreInstanceState(savedInstanceState); | |||
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.gongneng, R.mipmap.gongneng_selected, "功能")); | |||
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.dingdan, R.mipmap.dingdan_selected, "订单")); | |||
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(0, 0, "")); | |||
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.shezhi, R.mipmap.shezhi_selected, "设置")); | |||
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.comui_tab_person, R.mipmap.comui_tab_person_selected, "我的")); | |||
mNavigateTabBar.setTabSelectListener(mOnNavigationItemSelectedListener); | |||
initFragment(); | |||
Init(); | |||
try { | |||
ButterKnife.bind(this); | |||
MediaPlayerHelper.getInstance().SetConText(getBaseContext()); | |||
mNavigateTabBar.onRestoreInstanceState(savedInstanceState); | |||
// mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.gongneng, R.mipmap.gongneng_selected, "功能")); | |||
// mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.dingdan, R.mipmap.dingdan_selected, "日志")); | |||
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(0, 0, "")); | |||
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.shezhi, R.mipmap.shezhi_selected, "设置")); | |||
// mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.comui_tab_person, R.mipmap.comui_tab_person_selected, "我的")); | |||
mNavigateTabBar.setTabSelectListener(mOnNavigationItemSelectedListener); | |||
initFragment(); | |||
Init(); | |||
} | |||
catch (Exception e){ | |||
Log.i("TAG", "onCreate: "+e.getMessage()); | |||
} | |||
} | |||
@@ -88,21 +88,28 @@ public class BottomNavigationMainActivity extends BaseActivity { | |||
*/ | |||
private void initFragment() { | |||
fragmentList = new ArrayList<>(); | |||
fragmentList.add(new GongnengFragment()); | |||
fragmentList.add(new DingDanfragment()); | |||
// fragmentList.add(new GongnengFragment()); | |||
// fragmentList.add(new DingDanfragment()); | |||
if(ConfigName.getInstance().versionSelectionEnum.equals("一拖四")){ | |||
fragmentList.add(new RobotMain()); | |||
} | |||
else if (ConfigName.getInstance().versionSelectionEnum.equals("一拖二")){ | |||
fragmentList.add(new DoubleFryingpanFragment()); | |||
} | |||
// fragmentList.add(new MakeGoodFragment());//再来一单 | |||
fragmentList.add(new RobotMain()); | |||
fragmentList.add(new SheZhifragment()); | |||
fragmentList.add(new MyFragment()); | |||
// fragmentList.add(new MyFragment()); | |||
ConfigName.getInstance().fragmentAdapter = new FragmentAdapter(getSupportFragmentManager(), fragmentList); | |||
viewPager.setAdapter(ConfigName.getInstance().fragmentAdapter); | |||
ConfigName.getInstance().fragmentAdapter.SetViewPage(viewPager); | |||
//手指滑动 | |||
viewPager.addOnPageChangeListener(pageChangeListener); | |||
// 设置viewPager缓存多少个fragment | |||
viewPager.setOffscreenPageLimit(5); | |||
viewPager.setOffscreenPageLimit(2); | |||
// 再来一单 | |||
viewPager.setCurrentItem(2); | |||
viewPager.setCurrentItem(0); | |||
} | |||
/** | |||
@@ -115,42 +122,23 @@ public class BottomNavigationMainActivity extends BaseActivity { | |||
//ConfigData.getInstance().GetOrganize(this); | |||
//判断连接环境 | |||
ConfigData.getInstance().ToggleEnvironment(); | |||
if(ConfigName.getInstance().versionSelectionEnum.equals("一拖四")){ | |||
RobotControl.getInstance().Init(); | |||
} | |||
else if (ConfigName.getInstance().versionSelectionEnum.equals("一拖二")){ | |||
DoubleFryingpanControl.getInstance().Init(); | |||
} | |||
//2.初始化PLC | |||
ReconnectModbus(); | |||
// ReconnectModbus(); | |||
//MQTT数据监听 | |||
OrderServer.Get().MqttInit(); | |||
// OrderServer.Get().MqttInit(); | |||
} | |||
/** | |||
* 重新连接plc | |||
*/ | |||
public void ReconnectModbus() { | |||
new Thread(()->{ | |||
try { | |||
ModbusMaster.get().RtuConnect(ConfigName.getInstance().SerialPortName, 9600, new IOperateResult() { | |||
@Override | |||
public void onSuccess() { | |||
ConfigName.getInstance().PlcIsConnect = true; | |||
ConfigData.getInstance().PLC_Init(); | |||
} | |||
@Override | |||
public void onFailure(String message) { | |||
ConfigName.getInstance().PlcIsConnect = false; | |||
ToastUtils.info("设备 " + ConfigName.getInstance().Address + " 连接失败:" + message); | |||
} | |||
@Override | |||
public void onFinally() { | |||
} | |||
}); | |||
}catch (Exception e ) | |||
{ | |||
MessageLog.ShowInfo("重新连接Modbus异常," + e.getMessage()); | |||
} | |||
}).start(); | |||
} | |||
/** | |||
@@ -160,22 +148,40 @@ public class BottomNavigationMainActivity extends BaseActivity { | |||
= new MainNavigateTabBar.OnTabSelectedListener() { | |||
@Override | |||
public void onTabSelected(MainNavigateTabBar.ViewHolder holder) { | |||
int _postion = 2; | |||
// int _postion = 2; | |||
// switch (holder.tag) { | |||
// case "功能": | |||
// _postion = 0; | |||
// break; | |||
// case "订单": | |||
// _postion = 1; | |||
// break; | |||
// case "设置": | |||
// _postion = 3; | |||
// break; | |||
// case "我的": | |||
// _postion = 4; | |||
// break; | |||
// case "": | |||
// _postion = 2; | |||
// break; | |||
// } | |||
int _postion = 0; | |||
switch (holder.tag) { | |||
case "功能": | |||
_postion = 0; | |||
break; | |||
case "订单": | |||
_postion = 1; | |||
break; | |||
// case "功能": | |||
// _postion = 0; | |||
// break; | |||
// case "订单": | |||
// _postion = 1; | |||
// break; | |||
case "设置": | |||
_postion = 3; | |||
break; | |||
case "我的": | |||
_postion = 4; | |||
_postion =1; | |||
break; | |||
// case "我的": | |||
// _postion = 4; | |||
// break; | |||
case "": | |||
_postion = 2; | |||
_postion = 0; | |||
break; | |||
} | |||
viewPager.setCurrentItem(_postion); | |||
@@ -0,0 +1,554 @@ | |||
package com.bonait.bnframework.modules.home.fragment; | |||
import android.annotation.SuppressLint; | |||
import android.graphics.Color; | |||
import android.os.Bundle; | |||
import android.os.Handler; | |||
import android.os.Message; | |||
import android.util.Log; | |||
import android.view.Gravity; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.widget.AdapterView; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.Button; | |||
import android.widget.Spinner; | |||
import android.widget.TextView; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ConfigData; | |||
import com.bonait.bnframework.business.DoubleFryingpanControl; | |||
import com.bonait.bnframework.business.FryingPanPar; | |||
import com.bonait.bnframework.business.ICompleteNotify; | |||
import com.bonait.bnframework.business.IStatusNotify; | |||
import com.bonait.bnframework.business.RobotControl; | |||
import com.bonait.bnframework.business.RobotData; | |||
import com.bonait.bnframework.common.base.BaseFragment; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.constant.MessageName; | |||
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.I.IRun; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.linktab.LinkMode; | |||
import com.bonait.bnframework.common.linktab.makegood.MakeGoodRightAdapter; | |||
import com.bonait.bnframework.common.message.MessageLooper; | |||
import com.bonait.bnframework.common.message.MessageManager; | |||
import com.bonait.bnframework.common.modbus.ModbusMaster; | |||
import com.bonait.bnframework.common.model.mode.CloudGood; | |||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | |||
import com.bonait.bnframework.dialog.DialogManager; | |||
import com.bonait.bnframework.dialog.DialogView; | |||
import com.qmuiteam.qmui.widget.QMUITopBarLayout; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import butterknife.BindView; | |||
import butterknife.ButterKnife; | |||
public class DoubleFryingpanFragment extends BaseFragment { | |||
@BindView(R.id.main_btn1) | |||
Button btn1; | |||
@BindView(R.id.main_btn2) | |||
Button btn2; | |||
@BindView(R.id.btn_warehousing) | |||
Button btn_warehousing; | |||
@BindView(R.id.btn_maintenance) | |||
Button btn_maintenance; | |||
@BindView(R.id.tv_Status1) | |||
TextView tv_Status1; | |||
@BindView(R.id.tv_Status2) | |||
TextView tv_Status2; | |||
@BindView(R.id.robot_topbar) | |||
QMUITopBarLayout mTopBar;//顶部标题 | |||
RecyclerView material; | |||
private DialogView mDialogVisual; | |||
private DialogView mParSetVisual; | |||
/** | |||
* 库位选择 | |||
*/ | |||
private DialogView mWarehouselocSelectVisual; | |||
@Override | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_double_fryingpan, null); | |||
ButterKnife.bind(this, root); | |||
return root; | |||
} | |||
@Override | |||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | |||
super.onViewCreated(view, savedInstanceState); | |||
OpenGoodSelectDialog(); | |||
Init(); | |||
DoubleFryingpanControl.getInstance().completeNotify= new ICompleteNotify() { | |||
@Override | |||
public void onComplete(int num) { | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
if (num==1){ | |||
btn1.setText("选择菜品"); | |||
btn1.setBackgroundResource(R.drawable.button4); | |||
btn1.setVisibility(View.VISIBLE); | |||
btn1.setTextColor(Color.parseColor("#000000")); | |||
} | |||
else if (num==2){ | |||
btn2.setText("选择菜品"); | |||
btn2.setBackgroundResource(R.drawable.button4); | |||
btn2.setVisibility(View.VISIBLE); | |||
btn2.setTextColor(Color.parseColor("#000000")); | |||
} | |||
} | |||
}); | |||
} | |||
}; | |||
String status = ModbusMaster.get().IsConnected?"已连接":"未连接"; | |||
mTopBar.setTitle("机器人连接状态:"+ status); | |||
DoubleFryingpanControl.getInstance().statusNotify=new IStatusNotify() { | |||
@Override | |||
public void OnStatusChanged(String s1, String s2, String s3, String s4) { | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
tv_Status1.setText(s1); | |||
tv_Status2.setText(s2); | |||
String status = ModbusMaster.get().IsConnected?"已连接":"未连接"; | |||
mTopBar.setTitle("机器人连接状态:"+ status); | |||
} | |||
}); | |||
} | |||
}; | |||
mDialogVisual= DialogManager.getInstance().initView(getContext(), R.layout.activity_material_view, Gravity.BOTTOM); | |||
mParSetVisual = DialogManager.getInstance().initView(getContext(),R.layout.activity_par_set1,Gravity.BOTTOM); | |||
mWarehouselocSelectVisual = DialogManager.getInstance().initView(getContext(),R.layout.activity_warehouseloc_select,Gravity.BOTTOM); | |||
} | |||
@SuppressLint("HandlerLeak") | |||
private Handler mHandler = new Handler() { | |||
@Override | |||
public void handleMessage(Message msg) { | |||
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<BPA_GOODS> goods= QueryDB.GetGoodsALL(); | |||
// ArrayList<BPA_GOODSRECIPE> 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<BPA_GOODS> goods= QueryDB.GetGoodsALL(); | |||
ArrayList<BPA_GOODSRECIPE> 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); | |||
} | |||
LoadingGood(); | |||
} | |||
MessageLog.ShowInfo( "handleMessage: 获取商品信息成功"); | |||
} | |||
} | |||
}; | |||
private void Init(){ | |||
MessageLog.ShowInfo("Init: 开始获取云端数据"); | |||
ConfigData.getInstance().GetOrganize(getContext()); | |||
ConfigData.getInstance().GetGevGood(getContext(),mHandler); | |||
} | |||
private void OpenParSet(){ | |||
//参数配置界面确认按钮 | |||
ButtonClickBinder(mParSetVisual, R.id.parset_ok_btn,()->{ | |||
MessageLog.ShowInfo( "onClick: 确认参数配置"); | |||
if(!ModbusMaster.get().IsConnected){ | |||
AlertDialogUtils.showDialog(getContext(),"提示","请先连接机器人"); | |||
return; | |||
} | |||
DoubleFryingpanControl.getInstance(). GoodDown(fry.GoodID,fry.FryingPanNum); | |||
try { | |||
long startTime=System.currentTimeMillis(); | |||
while(!DoubleFryingpanControl.getInstance().GetGoodVery(fry.FryingPanNum)&&(System.currentTimeMillis()-startTime)<=4000){ | |||
Thread.sleep(100); | |||
} | |||
if (DoubleFryingpanControl.getInstance().GetGoodVery(fry.FryingPanNum)){ | |||
if (fry.FryingPanNum==1){ | |||
btn1.setText("强制取消"); | |||
btn1.setBackgroundResource(R.drawable.button5); | |||
btn1.setTextColor(Color.parseColor("#ffffff")); | |||
} | |||
else if (fry.FryingPanNum==2){ | |||
btn2.setText("强制取消"); | |||
btn2.setBackgroundResource(R.drawable.button5); | |||
btn2.setTextColor(Color.parseColor("#ffffff")); | |||
} | |||
DoubleFryingpanControl.getInstance().FryingPan.put(fry.FryingPanNum,fry); | |||
fry=new FryingPanPar(); | |||
DialogManager.getInstance().hide(mParSetVisual);//关闭参数设置窗口 | |||
} | |||
else{ | |||
AlertDialogUtils.showDialog(getContext(),"提示","商品验证失败"); | |||
} | |||
} | |||
catch (InterruptedException e) { | |||
} | |||
}); | |||
//参数配置界面取消按钮 | |||
ButtonClickBinder(mParSetVisual, R.id.parset_cancel_btn, ()->{ | |||
MessageLog.ShowInfo( "onClick: 退出参数配置"); | |||
fry=new FryingPanPar(); | |||
DialogManager.getInstance().hide(mParSetVisual);//关闭参数设置窗口 | |||
}); | |||
DialogManager.getInstance().hide(mDialogVisual);//关闭商品选择窗口 | |||
DialogManager.getInstance().show(mParSetVisual,R.id.parset_close_dialog); //打开参数设置窗口 | |||
ParSetInit(R.id.location_selection_1,new String[] {"0", "1", "2", "3", "4","5","6"}); | |||
ParSetInit(R.id.location_selection_2,new String[] {"0", "1", "2", "3", "4","5","6"}); | |||
ParSetInit(R.id.accessories_selection_1,new String[] {"0", "1", "2", "3", "4","5"}); | |||
ParSetInit(R.id.accessories_selection_2,new String[] {"0", "1", "2", "3", "4","5"}); | |||
} | |||
int Warehouseloc=0; | |||
/** | |||
* 手动入库 | |||
*/ | |||
private void WarehouselocInit(){ | |||
ButtonClickBinder(mWarehouselocSelectVisual, R.id.parset_ok_btn,()->{ | |||
if(Warehouseloc>=1&&Warehouseloc<=6){ | |||
btn_warehousing.setEnabled(false);//禁用按钮 | |||
btn_warehousing.setText("入库中..."); | |||
ModbusMaster.get().WriteShort("GI0",(short) (Warehouseloc+30),1,null);//写入机器人主任务,指定入库位置 | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
while(!RobotData.RobotWarehousingComplete[Warehouseloc-1]){ | |||
Thread.sleep(100); | |||
} | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
btn_warehousing.setText("入库"); | |||
btn_warehousing.setEnabled(true);//禁用按钮 | |||
} | |||
}); | |||
}catch(InterruptedException ex){ | |||
} | |||
} | |||
}).start(); | |||
}else{ | |||
AlertDialogUtils.showDialog(getContext(),"提示","错误的库位编号"); | |||
} | |||
}); | |||
//参数配置界面取消按钮 | |||
ButtonClickBinder(mWarehouselocSelectVisual, R.id.parset_cancel_btn, ()->{ | |||
MessageLog.ShowInfo("onClick: 退出参数配置"); | |||
Warehouseloc=0; | |||
DialogManager.getInstance().hide(mWarehouselocSelectVisual);//关闭参数设置窗口 | |||
}); | |||
String[] args=new String[] {"0", "1", "2", "3", "4","5","6"}; | |||
Spinner sp = mWarehouselocSelectVisual.findViewById(R.id.location_selection_1); | |||
ArrayAdapter<String> starAdapter = new ArrayAdapter<String>(getContext(), R.layout.select_item, args); | |||
sp.setAdapter(starAdapter); | |||
sp.setSelection(0); | |||
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | |||
@Override | |||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { | |||
if(R.id.location_selection_1==R.id.location_selection_1) { | |||
Warehouseloc=Integer.parseInt(adapterView.getItemAtPosition(i).toString()); | |||
} | |||
} | |||
@Override | |||
public void onNothingSelected(AdapterView<?> adapterView) { | |||
} | |||
}); | |||
} | |||
FryingPanPar fry=new FryingPanPar(); | |||
boolean IsMaintenanceMode=false; | |||
private void OpenGoodSelectDialog() | |||
{ | |||
MessageManager.getInstance().registerMessageReceiver(getActivity(), MessageName.ClickMakeGoodNew, new MessageLooper.OnMessageListener() { | |||
@Override | |||
public void onMessage(Object msg) { | |||
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(); | |||
} | |||
} | |||
}); | |||
} | |||
} | |||
}); | |||
btn1.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view){ | |||
ProductSelectionButtonBinder(R.id.main_btn1,1); | |||
} | |||
}); | |||
btn2.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view){ | |||
ProductSelectionButtonBinder(R.id.main_btn2,2); | |||
} | |||
}); | |||
//手动入库 | |||
btn_warehousing.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view){ | |||
if(!ModbusMaster.get().IsConnected){ | |||
AlertDialogUtils.showDialog(getContext(),"提示","机器人未连接"); | |||
return; | |||
} | |||
if(RobotData.RobotIdle){ | |||
WarehouselocInit(); | |||
mWarehouselocSelectVisual.setCanceledOnTouchOutside(false); | |||
DialogManager.getInstance().show(mWarehouselocSelectVisual,R.id.close_dialog); //打开商品选择窗口 | |||
} | |||
else{ | |||
AlertDialogUtils.showDialog(getContext(),"提示","机器人忙碌中,请稍后"); | |||
} | |||
} | |||
}); | |||
//机器人维护 | |||
btn_maintenance.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view){ | |||
if(!ModbusMaster.get().IsConnected){ | |||
AlertDialogUtils.showDialog(getContext(),"提示","机器人未连接"); | |||
return; | |||
} | |||
if(!IsMaintenanceMode) | |||
{ | |||
if(RobotData.RobotIdle){ | |||
AlertDialogUtils.showDialog(getContext(), "提示", "是否进入机器人维护模式?", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
btn_maintenance.setEnabled(false);//禁用按钮 | |||
btn_warehousing.setText("维护模式中..."); | |||
ModbusMaster.get().WriteShort("GI0",(short) (41),1,null);//写入机器人主任务,指定入库位置 | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
while(!RobotData.RobotReachTending){ | |||
Thread.sleep(100); | |||
} | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
btn_warehousing.setText("完成维护"); | |||
btn_warehousing.setEnabled(true);//取消禁用按钮 | |||
} | |||
}); | |||
}catch(InterruptedException ex){ | |||
} | |||
} | |||
}).start(); | |||
} | |||
}); | |||
} | |||
else{ | |||
AlertDialogUtils.showDialog(getContext(),"提示","机器人忙碌中,请稍后"); | |||
} | |||
} | |||
else{ | |||
ModbusMaster.get().WriteBool(DoubleFryingpanControl.getInstance().RobotAddress("M520"), true,1,null);//写入机器人主任务,指定入库位置 | |||
btn_warehousing.setText("维护"); | |||
IsMaintenanceMode=false; | |||
} | |||
} | |||
}); | |||
} | |||
/** | |||
* 同步商品 | |||
*/ | |||
private void synchronous(){ | |||
Button btn=mDialogVisual.findViewById(R.id.synchronous); | |||
btn.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
Init(); | |||
LoadingGood(); | |||
} | |||
}); | |||
} | |||
/** | |||
* 加载商品 | |||
*/ | |||
public void LoadingGood() { | |||
ArrayList<BPA_GOODS> goods= QueryDB.GetGoodsALL(); | |||
ArrayList<BPA_GOODS> goodsm=new ArrayList<>(); | |||
if (goods.size()>0){ | |||
for (BPA_GOODS item:goods)goodsm.add(item); | |||
}else{ | |||
for(CloudGood item: ConfigName.getInstance().cloudGoods){ | |||
BPA_GOODS bpa=new BPA_GOODS(); | |||
bpa.name=item.goods_Name; | |||
bpa.url=item.goods_ImgUrl; | |||
bpa.id=item.id; | |||
goodsm.add(bpa); | |||
} | |||
} | |||
List<LinkMode> Fdata = new ArrayList<>(); | |||
Fdata.add(new LinkMode("main", Arrays.asList(goodsm.toArray()),true)); | |||
MakeGoodRightAdapter rightAdapter = new MakeGoodRightAdapter(R.layout.item_right_lc, Fdata, getResources()); | |||
material.setAdapter(rightAdapter); | |||
} | |||
private void ParSetInit(int id,String[] args) | |||
{ | |||
Spinner sp = mParSetVisual.findViewById(id); | |||
ArrayAdapter<String> starAdapter = new ArrayAdapter<String>(getContext(), R.layout.select_item, args); | |||
sp.setAdapter(starAdapter); | |||
sp.setSelection(0); | |||
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | |||
@Override | |||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { | |||
if(R.id.location_selection_1==id) { | |||
fry.IngredientsLocs[0]=Integer.parseInt(adapterView.getItemAtPosition(i).toString()); | |||
} | |||
else if (R.id.location_selection_2==id) { | |||
fry.IngredientsLocs[1]=Integer.parseInt(adapterView.getItemAtPosition(i).toString());; | |||
} | |||
else if (R.id.accessories_selection_1==id) { | |||
fry.AccessoriesLocs[0]=Integer.parseInt(adapterView.getItemAtPosition(i).toString());; | |||
} | |||
else if (R.id.accessories_selection_2==id) { | |||
fry.AccessoriesLocs[1]=Integer.parseInt(adapterView.getItemAtPosition(i).toString());; | |||
} | |||
} | |||
@Override | |||
public void onNothingSelected(AdapterView<?> adapterView) { | |||
} | |||
}); | |||
} | |||
/** | |||
* 菜品选择事件执行 | |||
* @param id 按钮id | |||
* @param FiryNum 炒锅编号 | |||
*/ | |||
private void ProductSelectionButtonBinder(int id,int FiryNum){ | |||
Button btn =getActivity().findViewById(id); | |||
if(btn.getText().equals("强制取消")) | |||
{ | |||
AlertDialogUtils.showDialog(getContext(), "提示", "是否强制结束任务?", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
DoubleFryingpanControl.getInstance().SetForceEnd(FiryNum); | |||
btn.setVisibility(View.GONE); | |||
dialog.dismiss(); | |||
} | |||
}); | |||
} | |||
else | |||
{ | |||
fry.FryingPanNum=FiryNum; | |||
mDialogVisual.setCanceledOnTouchOutside(false); | |||
material=mDialogVisual.findViewById(R.id.rv_material); | |||
synchronous(); | |||
LoadingGood(); | |||
if(!getActivity().isFinishing()) | |||
DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
} | |||
} | |||
/** | |||
* 弹框按钮事件绑定 | |||
* @param dv 弹框页面 | |||
* @param id 按钮id | |||
* @param action 执行委托 | |||
*/ | |||
private void ButtonClickBinder(DialogView dv,int id, IRun action){ | |||
if(dv!=null&& !dv.findViewById(id).hasOnClickListeners()){ | |||
dv.findViewById(id).setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
if(action!=null) action.Run(); | |||
} | |||
}); | |||
} | |||
} | |||
} |
@@ -187,7 +187,6 @@ public class MakeGoodFragment extends BaseFragment { | |||
rv_left.setAdapter(leftAdapter); | |||
rv_right.setAdapter(rightAdapter); | |||
//添加分组悬浮效果 | |||
List<String> typeListener = new ArrayList<>(); | |||
for (LinkMode item : Fdata) { | |||
@@ -1,7 +1,10 @@ | |||
package com.bonait.bnframework.modules.home.fragment; | |||
import android.annotation.SuppressLint; | |||
import android.graphics.Color; | |||
import android.os.Bundle; | |||
import android.os.Handler; | |||
import android.os.Message; | |||
import android.util.Log; | |||
import android.view.Gravity; | |||
import android.view.LayoutInflater; | |||
@@ -10,27 +13,57 @@ import android.widget.AdapterView; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.Button; | |||
import android.widget.Spinner; | |||
import android.widget.TextView; | |||
import android.widget.Toast; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.recyclerview.widget.LinearLayoutManager; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ConfigData; | |||
import com.bonait.bnframework.business.DoubleFryingpanControl; | |||
import com.bonait.bnframework.business.ExecuteTheRecipe; | |||
import com.bonait.bnframework.business.FryingPanPar; | |||
import com.bonait.bnframework.business.ICompleteNotify; | |||
import com.bonait.bnframework.business.IStatusNotify; | |||
import com.bonait.bnframework.business.OrderData; | |||
import com.bonait.bnframework.business.RobotControl; | |||
import com.bonait.bnframework.common.base.BaseFragment; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.constant.DataBus; | |||
import com.bonait.bnframework.common.constant.MessageName; | |||
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.db.res.ResGoodsMake; | |||
import com.bonait.bnframework.common.helper.I.IRun; | |||
import com.bonait.bnframework.common.helper.I.MyClickListener; | |||
import com.bonait.bnframework.common.linktab.LinkMode; | |||
import com.bonait.bnframework.common.linktab.makegood.MakeGoodLeftAdapter; | |||
import com.bonait.bnframework.common.linktab.makegood.MakeGoodRightAdapter; | |||
import com.bonait.bnframework.common.message.MessageLooper; | |||
import com.bonait.bnframework.common.message.MessageManager; | |||
import com.bonait.bnframework.common.modbus.ModbusMaster; | |||
import com.bonait.bnframework.common.model.mode.CloudGood; | |||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | |||
import com.bonait.bnframework.dialog.DialogManager; | |||
import com.bonait.bnframework.dialog.DialogView; | |||
import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter; | |||
import com.qmuiteam.qmui.widget.QMUITopBarLayout; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import butterknife.BindView; | |||
import butterknife.ButterKnife; | |||
public class RobotMain extends BaseFragment { | |||
// @BindView(R.id.robot_topbar) | |||
// QMUITopBarLayout mTopBar;//顶部标题 | |||
@BindView(R.id.main_btn1) | |||
Button btn1; | |||
@@ -43,6 +76,23 @@ public class RobotMain extends BaseFragment { | |||
@BindView(R.id.main_btn4) | |||
Button btn4; | |||
@BindView(R.id.tv_Status1) | |||
TextView tv_Status1; | |||
@BindView(R.id.tv_Status2) | |||
TextView tv_Status2; | |||
@BindView(R.id.tv_Status3) | |||
TextView tv_Status3; | |||
@BindView(R.id.tv_Status4) | |||
TextView tv_Status4; | |||
@BindView(R.id.robot_topbar) | |||
QMUITopBarLayout mTopBar;//顶部标题 | |||
RecyclerView material; | |||
private DialogView mDialogVisual; | |||
private DialogView mParSetVisual; | |||
@@ -51,69 +101,449 @@ public class RobotMain extends BaseFragment { | |||
protected View onCreateView() { | |||
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_robot_main, null); | |||
ButterKnife.bind(this, root); | |||
return root; | |||
return root; | |||
} | |||
@Override | |||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | |||
super.onViewCreated(view, savedInstanceState); | |||
Init(); | |||
OpenGoodSelectDialog(); | |||
Init(); | |||
String status = ModbusMaster.get().IsConnected?"已连接":"未连接"; | |||
mTopBar.setTitle("机器人连接状态:"+ status); | |||
RobotControl.getInstance().completeNotify= new ICompleteNotify() { | |||
@Override | |||
public void onComplete(int num) { | |||
// getActivity().runOnUiThread(new Runnable() { | |||
// @Override | |||
// public void run() { | |||
// if (num==1)btn3.setVisibility(View.VISIBLE); | |||
// else if (num==2)btn1.setVisibility(View.VISIBLE); | |||
// else if (num==3)btn4.setVisibility(View.VISIBLE); | |||
// else if (num==4)btn2.setVisibility(View.VISIBLE); | |||
// } | |||
// }); | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
if (num==1){ | |||
btn3.setText("选择菜品"); | |||
btn3.setVisibility(View.VISIBLE); | |||
btn3.setBackgroundResource(R.drawable.button4); | |||
btn3.setTextColor(Color.parseColor("#000000")); | |||
} | |||
else if (num==2){ | |||
btn1.setText("选择菜品"); | |||
btn1.setVisibility(View.VISIBLE); | |||
btn1.setBackgroundResource(R.drawable.button4); | |||
btn1.setTextColor(Color.parseColor("#000000")); | |||
} | |||
else if (num==3){ | |||
btn4.setText("选择菜品"); | |||
btn4.setVisibility(View.VISIBLE); | |||
btn4.setBackgroundResource(R.drawable.button4); | |||
btn4.setTextColor(Color.parseColor("#000000")); | |||
} | |||
else if (num==4){ | |||
btn2.setText("选择菜品"); | |||
btn2.setVisibility(View.VISIBLE); | |||
btn2.setBackgroundResource(R.drawable.button4); | |||
btn2.setTextColor(Color.parseColor("#000000")); | |||
} | |||
} | |||
}); | |||
} | |||
}; | |||
RobotControl.getInstance().statusNotify=new IStatusNotify() { | |||
@Override | |||
public void OnStatusChanged(String s1, String s2, String s3, String s4) { | |||
getActivity().runOnUiThread(new Runnable() { | |||
@Override | |||
public void run() { | |||
tv_Status1.setText(s2); | |||
tv_Status2.setText(s4); | |||
tv_Status3.setText(s1); | |||
tv_Status4.setText(s3); | |||
String status = ModbusMaster.get().IsConnected?"已连接":"未连接"; | |||
mTopBar.setTitle("机器人连接状态:"+ status); | |||
} | |||
}); | |||
} | |||
}; | |||
mDialogVisual= DialogManager.getInstance().initView(getContext(), R.layout.activity_material_view, Gravity.BOTTOM); | |||
mParSetVisual = DialogManager.getInstance().initView(getContext(),R.layout.activity_par_set,Gravity.BOTTOM); | |||
} | |||
@SuppressLint("HandlerLeak") | |||
private Handler mHandler = new Handler() { | |||
@Override | |||
public void handleMessage(Message msg) { | |||
if (msg.obj.toString()== "MSG_REFRESH") { | |||
if(ConfigName.getInstance().cloudGoods!=null && ConfigName.getInstance().cloudGoods.size()>0) | |||
{ | |||
ArrayList<BPA_GOODS> goods= QueryDB.GetGoodsALL(); | |||
ArrayList<BPA_GOODSRECIPE> 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); | |||
} | |||
} | |||
Log.i("info", "handleMessage: 获取商品信息成功"); | |||
} | |||
} | |||
}; | |||
private void Init(){ | |||
Log.i("bpa", "Init: 开始获取云端数据"); | |||
ConfigData.getInstance().GetOrganize(getContext()); | |||
ConfigData.getInstance().GetGevGood(getContext(),null); | |||
ConfigData.getInstance().GetGevGood(getContext(),mHandler); | |||
} | |||
private void OpenParSet(){ | |||
//参数配置界面确认按钮 | |||
ButtonClickBinder(mParSetVisual, R.id.parset_ok_btn,()->{ | |||
Log.i("TAG", "onClick: 确认参数配置"); | |||
if(!ModbusMaster.get().IsConnected){ | |||
AlertDialogUtils.showDialog(getContext(),"提示","请先连接机器人"); | |||
return; | |||
} | |||
RobotControl.getInstance(). GoodDown(fry.GoodID,fry.FryingPanNum); | |||
try { | |||
// Thread.sleep(4000); | |||
long startTime=System.currentTimeMillis(); | |||
while(!RobotControl.getInstance().GetGoodVery(fry.FryingPanNum)&&(System.currentTimeMillis()-startTime)<=4000){ | |||
Thread.sleep(100); | |||
} | |||
if (RobotControl.getInstance().GetGoodVery(fry.FryingPanNum)){ | |||
if (fry.FryingPanNum==1) { | |||
btn3.setText("强制取消"); | |||
btn3.setBackgroundResource(R.drawable.button5); | |||
btn3.setTextColor(Color.parseColor("#ffffff")); | |||
} | |||
else if (fry.FryingPanNum==2){ | |||
btn1.setText("强制取消"); | |||
btn1.setBackgroundResource(R.drawable.button5); | |||
btn1.setTextColor(Color.parseColor("#ffffff")); | |||
} | |||
else if (fry.FryingPanNum==3) { | |||
btn4.setText("强制取消"); | |||
btn4.setBackgroundResource(R.drawable.button5); | |||
btn4.setTextColor(Color.parseColor("#ffffff")); | |||
} | |||
else if (fry.FryingPanNum==4) { | |||
btn2.setText("强制取消"); | |||
btn2.setBackgroundResource(R.drawable.button5); | |||
btn2.setTextColor(Color.parseColor("#ffffff")); | |||
} | |||
RobotControl.getInstance().FryingPan.put(fry.FryingPanNum,fry); | |||
fry=new FryingPanPar(); | |||
DialogManager.getInstance().hide(mParSetVisual);//关闭参数设置窗口 | |||
} | |||
else{ | |||
AlertDialogUtils.showDialog(getContext(),"提示","商品验证失败"); | |||
} | |||
} | |||
catch (InterruptedException e) { | |||
} | |||
// if (RobotControl.getInstance().GetGoodVery(fry.FryingPanNum)){ | |||
// if (fry.FryingPanNum==1)btn3.setVisibility(View.GONE); | |||
// else if (fry.FryingPanNum==2)btn1.setVisibility(View.GONE); | |||
// else if (fry.FryingPanNum==3)btn4.setVisibility(View.GONE); | |||
// else if (fry.FryingPanNum==4)btn2.setVisibility(View.GONE); | |||
// RobotControl.getInstance().FryingPan.put(fry.FryingPanNum,fry); | |||
// fry=new FryingPanPar(); | |||
// DialogManager.getInstance().hide(mParSetVisual);//关闭参数设置窗口 | |||
// } | |||
// else{ | |||
// AlertDialogUtils.showDialog(getContext(),"提示","商品验证失败"); | |||
// } | |||
}); | |||
//参数配置界面取消按钮 | |||
ButtonClickBinder(mParSetVisual, R.id.parset_cancel_btn, ()->{ | |||
Log.i("TAG", "onClick: 退出参数配置"); | |||
fry=new FryingPanPar(); | |||
DialogManager.getInstance().hide(mParSetVisual);//关闭参数设置窗口 | |||
}); | |||
DialogManager.getInstance().hide(mDialogVisual);//关闭商品选择窗口 | |||
DialogManager.getInstance().show(mParSetVisual,R.id.parset_close_dialog); //打开参数设置窗口 | |||
if (fry.FryingPanNum==1){ | |||
ParSetInit(R.id.location_selection,new String[] { "1", "2", "3"}); | |||
}else if (fry.FryingPanNum==2){ | |||
ParSetInit(R.id.location_selection,new String[] { "4","5","6"}); | |||
}else if (fry.FryingPanNum==3){ | |||
ParSetInit(R.id.location_selection,new String[] { "4","5","6"}); | |||
}else if (fry.FryingPanNum==4){ | |||
ParSetInit(R.id.location_selection,new String[] { "1", "2", "3"}); | |||
} | |||
// ParSetInit(R.id.location_selection,new String[] {"0", "1", "2", "3", "4","5","6"}); | |||
ParSetInit(R.id.accessories_selection_1,new String[] {"0", "1", "2", "3", "4","5","6","7","8"}); | |||
ParSetInit(R.id.accessories_selection_2,new String[] {"0", "1", "2", "3", "4","5","6","7","8"}); | |||
} | |||
FryingPanPar fry=new FryingPanPar(); | |||
private void OpenGoodSelectDialog() | |||
{ | |||
MessageManager.getInstance().registerMessageReceiver(getActivity(), MessageName.ClickMakeGoodNew, new MessageLooper.OnMessageListener() { | |||
@Override | |||
public void onMessage(Object msg) { | |||
if (msg != null) { | |||
BPA_GOODS goods = (BPA_GOODS) msg; | |||
// OrderData.getInstance().goods=(BPA_GOODS) msg ; | |||
fry.GoodID= goods.id; | |||
OpenParSet(); | |||
} | |||
} | |||
}); | |||
btn1.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view){ | |||
mDialogVisual.setCanceledOnTouchOutside(false); | |||
Button openSetView = mDialogVisual .findViewById(R.id.open); | |||
openSetView.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
//参数配置界面确认按钮 | |||
ButtonClickBinder(mParSetVisual, R.id.parset_ok_btn,()->{ | |||
Log.i("TAG", "onClick: 确认参数配置"); | |||
DialogManager.getInstance().hide(mParSetVisual);//关闭参数设置窗口 | |||
}); | |||
//参数配置界面取消按钮 | |||
ButtonClickBinder(mParSetVisual, R.id.parset_cancel_btn, ()->{ | |||
Log.i("TAG", "onClick: 退出参数配置"); | |||
DialogManager.getInstance().hide(mParSetVisual);//关闭参数设置窗口 | |||
}); | |||
DialogManager.getInstance().hide(mDialogVisual);//关闭商品选择窗口 | |||
DialogManager.getInstance().show(mParSetVisual,R.id.parset_close_dialog); //打开参数设置窗口 | |||
ParSetInit(R.id.location_selection,new String[] {"0", "1", "2", "3", "4","5","6"}); | |||
ParSetInit(R.id.accessories_selection_1,new String[] {"0", "1", "2", "3", "4","5","6","7","8"}); | |||
ParSetInit(R.id.accessories_selection_2,new String[] {"0", "1", "2", "3", "4","5","6","7","8"}); | |||
} | |||
}); | |||
DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
ProductSelectionButtonBinder(R.id.main_btn1,2); | |||
// if(btn1.getText().equals("强制取消")) | |||
// { | |||
// AlertDialogUtils.showDialog(getContext(), "提示", "是否强制结束任务?", new QMUIDialogAction.ActionListener() { | |||
// @Override | |||
// public void onClick(QMUIDialog dialog, int index) { | |||
// RobotControl.getInstance().SetForceEnd(2); | |||
// btn1.setVisibility(View.GONE); | |||
// dialog.dismiss(); | |||
// } | |||
// }); | |||
// } | |||
// else{ | |||
// fry.FryingPanNum=2; | |||
// mDialogVisual.setCanceledOnTouchOutside(false); | |||
// material=mDialogVisual.findViewById(R.id.rv_material); | |||
// synchronous(); | |||
// LoadingGood(); | |||
// if(!getActivity().isFinishing()) | |||
// DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
// } | |||
// fry.FryingPanNum=2; | |||
// mDialogVisual.setCanceledOnTouchOutside(false); | |||
// material=mDialogVisual.findViewById(R.id.rv_material); | |||
// synchronous(); | |||
// LoadingGood(); | |||
// DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
} | |||
}); | |||
btn2.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view){ | |||
ProductSelectionButtonBinder(R.id.main_btn2,4); | |||
// if(btn2.getText().equals("强制取消")) | |||
// { | |||
// AlertDialogUtils.showDialog(getContext(), "提示", "是否强制结束任务?", new QMUIDialogAction.ActionListener() { | |||
// @Override | |||
// public void onClick(QMUIDialog dialog, int index) { | |||
// RobotControl.getInstance().SetForceEnd(4); | |||
// btn2.setVisibility(View.GONE); | |||
// dialog.dismiss(); | |||
// } | |||
// }); | |||
// } | |||
// else | |||
// { | |||
// fry.FryingPanNum=4; | |||
// mDialogVisual.setCanceledOnTouchOutside(false); | |||
// material=mDialogVisual.findViewById(R.id.rv_material); | |||
// synchronous(); | |||
// LoadingGood(); | |||
// if(!getActivity().isFinishing()) | |||
// DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
// } | |||
// if(RobotControl.getInstance().GetFryingPan(4)) { | |||
// fry.FryingPanNum=4; | |||
// mDialogVisual.setCanceledOnTouchOutside(false); | |||
// material=mDialogVisual.findViewById(R.id.rv_material); | |||
// synchronous(); | |||
// LoadingGood(); | |||
// DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
// } | |||
// else{ | |||
// AlertDialogUtils.showDialog(getContext(),"提示","炒锅状态异常"); | |||
// } | |||
} | |||
}); | |||
btn3.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view){ | |||
ProductSelectionButtonBinder(R.id.main_btn3,1); | |||
// if(btn3.getText().equals("强制取消")) | |||
// { | |||
// AlertDialogUtils.showDialog(getContext(), "提示", "是否强制结束任务?", new QMUIDialogAction.ActionListener() { | |||
// @Override | |||
// public void onClick(QMUIDialog dialog, int index) { | |||
// RobotControl.getInstance().SetForceEnd(1); | |||
// btn3.setVisibility(View.GONE); | |||
// dialog.dismiss(); | |||
// } | |||
// }); | |||
// } | |||
// else | |||
// { | |||
// fry.FryingPanNum=1; | |||
// mDialogVisual.setCanceledOnTouchOutside(false); | |||
// material=mDialogVisual.findViewById(R.id.rv_material); | |||
// synchronous(); | |||
// LoadingGood(); | |||
// if(!getActivity().isFinishing()) | |||
// DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
// } | |||
// if(RobotControl.getInstance().GetFryingPan(2)){ | |||
// fry.FryingPanNum=1; | |||
// mDialogVisual.setCanceledOnTouchOutside(false); | |||
// material=mDialogVisual.findViewById(R.id.rv_material); | |||
// synchronous(); | |||
// LoadingGood(); | |||
// DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
// } | |||
// else{ | |||
// AlertDialogUtils.showDialog(getContext(),"提示","炒锅状态异常"); | |||
// } | |||
} | |||
}); | |||
btn4.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view){ | |||
ProductSelectionButtonBinder(R.id.main_btn4,3); | |||
// if(btn4.getText().equals("强制取消")) | |||
// { | |||
// AlertDialogUtils.showDialog(getContext(), "提示", "是否强制结束任务?", new QMUIDialogAction.ActionListener() { | |||
// @Override | |||
// public void onClick(QMUIDialog dialog, int index) { | |||
// DoubleFryingpanControl.getInstance().SetForceEnd(3); | |||
// btn4.setVisibility(View.GONE); | |||
// dialog.dismiss(); | |||
// } | |||
// }); | |||
// } | |||
// else | |||
// { | |||
// fry.FryingPanNum=3; | |||
// mDialogVisual.setCanceledOnTouchOutside(false); | |||
// material=mDialogVisual.findViewById(R.id.rv_material); | |||
// synchronous(); | |||
// LoadingGood(); | |||
// if(!getActivity().isFinishing()) | |||
// DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
// } | |||
// if(RobotControl.getInstance().GetFryingPan(3)){ | |||
// fry.FryingPanNum=3; | |||
// mDialogVisual.setCanceledOnTouchOutside(false); | |||
// material=mDialogVisual.findViewById(R.id.rv_material); | |||
// synchronous(); | |||
// LoadingGood(); | |||
// DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
// } | |||
// else{ | |||
// AlertDialogUtils.showDialog(getContext(),"提示","炒锅状态异常"); | |||
// } | |||
} | |||
}); | |||
} | |||
/** | |||
* 同步商品 | |||
*/ | |||
private void synchronous(){ | |||
Button btn=mDialogVisual.findViewById(R.id.synchronous); | |||
btn.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
Init(); | |||
LoadingGood(); | |||
} | |||
}); | |||
} | |||
/** | |||
* 加载商品 | |||
*/ | |||
public void LoadingGood() { | |||
ArrayList<BPA_GOODS> goods= QueryDB.GetGoodsALL(); | |||
ArrayList<BPA_GOODS> goodsm=new ArrayList<>(); | |||
if (goods.size()>0){ | |||
for (BPA_GOODS item:goods)goodsm.add(item); | |||
}else{ | |||
for(CloudGood item: ConfigName.getInstance().cloudGoods){ | |||
BPA_GOODS bpa=new BPA_GOODS(); | |||
bpa.name=item.goods_Name; | |||
bpa.url=item.goods_ImgUrl; | |||
bpa.id=item.id; | |||
goodsm.add(bpa); | |||
} | |||
} | |||
List<LinkMode> Fdata = new ArrayList<>(); | |||
Fdata.add(new LinkMode("main", Arrays.asList(goodsm.toArray()),true)); | |||
MakeGoodRightAdapter rightAdapter = new MakeGoodRightAdapter(R.layout.item_right_lc, Fdata, getResources()); | |||
material.setAdapter(rightAdapter); | |||
} | |||
private void ParSetInit(int id,String[] args) | |||
{ | |||
Spinner sp = mParSetVisual.findViewById(id); | |||
ArrayAdapter<String> starAdapter = new ArrayAdapter<String>(getContext(), R.layout.select_item, args); | |||
sp.setAdapter(starAdapter); | |||
sp.setSelection(0); | |||
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | |||
@Override | |||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { | |||
if(R.id.location_selection==id) { | |||
fry.IngredientsLocs[0]=Integer.parseInt(adapterView.getItemAtPosition(i).toString()); | |||
} | |||
else if (R.id.accessories_selection_1==id) { | |||
fry.AccessoriesLocs[0]=Integer.parseInt(adapterView.getItemAtPosition(i).toString());; | |||
} | |||
else if (R.id.accessories_selection_2==id) { | |||
fry.AccessoriesLocs[1]=Integer.parseInt(adapterView.getItemAtPosition(i).toString());; | |||
} | |||
} | |||
@Override | |||
@@ -123,6 +553,32 @@ public class RobotMain extends BaseFragment { | |||
}); | |||
} | |||
private void ProductSelectionButtonBinder(int id,int FiryNum){ | |||
Button btn =getActivity().findViewById(id); | |||
if(btn.getText().equals("强制取消")) | |||
{ | |||
AlertDialogUtils.showDialog(getContext(), "提示", "是否强制结束任务?", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
DoubleFryingpanControl.getInstance().SetForceEnd(FiryNum); | |||
btn.setVisibility(View.GONE); | |||
dialog.dismiss(); | |||
} | |||
}); | |||
} | |||
else | |||
{ | |||
fry.FryingPanNum=FiryNum; | |||
mDialogVisual.setCanceledOnTouchOutside(false); | |||
material=mDialogVisual.findViewById(R.id.rv_material); | |||
synchronous(); | |||
LoadingGood(); | |||
if(!getActivity().isFinishing()) | |||
DialogManager.getInstance().show(mDialogVisual,R.id.close_dialog); //打开商品选择窗口 | |||
} | |||
} | |||
/** | |||
* 弹框按钮事件绑定 | |||
* @param dv 弹框页面 | |||
@@ -12,6 +12,7 @@ import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.common.base.BaseFragment; | |||
import com.bonait.bnframework.modules.home.fragment.from.DeviceInformationActivity; | |||
import com.bonait.bnframework.modules.home.fragment.from.ImageSourceActivity; | |||
import com.bonait.bnframework.modules.home.fragment.from.LogActivity; | |||
import com.bonait.bnframework.modules.home.fragment.from.PlcControlActivity; | |||
import com.bonait.bnframework.modules.home.fragment.from.SystemParameterActivity; | |||
import com.bonait.bnframework.modules.home.fragment.from.DzcjyActivity; | |||
@@ -54,29 +55,30 @@ public class SheZhifragment extends BaseFragment { | |||
mTopBar.setTitle("订单管理"); | |||
} | |||
@OnClick({R.id.xtcs,R.id.imagegl,R.id.shebeixinxi | |||
,R.id.plckz,R.id.dzcsz,R.id.wdsz}) | |||
// @OnClick({R.id.xtcs,R.id.imagegl,R.id.shebeixinxi | |||
// ,R.id.plckz,R.id.dzcsz,R.id.wdsz}) | |||
@OnClick({R.id.xtcs,R.id.rl_log}) | |||
public void onViewClicked(View view) { | |||
switch (view.getId()) { | |||
case R.id.plckz:// | |||
skipToActivity(PlcControlActivity.class); | |||
break; | |||
// case R.id.plckz:// | |||
// skipToActivity(PlcControlActivity.class); | |||
// break; | |||
case R.id.xtcs:// | |||
skipToActivity(SystemParameterActivity.class); | |||
break; | |||
case R.id.imagegl:// | |||
skipToActivity(ImageSourceActivity.class); | |||
break; | |||
case R.id.shebeixinxi:// | |||
skipToActivity(DeviceInformationActivity.class); | |||
case R.id.rl_log:// | |||
skipToActivity(LogActivity.class); | |||
break; | |||
// case R.id.shebeixinxi:// | |||
// skipToActivity(DeviceInformationActivity.class); | |||
// break; | |||
case R.id.dzcsz://电子秤设置 | |||
skipToActivity(DzcjyActivity.class); | |||
break; | |||
case R.id.wdsz://温度设置 | |||
skipToActivity(WdszActivity.class); | |||
break; | |||
// case R.id.dzcsz://电子秤设置 | |||
// skipToActivity(DzcjyActivity.class); | |||
// break; | |||
// case R.id.wdsz://温度设置 | |||
// skipToActivity(WdszActivity.class); | |||
// break; | |||
} | |||
} | |||
@@ -122,8 +122,12 @@ public class SystemParameterActivity extends BaseActivity { | |||
for (BPA_SYSTEMSET item : bpa_systemsets) { | |||
switch (item.type) { | |||
case -100: | |||
ConfigName.getInstance().versionSelectionEnum = item.value; | |||
versionselection.setSelection(material_map_vis.get(item.value)); | |||
try { | |||
ConfigName.getInstance().versionSelectionEnum = item.value; | |||
versionselection.setSelection(material_map_vis.get(item.value)); | |||
}catch(Exception ex){ | |||
} | |||
break; | |||
case -99: | |||
ConfigName.getInstance().Environment = item.value; | |||
@@ -22,7 +22,6 @@ import android.widget.ImageView; | |||
import android.widget.LinearLayout; | |||
import android.widget.RelativeLayout; | |||
import com.bonait.bnframework.MainActivity; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ConfigData; | |||
import com.bonait.bnframework.common.base.BaseActivity; | |||
@@ -0,0 +1,30 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<ripple xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:color="@color/black" | |||
android:radius="-1dp"> | |||
<item android:state_pressed="true"> | |||
<shape> | |||
<solid android:color="@color/orange_primary_dark" /> | |||
<corners android:radius="10dp" /> | |||
</shape> | |||
</item> | |||
<item android:state_enabled="false"> | |||
<shape> | |||
<solid android:color="#cccccc" /> | |||
<corners android:radius="10dp" /> | |||
</shape> | |||
</item> | |||
<item> | |||
<shape> | |||
<solid android:color="@color/colorAccent" /> | |||
<corners android:radius="10dp" /> | |||
<stroke | |||
android:width="1dp" | |||
android:color="@color/colorAccent" /> | |||
</shape> | |||
</item> | |||
</ripple> |
@@ -1,213 +0,0 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:background="#dddddd" | |||
android:rowCount="2" | |||
android:columnCount="2" | |||
android:orientation="horizontal" | |||
android:layout_height="match_parent" | |||
tools:context=".MainActivity"> | |||
<GridLayout android:layout_margin="10dp" | |||
android:columnCount="2" | |||
android:background="@drawable/border_background" | |||
android:elevation="10dp" | |||
android:layout_rowWeight="1" | |||
android:orientation="horizontal" | |||
android:layout_columnWeight="1"> | |||
<ImageView | |||
android:layout_height="0dp" | |||
android:layout_width="0dp" | |||
android:src="@mipmap/cg" | |||
android:layout_margin="10dp" | |||
android:layout_rowWeight="1" | |||
android:layout_columnWeight="1"/> | |||
<LinearLayout | |||
android:layout_width="0dp" | |||
android:layout_rowWeight="1" | |||
android:layout_height="0dp" | |||
android:layout_margin="10dp" | |||
android:orientation="vertical" | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginTop="20dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
<Button | |||
android:id="@+id/main_btn1" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_margin="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
</LinearLayout> | |||
</GridLayout> | |||
<GridLayout android:layout_margin="10dp" | |||
android:columnCount="2" | |||
android:background="@drawable/border_background" | |||
android:elevation="10dp" | |||
android:layout_rowWeight="1" | |||
android:orientation="horizontal" | |||
android:layout_columnWeight="1"> | |||
<ImageView | |||
android:layout_height="0dp" | |||
android:layout_width="0dp" | |||
android:src="@mipmap/cg" | |||
android:layout_margin="10dp" | |||
android:layout_rowWeight="1" | |||
android:layout_columnWeight="1"/> | |||
<LinearLayout | |||
android:layout_width="0dp" | |||
android:layout_rowWeight="1" | |||
android:layout_height="0dp" | |||
android:layout_margin="10dp" | |||
android:orientation="vertical" | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginTop="20dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
<Button | |||
android:id="@+id/main_btn2" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_margin="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
</LinearLayout> | |||
</GridLayout> | |||
<GridLayout android:layout_margin="10dp" | |||
android:columnCount="2" | |||
android:background="@drawable/border_background" | |||
android:elevation="10dp" | |||
android:layout_rowWeight="1" | |||
android:orientation="horizontal" | |||
android:layout_columnWeight="1"> | |||
<ImageView | |||
android:layout_height="0dp" | |||
android:layout_width="0dp" | |||
android:src="@mipmap/cg" | |||
android:layout_margin="10dp" | |||
android:layout_rowWeight="1" | |||
android:layout_columnWeight="1"/> | |||
<LinearLayout | |||
android:layout_width="0dp" | |||
android:layout_rowWeight="1" | |||
android:layout_height="0dp" | |||
android:layout_margin="10dp" | |||
android:orientation="vertical" | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginTop="20dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
<Button | |||
android:id="@+id/main_btn3" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_margin="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
</LinearLayout> | |||
</GridLayout> | |||
<GridLayout android:layout_margin="10dp" | |||
android:columnCount="2" | |||
android:background="@drawable/border_background" | |||
android:elevation="10dp" | |||
android:layout_rowWeight="1" | |||
android:orientation="horizontal" | |||
android:layout_columnWeight="1"> | |||
<ImageView | |||
android:layout_height="0dp" | |||
android:layout_width="0dp" | |||
android:src="@mipmap/cg" | |||
android:layout_margin="10dp" | |||
android:layout_rowWeight="1" | |||
android:layout_columnWeight="1"/> | |||
<LinearLayout | |||
android:layout_width="0dp" | |||
android:layout_rowWeight="1" | |||
android:layout_height="0dp" | |||
android:layout_margin="10dp" | |||
android:orientation="vertical" | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginTop="20dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
<Button | |||
android:id="@+id/main_btn4" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_margin="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
</LinearLayout> | |||
</GridLayout> | |||
</GridLayout> |
@@ -8,10 +8,10 @@ | |||
tools:context=".material_view"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_width="687dp" | |||
android:orientation="vertical" | |||
android:layout_marginTop="5dp" | |||
android:layout_height="400dp"> | |||
android:layout_height="600dp"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
@@ -28,17 +28,34 @@ | |||
android:textStyle="bold" | |||
android:layout_height="25dp"/> | |||
<Button | |||
android:id="@+id/close_dialog" | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginRight="10dp" | |||
android:textColor="@color/red_primary_dark" | |||
android:text="×" | |||
android:textSize="40sp" | |||
android:background="@android:color/transparent" | |||
android:layout_margin="5dp"/> | |||
<Button | |||
android:id="@+id/close_dialog" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true" | |||
android:layout_marginStart="5dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_marginEnd="5dp" | |||
android:layout_marginRight="10dp" | |||
android:layout_marginBottom="5dp" | |||
android:background="@android:color/transparent" | |||
android:text="×" | |||
android:textColor="@color/red_primary_dark" | |||
android:textSize="40sp" /> | |||
<Button | |||
android:id="@+id/synchronous" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentLeft="true" | |||
android:layout_marginStart="5dp" | |||
android:layout_marginTop="5dp" | |||
android:layout_marginEnd="5dp" | |||
android:layout_marginRight="50dp" | |||
android:layout_marginBottom="5dp" | |||
android:background="@drawable/button4" | |||
android:text="同步" | |||
android:textSize="20sp" /> | |||
</RelativeLayout> | |||
@@ -51,10 +68,13 @@ | |||
android:layout_width="match_parent" | |||
android:gravity="center" | |||
android:layout_height="match_parent"> | |||
<Button android:layout_width="wrap_content" | |||
android:text="打开" | |||
android:id="@+id/open" | |||
android:layout_height="wrap_content"/> | |||
<androidx.recyclerview.widget.RecyclerView | |||
android:id="@+id/rv_material" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_margin="10dp" | |||
android:orientation="vertical" | |||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | |||
</LinearLayout> | |||
</LinearLayout> | |||
@@ -0,0 +1,165 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="400dp" | |||
android:orientation="vertical" | |||
android:background="@drawable/par_set_bg" | |||
android:layout_height="wrap_content" | |||
tools:context=".par_set"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<Button | |||
android:id="@+id/parset_close_dialog" | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginRight="10dp" | |||
android:textColor="@color/red_primary_dark" | |||
android:text="×" | |||
android:textSize="40sp" | |||
android:background="@android:color/transparent" | |||
android:layout_margin="5dp"/> | |||
</RelativeLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:orientation="horizontal" | |||
android:layout_margin="20dp" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textColor="#000000" | |||
android:text=" 选择主料1:"/> | |||
<Spinner | |||
android:id="@+id/location_selection_1" | |||
android:layout_width="match_parent" | |||
android:spinnerMode="dropdown" | |||
android:layout_marginLeft="10dp" | |||
android:paddingLeft="-10dp" | |||
android:paddingRight="-10dp" | |||
android:dropDownWidth="match_parent" | |||
android:background="@drawable/spinner_br" | |||
android:dropDownVerticalOffset="0dp" | |||
android:dropDownSelector="@color/red_primary_dark" | |||
android:entries="@array/sp1" | |||
android:layout_height="48dp"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:orientation="horizontal" | |||
android:layout_margin="20dp" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textColor="#000000" | |||
android:text=" 选择主料2:"/> | |||
<Spinner | |||
android:id="@+id/location_selection_2" | |||
android:layout_width="match_parent" | |||
android:spinnerMode="dropdown" | |||
android:layout_marginLeft="10dp" | |||
android:paddingLeft="-10dp" | |||
android:paddingRight="-10dp" | |||
android:dropDownWidth="match_parent" | |||
android:background="@drawable/spinner_br" | |||
android:dropDownVerticalOffset="0dp" | |||
android:dropDownSelector="@color/red_primary_dark" | |||
android:entries="@array/sp1" | |||
android:layout_height="48dp"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:orientation="horizontal" | |||
android:layout_margin="20dp" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textColor="#000000" | |||
android:text="选择辅料1:"/> | |||
<Spinner | |||
android:id="@+id/accessories_selection_1" | |||
android:layout_width="match_parent" | |||
android:spinnerMode="dropdown" | |||
android:layout_marginLeft="10dp" | |||
android:paddingLeft="-10dp" | |||
android:paddingRight="-10dp" | |||
android:dropDownWidth="match_parent" | |||
android:background="@drawable/spinner_br" | |||
android:dropDownVerticalOffset="0dp" | |||
android:dropDownSelector="@color/red_primary_dark" | |||
android:entries="@array/accessories_sp" | |||
android:layout_height="48dp"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:orientation="horizontal" | |||
android:layout_margin="20dp" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textColor="#000000" | |||
android:text="选择辅料2:"/> | |||
<Spinner | |||
android:id="@+id/accessories_selection_2" | |||
android:layout_width="match_parent" | |||
android:spinnerMode="dropdown" | |||
android:layout_marginLeft="10dp" | |||
android:paddingLeft="-10dp" | |||
android:paddingRight="-10dp" | |||
android:dropDownWidth="match_parent" | |||
android:background="@drawable/spinner_br" | |||
android:dropDownVerticalOffset="0dp" | |||
android:dropDownSelector="@color/red_primary_dark" | |||
android:entries="@array/accessories_sp" | |||
android:layout_height="48dp"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:orientation="horizontal" | |||
android:layout_margin="20dp" | |||
android:layout_height="wrap_content"> | |||
<Button | |||
android:id="@+id/parset_ok_btn" | |||
android:layout_width="0dp" | |||
android:layout_weight="1" | |||
android:layout_marginRight="10dp" | |||
android:background="@drawable/button4" | |||
android:text="确认" | |||
android:layout_height="wrap_content"/> | |||
<Button | |||
android:id="@+id/parset_cancel_btn" | |||
android:layout_width="0dp" | |||
android:text="取消" | |||
android:layout_weight="1" | |||
android:layout_marginLeft="10dp" | |||
android:background="@drawable/button4" | |||
android:layout_height="wrap_content"/> | |||
</LinearLayout> | |||
</LinearLayout> |
@@ -0,0 +1,82 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="400dp" | |||
android:orientation="vertical" | |||
android:background="@drawable/par_set_bg" | |||
android:layout_height="wrap_content" | |||
tools:context=".par_set"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<Button | |||
android:id="@+id/parset_close_dialog" | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginRight="10dp" | |||
android:textColor="@color/red_primary_dark" | |||
android:text="×" | |||
android:textSize="40sp" | |||
android:background="@android:color/transparent" | |||
android:layout_margin="5dp"/> | |||
</RelativeLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:orientation="horizontal" | |||
android:layout_margin="20dp" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textColor="#000000" | |||
android:text=" 选择库位:"/> | |||
<Spinner | |||
android:id="@+id/location_selection_1" | |||
android:layout_width="match_parent" | |||
android:spinnerMode="dropdown" | |||
android:layout_marginLeft="10dp" | |||
android:paddingLeft="-10dp" | |||
android:paddingRight="-10dp" | |||
android:dropDownWidth="match_parent" | |||
android:background="@drawable/spinner_br" | |||
android:dropDownVerticalOffset="0dp" | |||
android:dropDownSelector="@color/red_primary_dark" | |||
android:entries="@array/sp1" | |||
android:layout_height="48dp"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:orientation="horizontal" | |||
android:layout_margin="20dp" | |||
android:layout_height="wrap_content"> | |||
<Button | |||
android:id="@+id/parset_ok_btn" | |||
android:layout_width="0dp" | |||
android:layout_weight="1" | |||
android:layout_marginRight="10dp" | |||
android:background="@drawable/button4" | |||
android:text="确认" | |||
android:layout_height="wrap_content"/> | |||
<Button | |||
android:id="@+id/parset_cancel_btn" | |||
android:layout_width="0dp" | |||
android:text="取消" | |||
android:layout_weight="1" | |||
android:layout_marginLeft="10dp" | |||
android:background="@drawable/button4" | |||
android:layout_height="wrap_content"/> | |||
</LinearLayout> | |||
</LinearLayout> |
@@ -1 +1,4 @@ | |||
<resources></resources> | |||
<resources> | |||
<!-- TODO: Remove or change this placeholder text --> | |||
<string name="hello_blank_fragment">Hello blank fragment</string> | |||
</resources> |
@@ -0,0 +1,198 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:background="@color/app_color_blue" | |||
android:layout_height="match_parent" | |||
tools:context=".modules.home.fragment.DoubleFryingpanFragment"> | |||
<GridLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_marginTop="?attr/qmui_topbar_height" | |||
android:background="#dddddd" | |||
android:rowCount="2" | |||
android:columnCount="2" | |||
android:orientation="horizontal"> | |||
<RelativeLayout android:layout_margin="10dp" | |||
android:columnCount="1" | |||
android:layout_height="0dp" | |||
android:layout_width="0dp" | |||
android:background="@drawable/border_background" | |||
android:elevation="10dp" | |||
android:layout_rowWeight="1" | |||
android:layout_rowSpan="2" | |||
android:layout_columnWeight="1"> | |||
<!-- <ImageView--> | |||
<!-- android:layout_height="0dp"--> | |||
<!-- android:layout_width="0dp"--> | |||
<!-- android:src="@mipmap/robot"--> | |||
<!-- android:layout_margin="10dp"--> | |||
<!-- android:layout_rowWeight="1"--> | |||
<!-- android:layout_columnWeight="1"/>--> | |||
<ImageView | |||
android:layout_height="990dp" | |||
android:layout_width="990dp" | |||
android:src="@mipmap/robot" | |||
android:layout_rowWeight="1" | |||
android:layout_columnWeight="1" | |||
android:layout_margin="10dp"/> | |||
<LinearLayout android:layout_width="200dp" | |||
android:layout_margin="10dp" | |||
android:orientation="vertical" | |||
android:layout_rowWeight="1" | |||
android:layout_alignParentRight="true" | |||
android:layout_alignParentBottom="true" | |||
android:layout_columnWeight="1" | |||
android:layout_height="130dp"> | |||
<Button | |||
android:id="@+id/btn_warehousing" | |||
android:layout_width="160dp" | |||
android:layout_height="50dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="入库"/> | |||
<Button | |||
android:id="@+id/btn_maintenance" | |||
android:layout_width="160dp" | |||
android:layout_height="50dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="维护"/> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<GridLayout android:layout_margin="10dp" | |||
android:columnCount="2" | |||
android:background="@drawable/border_background" | |||
android:elevation="10dp" | |||
android:layout_rowWeight="1" | |||
android:orientation="horizontal" | |||
android:layout_columnWeight="1"> | |||
<LinearLayout | |||
android:layout_width="0dp" | |||
android:layout_rowWeight="1" | |||
android:layout_height="0dp" | |||
android:layout_margin="10dp" | |||
android:orientation="vertical" | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="40dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:id="@+id/tv_Status1" | |||
android:layout_width="300dp" | |||
android:layout_height="40dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
<Button | |||
android:id="@+id/main_btn1" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
</LinearLayout> | |||
<ImageView | |||
android:layout_height="0dp" | |||
android:layout_width="0dp" | |||
android:src="@mipmap/cg" | |||
android:layout_margin="10dp" | |||
android:layout_rowWeight="1" | |||
android:layout_columnWeight="1"/> | |||
</GridLayout> | |||
<GridLayout android:layout_margin="10dp" | |||
android:columnCount="2" | |||
android:background="@drawable/border_background" | |||
android:elevation="10dp" | |||
android:layout_rowWeight="1" | |||
android:orientation="horizontal" | |||
android:layout_columnWeight="1"> | |||
<LinearLayout | |||
android:layout_width="0dp" | |||
android:layout_rowWeight="1" | |||
android:layout_height="0dp" | |||
android:layout_margin="10dp" | |||
android:orientation="vertical" | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="40dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:id="@+id/tv_Status2" | |||
android:layout_width="300dp" | |||
android:layout_height="40dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
<Button | |||
android:id="@+id/main_btn2" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
</LinearLayout> | |||
<ImageView | |||
android:layout_height="0dp" | |||
android:layout_width="0dp" | |||
android:src="@mipmap/cg" | |||
android:layout_margin="10dp" | |||
android:layout_rowWeight="1" | |||
android:layout_columnWeight="1"/> | |||
</GridLayout> | |||
</GridLayout> | |||
<com.qmuiteam.qmui.widget.QMUITopBarLayout | |||
android:id="@+id/robot_topbar" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:background="@color/app_color_blue" /> | |||
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout> |
@@ -40,18 +40,19 @@ | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_height="40dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:id="@+id/tv_Status1" | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginTop="20dp" | |||
android:layout_height="40dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
@@ -59,7 +60,8 @@ | |||
android:id="@+id/main_btn1" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_margin="20dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
@@ -90,18 +92,19 @@ | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_height="40dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:id="@+id/tv_Status2" | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginTop="20dp" | |||
android:layout_height="40dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
@@ -109,7 +112,8 @@ | |||
android:id="@+id/main_btn2" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_margin="20dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
@@ -140,18 +144,19 @@ | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_height="40dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:id="@+id/tv_Status3" | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginTop="20dp" | |||
android:layout_height="40dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
@@ -159,7 +164,8 @@ | |||
android:id="@+id/main_btn3" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_margin="20dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
@@ -190,18 +196,19 @@ | |||
android:layout_columnWeight="1"> | |||
<TextView | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_height="40dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="状态:"/> | |||
<TextView | |||
android:id="@+id/tv_Status4" | |||
android:layout_width="300dp" | |||
android:layout_height="60dp" | |||
android:layout_marginTop="20dp" | |||
android:layout_height="40dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="40sp" | |||
android:textSize="20sp" | |||
android:textColor="#f0a732" | |||
android:text="空闲中"/> | |||
@@ -209,7 +216,8 @@ | |||
android:id="@+id/main_btn4" | |||
android:layout_width="match_parent" | |||
android:layout_height="50dp" | |||
android:layout_margin="20dp" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="20sp" | |||
android:background="@drawable/button4" | |||
android:text="选择菜品"/> | |||
@@ -29,24 +29,109 @@ | |||
android:layout_height="match_parent" | |||
android:orientation="horizontal"> | |||
<!-- <RelativeLayout--> | |||
<!-- android:id="@+id/dzcsz"--> | |||
<!-- android:layout_width="0dp"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_margin="20dp"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <LinearLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:layout_centerInParent="true"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <RelativeLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="120dp"--> | |||
<!-- android:background="@drawable/goodpf_bj">--> | |||
<!-- <ImageView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_marginStart="@dimen/dp_10"--> | |||
<!-- android:layout_marginTop="@dimen/dp_10"--> | |||
<!-- android:layout_marginEnd="@dimen/dp_10"--> | |||
<!-- android:layout_marginBottom="@dimen/dp_10"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:src="@mipmap/sz1" />--> | |||
<!-- </RelativeLayout>--> | |||
<!-- <TextView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:fontFamily="sans-serif-condensed-medium"--> | |||
<!-- android:text="电子秤设置"--> | |||
<!-- android:textAlignment="center"--> | |||
<!-- android:textColor="#B68D0C"--> | |||
<!-- android:textSize="26dp" />--> | |||
<!-- </LinearLayout>--> | |||
<!-- </RelativeLayout>--> | |||
<!-- <RelativeLayout--> | |||
<!-- android:id="@+id/wdsz"--> | |||
<!-- android:layout_width="0dp"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_margin="20dp"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <LinearLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:layout_centerInParent="true"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <RelativeLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="120dp"--> | |||
<!-- android:background="@drawable/log_bj">--> | |||
<!-- <ImageView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_marginStart="@dimen/dp_10"--> | |||
<!-- android:layout_marginTop="@dimen/dp_10"--> | |||
<!-- android:layout_marginEnd="@dimen/dp_10"--> | |||
<!-- android:layout_marginBottom="@dimen/dp_10"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:src="@mipmap/sz2" />--> | |||
<!-- </RelativeLayout>--> | |||
<!-- <TextView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:fontFamily="sans-serif-condensed-medium"--> | |||
<!-- android:text="温度设置"--> | |||
<!-- android:textAlignment="center"--> | |||
<!-- android:textColor="#8A0FA2"--> | |||
<!-- android:textSize="26dp" />--> | |||
<!-- </LinearLayout>--> | |||
<!-- </RelativeLayout>--> | |||
<RelativeLayout | |||
android:id="@+id/dzcsz" | |||
android:layout_width="0dp" | |||
android:id="@+id/xtcs" | |||
android:layout_width="250dp" | |||
android:layout_height="match_parent" | |||
android:layout_margin="20dp" | |||
android:layout_weight="1" | |||
android:orientation="vertical"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_centerInParent="true" | |||
android:orientation="vertical"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="120dp" | |||
android:background="@drawable/goodpf_bj"> | |||
android:background="@drawable/jcsjgl_bj"> | |||
<ImageView | |||
android:layout_width="match_parent" | |||
@@ -57,7 +142,7 @@ | |||
android:layout_marginBottom="@dimen/dp_10" | |||
android:layout_weight="1" | |||
android:focusable="false" | |||
android:src="@mipmap/sz1" /> | |||
android:src="@mipmap/sz3" /> | |||
</RelativeLayout> | |||
<TextView | |||
@@ -65,25 +150,25 @@ | |||
android:layout_height="wrap_content" | |||
android:focusable="false" | |||
android:fontFamily="sans-serif-condensed-medium" | |||
android:text="电子秤设置" | |||
android:text="系统参数" | |||
android:textAlignment="center" | |||
android:textColor="#B68D0C" | |||
android:textColor="#088BAD" | |||
android:textSize="26dp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:id="@+id/wdsz" | |||
android:layout_width="0dp" | |||
android:id="@+id/rl_log" | |||
android:layout_width="250dp" | |||
android:layout_height="match_parent" | |||
android:layout_margin="20dp" | |||
android:layout_weight="1" | |||
android:orientation="vertical"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_centerInParent="true" | |||
android:orientation="vertical"> | |||
<RelativeLayout | |||
@@ -100,7 +185,7 @@ | |||
android:layout_marginBottom="@dimen/dp_10" | |||
android:layout_weight="1" | |||
android:focusable="false" | |||
android:src="@mipmap/sz2" /> | |||
android:src="@mipmap/new1" /> | |||
</RelativeLayout> | |||
<TextView | |||
@@ -108,55 +193,14 @@ | |||
android:layout_height="wrap_content" | |||
android:focusable="false" | |||
android:fontFamily="sans-serif-condensed-medium" | |||
android:text="温度设置" | |||
android:text="系统日志" | |||
android:textAlignment="center" | |||
android:textColor="#8A0FA2" | |||
android:textSize="26dp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:id="@+id/xtcs" | |||
android:layout_width="0dp" | |||
android:layout_height="match_parent" | |||
android:layout_margin="20dp" | |||
android:layout_weight="1" | |||
android:orientation="vertical"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_centerInParent="true" | |||
android:orientation="vertical"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="120dp" | |||
android:background="@drawable/jcsjgl_bj"> | |||
<ImageView | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_marginStart="@dimen/dp_10" | |||
android:layout_marginTop="@dimen/dp_10" | |||
android:layout_marginEnd="@dimen/dp_10" | |||
android:layout_marginBottom="@dimen/dp_10" | |||
android:layout_weight="1" | |||
android:focusable="false" | |||
android:src="@mipmap/sz3" /> | |||
</RelativeLayout> | |||
<TextView | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:focusable="false" | |||
android:fontFamily="sans-serif-condensed-medium" | |||
android:text="系统参数" | |||
android:textAlignment="center" | |||
android:textColor="#088BAD" | |||
android:textSize="26dp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</LinearLayout> | |||
@@ -170,133 +214,133 @@ | |||
android:layout_height="match_parent" | |||
android:orientation="horizontal"> | |||
<RelativeLayout | |||
android:id="@+id/plckz" | |||
android:layout_width="0dp" | |||
android:layout_height="match_parent" | |||
android:layout_margin="20dp" | |||
android:layout_weight="1" | |||
android:orientation="vertical"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_centerInParent="true" | |||
android:orientation="vertical"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="120dp" | |||
android:background="@drawable/plc_bj"> | |||
<ImageView | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_marginStart="@dimen/dp_10" | |||
android:layout_marginTop="@dimen/dp_10" | |||
android:layout_marginEnd="@dimen/dp_10" | |||
android:layout_marginBottom="@dimen/dp_10" | |||
android:layout_weight="1" | |||
android:focusable="false" | |||
android:src="@mipmap/sz4" /> | |||
</RelativeLayout> | |||
<TextView | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:focusable="false" | |||
android:fontFamily="sans-serif-condensed-medium" | |||
android:text="PLC地址" | |||
android:textAlignment="center" | |||
android:textColor="#639F05" | |||
android:textSize="26dp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:id="@+id/imagegl" | |||
android:layout_width="0dp" | |||
android:layout_height="match_parent" | |||
android:layout_margin="20dp" | |||
android:layout_weight="1" | |||
android:orientation="vertical"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_centerInParent="true" | |||
android:orientation="vertical"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="120dp" | |||
android:background="@drawable/silos_bj"> | |||
<ImageView | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_marginStart="@dimen/dp_10" | |||
android:layout_marginTop="@dimen/dp_10" | |||
android:layout_marginEnd="@dimen/dp_10" | |||
android:layout_marginBottom="@dimen/dp_10" | |||
android:layout_weight="1" | |||
android:focusable="false" | |||
android:src="@mipmap/sz5" /> | |||
</RelativeLayout> | |||
<TextView | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:focusable="false" | |||
android:fontFamily="sans-serif-condensed-medium" | |||
android:text="图片资源" | |||
android:textAlignment="center" | |||
android:textColor="#0956B8" | |||
android:textSize="26dp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:id="@+id/shebeixinxi" | |||
android:layout_width="0dp" | |||
android:layout_height="match_parent" | |||
android:layout_margin="20dp" | |||
android:layout_weight="1" | |||
android:orientation="vertical"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:layout_centerInParent="true" | |||
android:orientation="vertical"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="120dp" | |||
android:background="@drawable/sbxx_bj"> | |||
<ImageView | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_marginStart="@dimen/dp_10" | |||
android:layout_marginTop="@dimen/dp_10" | |||
android:layout_marginEnd="@dimen/dp_10" | |||
android:layout_marginBottom="@dimen/dp_10" | |||
android:layout_weight="1" | |||
android:focusable="false" | |||
android:src="@mipmap/sz6" /> | |||
</RelativeLayout> | |||
<TextView | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:focusable="false" | |||
android:fontFamily="sans-serif-condensed-medium" | |||
android:text="设备信息" | |||
android:textAlignment="center" | |||
android:textColor="#B1265E" | |||
android:textSize="26dp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<!-- <RelativeLayout--> | |||
<!-- android:id="@+id/plckz"--> | |||
<!-- android:layout_width="0dp"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_margin="20dp"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <LinearLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:layout_centerInParent="true"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <RelativeLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="120dp"--> | |||
<!-- android:background="@drawable/plc_bj">--> | |||
<!-- <ImageView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_marginStart="@dimen/dp_10"--> | |||
<!-- android:layout_marginTop="@dimen/dp_10"--> | |||
<!-- android:layout_marginEnd="@dimen/dp_10"--> | |||
<!-- android:layout_marginBottom="@dimen/dp_10"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:src="@mipmap/sz4" />--> | |||
<!-- </RelativeLayout>--> | |||
<!-- <TextView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:fontFamily="sans-serif-condensed-medium"--> | |||
<!-- android:text="PLC地址"--> | |||
<!-- android:textAlignment="center"--> | |||
<!-- android:textColor="#639F05"--> | |||
<!-- android:textSize="26dp" />--> | |||
<!-- </LinearLayout>--> | |||
<!-- </RelativeLayout>--> | |||
<!-- <RelativeLayout--> | |||
<!-- android:id="@+id/imagegl"--> | |||
<!-- android:layout_width="0dp"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_margin="20dp"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <LinearLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:layout_centerInParent="true"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <RelativeLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="120dp"--> | |||
<!-- android:background="@drawable/silos_bj">--> | |||
<!-- <ImageView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_marginStart="@dimen/dp_10"--> | |||
<!-- android:layout_marginTop="@dimen/dp_10"--> | |||
<!-- android:layout_marginEnd="@dimen/dp_10"--> | |||
<!-- android:layout_marginBottom="@dimen/dp_10"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:src="@mipmap/sz5" />--> | |||
<!-- </RelativeLayout>--> | |||
<!-- <TextView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:fontFamily="sans-serif-condensed-medium"--> | |||
<!-- android:text="图片资源"--> | |||
<!-- android:textAlignment="center"--> | |||
<!-- android:textColor="#0956B8"--> | |||
<!-- android:textSize="26dp" />--> | |||
<!-- </LinearLayout>--> | |||
<!-- </RelativeLayout>--> | |||
<!-- <RelativeLayout--> | |||
<!-- android:id="@+id/shebeixinxi"--> | |||
<!-- android:layout_width="0dp"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_margin="20dp"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <LinearLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:layout_centerInParent="true"--> | |||
<!-- android:orientation="vertical">--> | |||
<!-- <RelativeLayout--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="120dp"--> | |||
<!-- android:background="@drawable/sbxx_bj">--> | |||
<!-- <ImageView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="match_parent"--> | |||
<!-- android:layout_marginStart="@dimen/dp_10"--> | |||
<!-- android:layout_marginTop="@dimen/dp_10"--> | |||
<!-- android:layout_marginEnd="@dimen/dp_10"--> | |||
<!-- android:layout_marginBottom="@dimen/dp_10"--> | |||
<!-- android:layout_weight="1"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:src="@mipmap/sz6" />--> | |||
<!-- </RelativeLayout>--> | |||
<!-- <TextView--> | |||
<!-- android:layout_width="match_parent"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:focusable="false"--> | |||
<!-- android:fontFamily="sans-serif-condensed-medium"--> | |||
<!-- android:text="设备信息"--> | |||
<!-- android:textAlignment="center"--> | |||
<!-- android:textColor="#B1265E"--> | |||
<!-- android:textSize="26dp" />--> | |||
<!-- </LinearLayout>--> | |||
<!-- </RelativeLayout>--> | |||
</LinearLayout> | |||
</LinearLayout> | |||
</LinearLayout> | |||