Browse Source

自动控制

燃气自翻炒锅
fyf 11 months ago
parent
commit
ee3f170eb7
12 changed files with 1046 additions and 570 deletions
  1. +152
    -493
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  2. +3
    -3
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  3. +4
    -1
      app/src/main/java/com/bonait/bnframework/common/db/res/StatusMode.java
  4. +114
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/devicestatus_adapter.java
  5. +390
    -4
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java
  6. +4
    -4
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_plc_control.java
  7. +27
    -0
      app/src/main/res/drawable/bg_btn_login_red.xml
  8. +27
    -0
      app/src/main/res/drawable/main_bj1.xml
  9. +28
    -0
      app/src/main/res/layout/datatab/layout/status_item.xml
  10. +296
    -64
      app/src/main/res/layout/fragment_make_good.xml
  11. BIN
     
  12. +1
    -1
      app/src/main/res/values/strings.xml

+ 152
- 493
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -34,42 +34,23 @@ import java.util.Map;
*/
public class ExecuteTheRecipe {

//获取工艺
//ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(goods.id);
//region 变量
/**
* 等待超时时间
*/
public static int whileTime = 100;

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

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

/**
* 商品是否强制结束
*/
public static boolean IsForcedEnd = false;
/**
* 当前配方
*/
public static ArrayList<BPA_GOODSRECIPE> all_list = new ArrayList<>();

static BPA_GOODSRECIPE selectpf;
/**
* 当前工序的index
*/
static int Index_select = 0;
/**
* 商品是否开始制作
*/
public static boolean MakeStatus = false;
/**
* 是否启动
*/
@@ -78,19 +59,6 @@ public class ExecuteTheRecipe {
* 是否暂停
*/
public static boolean IsPause = false;

/**
* 当前执行工序
*/
public static IRunT ExecuteCurrentOperation = null;
/**
* plc 当前版本号
*/
public static String PlcVersion = "0001";
/**
* 通知版本号更新显示
*/
public static IRun NotifyVersionNumUpdates = null;
//endregion

//region 强制结束
@@ -119,11 +87,8 @@ public class ExecuteTheRecipe {
* @param recipe
* @return
*/
public static boolean Execute(BPA_GOODSRECIPE recipe, ArrayList<BPA_GOODSRECIPE> all, int index) {
public static boolean Execute(BPA_GOODSRECIPE recipe) {
boolean status = false;
all_list = all;
selectpf = recipe;
Index_select = index;
try {
//1.解析
if (IsForcedEnd) {
@@ -131,7 +96,6 @@ public class ExecuteTheRecipe {
return false;
}
ExecuteTheRecipe.showlog("开始执行:" + recipe.sort + "、" + recipe.processms);

if (recipe.materialType == 0)//正常物料
{
//开始配料
@@ -159,6 +123,7 @@ public class ExecuteTheRecipe {
if (!text.isEmpty()) {
//仓号 出料克数
HashMap<BPA_SILOS, Integer> formulation = new HashMap<>();

//region 获取仓号和值
List<String> data = new ArrayList<>();
if (text.contains("|")) {
@@ -174,8 +139,7 @@ public class ExecuteTheRecipe {
String[] wl = item.split("[,]");
if (wl != null && wl.length == 2) {
String name = wl[0];
int val = (int) Math.round((Double.parseDouble(wl[1]) * 10));
//int val = Integer.parseInt(wl[1]);
int val = (int) Math.round((Double.parseDouble(wl[1])));
List<BPA_SILOS> bpa_silos = QueryDB.GetSolisByMaterialName(name);
if (bpa_silos.size() > 0 && val > 0) {
BPA_SILOS silos = bpa_silos.get(0);
@@ -192,14 +156,6 @@ public class ExecuteTheRecipe {
Integer value = entry.getValue();
Write_PLC_Material(silos, value);
}

Thread.sleep(200);//等待写入完成

//一直等待下料完成 否则就一直等待 40s超时
for (Map.Entry<BPA_SILOS, Integer> entry : formulation.entrySet()) {
BPA_SILOS silos = entry.getKey();
ThreadWhile("料仓" + silos.num + "下料完成");
}
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -240,30 +196,19 @@ public class ExecuteTheRecipe {
//写入PLC
if (formulation.size() > 0) {
switch (processname) {
case "主料":
Write_PLC_Ingredients(formulation);
break;
case "搅拌":
Write_PLC_Stir(formulation);
break;
case "位置":
Write_PLC_Location(formulation);
break;
case "打火":
case "火力设置":
Write_PLC_Heating(formulation);
break;
case "约束条件":
Write_PLC_ConstraintCondition(formulation);
break;
case "主料":
Write_PLC_Ingredients(formulation);
break;
case "延迟":
Write_PLC_Delay(formulation);
break;
case "出菜":
Write_PLC_Outdishes(formulation);
break;
case "清洗":
Write_PLC_CleanPan(formulation);
break;

}
}
}
@@ -283,149 +228,30 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_Material(BPA_SILOS silos, int val) {
try {
if (ExecuteCurrentOperation != null) {
ExecuteCurrentOperation.Run("液体料|" + silos.num);
}
ExecuteTheRecipe.showlog("准备写入PLC仓号需求:" + silos.num + "," + val / 10.0);

String name = "料仓" + silos.num + "下料完成";
ExecuteTheRecipe.WritePLC(name, false, null);

final boolean[] IsComplete = {false};

WritePLC("料仓" + silos.num + "需求值", val, new IWriteCallBack() {
@Override
public void onSuccess() {
ExecuteTheRecipe.showlog("需求值写入成功!");
IsComplete[0] = true;
}
ExecuteTheRecipe.showlog("准备写入PLC仓号需求:" + silos.num + "," + val);
String name = "料仓" + silos.num + "出料";
WritePLC(name, false); //复位料仓1号

@Override
public void onFailure(String ErrorMsg) {
ExecuteTheRecipe.showlog("需求值写入失败!尝试再次写入...错误原因:" + ErrorMsg);
WritePLC("料仓" + silos.num + "需求值", val, null);
IsComplete[0] = true;
}
});
long a = System.currentTimeMillis();
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
}
Thread.sleep(100);//10 *6
}

BottomClick("料仓" + silos.num + "下料");
ExecuteTheRecipe.showlog("料仓" + silos.num + "下料");
WritePLC("设定重量", val);
WritePLC("设定提前量", 20);
ExecuteTheRecipe.showlog("需求值写入成功!");

//減去料仓数量
int otherG = silos.silosmargin - (val / 10);
QueryDB.UpdateYL(silos.id, otherG >= 0 ? otherG : 0);
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}
//endregion

//region 写PLC工序

/**
* 写PLC搅拌
*
* @param data
*/
private static void Write_PLC_Stir(HashMap<String, String> data) {
try {
int val = 0;

for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("(秒)")) {
val = Integer.parseInt(value);
} else {
ToastUtils.info("工序:" + key + "," + value);
int writeValue = GetMXValue(key, value);
if (ExecuteCurrentOperation != null) {
ExecuteCurrentOperation.Run("搅拌" + "|" + writeValue);
}
WritePLC(key, writeValue, new IWriteCallBack() {
@Override
public void onSuccess() {
ExecuteTheRecipe.showlog("搅拌,挡位-" + writeValue + ",写入成功!");
if (writeValue == 0) {
WritePLC("搅拌", false, null);
} else {
WritePLC("搅拌", true, null);
}
}

@Override
public void onFailure(String ErrorMsg) {
ExecuteTheRecipe.showlog("搅拌,挡位-" + writeValue + ",写入失败!原因:" + ErrorMsg);
WritePLC(key, writeValue, null);
if (writeValue == 0) {
WritePLC("搅拌", false, null);
} else {
WritePLC("搅拌", true, null);
}
}
});
}
}
WritePLC(name, true); //开始出料

if (val > 0) {
ThreadDelay(val);
}
//等待出料完成,false信号
ThreadWhileFlase(name);
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}
//endregion

/**
* 写PLC位置
*
* @param data
*/
private static void Write_PLC_Location(HashMap<String, String> data) {
try {
int val = 0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("(秒)")) {
val = Integer.parseInt(value);
} else if (key.contains("速度")) {
int writeValue = GetMXValue(key, value);
//修改最高速度40
WritePLC(key, writeValue >= 30 ? 30 : writeValue, null);
}
}

for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (!key.contains("(秒)") && !key.contains("速度")) {
ExecuteTheRecipe.showlog("工序:" + key + "," + value);

if (ExecuteCurrentOperation != null) {
ExecuteCurrentOperation.Run("位置" + "|" + value);
}
//原点位,等待机器移动倒响应位置
BottomClick1(value);

//一直等待机器移动到该位置
ThreadWhile(value + "反馈");
}
}

if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}
//region 写PLC工序

/**
* 写PLC主料
@@ -435,19 +261,17 @@ public class ExecuteTheRecipe {
private static void Write_PLC_Ingredients(HashMap<String, String> data) {
try {
String name = "";
String zl = "";
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("名称")) {
name = value;
} else if (key.contains("重量")) {
zl = value;
}
}
ExecuteTheRecipe.showlog("工序:手动投料," + name + "," + zl);

ExecuteTheRecipe.showlog("工序:手动投料," + name);
String title = "手动投料-温馨提示!";
String message = "客官请投入主料,[" + name + "]重量" + zl + "g,投入后点击[确定]继续流程!";
String message = "客官请投入主料,[" + name + "],投入后点击[确定]继续流程!";

final boolean[] IsComplete = {false};
Activity activity = findActivity(context);
@@ -456,7 +280,6 @@ public class ExecuteTheRecipe {
@Override
public void run() {
try {

new QMUIDialog.MessageDialogBuilder(context).setCancelable(false).setTitle(title).setMessage(message).addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
@@ -464,7 +287,6 @@ public class ExecuteTheRecipe {
dialog.dismiss();
}
}).create(com.qmuiteam.qmui.R.style.QMUI_Dialog).show();

} catch (Exception e) {

}
@@ -477,154 +299,36 @@ public class ExecuteTheRecipe {
}

ExecuteTheRecipe.showlog("手动已确认投入主料:" + name + "-继续流程");

//判断是否有烹饪时间
int val = 0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("(秒)")) {
val = Integer.parseInt(value);
}
}

if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
}

ExecuteTheRecipe.showlog("烹饪时间等待结束!继续下一步.");
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}

/**
* 按下
*
* @param name
*/
public static void BottomClick(String name) {
try {
Log.e("按钮按下", name);
WritePLC(name, true, null);
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
Log.e("按钮复位", name);
ExecuteTheRecipe.WritePLC(name, false, null);
}
}, 500);
} catch (Exception ex) {
Log.e("按钮异常", name + ex.getMessage());
}
}

/**
* 组断执行
*
* @param name
*/
public static void BottomClick1(String name) {
try {
Log.e("按钮按下", name);
WritePLC(name, true, null);
Thread.sleep(200);
WritePLC(name, false, null);
Log.e("按钮复位", name);
ExecuteTheRecipe.showlog("写入plc-------" + name);
} catch (Exception ex) {
Log.e("按钮异常", name + ex.getMessage());
WritePLC(name, false, null);
}
}

private static Activity findActivity(@NonNull Context context) {
if (context instanceof Activity) {
return (Activity) context;
} else if (context instanceof ContextWrapper) {
return findActivity(((ContextWrapper) context).getBaseContext());
} else {
return null;
}
}

/**
* 写PLC 加热
*
* @param data
*/
private static void Write_PLC_Heating(HashMap<String, String> data) {
try {
int val = 0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("(秒)")) {
val = Integer.parseInt(value);
} else {
ToastUtils.info("工序:" + key + "," + value);
if (value.contains("自动打火")) {
//WritePLC(value,true,null);
} else //手动打火
{

}
}
}

if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
}

} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}

/**
* 写PLC 约束条件
* 写PLC搅拌
*
* @param data
*/
private static void Write_PLC_ConstraintCondition(HashMap<String, String> data) {
private static void Write_PLC_Stir(HashMap<String, String> data) {
try {
int val = 0;
int seep = 0;
boolean status = false;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("(秒)")) {
val = Integer.parseInt(value);
} else {


if (key.contains("搅拌速度")) {
seep = Integer.parseInt(value);
} else if (key.contains("搅拌状态")) {
status = value.contains("启动") ? true : false;
}
}

if (val > 0 && !IsForcedEnd) {
ThreadDelay(val);
//Thread.sleep(val * 1000);
}
WritePLC("搅拌速度", seep);

} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}

/**
* 写PLC 延迟
*
* @param data
*/
private static void Write_PLC_Delay(HashMap<String, String> data) {
try {
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ExecuteTheRecipe.showlog("工序:" + key + "," + value);
if (key.contains("(秒)") && !IsForcedEnd) {
int val = Integer.parseInt(value);
ThreadDelay(val);
}
if (status) {
BottomClick("搅拌启动开关");
} else {
BottomClick("搅拌停止开关");
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -632,104 +336,79 @@ public class ExecuteTheRecipe {
}

/**
* 写PLC 出菜
* 写PLC 设置加热功率
*
* @param data
*/
private static void Write_PLC_Outdishes(HashMap<String, String> data) {
private static void Write_PLC_Heating(HashMap<String, String> data) {
try {
ExecuteTheRecipe.showlog("准备出菜!");
int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;

//先延迟
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)")) {
int val = Integer.parseInt(value);
if (all_list.size() > 0 && !IsForcedEnd) {
ThreadDelay(val);
}
if (key.contains("一环功率")) {
val1 = Integer.parseInt(value);
} else if (key.contains("二环功率")) {
val2 = Integer.parseInt(value);
} else if (key.contains("三环功率")) {
val3 = Integer.parseInt(value);
} else if (key.contains("四环功率")) {
val4 = Integer.parseInt(value);
}
}

ExecuteTheRecipe.WritePLC("搅拌", false, null);
ExecuteTheRecipe.WritePLC("加热", false, null);
ExecuteTheRecipe.showlog("关闭搅拌、关闭加热!");

BottomClick1("出菜");

//一直等待机器移动到该位置,否则就一直等待 6s超时
ThreadWhile3("出餐启动反馈", 5);

ExecuteTheRecipe.showlog("出菜完成,锅体准备回到原位!");
WritePLC("小火开关(一圈)", val1);
WritePLC("中火开关(二圈)", val2);
WritePLC("大火开关(三圈)", val3);
WritePLC("强火开关(四圈)", val4);
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}

/**
* 写PLC 清洗
* 写PLC 约束条件
*
* @param data
*/
private static void Write_PLC_CleanPan(HashMap<String, String> data) {
private static void Write_PLC_ConstraintCondition(HashMap<String, String> data) {
try {
ExecuteTheRecipe.showlog("准备清洗!");
//先延迟
int time = 0;
int temp = 0;
int val = 0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)") && !IsForcedEnd) {
int val = Integer.parseInt(value);
ThreadDelay(val);
if (key.contains("(秒)")) {
time = Integer.parseInt(value);
}
if (key.contains("锅内重量")) {
val = Integer.parseInt(value);
}
if (key.contains("温度设定")) {
temp = Integer.parseInt(value);
}
}

//复位反馈信号
ExecuteTheRecipe.WritePLC("炒锅清洗反馈", false, null);

//开始清洗
BottomClick1("炒锅清洗");

//等待清洗完成
ThreadWhile3("炒锅清洗反馈", 5);

ExecuteTheRecipe.showlog("炒锅清洗完成!");
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}
//endregion

//region 主页按钮
//1.判断等待时长是否满足
if (time > 0 && !IsForcedEnd) {
ThreadDelay(time);
}

/**
* 火力点击
*
* @param data
*/
public static void Write_PLC_HuoLI(int data) {
try {
WritePLC("加热功率", data, new IWriteCallBack() {
@Override
public void onSuccess() {
if (data == 0) {
ConfigName.getInstance().IsOpenHuoLi = false;
WritePLC("加热", false, null);
} else {
ConfigName.getInstance().IsOpenHuoLi = true;
WritePLC("加热", true, null);
}
}
//2.判断温度是否满足
if (temp > 0 && !IsForcedEnd) {
ThreadWhile("炒锅当前温度", temp);
}

@Override
public void onFailure(String ErrorMsg) {
}
});
ToastUtils.info("火力按钮点击,当前级别:" + data);
//3.判断重量是否到达
if (val > 0 && !IsForcedEnd) {
ThreadWhile("炒锅当前重量", val);
}

} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -755,21 +434,7 @@ public class ExecuteTheRecipe {
new Thread(new Runnable() {
@Override
public void run() {
try {
WritePLC("初始化", true, null);
Thread.sleep(500);
WritePLC("初始化", false, null);

ExecuteTheRecipe.WritePLC("温控开关", false, null);//开关闭合
ExecuteTheRecipe.WritePLC("暂停开关", false, null);//开关闭合

ExecuteTheRecipe.WritePLC("校准时间", 50, null);//默认校准时间5秒
ExecuteTheRecipe.WritePLC("料仓1校准开关", false, null);//默认校准时间5秒
ExecuteTheRecipe.WritePLC("料仓2校准开关", false, null);//默认校准时间5秒
ExecuteTheRecipe.WritePLC("料仓3校准开关", false, null);//默认校准时间5秒
} catch (InterruptedException e) {
ToastUtils.info("异常信息:" + e.getMessage());
}
WritePLC("系统启停开关", true);
}
}).start();

@@ -804,16 +469,14 @@ public class ExecuteTheRecipe {
try {
if (ConfigName.getInstance().PlcIsConnect) {
//心跳
WritePLC("心跳位", 0, null);
Log.e("心跳", "心跳: ");
//Log.e("心跳", "心跳: "+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

WritePLC("上位机-PLC", true);
Thread.sleep(500);
WritePLC("上位机-PLC", false);
}

} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
Thread.sleep(2000);
Thread.sleep(500);
}

@Override
@@ -824,61 +487,43 @@ public class ExecuteTheRecipe {
}
//endregion

//region 获取基础挡位变量

//region 界面事件
/**
* 执行位置
* 阻断按钮
*
* @param name
*/
public static void Make位置(String name) {
ExecuteOperationSteps(Get位置("高速", name).processname, Get位置("高速", name).processvalue);
}

/**
* 获取位置
*
* @param sd
* @return
*/
public static BPA_GOODSRECIPE Get位置(String sd, String name) {
BPA_GOODSRECIPE pf = new BPA_GOODSRECIPE();
pf.materialType = 1;
pf.processname = "位置";
pf.processms = "位置(" + sd + "," + name + ",0)";
pf.processvalue = "转动速度," + sd + "|位置动作," + name + "|延迟(秒),0";
return pf;
public static void BottomClick(String name) {
try {
Log.e("按钮按下", name);
WritePLC(name, true);
Thread.sleep(200);
WritePLC(name, false);
Log.e("按钮复位", name);
ExecuteTheRecipe.showlog("写入plc-------" + name);
} catch (Exception ex) {
Log.e("按钮异常", name + ex.getMessage());
WritePLC(name, false);
}
}

/**
* 获取挡位变量
*
* @param name
* @param value
* 发现主窗体
* @param context
* @return
*/
public static int GetMXValue(String name, String value) {
final int[] ReturnsVariable = {0};
try {
if (name.contains("速度")) {
ReturnsVariable[0] = ConfigName.getInstance().StirringSpeed.get(value);
} else if (name.contains("功率")) {
ReturnsVariable[0] = ConfigName.getInstance().HeatingGear.get(value);
int max = ConfigName.getInstance().HeatingGear.get(ConfigName.getInstance().HuoLi);
if (ReturnsVariable[0] > max) {
ReturnsVariable[0] = max;
}
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
return ReturnsVariable[0];
private static Activity findActivity(@NonNull Context context) {
if (context instanceof Activity) {
return (Activity) context;
} else if (context instanceof ContextWrapper) {
return findActivity(((ContextWrapper) context).getBaseContext());
} else {
return null;
}
}
//endregion

//region 延迟函数

/**
* 线程延迟函数(避免线程阻塞等待)
*
@@ -888,7 +533,7 @@ public class ExecuteTheRecipe {
ExecuteTheRecipe.showlog("工序线程等待-------时长:" + delay + "秒,请耐心等待,开始计时!");

long startTime = System.currentTimeMillis();
while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd) //
while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd)
{
try {
Thread.sleep(100);
@@ -902,7 +547,7 @@ public class ExecuteTheRecipe {
}

/**
* 线程等待
* 线程等待true信号
*
* @param name
*/
@@ -916,14 +561,14 @@ public class ExecuteTheRecipe {
ExecuteTheRecipe.showlog(name + ",异常超时退出!");
break;
} else {
Object sb = ReadPLC(name);//ListeningValue.get(name);
Object sb = ReadPLC(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
ExecuteTheRecipe.showlog(name + ",接收到信号!");
}
}
try {
Thread.sleep(100);//10 *6
Thread.sleep(100);
} catch (InterruptedException e) {
IsComplete[0] = true;
ExecuteTheRecipe.showlog(name + ",异常退出!" + e.getMessage());
@@ -933,28 +578,61 @@ public class ExecuteTheRecipe {
}

/**
* 线程等待
* 线程等待false信号
*
* @param name
*/
public static void ThreadWhile3(String name, int k) {
public static void ThreadWhileFlase(String name) {
//"炒菜位1反馈";
final boolean[] IsComplete = {false};
final boolean[] IsComplete = {true};
long a = System.currentTimeMillis();
ExecuteTheRecipe.showlog(name + ",等待中");
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime * k) {
while (IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
ExecuteTheRecipe.showlog(name + ",异常超时退出!");
break;
} else {
Object sb = ReadPLC(name);//ListeningValue.get(name);
Object sb = ReadPLC(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
ExecuteTheRecipe.showlog(name + ",接收到信号!");
}
}
try {
Thread.sleep(100);//10 *6
Thread.sleep(100);
} catch (InterruptedException e) {
IsComplete[0] = false;
ExecuteTheRecipe.showlog(name + ",异常退出!" + e.getMessage());
}
}
ExecuteTheRecipe.showlog(name + ",等待结束!");
}

/**
* 线程等待--等待int数据是否大于int
*
* @param name
*/
public static void ThreadWhile(String name, int val) {
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
ExecuteTheRecipe.showlog(name + ",等待数据大于" + val);
while (!IsComplete[0] && !IsForcedEnd) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
ExecuteTheRecipe.showlog(name + ",异常超时退出!");
break;
} else {
Object sb = ReadPLC(name);
int value = sb == null ? 0 : (int) (sb);
if (value >= val) {
IsComplete[0] = true;
ExecuteTheRecipe.showlog(name + ",接收到信号!");
} else {
IsComplete[0] = false;
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
IsComplete[0] = true;
ExecuteTheRecipe.showlog(name + ",异常退出!" + e.getMessage());
@@ -1129,7 +807,7 @@ public class ExecuteTheRecipe {
* @param name
* @param value
*/
public static void WritePLC(String name, Object value, IWriteCallBack callback) {
public static void WritePLC(String name, Object value) {
try {
if (ConfigName.getInstance().PLC_Address.containsKey(name)) {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
@@ -1166,25 +844,6 @@ public class ExecuteTheRecipe {
}
}


/**
* 获取搅拌电机
*
* @param
* @return
*/
public static int getConcurrentHash_dj(String name) {
if (!ListeningValue.containsKey(name)) {
return 0;
}
Object obj = ListeningValue.get(name);
if (obj == null) {
return 0;
} else {
return (int) obj;
}
}

/**
* 获取监听变量
*


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

@@ -309,7 +309,7 @@ public class ConfigName {
add(new Res_PLCADDRESS("搅拌启动开关", "V221.2", 0, 1));
add(new Res_PLCADDRESS("搅拌停止开关", "V221.3", 0, 1));
add(new Res_PLCADDRESS("搅拌速度", "VD1200", 0, 1));
add(new Res_PLCADDRESS("炒锅当前温度", "VD2250", 0, 1));
add(new Res_PLCADDRESS("炒锅当前温度", "VD2250", 1, 1));
add(new Res_PLCADDRESS("炒锅温度修正", "VD1204", 0, 1));
add(new Res_PLCADDRESS("炒锅温度上限设置", "VD1828", 0, 1));

@@ -323,8 +323,8 @@ public class ConfigName {

//称重画面
add(new Res_PLCADDRESS("称重画面", "-------------", 0, 0));
add(new Res_PLCADDRESS("抽油开关", "V222.0", 1, 1));
add(new Res_PLCADDRESS("备用气缸开关", "V222.1", 1, 1));
add(new Res_PLCADDRESS("料仓1出料", "V222.0", 1, 1));
add(new Res_PLCADDRESS("料仓2出料", "V222.1", 1, 1));
add(new Res_PLCADDRESS("炒锅当前重量", "VD500", 1, 0));
add(new Res_PLCADDRESS("设定重量", "VD510", 0, 1));
add(new Res_PLCADDRESS("设定提前量", "VD514", 0, 1));


+ 4
- 1
app/src/main/java/com/bonait/bnframework/common/db/res/StatusMode.java View File

@@ -5,16 +5,19 @@ package com.bonait.bnframework.common.db.res;
*/
public class StatusMode {
public String Name;
public String YName;//内部名称

public Boolean Status;
public int Url_open;
public int Url_close;

public int sort;

public StatusMode(String name,Boolean Status,int Url_open,int
public StatusMode(String name,String yName,Boolean Status,int Url_open,int
Url_close,int sort)
{
this.Name=name;
this.YName=yName;
this.Status=Status;
this.Url_open=Url_open;
this.Url_close=Url_close;


+ 114
- 0
app/src/main/java/com/bonait/bnframework/modules/home/adapter/devicestatus_adapter.java View File

@@ -0,0 +1,114 @@
package com.bonait.bnframework.modules.home.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL;
import com.bonait.bnframework.common.db.res.StatusMode;
import com.bonait.bnframework.common.db.res.lcMode;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

public class devicestatus_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

private final LayoutInflater mLayoutInflater;

private Context context;

List<StatusMode> StatusList = new ArrayList<>();

public devicestatus_adapter(Context context, List<StatusMode> data) {
this.context = context;
mLayoutInflater = LayoutInflater.from(context);
StatusList = data;
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View inflate = mLayoutInflater.inflate(R.layout.status_item, parent, false);
return new MyLCViewHolder1(inflate);
}

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
try {
if (holder instanceof MyLCViewHolder1) {

StatusMode mode = (StatusMode) StatusList.get(position);
MyLCViewHolder1 myViewHolder = (MyLCViewHolder1) holder;

myViewHolder.name_1.setText(mode.Name + "");
myViewHolder.image_1.setImageResource(mode.Status?mode.Url_open:mode.Url_close);
}
} catch (Exception e) {
e.printStackTrace();
}
}

private Activity findActivity(@NonNull Context context) {
if (context instanceof Activity) {
return (Activity) context;
} else if (context instanceof ContextWrapper) {
return findActivity(((ContextWrapper) context).getBaseContext());
} else {
return null;
}
}

/**
* 刷新
*
* @param
*/
public void refresh() {
Activity activity = findActivity(context);
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
notifyDataSetChanged();
} catch (Exception e) {

}
}
});
}
}

@Override
public int getItemCount() {
return StatusList.size();
}

public static class MyLCViewHolder1 extends RecyclerView.ViewHolder {
ImageView image_1;
TextView name_1;

public MyLCViewHolder1(View view) {
super(view);
image_1 = view.findViewById(R.id.image_1);//序号
name_1 = view.findViewById(R.id.name_1);
}
}
}



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

@@ -3,13 +3,19 @@ package com.bonait.bnframework.modules.home.fragment;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
@@ -17,12 +23,20 @@ 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.StatusMode;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.helper.CountDownTimerExt;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.adapter.devicestatus_adapter;
import com.bonait.bnframework.modules.home.adapter.liaochang_adapter;
import com.bonait.bnframework.modules.home.fragment.from.CpxzActivity;
import com.capton.colorfulprogressbar.ColorfulProgressbar;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
@@ -30,6 +44,9 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.qmuiteam.qmui.widget.textview.QMUILinkTextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@@ -38,14 +55,27 @@ public class MakeGoodFragment extends BaseFragment {
//region 变量
@BindView(R.id.topbar)
QMUITopBarLayout mTopBar;//顶部标题
@BindView(R.id.xzcp)
RelativeLayout xzcp;//选择菜谱

@BindView(R.id.recycler_view_sbzt)
RecyclerView recycler_view_sbzt;

@BindView(R.id.recycler_view_gzzt)
RecyclerView recycler_view_gzzt;


@BindView(R.id.cpfm)
ImageView cpfm;//菜谱封面
@BindView(R.id.caipumingcheng)
QMUILinkTextView caipumingcheng;//菜谱名称
TextView caipumingcheng;//菜谱名称
@BindView(R.id.shengyushijian)
QMUILinkTextView shengyushijian;//剩余时间
TextView shengyushijian;//剩余时间
@BindView(R.id.jingdu)
ColorfulProgressbar jingdu;//进度条
@BindView(R.id.startbutton)
Button startbutton;
@BindView(R.id.xzcp)
Button xzcp;

/**
* 当前制作商品信息
*/
@@ -73,6 +103,7 @@ public class MakeGoodFragment extends BaseFragment {
context = getContext();
initTopBar();
Initdata();
StatusThread();
}

/**
@@ -98,7 +129,40 @@ public class MakeGoodFragment extends BaseFragment {
ToastUtils.info("打开菜谱选择界面");
break;
case R.id.startbutton:
if (ExecuteTheRecipe.IsStart) {
//按钮点击
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();
onRecordStart();
dialog.dismiss();
}
});
}
break;
}
}
@@ -110,6 +174,328 @@ public class MakeGoodFragment extends BaseFragment {
* 初始化数据
*/
public void Initdata() {
//1.初始化状态数据
InitStatusdata();
//2.
SetProcesssUI(0);
startbutton.setText("开始烹饪");
startbutton.setBackgroundResource(R.drawable.bg_btn_login_selected);

//3.接收选择菜谱事件
DataBus.getInstance().mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {

getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// if (!IsMake(true)) {
// return;
// }
good = (BPA_GOODS) data;
SetProcesssUI(0);
}
});
}

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

}
};
}

/**
* 状态线程
*/
public void StatusThread() {
//商品制作线程
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {

if (ExecuteTheRecipe.IsStart && good != null) {
long startTime = System.currentTimeMillis(); //起始时间
ExecuteTheRecipe.showlog("--------------------------------------");
ExecuteTheRecipe.showlog("开始烹饪菜谱【" + good.name + "】");

try {
//获取工艺
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id);
for (BPA_GOODSRECIPE item : goodsrecipes) {
ExecuteTheRecipe.Execute(item);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
long endTime = System.currentTimeMillis(); //结束时间
int time = (int) ((endTime - startTime) / 1000);

ExecuteTheRecipe.showlog("结束烹饪菜谱【" + good.name + "】,关闭搅拌、关闭加热," + String.format("方法使用时间 %d s", time));

if (!ExecuteTheRecipe.IsForcedEnd) {
QueryDB.UpdateGoodsMakeTime(good.id, time);
}

Activity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
onRecordStop();
if (ExecuteTheRecipe.IsForcedEnd)//强制结束
{
ExecuteTheRecipe.showlog("菜谱【" + good.name + "】已强制结束...");
ExecuteTheRecipe.StopForcedEnd();//设置恢复强制结束
}
}
});
}
ExecuteTheRecipe.showlog("--------------------------------------");
}
}
Thread.sleep(1000);
} catch (InterruptedException e) {

}
}
}
}).start();


//刷新UI监控
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
if(ConfigName.getInstance().PlcIsConnect)
{
for(StatusMode mode:sbzt)
{
Object obj= ExecuteTheRecipe.ReadPLC(mode.YName);
if(obj!=null)
{
mode.Status=(boolean)obj;
}
}

for(StatusMode mode:gzzt)
{
Object obj= ExecuteTheRecipe.ReadPLC(mode.YName);
if(obj!=null)
{
mode.Status=(boolean)obj;
}
}

getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ReshData();
}
});
}

Thread.sleep(1000);
} catch (InterruptedException e) {
ToastUtils.info("异常信息:" + e.getMessage());
}
}
}
}).start();
}

