Browse Source

增加主页 商品制作,强制结束

tags/old_version_1
fyf 1 year ago
parent
commit
255beef8a4
10 changed files with 423 additions and 217 deletions
  1. +2
    -9
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  2. +47
    -4
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  3. +68
    -14
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  4. +13
    -5
      app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java
  5. +1
    -2
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java
  6. +210
    -122
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java
  7. +45
    -36
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java
  8. +4
    -4
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebutton_control.java
  9. +2
    -4
      app/src/main/res/layout/fragment_system_internet.xml
  10. +31
    -17
      app/src/main/res/layout/item/layout/item_file_picker_show.xml

+ 2
- 9
app/src/main/java/com/bonait/bnframework/business/ConfigData.java View File

@@ -930,14 +930,6 @@ public class ConfigData {
* 连接PLC
*/
public void ConnectPLC() {
ConfigName.getInstance().PLC_Address.clear();
ArrayList<BPA_PLCADDRESS> address = QueryDB.GetPlcaddressALL();
for (BPA_PLCADDRESS item : address) {
if (!item.address.isEmpty() && !item.address.equals("-------------")) {
ConfigName.getInstance().PLC_Address.put(item.name, item);
}
}
ExecuteTheRecipe.Listening();//启动数据监听
new Thread(new Runnable() {
@Override
public void run() {
@@ -959,7 +951,8 @@ public class ConfigData {
* PLC初始化完成时,需要注册的服务
*/
public void PLC_Init() {

//PLC连接成功,启动数据监听
ExecuteTheRecipe.Listening();

}
//endregion


+ 47
- 4
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -36,29 +36,64 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class ExecuteTheRecipe {

//region 变量
/**
* 等待超时时间
*/
public static int whileTime = 2;
public static int whileTime = 10;

/**
* 监听变量值
*/
public static HashMap<String, Object> ListeningValue = new HashMap<String, Object>();

/**
* 外部界面
*/
public static Context context = null;

/**
* 商品是否强制结束
*/
public static boolean IsForcedEnd = false;
//endregion

//region 强制结束
/**
* 设置强制结束
*/
public static void SetForcedEnd()
{
ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!");
IsForcedEnd=true;
}

/**
* 停止强制结束
*/
public static void StopForcedEnd()
{
IsForcedEnd=false;
}
//endregion

//region 执行配方
/**
* 执行配方
*
* @param recipe
* @return
*/
public static Context context = null;

public static boolean Execute(BPA_GOODSRECIPE recipe) {
boolean status = false;
try {
ToastUtils.info("开始执行:" + recipe.sort + "、" + recipe.processms);
//1.解析
if(IsForcedEnd)
{
ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!");
return false;
}
ToastUtils.info("开始执行:" + recipe.sort + "、" + recipe.processms);
if (recipe.materialType == 0)//正常物料
{
ExecuteMaterialIssuance(recipe.processvalue);
@@ -180,6 +215,7 @@ public class ExecuteTheRecipe {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}
//endregion

//region 物料PLC控制

@@ -640,6 +676,13 @@ public class ExecuteTheRecipe {

//region PLC监听线程
public static void Listening() {
ConfigName.getInstance().PLC_Address.clear();
ArrayList<BPA_PLCADDRESS> address = QueryDB.GetPlcaddressALL();
for (BPA_PLCADDRESS item : address) {
if (!item.address.isEmpty() && !item.address.equals("-------------")) {
ConfigName.getInstance().PLC_Address.put(item.name, item);
}
}
ThreadManager.Get().StartLong("PLC设备数据监听", true, new IThread() {
@Override
public void Run() throws InterruptedException {


+ 68
- 14
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java View File

@@ -577,10 +577,6 @@ public class ConfigName {

//翻转正转模型
add(new Res_PLCADDRESS("翻转正转", "M10.4", 0, 1));
add(new Res_PLCADDRESS("转动速度", "VW104", 1, 1));


//翻转反转模型
add(new Res_PLCADDRESS("翻转反转", "M10.5", 0, 1));
add(new Res_PLCADDRESS("转动速度", "VW104", 1, 1));

@@ -589,6 +585,8 @@ public class ConfigName {
add(new Res_PLCADDRESS("加热", "M10.6", 0, 1));
add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1));

//主料
add(new Res_PLCADDRESS("主料", "M17.4", 0, 1));

//抽水放水
add(new Res_PLCADDRESS("炒锅抽水", "M10.7", 0, 1));
@@ -614,21 +612,20 @@ public class ConfigName {

//液体料模型
add(new Res_PLCADDRESS("液体料", "-------------", 0, 0));
add(new Res_PLCADDRESS("料仓1下料", "M11.1", 0, 1));
add(new Res_PLCADDRESS("料仓2下料", "M11.2", 0, 1));
add(new Res_PLCADDRESS("料仓3下料", "M11.3", 0, 1));
add(new Res_PLCADDRESS("校准时间", "VW112", 1, 1));
add(new Res_PLCADDRESS("料仓1校准值", "VW114", 1, 1));
add(new Res_PLCADDRESS("料仓2校准值", "VW116", 1, 1));
add(new Res_PLCADDRESS("料仓3校准值", "VW118", 1, 1));
add(new Res_PLCADDRESS("开始校正", "M12.6", 0, 1));
add(new Res_PLCADDRESS("料仓1下料手动", "M12.3", 0, 1));
add(new Res_PLCADDRESS("料仓2下料手动", "M12.4", 0, 1));
add(new Res_PLCADDRESS("料仓3下料手动", "M12.5", 0, 1));
add(new Res_PLCADDRESS("开始校正", "M12.6", 0, 1));
add(new Res_PLCADDRESS("料仓1需求值", "VW106", 1, 1));
add(new Res_PLCADDRESS("料仓2需求值", "VW108", 1, 1));
add(new Res_PLCADDRESS("料仓3需求值", "VW110", 1, 1));
add(new Res_PLCADDRESS("校准时间", "VW112", 1, 1));
add(new Res_PLCADDRESS("料仓1校准值", "VW114", 1, 1));
add(new Res_PLCADDRESS("料仓2校准值", "VW116", 1, 1));
add(new Res_PLCADDRESS("料仓3校准值", "VW118", 1, 1));

add(new Res_PLCADDRESS("料仓1下料", "M11.1", 0, 1));
add(new Res_PLCADDRESS("料仓2下料", "M11.2", 0, 1));
add(new Res_PLCADDRESS("料仓3下料", "M11.3", 0, 1));

//上下限
add(new Res_PLCADDRESS("位置上下限", "-------------", 0, 0));
@@ -649,6 +646,54 @@ public class ConfigName {
add(new Res_PLCADDRESS("炒锅工作范围下限", "VD206", 1, 1));
add(new Res_PLCADDRESS("炒锅工作范围上限", "VD210", 1, 1));

//自动投料-平移轴
add(new Res_PLCADDRESS("转轴控制", "-------------", 0, 0));
add(new Res_PLCADDRESS("平移-点动正转", "M14.0", 0, 1));
add(new Res_PLCADDRESS("平移-点动反转", "M14.1", 0, 1));
add(new Res_PLCADDRESS("平移-回原点", "M14.2", 0, 1));
add(new Res_PLCADDRESS("平移-去1号位", "M14.3", 0, 1));
add(new Res_PLCADDRESS("平移-去2号位", "M14.4", 0, 1));
add(new Res_PLCADDRESS("平移-去3号位", "M14.5", 0, 1));
add(new Res_PLCADDRESS("平移-去4号位", "M14.6", 0, 1));
add(new Res_PLCADDRESS("平移-1#位置设定", "M15.0", 0, 1));
add(new Res_PLCADDRESS("平移-2#位置设定", "M15.1", 0, 1));
add(new Res_PLCADDRESS("平移-3#位置设定", "M15.2", 0, 1));
add(new Res_PLCADDRESS("平移-4#位置设定", "M15.3", 0, 1));

add(new Res_PLCADDRESS("翻转-点动正转", "M16.0", 0, 1));
add(new Res_PLCADDRESS("翻转-点动反转", "M16.1", 0, 1));
add(new Res_PLCADDRESS("翻转-回原点", "M16.2", 0, 1));
add(new Res_PLCADDRESS("翻转-去1号位", "M16.3", 0, 1));
add(new Res_PLCADDRESS("翻转-去2号位", "M16.4", 0, 1));
add(new Res_PLCADDRESS("翻转-去3号位", "M16.5", 0, 1));
add(new Res_PLCADDRESS("翻转-去4号位", "M16.6", 0, 1));
add(new Res_PLCADDRESS("翻转-1#位置设定", "M17.0", 0, 1));
add(new Res_PLCADDRESS("翻转-2#位置设定", "M17.1", 0, 1));
add(new Res_PLCADDRESS("翻转-3#位置设定", "M17.2", 0, 1));
add(new Res_PLCADDRESS("翻转-4#位置设定", "M17.3", 0, 1));
add(new Res_PLCADDRESS("倒菜启动", "M17.4", 0, 1));
add(new Res_PLCADDRESS("磁铁吸合", "M17.5", 0, 1));

//自动投料-翻转轴
add(new Res_PLCADDRESS("转轴监控", "-------------", 0, 0));
add(new Res_PLCADDRESS("平移-伺服当前值", "VD220", 1, 1));
add(new Res_PLCADDRESS("平移-点动速度", "VD224", 1, 1));
add(new Res_PLCADDRESS("平移-回原点速度", "VD228", 1, 1));
add(new Res_PLCADDRESS("平移-定位运行速度", "VD232", 1, 1));
add(new Res_PLCADDRESS("平移-1号位置值", "VD236", 1, 1));
add(new Res_PLCADDRESS("平移-2号位置值", "VD240", 1, 1));
add(new Res_PLCADDRESS("平移-3号位置值", "VD244", 1, 1));
add(new Res_PLCADDRESS("平移-4号位置值", "VD248", 1, 1));

add(new Res_PLCADDRESS("翻转-伺服当前值", "VD260", 1, 1));
add(new Res_PLCADDRESS("翻转-点动速度", "VD264", 1, 1));
add(new Res_PLCADDRESS("翻转-回原点速度", "VD268", 1, 1));
add(new Res_PLCADDRESS("翻转-定位运行速度", "VD272", 1, 1));
add(new Res_PLCADDRESS("翻转-1号位置值", "VD276", 1, 1));
add(new Res_PLCADDRESS("翻转-2号位置值", "VD280", 1, 1));
add(new Res_PLCADDRESS("翻转-3号位置值", "VD284", 1, 1));
add(new Res_PLCADDRESS("翻转-4号位置值", "VD288", 1, 1));

//反馈信号
add(new Res_PLCADDRESS("反馈信号", "-------------", 0, 0));
add(new Res_PLCADDRESS("初始化完成", "M40.0", 1, 0));
@@ -667,6 +712,15 @@ public class ConfigName {
add(new Res_PLCADDRESS("炒锅清洗反馈", "M41.5", 1, 0));
add(new Res_PLCADDRESS("出餐启动反馈", "M41.6", 1, 0));
add(new Res_PLCADDRESS("炒锅倒菜减速位", "M41.7", 1, 0));
add(new Res_PLCADDRESS("平移轴在1号位", "M43.0", 1, 0));
add(new Res_PLCADDRESS("平移轴在2号位", "M43.1", 1, 0));
add(new Res_PLCADDRESS("平移轴在3号位", "M43.2", 1, 0));
add(new Res_PLCADDRESS("平移轴在4号位", "M43.3", 1, 0));
add(new Res_PLCADDRESS("翻转轴在1号位", "M44.0", 1, 0));
add(new Res_PLCADDRESS("翻转轴在2号位", "M44.1", 1, 0));
add(new Res_PLCADDRESS("翻转轴在3号位", "M44.2", 1, 0));
add(new Res_PLCADDRESS("翻转轴在4号位", "M44.3", 1, 0));
add(new Res_PLCADDRESS("倒菜完成", "M44.4", 1, 0));

//检测信号
add(new Res_PLCADDRESS("监测信号", "-------------", 0, 0));
@@ -700,7 +754,7 @@ public class ConfigName {
add(new ProcessT("搅拌", Arrays.asList("搅拌速度", "延迟(秒)")));
add(new ProcessT("位置", Arrays.asList("转动速度", "位置动作", "延迟(秒)")));
add(new ProcessT("加热", Arrays.asList("加热功率", "延迟(秒)")));
add(new ProcessT("主料", Arrays.asList("主料名称", "主料重量", "延迟(秒)", "投料动作")));
add(new ProcessT("主料", Arrays.asList("主料名称", "主料位置", "主料重量", "投料动作")));
add(new ProcessT("液体料", new ArrayList<>()));
add(new ProcessT("延迟", Arrays.asList("延迟(秒)")));
add(new ProcessT("出菜", Arrays.asList("延迟(秒)")));


+ 13
- 5
app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java View File

@@ -5,6 +5,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
@@ -74,7 +75,7 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie
holder.mIvType.setImageResource(R.mipmap.file_picker_def);
}

holder.itemView.setOnClickListener(new View.OnClickListener() {
holder.image_open.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mOnItemClickListener != null) {
@@ -86,9 +87,15 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie
holder.mIvDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDataList.remove(holder.getAdapterPosition());
if (mOnDeleteListener != null)
mOnDeleteListener.delete(holder.getAdapterPosition());
int position=holder.getAdapterPosition();


File file= mDataList.get(position).getFile();
if (file.exists() && file.isFile())
{
file.delete();
mDataList.remove(position);
}
notifyDataSetChanged();
}
});
@@ -106,13 +113,14 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie
class FileShowViewHolder extends RecyclerView.ViewHolder {
private ImageView mIvType, mIvDelete;
private TextView mTvName, mTvDetail;
private LinearLayout image_open;
public FileShowViewHolder(View itemView) {
super(itemView);
mIvType = (ImageView) itemView.findViewById(R.id.iv_type);
mIvDelete = (ImageView) itemView.findViewById(R.id.iv_delete);
mTvName = (TextView) itemView.findViewById(R.id.tv_name);
mTvDetail = (TextView) itemView.findViewById(R.id.tv_detail);
image_open=itemView.findViewById(R.id.image_open);
}
}
}

+ 1
- 2
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java View File

@@ -158,7 +158,6 @@ public class BottomNavigation2Activity extends BaseActivity {
//判断连接环境
ConfigData.getInstance().ToggleEnvironment();
//2.初始化PLC
//ConfigData.getInstance().ConnectPLC();
//3.
ConfigData.getInstance().ConnectPLC();
}
}

+ 210
- 122
app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java View File

@@ -108,7 +108,9 @@ public class Home1Fragment extends BaseFragment {

@BindView(R.id.nifty_slider3)
NiftySlider nifty_slider3;//

/**
* 商品是否开始制作
*/
public boolean Status = false;
/**
* 当前制作商品信息
@@ -139,14 +141,14 @@ public class Home1Fragment extends BaseFragment {
nifty_slider2.setOnValueChangeListener(new NiftySlider.OnValueChangeListener() {
@Override
public void onValueChange(@NonNull NiftySlider niftySlider, float v, boolean b) {
nifty_slider2.setThumbText((int)v+"");
nifty_slider2.setThumbText((int) v + "");
}
});

nifty_slider3.setOnValueChangeListener(new NiftySlider.OnValueChangeListener() {
@Override
public void onValueChange(@NonNull NiftySlider niftySlider, float v, boolean b) {
nifty_slider3.setThumbText((int)v+"");
nifty_slider3.setThumbText((int) v + "");
}
});
}
@@ -181,6 +183,10 @@ public class Home1Fragment extends BaseFragment {

DataBus.getInstance().lcadapter = new lc_adapter(getContext());
recyclerView.setAdapter(DataBus.getInstance().lcadapter);

nifty_slider2.setValue(0,true);
nifty_slider3.setValue(0,true);

} catch (Exception e) {
ToastUtils.info("异常信息:" + e.getMessage());
}
@@ -193,7 +199,7 @@ public class Home1Fragment extends BaseFragment {
huoli.mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
ExecuteTheRecipe.Write_PLC_HuoLI((int)data);
ExecuteTheRecipe.Write_PLC_HuoLI((int) data);
}

@Override
@@ -205,6 +211,7 @@ public class Home1Fragment extends BaseFragment {
DataBus.getInstance().mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
//if (!IsMake(true)) { return; }
good = (BPA_GOODS) data;
SetBottonStatus(false);
caipumingcheng.setText(good.name);
@@ -218,117 +225,145 @@ public class Home1Fragment extends BaseFragment {
};
}

public void ControlClicked()
{
// @BindView(R.id.choushui_control)
// imagebutton_control choushui_control;//抽水
// @BindView(R.id.fangshui_control)
// imagebutton_control fangshui_control;//防水
jiaoban_control.mListener=new MyClickListener() {
/**
* Image Button 按钮点击事件
*/
public void ControlClicked() {
//搅拌挡位
jiaoban_control.mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
boolean status=(boolean) data;
int jd=(int) nifty_slider2.getValue();
ToastUtils.info("点击按钮:搅拌"+status+".搅拌频率:"+jd);
boolean status = (boolean) data;
if (!IsMake(true))
{
jiaoban_control.SetStatus(!status);
return;
}
int jd = (int) nifty_slider2.getValue();
ToastUtils.info("点击按钮:搅拌" + status + ".搅拌频率:" + jd);
ExecuteTheRecipe.WritePLC("搅拌速度", jd, new IWriteCallBack() {
@Override
public void onSuccess() {
if(jd==0)
{
ExecuteTheRecipe.WritePLC("搅拌", false,null);
}else
{
ExecuteTheRecipe.WritePLC("搅拌", status,null);
if (jd == 0) {
ExecuteTheRecipe.WritePLC("搅拌", false, null);
} else {
ExecuteTheRecipe.WritePLC("搅拌", status, null);
}
}

@Override
public void onFailure(String ErrorMsg) {
}
});

}

@Override
public void clickListenerNew(View v, int k, Object data) {

}
};
zhuandong_control_left.mListener=new MyClickListener() {
//转动 左
zhuandong_control_left.mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
boolean status=(boolean) data;
ToastUtils.info("点击按钮:炒锅正转"+status);
int jd= (int) nifty_slider3.getValue();
ToastUtils.info("点击按钮:搅拌"+status+".转动频率:"+jd);
boolean status = (boolean) data;
if (!IsMake(true))
{
zhuandong_control_left.SetStatus(!status);
return;
}
ToastUtils.info("点击按钮:炒锅正转" + status);
int jd = (int) nifty_slider3.getValue();
ToastUtils.info("点击按钮:搅拌" + status + ".转动频率:" + jd);
ExecuteTheRecipe.WritePLC("转动速度", jd, new IWriteCallBack() {
@Override
public void onSuccess() {
if(jd==0)
{
ExecuteTheRecipe.WritePLC("翻转正转", false,null);
}else
{
ExecuteTheRecipe.WritePLC("翻转正转", status,null);
if (jd == 0) {
ExecuteTheRecipe.WritePLC("翻转正转", false, null);
} else {
ExecuteTheRecipe.WritePLC("翻转正转", status, null);
}
}

@Override
public void onFailure(String ErrorMsg) {
}
});
}

@Override
public void clickListenerNew(View v, int k, Object data) {

}
};
zhuandong_control_Rift.mListener=new MyClickListener() {
//转动 右
zhuandong_control_Rift.mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
boolean status=(boolean) data;
ToastUtils.info("点击按钮:炒锅反转"+status);
int jd= (int) nifty_slider3.getValue();
ToastUtils.info("点击按钮:搅拌"+status+".转动频率:"+jd);
boolean status = (boolean) data;
if (!IsMake(true))
{
zhuandong_control_Rift.SetStatus(!status);
return;
}
ToastUtils.info("点击按钮:炒锅反转" + status);
int jd = (int) nifty_slider3.getValue();
ToastUtils.info("点击按钮:搅拌" + status + ".转动频率:" + jd);
ExecuteTheRecipe.WritePLC("转动速度", jd, new IWriteCallBack() {
@Override
public void onSuccess() {
if(jd==0)
{
ExecuteTheRecipe.WritePLC("翻转反转", false,null);
}else
{
ExecuteTheRecipe.WritePLC("翻转反转", status,null);
if (jd == 0) {
ExecuteTheRecipe.WritePLC("翻转反转", false, null);
} else {
ExecuteTheRecipe.WritePLC("翻转反转", status, null);
}
}

@Override
public void onFailure(String ErrorMsg) {
}
});
}

@Override
public void clickListenerNew(View v, int k, Object data) {

}
};
choushui_control.mListener=new MyClickListener() {
//抽水启动
choushui_control.mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
boolean status=(boolean) data;
ToastUtils.info("点击按钮:炒锅抽水"+status);
ExecuteTheRecipe.WritePLC("炒锅抽水", status,null);
boolean status = (boolean) data;
if (!IsMake(true))
{
choushui_control.SetStatus(!status);
return;
}
ToastUtils.info("点击按钮:炒锅抽水" + status);
ExecuteTheRecipe.WritePLC("炒锅抽水", status, null);
}

@Override
public void clickListenerNew(View v, int k, Object data) {

}
};
fangshui_control.mListener=new MyClickListener() {
//放水启动
fangshui_control.mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
boolean status=(boolean) data;
ToastUtils.info("点击按钮:炒锅放水"+status);
ExecuteTheRecipe.WritePLC("炒锅放水", status,null);
boolean status = (boolean) data;
if (!IsMake(true))
{
fangshui_control.SetStatus(!status);
return;
}
ToastUtils.info("点击按钮:炒锅放水" + status);
ExecuteTheRecipe.WritePLC("炒锅放水", status, null);
}

@Override
public void clickListenerNew(View v, int k, Object data) {

@@ -339,9 +374,8 @@ public class Home1Fragment extends BaseFragment {
/**
* 商品制作线程
*/
public void MakeThread()
{
ExecuteTheRecipe.context=context;
public void MakeThread() {
ExecuteTheRecipe.context = context;

new Thread(new Runnable() {
@Override
@@ -349,24 +383,18 @@ public class Home1Fragment extends BaseFragment {
while (true) {
try {

if(Status && good!=null)
{
try
{
if (Status && good != null) {
try {
//获取工艺
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id);
for(BPA_GOODSRECIPE item:goodsrecipes)
{

for (BPA_GOODSRECIPE item : goodsrecipes) {
ExecuteTheRecipe.Execute(item);
}
}catch (Exception ex)
{
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}finally {
Activity activity=getActivity();
if(activity!=null)
{
} finally {
Activity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -376,7 +404,19 @@ public class Home1Fragment extends BaseFragment {
}
}
}
Thread.sleep(1000);
} catch (InterruptedException e) {
ToastUtils.info("异常信息:" + e.getMessage());
}
}
}
}).start();

new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
SxUI();
Thread.sleep(1000);
} catch (InterruptedException e) {
@@ -390,40 +430,46 @@ public class Home1Fragment extends BaseFragment {
/**
* 刷新UI界面
*/
public void SxUI()
{
Activity activity=getActivity();
if(activity!=null)
{
public void SxUI() {
Activity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Object val_wd= ExecuteTheRecipe.getListingValue("当前锅底温度");
Object val_wz= ExecuteTheRecipe.getListingValue("编码器当前位值");
if(val_wd!=null)
{
chaoguo_wendu.setText(val_wd+"");
}else
{
Object val_wd = ExecuteTheRecipe.getListingValue("当前锅底温度");
Object val_wz = ExecuteTheRecipe.getListingValue("编码器当前位值");
Object val_jbpl = ExecuteTheRecipe.getListingValue("搅拌频率");
Object val_fzpv = ExecuteTheRecipe.getListingValue("翻转频率");

if (val_wd != null) {
chaoguo_wendu.setText(val_wd + "");
} else {
chaoguo_wendu.setText("未知");
}

if(val_wz!=null)
{
chaoguo_weizhi.setText(val_wz+"");
}else
{
if (val_wz != null) {
chaoguo_weizhi.setText(val_wz + "");
} else {
chaoguo_weizhi.setText("未知");
}

plc_zhuangtai.setText(ConfigName.getInstance().PlcIsConnect?"已连接":"断开");
plc_zhuangtai.setTextColor(ConfigName.getInstance().PlcIsConnect? Color.GREEN:Color.BLACK);
if (val_jbpl != null) {
int val=Integer.parseInt(String.valueOf(val_jbpl));
nifty_slider2.setValue(val,true);
}

if (val_fzpv != null) {
int val=Integer.parseInt(String.valueOf(val_jbpl));
nifty_slider3.setValue(val,true);
}

SetBottonStatus(false);
plc_zhuangtai.setText(ConfigName.getInstance().PlcIsConnect ? "已连接" : "断开");
plc_zhuangtai.setTextColor(ConfigName.getInstance().PlcIsConnect ? Color.GREEN : Color.BLACK);
}
});
}
}

/**
* 设置进度条百分比
*
@@ -434,7 +480,7 @@ public class Home1Fragment extends BaseFragment {
try {
jingdu.setProgress((usertime * 100) / alltime);
jingdu.setSecondProgress((usertime * 100) / alltime);
shengyushijian.setText("预计剩余时间:" + (alltime-usertime) + "s");
shengyushijian.setText("预计剩余时间:" + (alltime - usertime) + "s");
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
@@ -450,10 +496,10 @@ public class Home1Fragment extends BaseFragment {
Status = status;
if (status) {
startbutton.setImageResource(R.mipmap.tzzz);
TimerCount(good.maketime,true);//开始计时器,记录进度条
TimerCount(good.maketime, true);//开始计时器,记录进度条
} else {
startbutton.setImageResource(R.mipmap.qdzz);
TimerCount(0,false);//停止计时器
TimerCount(0, false);//停止计时器
}
if (good != null) {
SetProcesssUI(good.maketime, 0);
@@ -467,33 +513,31 @@ public class Home1Fragment extends BaseFragment {

/**
* 计时器
*
* @param alltime
* @param status
*/
public void TimerCount(int alltime, boolean status) {
if(status)
{
if(countDownTimer==null)
{
if (status) {
if (countDownTimer == null) {
countDownTimer = new CountDownTimer(alltime * 1000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
int overtime = (int) ((millisUntilFinished) / 1000);//剩余时间
SetProcesssUI(alltime,alltime-overtime);
SetProcesssUI(alltime, alltime - overtime);
}

@Override
public void onFinish() {
SetProcesssUI(alltime,alltime);//进度条100%
SetProcesssUI(alltime, alltime);//进度条100%
}
};
}
countDownTimer.start();
}else
{
if(countDownTimer!=null)
{
} else {
if (countDownTimer != null) {
countDownTimer.cancel();
countDownTimer=null;
countDownTimer = null;
}
}
}
@@ -505,8 +549,8 @@ public class Home1Fragment extends BaseFragment {
*/
@OnClick({R.id.xzcp, R.id.startbutton, R.id.qdjb, R.id.tzjb
, R.id.yaoqian, R.id.tingyao
, R.id.ydw, R.id.dcw, R.id.clw,R.id.qxw,R.id.ccw1,R.id.ccw2,R.id.ccw3
, R.id.chushihua,R.id.jiting})
, R.id.ydw, R.id.dcw, R.id.clw, R.id.qxw, R.id.ccw1, R.id.ccw2, R.id.ccw3
, R.id.chushihua, R.id.jiting})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.xzcp://选择菜谱按钮点击
@@ -515,81 +559,125 @@ public class Home1Fragment extends BaseFragment {
break;
case R.id.startbutton:
if (Status) {
ToastUtils.info("客官菜谱正在制作过程中,请耐心等待一下,马上就好啦!");
return;
// //按钮点击
// String title = "停止操作提示!";
// String message = "请问客官确定要停止制作吗,小菠萝会生气的,啊啊啊啊啊啊啊...我的饭饭?";
// AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() {
// @Override
// public void onClick(QMUIDialog dialog, int index) {
// SetBottonStatus(false);
// dialog.dismiss();
// }
// });
// ToastUtils.info("客官菜谱正在制作过程中,请耐心等待一下,马上就好啦!");
// return;
//按钮点击
String title = "停止操作提示!";
String message = "请问客官确定要停止制作吗,小菠萝会生气的,啊啊啊啊啊啊啊...我的饭饭?";
AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
//强制结束
ExecuteTheRecipe.SetForcedEnd();
dialog.dismiss();
}
});
} else {
if (good == null) {
ToastUtils.info("请先选择一个商品");
return;
}
//if (!IsMake(false)) { return; }
//按钮点击
String title = "开始操作提示!";
String message = "请问客官确定要开始制作吗,小菠萝好开心呀,马上就有好吃的耶?";
AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
ExecuteTheRecipe.StopForcedEnd();
SetBottonStatus(true);

dialog.dismiss();
}
});
}
break;
case R.id.qdjb://开始搅拌
case R.id.qdjb://开始清洗
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_Clean(MyStatus.Start);
break;
case R.id.tzjb://停止搅拌
case R.id.tzjb://停止清洗
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_Clean(MyStatus.Stop);
break;
case R.id.yaoqian:
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_YaoQian(MyStatus.Start);
break;
case R.id.tingyao:
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_YaoQian(MyStatus.Stop);
break;
case R.id.ydw://R.id.ydw, R.id.dcw, R.id.clw,R.id.qxw,R.id.ccw1,R.id.ccw2,R.id.ccw3
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_Location("原点位");
break;
case R.id.dcw:
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_Location("倒菜位");
break;
case R.id.clw:
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_Location("抽料位");
break;
case R.id.qxw:
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_Location("清洗位");
break;
case R.id.ccw1:
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_Location("炒菜位1");
break;
case R.id.ccw2:
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_Location("炒菜位2");
break;
case R.id.ccw3:
if (!IsMake(true)) { return; }
ExecuteTheRecipe.Write_PLC_Location("炒菜位3");
break;

case R.id.chushihua:
if (!IsMake(true)) { return; }
ToastUtils.info("点击按钮:初始化");
ExecuteTheRecipe.WritePLC("初始化", true,null);
ExecuteTheRecipe.WritePLC("初始化", true, null);
break;
case R.id.jiting:
if (!IsMake(true)) { return; }
ToastUtils.info("点击按钮:急停");
ExecuteTheRecipe.WritePLC("停止", true,null);
ExecuteTheRecipe.WritePLC("停止", true, null);
break;
}
}

/**
* 是否可以制作商品
* @return
*/
public boolean IsMake(boolean k)
{
if (!ConfigName.getInstance().PlcIsConnect) {
ToastUtils.warning("PLC未准备就绪!!!");
return false;
}

Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
Object jiting = ExecuteTheRecipe.getListingValue("设备急停");
if (chushiover == null || !(boolean) chushiover) {
ToastUtils.warning("设备未初始化,请先手动初始化设备!!!");
return false;
}
if (jiting == null || !(boolean) jiting) {
ToastUtils.warning("设备已急停,请检查设备!!!");
return false;
}

if (Status && k)
{
ToastUtils.warning("客官,商品制作未结束请勿进行其他操作.请耐心等待商品制作结束!!!");
return false;
}
return true;
}

/**
* 跳转界面
*/


+ 45
- 36
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java View File

@@ -1,6 +1,7 @@
package com.bonait.bnframework.modules.home.fragment.from.fragment;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
@@ -10,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.LayoutInflater;
@@ -52,7 +54,7 @@ import pub.devrel.easypermissions.EasyPermissions;
/**
* 资源管理
*/
public class systeminternetfragment extends BaseFragment{
public class systeminternetfragment extends BaseFragment {
@BindView(R.id.rl_file)
RecyclerView mRecyclerView;
@BindView(R.id.rl_yx_file)
@@ -60,6 +62,7 @@ public class systeminternetfragment extends BaseFragment{
@BindView(R.id.baocunbendi)
Button baocunbendi;
private Context context;

@Override
protected View onCreateView() {
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_system_internet, null);
@@ -75,7 +78,7 @@ public class systeminternetfragment extends BaseFragment{
FlushedImage();
}

@OnClick({R.id.xuanzhewenjian,R.id.baocunbendi})
@OnClick({R.id.xuanzhewenjian, R.id.baocunbendi})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.xuanzhewenjian://保存按钮
@@ -84,13 +87,12 @@ public class systeminternetfragment extends BaseFragment{
break;
case R.id.baocunbendi://保存按钮
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize=2;//宽高压缩为原来的1/2
for (FileEntity item:PickerManager.getInstance().files)
{
File file= item.getFile();
options.inSampleSize = 2;//宽高压缩为原来的1/2
for (FileEntity item : PickerManager.getInstance().files) {
File file = item.getFile();
try {
Bitmap bitmap1= BitmapFactory.decodeStream(new FileInputStream(file));
new LocalCacheUtils().setBitmapToLocal(file.getName(),bitmap1);
Bitmap bitmap1 = BitmapFactory.decodeStream(new FileInputStream(file));
new LocalCacheUtils().setBitmapToLocal(file.getName(), bitmap1);
} catch (Exception e) {
}
}
@@ -98,10 +100,11 @@ public class systeminternetfragment extends BaseFragment{
break;
}
}
ArrayList<FileEntity> yx_files=new ArrayList<>();
private static final String CACHE_PATH= Environment.getExternalStorageDirectory().getAbsolutePath()+"/hblxiaochaodb/WebImage";
public void FlushedImage()
{

ArrayList<FileEntity> yx_files = new ArrayList<>();
private static final String CACHE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/hblxiaochaodb/WebImage";

public void FlushedImage() {
File path = new File(CACHE_PATH);// 获得路径
File[] files = path.listFiles();// 读取文件
yx_files.clear();
@@ -113,24 +116,25 @@ public class systeminternetfragment extends BaseFragment{
} else {
e = new FileEntity(absolutePath, f, false);
}
if(f.isFile())
{
String[] imgs = {"png","jpg","jpeg","gif"};
e.setFileType(new FileType("IMG",imgs,0));
if (f.isFile()) {
String[] imgs = {"png", "jpg", "jpeg", "gif"};
e.setFileType(new FileType("IMG", imgs, 0));
yx_files.add(e);
}
}
rl_yx_file.setLayoutManager(new LinearLayoutManager(context));
FilePickerShowAdapter adapter = new FilePickerShowAdapter(context,yx_files);
FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, yx_files);
rl_yx_file.setAdapter(adapter);
adapter.setOnDeleteListener(new OnDeleteListener() {
adapter.setOnItemClickListener(new OnFileItemClickListener() {
@Override
public void delete(int position) {
File file= yx_files.get(position).getFile();
if (file.exists() && file.isFile())
{
file.delete();
}
public void click(int position) {

String path=yx_files.get(position).getPath();
//打开系统相册浏览照片
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + path), "image/*");
startActivity(intent);
}
});
}
@@ -147,19 +151,24 @@ public class systeminternetfragment extends BaseFragment{
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == Constants.REQ_CODE){
if (requestCode == Constants.REQ_CODE) {
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
FilePickerShowAdapter adapter = new FilePickerShowAdapter(context,PickerManager.getInstance().files);
FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, PickerManager.getInstance().files);
mRecyclerView.setAdapter(adapter);

String res = "("+ PickerManager.getInstance().files.size()+"/"+PickerManager.getInstance().maxCount+")";
baocunbendi.setText(getString(R.string.file_select_res1,res));
// adapter.setOnItemClickListener(new OnFileItemClickListener() {
// @Override
// public void click(int position) {
// startActivity(Intent.createChooser(OpenFile.openFile(PickerManager.getInstance().files.get(position).getPath(),getBaseFragmentActivity()), "选择程序"));
// }
// });
String res = "(" + PickerManager.getInstance().files.size() + "/" + PickerManager.getInstance().maxCount + ")";
baocunbendi.setText(getString(R.string.file_select_res1, res));
adapter.setOnItemClickListener(new OnFileItemClickListener() {
@Override
public void click(int position) {

String path=PickerManager.getInstance().files.get(position).getPath();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + path), "image/*");
startActivity(intent);
}
});
}
}

@@ -173,9 +182,9 @@ public class systeminternetfragment extends BaseFragment{
* 当在activity设置viewPager + BottomNavigation + fragment时,
* 为防止viewPager左滑动切换界面,与fragment左滑返回上一界面冲突引起闪退问题,
* 必须加上此方法,禁止fragment左滑返回上一界面。
*
* <p>
* 切记!切记!切记!否则会闪退!
*
* <p>
* 当在fragment设置viewPager + BottomNavigation + fragment时,则不会出现这个问题。
*/
@Override


+ 4
- 4
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebutton_control.java View File

@@ -75,7 +75,7 @@ public class imagebutton_control extends LinearLayout {
text_u.setText("");
}

SetStatus();
SetStatus(Status);
}

@OnClick({R.id.startjb})
@@ -83,7 +83,7 @@ public class imagebutton_control extends LinearLayout {
switch (view.getId()) {
case R.id.startjb:
Status=!Status;
SetStatus();
SetStatus(Status);
break;
}

@@ -97,9 +97,9 @@ public class imagebutton_control extends LinearLayout {
* 设置级别
* @param
*/
public void SetStatus()
public void SetStatus(boolean status)
{
if(Status)
if(status)
{
image_u.setImageResource(ks_ys);
}else


+ 2
- 4
app/src/main/res/layout/fragment_system_internet.xml View File

@@ -38,8 +38,7 @@
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="@dimen/dp_10"

android:background="@color/main_background">
>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rl_yx_file"
@@ -73,8 +72,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="@dimen/dp_10"
android:background="@color/main_background">
android:layout_marginBottom="@dimen/dp_10">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rl_file"


+ 31
- 17
app/src/main/res/layout/item/layout/item_file_picker_show.xml View File

@@ -6,38 +6,46 @@
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_marginTop="10dp"
android:id="@+id/image_open"
android:layout_marginTop="5dp"
android:background="@color/activity_background"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/iv_type"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp" />
<RelativeLayout
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_type"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:src="@mipmap/image1"/>
</RelativeLayout>


<LinearLayout
android:id="@+id/layout_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/iv_type"
android:layout_weight="1"
android:orientation="vertical"
android:padding="10dp">
>

<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textSize="@dimen/text_size_16"
android:textColor="@color/file_picker_title"
tools:text="文件名" />
tools:text="image.png" />

<TextView
android:id="@+id/tv_detail"
@@ -50,12 +58,18 @@
/>
</LinearLayout>

<ImageView
android:id="@+id/iv_delete"
android:layout_width="40dp"
android:layout_height="40dp"
<RelativeLayout
android:layout_marginRight="10dp"
android:src="@mipmap/file_picker_delete"
android:visibility="gone" />
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:layout_centerVertical="true"
android:id="@+id/iv_delete"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@mipmap/file_picker_delete"
/>
</RelativeLayout>

</LinearLayout>
</LinearLayout>

Loading…
Cancel
Save