//endregion

//region 设备监控状态
/**
* 设备状态
*/
public List<StatusMode> sbzt = new ArrayList<>();
public devicestatus_adapter adapter_sbzt = null;
/**
* 故障状态
*/
public List<StatusMode> gzzt = new ArrayList<>();
public devicestatus_adapter adapter_gzzt = null;

/**
* 初始化数据
*/
public void InitStatusdata() {
sbzt.clear();
sbzt.add(new StatusMode("急停按钮", "监控_急停按钮", false, R.mipmap.status_y, R.mipmap.status_z, 0));
sbzt.add(new StatusMode("搅拌上限", "监控_搅拌上限", false, R.mipmap.status_y, R.mipmap.status_z, 0));
sbzt.add(new StatusMode("搅拌下限", "监控_搅拌下限", false, R.mipmap.status_y, R.mipmap.status_z, 0));
sbzt.add(new StatusMode("锅后限位", "监控_锅后限位", false, R.mipmap.status_y, R.mipmap.status_z, 0));
sbzt.add(new StatusMode("搅拌原点", "监控_搅拌原点", false, R.mipmap.status_y, R.mipmap.status_z, 0));
sbzt.add(new StatusMode("点火正常", "监控_点火正常", false, R.mipmap.status_y, R.mipmap.status_z, 0));


gzzt.clear();
gzzt.add(new StatusMode("急停按下", "急停按下!", false, R.mipmap.status_y, R.mipmap.status_z, 0));
gzzt.add(new StatusMode("油泵故障", "油泵故障!", false, R.mipmap.status_y, R.mipmap.status_z, 0));
gzzt.add(new StatusMode("搅拌故障", "搅拌故障!", false, R.mipmap.status_y, R.mipmap.status_z, 0));
gzzt.add(new StatusMode("点火异常", "点火异常!", false, R.mipmap.status_y, R.mipmap.status_z, 0));
gzzt.add(new StatusMode("高温报警", "高温报警!", false, R.mipmap.status_y, R.mipmap.status_z, 0));
gzzt.add(new StatusMode("备用故障1", "备用故障1", false, R.mipmap.status_y, R.mipmap.status_z, 0));

StaggeredGridLayoutManager layout = new StaggeredGridLayoutManager
(3, StaggeredGridLayoutManager.VERTICAL);
recycler_view_sbzt.setLayoutManager(layout);
adapter_sbzt = new devicestatus_adapter(getContext(), sbzt);
recycler_view_sbzt.setAdapter(adapter_sbzt);


StaggeredGridLayoutManager layout1 = new StaggeredGridLayoutManager
(3, StaggeredGridLayoutManager.VERTICAL);
recycler_view_gzzt.setLayoutManager(layout1);
adapter_gzzt = new devicestatus_adapter(getContext(), gzzt);
recycler_view_gzzt.setAdapter(adapter_gzzt);
}

/**
* 刷新数据
*/
public void ReshData() {
adapter_sbzt.refresh();
adapter_gzzt.refresh();
}
//endregion

//region
private CountDownTimerExt countDownTimer = null;//计时器

/**
* 启动
*/
public void onRecordStart() {
if (good != null) {
startbutton.setText("强制结束");
startbutton.setBackgroundResource(R.drawable.bg_btn_login_red);
xzcp.setVisibility(View.INVISIBLE);

int time = good.maketime;
SetProcesssUI(0);
if (countDownTimer == null) {
countDownTimer = new CountDownTimerExt(time * 1000, 1000) {
@Override
public void onTimerTick(long value) {
int overtime = (int) ((value) / 1000);//剩余时间
SetProcesssUI(time - overtime);
}

@Override
public void onTimerFinish() {
SetProcesssUI(time);
}
};
}
countDownTimer.start();
ExecuteTheRecipe.IsStart = true;
}
}

/**
* 停止
*/
public void onRecordStop() {
if (good != null) {
startbutton.setText("开始烹饪");
startbutton.setBackgroundResource(R.drawable.bg_btn_login_selected);
xzcp.setVisibility(View.VISIBLE);

SetProcesssUI(0);

if (countDownTimer != null) {
countDownTimer.stop();
countDownTimer = null;
}

ExecuteTheRecipe.IsStart = false;
}
}
//endregion

//region 私有

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

Object chushiover = ExecuteTheRecipe.getListingValue("监控_急停按钮");
if (chushiover == null || (boolean) chushiover) {
ToastUtils.warning("设备停止,请先启动设备!!!");
return false;
}

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

return true;
}

/**
* 设置进度条百分比
*
* @param usertime
*/
public void SetProcesssUI(int usertime) {
try {
if (good == null) {
caipumingcheng.setText("暂无");
jingdu.setProgress(0);
jingdu.setSecondProgress(0);
shengyushijian.setText("未知");
new MyBitmapUtils().disPlay(cpfm, "未知");
} else {
caipumingcheng.setText(good.name + "");
jingdu.setProgress((usertime * 100) / good.maketime);
jingdu.setSecondProgress((usertime * 100) / good.maketime);
shengyushijian.setText(formatTime(good.maketime - usertime));
new MyBitmapUtils().disPlay(cpfm, good.url);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}

/**
* 将毫秒转化为 分钟:秒 的格式 100* 1000
*
* @param millisecond 毫秒
* @return
*/
public String formatTime(long millisecond) {
int minute;//分钟
int second;//秒数
minute = (int) ((millisecond / 1) / 60);
second = (int) ((millisecond / 1) % 60);
if (minute < 10) {
if (second < 10) {
return "0" + minute + "分" + "0" + second+"秒";
} else {
return "0" + minute + " : " + second;
}
} else {
if (second < 10) {
return minute + "分" + "0" + second+"秒";
} else {
return minute + "分" + second+"秒";
}
}
}
//endregion
}

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

@@ -188,7 +188,7 @@ public class fragment_plc_control extends LinearLayout {
@Override
public void onCheckedChanged(SwitchButton view, boolean isChecked) {
boolean ischick= control_switch.isChecked();
ExecuteTheRecipe.WritePLC(model.name,ischick,null);
ExecuteTheRecipe.WritePLC(model.name,ischick);
ToastUtils.info("写入地址:"+model.address+"成功!状态:"+(ischick?"打开":"关闭"));
}
});
@@ -199,11 +199,11 @@ public class fragment_plc_control extends LinearLayout {
control_botton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
ExecuteTheRecipe.WritePLC(model.name,true,null);
ExecuteTheRecipe.WritePLC(model.name,true);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.WritePLC(model.name, false, null);
ExecuteTheRecipe.WritePLC(model.name, false);
}
}, 500);

@@ -223,7 +223,7 @@ public class fragment_plc_control extends LinearLayout {
return;
}
int val=Integer.parseInt(text);
ExecuteTheRecipe.WritePLC(model.name,val,null);
ExecuteTheRecipe.WritePLC(model.name,val);

ToastUtils.info("写入地址:"+model.address+"成功!");
break;


+ 27
- 0
app/src/main/res/drawable/bg_btn_login_red.xml View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#7FEF5362"
android:radius="-1dp">

<item android:state_pressed="true">
<shape>
<solid android:color="#D32F2F" />
<corners android:radius="6dp" />
</shape>
</item>

<item android:state_enabled="false">
<shape>
<solid android:color="#D32F2F" />
<corners android:radius="6dp" />
</shape>
</item>


<item>
<shape>
<solid android:color="#D32F2F" />
<corners android:radius="6dp" />
</shape>
</item>
</ripple>

+ 27
- 0
app/src/main/res/drawable/main_bj1.xml View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#7FEF5362"
android:radius="-1dp">

<item android:state_pressed="true">
<shape>
<solid android:color="#3B0088FF" />
<corners android:radius="10dp" />
</shape>
</item>

<item android:state_enabled="false">
<shape>
<solid android:color="#3B0088FF" />
<corners android:radius="10dp" />
</shape>
</item>


<item>
<shape>
<solid android:color="#3B0088FF" />
<corners android:radius="10dp" />
</shape>
</item>
</ripple>

+ 28
- 0
app/src/main/res/layout/datatab/layout/status_item.xml View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:id="@+id/image_1"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@mipmap/status_y"/>
<TextView
android:id="@+id/name_1"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="急停按钮"
android:textAlignment="center"
android:textSize="20dp" />
</LinearLayout>

</RelativeLayout>

+ 296
- 64
app/src/main/res/layout/fragment_make_good.xml View File

@@ -12,10 +12,305 @@
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/main_background">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_weight="1">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/cgtp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginTop="120dp"
android:text="重量:100KG"
android:textColor="@color/app_color_blue"
android:textSize="30dp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="100dp"
android:layout_marginBottom="30dp"
android:text="温度:100°C"
android:textColor="@color/app_color_theme_1"
android:textSize="30dp"
android:textStyle="bold" />
</RelativeLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1.5"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/main_bj1">
<RelativeLayout
android:layout_marginLeft="20dp"
android:layout_width="40dp"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="设备状态"
android:textSize="25dp"
android:textStyle="bold"
android:textColor="@color/file_picker_title"
android:layout_centerVertical="true"/>
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_margin="@dimen/dp_10"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_sbzt"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/main_bj1">
<RelativeLayout
android:layout_marginLeft="20dp"
android:layout_width="40dp"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="故障状态"
android:textColor="@color/red_primary_dark"
android:textSize="25dp"
android:textStyle="bold"
android:layout_centerVertical="true"/>
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_margin="@dimen/dp_10"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_gzzt"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</LinearLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/main_bj1">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<RelativeLayout
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/cpfm"
android:layout_width="160dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:src="@mipmap/loading3" />
</RelativeLayout>
<RelativeLayout
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="配方名称:"
android:textColor="@color/file_picker_title"
android:textSize="25dp" />

<TextView
android:id="@+id/caipumingcheng"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="牛油火锅"
android:textColor="@color/purple_primary_dark"
android:textSize="25dp" />
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="剩余时间:"
android:textColor="@color/file_picker_title"
android:textSize="25dp" />

<TextView
android:id="@+id/shengyushijian"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="3分29秒"
android:textColor="@color/purple_primary_dark"
android:textSize="25dp" />
</LinearLayout>

<com.capton.colorfulprogressbar.ColorfulProgressbar
android:id="@+id/jingdu"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="400dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:duration="3000"
android:indeterminate="true"
android:max="100"
android:visibility="visible"
app:progress="10"
app:style="@string/style_colorful" />
</LinearLayout>
</RelativeLayout>

</LinearLayout>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<LinearLayout
android:layout_marginRight="20dp"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@+id/xzcp"
android:layout_width="120dp"
android:layout_height="45dp"
android:background="@drawable/bg_btn_login_selected"
android:text="选择菜品"
android:textColor="@color/white"
android:textSize="18sp" />
<Button
android:id="@+id/startbutton"
android:layout_width="120dp"
android:layout_height="45dp"
android:layout_marginTop="20dp"
android:background="@drawable/bg_btn_login_red"
android:text="强制结束"
android:textColor="@color/white"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:text="执行步骤:搅拌"
android:textColor="@color/text_color"
android:textSize="30dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal">

<Button
android:layout_width="120dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_btn_login_selected"
android:text="系统控制"
android:textColor="@color/white"
android:textSize="18sp" />

<Button
android:layout_width="120dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_btn_login_selected"
android:text="火力控制"
android:textColor="@color/white"
android:textSize="18sp" />

<Button
android:layout_width="120dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_btn_login_selected"
android:text="搅拌/升降控制"
android:textColor="@color/white"
android:textSize="18sp" />

<Button
android:layout_width="120dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_btn_login_selected"
android:text="进油控制"
android:textColor="@color/white"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone">
<!-- 选择菜谱 -->
<LinearLayout
android:layout_width="match_parent"
@@ -54,69 +349,6 @@
</LinearLayout>
</RelativeLayout>
</LinearLayout>

<!-- 开始启动 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="2dp"
android:background="@color/qmui_config_color_white"
android:padding="5dp">

<RelativeLayout
android:layout_width="60dp"
android:layout_height="match_parent">

<ImageView
android:id="@+id/startbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@mipmap/qdzz" />
</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="菜谱名称"
android:textSize="16dp" />

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:id="@+id/caipumingcheng"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginTop="-3dp"
android:text=""
android:textColor="@color/app_color_blue"
android:textSize="18dp" />

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:id="@+id/shengyushijian"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="预计剩余时间:300s" />

<com.capton.colorfulprogressbar.ColorfulProgressbar xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/jingdu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:duration="3000"
android:indeterminate="true"
android:max="100"
android:visibility="visible"
app:progress="10"
app:style="@string/style_colorful" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>

</RelativeLayout>


BIN
View File


+ 1
- 1
app/src/main/res/values/strings.xml View File

@@ -1,5 +1,5 @@
<resources>
<string name="app_name">菠萝小炒</string>
<string name="app_name">燃气小炒</string>
<string name="file_normal">常用文件</string>
<string name="file_all">全部文件</string>
<string name="empty_data">没有数据</string>


Loading…
Cancel
Save