Browse Source

更新主页面

燃气自翻炒锅
fyf 11 months ago
parent
commit
fcf3070c1d
5 changed files with 618 additions and 319 deletions
  1. +1
    -18
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  2. +32
    -14
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  3. +0
    -40
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  4. +522
    -214
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java
  5. +63
    -33
      app/src/main/res/layout/fragment_make_good.xml

+ 1
- 18
app/src/main/java/com/bonait/bnframework/business/ConfigData.java View File

@@ -248,15 +248,7 @@ public class ConfigData {
ConfigName.getInstance().HuoLi = ConfigUtil.read(ConfigName.getInstance().dishesCon, "HuoLi", ConfigName.getInstance().HuoLi);
ConfigName.getInstance().MaxTemp = ConfigUtil.read(ConfigName.getInstance().dishesCon, "MaxTemp", ConfigName.getInstance().MaxTemp);

ConfigName.getInstance().gkcxCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "gkcxCount", ConfigName.getInstance().gkcxCount);
ConfigName.getInstance().jiaobanCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "jiaobanCount", ConfigName.getInstance().jiaobanCount);
ConfigName.getInstance().qingxiCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "qingxiCount", ConfigName.getInstance().qingxiCount);
ConfigName.getInstance().touliaoCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "touliaoCount", ConfigName.getInstance().touliaoCount);
ConfigName.getInstance().yetiliaoCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "yetiliaoCount", ConfigName.getInstance().yetiliaoCount);
ConfigName.getInstance().yanchiCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "yanchiCount", ConfigName.getInstance().yanchiCount);
ConfigName.getInstance().jiareCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "jiareCount", ConfigName.getInstance().jiareCount);
ConfigName.getInstance().jiarewendingCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "jiarewendingCount", ConfigName.getInstance().jiarewendingCount);
ConfigName.getInstance().RunCount = ConfigUtil.read(ConfigName.getInstance().dishesCon, "RunCount", ConfigName.getInstance().RunCount);


}

@@ -275,15 +267,6 @@ public class ConfigData {
ConfigUtil.write(ConfigName.getInstance().dishesCon, "HuoLi", ConfigName.getInstance().HuoLi);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "MaxTemp", ConfigName.getInstance().MaxTemp);

ConfigUtil.write(ConfigName.getInstance().dishesCon, "gkcxCount", ConfigName.getInstance().gkcxCount);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "jiaobanCount", ConfigName.getInstance().jiaobanCount);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "qingxiCount", ConfigName.getInstance().qingxiCount);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "touliaoCount", ConfigName.getInstance().touliaoCount);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "yetiliaoCount", ConfigName.getInstance().yetiliaoCount);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "yanchiCount", ConfigName.getInstance().yanchiCount);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "jiareCount", ConfigName.getInstance().jiareCount);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "jiarewendingCount", ConfigName.getInstance().jiarewendingCount);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "RunCount", ConfigName.getInstance().RunCount);

}



+ 32
- 14
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -56,9 +56,13 @@ public class ExecuteTheRecipe {
*/
public static boolean IsStart = false;
/**
* 是否暂停
* 通知手动暂停
*/
public static boolean IsPause = false;
public static IRunT NoticeHandSuspension = null;
/**
* 手动操作耗时时长
*/
public static int HandTime = 0;
//endregion

//region 强制结束
@@ -240,11 +244,11 @@ public class ExecuteTheRecipe {
int otherG = silos.silosmargin - (val / 10);
QueryDB.UpdateYL(silos.id, otherG >= 0 ? otherG : 0);

WritePLC(name, true); //开始出料
//开始出料
WritePLC(name, true);

//等待出料完成,false信号
ThreadWhileFlase(name);
ThreadWhileMaterialOver(name);
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
@@ -260,6 +264,11 @@ public class ExecuteTheRecipe {
*/
private static void Write_PLC_Ingredients(HashMap<String, String> data) {
try {
long startTime = System.currentTimeMillis(); //起始时间
if (NoticeHandSuspension != null) {
NoticeHandSuspension.Run(true);
}

String name = "";
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
@@ -280,7 +289,7 @@ public class ExecuteTheRecipe {
@Override
public void run() {
try {
new QMUIDialog.MessageDialogBuilder(context).setCancelable(false).setTitle(title).setMessage(message).addAction("确定", new QMUIDialogAction.ActionListener() {
new QMUIDialog.MessageDialogBuilder(context).setCancelable(false).setCanceledOnTouchOutside(false).setTitle(title).setMessage(message).addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
IsComplete[0] = true;
@@ -298,6 +307,13 @@ public class ExecuteTheRecipe {
Thread.sleep(100);//10 *6
}

long endTime = System.currentTimeMillis(); //结束时间
int time = (int) ((endTime - startTime) / 1000);
HandTime = HandTime + time;
if (NoticeHandSuspension != null) {
NoticeHandSuspension.Run(false);
}

ExecuteTheRecipe.showlog("手动已确认投入主料:" + name + "-继续流程");
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
@@ -488,6 +504,7 @@ public class ExecuteTheRecipe {
//endregion

//region 界面事件

/**
* 阻断按钮
*
@@ -497,7 +514,7 @@ public class ExecuteTheRecipe {
try {
Log.e("按钮按下", name);
WritePLC(name, true);
Thread.sleep(200);
Thread.sleep(100);
WritePLC(name, false);
Log.e("按钮复位", name);
ExecuteTheRecipe.showlog("写入plc-------" + name);
@@ -509,6 +526,7 @@ public class ExecuteTheRecipe {

/**
* 发现主窗体
*
* @param context
* @return
*/
@@ -524,6 +542,7 @@ public class ExecuteTheRecipe {
//endregion

//region 延迟函数

/**
* 线程延迟函数(避免线程阻塞等待)
*
@@ -533,8 +552,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);
} catch (InterruptedException ex) {
@@ -564,8 +582,7 @@ public class ExecuteTheRecipe {
Object sb = ReadPLC(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
if(IsComplete[0])
{
if (IsComplete[0]) {
ExecuteTheRecipe.showlog(name + ",接收到信号!");
}
}
@@ -585,7 +602,7 @@ public class ExecuteTheRecipe {
*
* @param name
*/
public static void ThreadWhileFlase(String name) {
public static void ThreadWhileMaterialOver(String name) {
//"炒菜位1反馈";
final boolean[] IsComplete = {true};
long a = System.currentTimeMillis();
@@ -598,8 +615,7 @@ public class ExecuteTheRecipe {
Object sb = ReadPLC(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
if(IsComplete[0]==false)
{
if (IsComplete[0] == false) {
ExecuteTheRecipe.showlog(name + ",接收到信号!");
}
}
@@ -800,6 +816,7 @@ public class ExecuteTheRecipe {
* 显示日志
*/
public static void showlog(String msg) {
msg=ConfigName.getInstance().user.name+"_"+msg;
Log.e("hbl", msg);
ToastUtils.info(msg);
}
@@ -819,6 +836,7 @@ public class ExecuteTheRecipe {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
SiemensHelper1.get().writePLC(plcaddress.address, value);
showlog(name+"_写入值_"+value);
}
}
} catch (Exception ex) {


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

@@ -447,44 +447,4 @@ public class ConfigName {
add("超级管理员");
}};
//endregion

//region 计数累计
/**
* 锅口朝向次数
*/
public int gkcxCount=0;
/**
* 搅拌分钟数
*/
public int jiaobanCount = 0;//搅拌分钟数
/**
* 清洗次数
*/
public int qingxiCount = 0;
/**
* 投料次数
*/
public int touliaoCount = 0;
/**
* 液体料次数
*/
public int yetiliaoCount = 0;

/**
* 延迟加热次数
*/
public int yanchiCount = 0;
/**
* 加热次数
*/
public int jiareCount = 0;
/**
* 加热稳定性次数
*/
public int jiarewendingCount = 0;
/**
* 炒菜运行
*/
public int RunCount = 0;
//endregion
}

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

@@ -11,10 +11,15 @@ import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;

import com.bonait.bnframework.R;
@@ -26,9 +31,12 @@ 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.mode.BPA_MATERIAL;
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.IRunT;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageLooper;
@@ -43,6 +51,7 @@ import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.qmuiteam.qmui.widget.textview.QMUILinkTextView;
import com.suke.widget.SwitchButton;

import java.util.ArrayList;
import java.util.List;
@@ -88,6 +97,8 @@ public class MakeGoodFragment extends BaseFragment {
@BindView(R.id.dialog_jykz)
RelativeLayout dialog_jykz;

@BindView(R.id.gongxumiaoshu)
TextView gongxumiaoshu;//工序描述

/**
* 当前制作商品信息
@@ -116,7 +127,8 @@ public class MakeGoodFragment extends BaseFragment {
context = getContext();
initTopBar();
Initdata();
StatusThread();
StatusOrMakeGoodThread();
Init_弹窗();
}

/**
@@ -125,9 +137,21 @@ public class MakeGoodFragment extends BaseFragment {
private void initTopBar() {
mTopBar.setTitle("菠萝燃气炒菜系统" + ConfigName.getInstance().Version);
}

/**
* 设置下拉框
*
* @param spinner
* @param map
*/
private void SetAdapter(Spinner spinner, List<String> map) {
ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, map);
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
spinner.setAdapter(adapter);
}
//endregion

//region 私有函数
//region 点击事件处理

/**
* 点击事件
@@ -138,9 +162,19 @@ public class MakeGoodFragment extends BaseFragment {
, R.id.btn_xtkz, R.id.btn_hlkz
, R.id.btn_sjkz, R.id.btn_jykz
, R.id.close_xtkz, R.id.close_hlkz
, R.id.close_kbkz, R.id.close_jykz})
, R.id.close_kbkz, R.id.close_jykz


, R.id.button_搅拌点动
, R.id.button_搅拌上升, R.id.button_搅拌下降
, R.id.button_锅前倾, R.id.button_锅后仰

, R.id.button_出料
, R.id.button_点火复位
})
public void onViewClicked(View view) {
switch (view.getId()) {
//region 界面的操作
case R.id.xzcp://选择菜谱按钮点击
skipToActivity(CpxzActivity.class);
ToastUtils.info("打开菜谱选择界面");
@@ -199,254 +233,188 @@ public class MakeGoodFragment extends BaseFragment {
});
}
break;
}
}
//endregion
//endregion

//region 公共函数
//region PLC操作

/**
* 初始化数据
*/
public void Initdata() {
//1.初始化状态数据
InitStatusdata();
//2.
SetProcesssUI(0);
startbutton.setText("开始烹饪");
startbutton.setBackgroundResource(R.drawable.bg_btn_login_selected);
SetVisibility(0);
//3.接收选择菜谱事件
DataBus.getInstance().mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
case R.id.button_搅拌上升:
ExecuteTheRecipe.BottomClick("搅拌上升");
break;
case R.id.button_搅拌下降:
ExecuteTheRecipe.BottomClick("搅拌下降");
break;
case R.id.button_锅前倾:
ExecuteTheRecipe.BottomClick("锅口向前");
break;
case R.id.button_锅后仰:
ExecuteTheRecipe.BottomClick("锅口向后");
break;

getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// if (!IsMake(true)) {
// return;
// }
good = (BPA_GOODS) data;
SetProcesssUI(0);
}
});
}
case R.id.button_出料:
String s1 = edit_设定重量.getText().toString();
String s2 = edit_提前量.getText().toString();
if (s1.isEmpty()) {
ToastUtils.warning("设定重量不能为空!");
return;
}
if (s2.isEmpty()) {
ToastUtils.warning("提前量不能为空!");
return;
}
int s1_1 = 0;
int s2_1 = 0;
try {
s1_1 = Integer.parseInt(s1);
s2_1 = Integer.parseInt(s2);
} catch (Exception ex) {
ToastUtils.warning("数据解析异常!" + ex.getMessage());
return;
}
ExecuteTheRecipe.WritePLC("设定重量", s1_1);
ExecuteTheRecipe.WritePLC("设定提前量", s2_1);
ExecuteTheRecipe.WritePLC("设定提前量", s2_1);
ExecuteTheRecipe.WritePLC("料仓1出料", true);
break;

@Override
public void clickListenerNew(View v, int k, Object data) {
case R.id.button_点火复位:
ExecuteTheRecipe.BottomClick("点火复位开关");
break;

}
};
//endregion
}
}

/**
* 状态线程
* 开关事件处理
*/
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);
}
public SwitchButton.OnCheckedChangeListener checkedChangeListener = new SwitchButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(SwitchButton view, boolean isChecked) {
switch (view.getId()) {
case R.id.switch_系统启停:
ExecuteTheRecipe.WritePLC("系统启停开关", isChecked);
break;
case R.id.switch_超温停气:
ExecuteTheRecipe.WritePLC("超温停气开关", isChecked);
break;
case R.id.switch_搅拌控制:
if (isChecked) {
ExecuteTheRecipe.BottomClick("搅拌启动开关");
} else {
ExecuteTheRecipe.BottomClick("搅拌停止开关");
}
break;
case R.id.switch_抽油启停:
ExecuteTheRecipe.WritePLC("料仓1出料", isChecked);
break;
case R.id.switch_备用气缸:
ExecuteTheRecipe.WritePLC("料仓2出料", isChecked);
break;
case R.id.switch_点火控制:
ExecuteTheRecipe.WritePLC("点火启动开关", isChecked);
break;

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) {
}
}
};

public View.OnTouchListener touchListener=new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
boolean IsChick=false;
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下: ");
IsChick=true;
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
IsChick=false;
}

}
}
switch (view.getId()) {
case R.id.button_搅拌点动:
ExecuteTheRecipe.WritePLC("搅拌点动开关",IsChick);
break;
}
}).start();
return false;
}
};
//endregion

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

//刷新UI监控
new Thread(new Runnable() {
/**
* 启动
*/
public void onRecordStart() {
getActivity().runOnUiThread(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;
}
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);
}

for (StatusMode mode : gzzt) {
Object obj = ExecuteTheRecipe.ReadPLC(mode.YName);
if (obj != null) {
mode.Status = (boolean) obj;
}
@Override
public void onTimerFinish() {
SetProcesssUI(time);
}

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

Thread.sleep(1000);
} catch (InterruptedException e) {
ToastUtils.info("异常信息:" + e.getMessage());
};
}
countDownTimer.start();
ExecuteTheRecipe.IsStart = true;
}
}
}).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);
public void onRecordStop() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (good != null) {
startbutton.setText("开始烹饪");
startbutton.setBackgroundResource(R.drawable.bg_btn_login_selected);
xzcp.setVisibility(View.VISIBLE);

SetProcesssUI(0);

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);
}
if (countDownTimer != null) {
countDownTimer.stop();
countDownTimer = null;
}
ExecuteTheRecipe.IsStart = false;
}
}
});

/**
* 刷新数据
*/
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 onRecordPause() {
countDownTimer.pause();
}

/**
* 停止
* 继续
*/
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;
}
public void onRecordPauseStart() {
countDownTimer.resume();
}
//endregion

@@ -565,5 +533,345 @@ public class MakeGoodFragment extends BaseFragment {

}
}

/**
* 设置工序描述
*
* @param text
*/
public void SetProcessDescription(String text) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
gongxumiaoshu.setText(text + "");
}
});
}
//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 公共函数

/**
* 初始化数据
*/
public void Initdata() {
//1.初始化状态数据
InitStatusdata();
//2.
SetProcesssUI(0);
startbutton.setText("开始烹饪");
startbutton.setBackgroundResource(R.drawable.bg_btn_login_selected);
SetVisibility(0);
SetProcessDescription("等待开始...");
//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;
// }
SetProcessDescription("等待开始...");
good = (BPA_GOODS) data;
SetProcesssUI(0);
}
});
}

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

}
};
}
//endregion

//region 状态显示或商品制作线程

/**
* 线程
*/
public void StatusOrMakeGoodThread() {
ExecuteTheRecipe.context = getContext();
//商品制作线程
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 + "】");
ExecuteTheRecipe.HandTime = 0;//默认将手动操作时间复位
try {
//获取工艺
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id);
for (BPA_GOODSRECIPE item : goodsrecipes) {
SetProcessDescription("正在执行:" + item.processms);
ExecuteTheRecipe.Execute(item);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
int time = (int) ((System.currentTimeMillis() - startTime) / 1000);//使用总时间
ExecuteTheRecipe.showlog("结束烹饪菜谱【" + good.name + "】," + String.format("方法使用时间 %d s", time));
if (!ExecuteTheRecipe.IsForcedEnd) //不是强制结束,从写炒制时间
{
int ztime = time - ExecuteTheRecipe.HandTime;
good.maketime = ztime > 0 ? ztime : time;
QueryDB.UpdateGoodsMakeTime(good.id, good.maketime);
} else {
ExecuteTheRecipe.showlog("菜谱【" + good.name + "】已强制结束...");
}

onRecordStop();
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;
}
}

//读取锅体重量
Object zl = ExecuteTheRecipe.ReadPLC("炒锅当前重量");
if (zl != null) {
PanWeight.setText(zl + "");
}

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

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

//接收暂停计时器
ExecuteTheRecipe.NoticeHandSuspension = new IRunT() {
@Override
public void Run(Object o) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if ((boolean) o) {
onRecordPause();
} else {
onRecordPauseStart();
}
}
});
}
};
}
//endregion

//region 弹窗处理
@BindView(R.id.switch_系统启停)
SwitchButton switch_系统启停;

@BindView(R.id.switch_超温停气)
SwitchButton switch_超温停气;

@BindView(R.id.switch_搅拌控制)
SwitchButton switch_搅拌控制;

@BindView(R.id.switch_抽油启停)
SwitchButton switch_抽油启停;

@BindView(R.id.switch_备用气缸)
SwitchButton switch_备用气缸;

@BindView(R.id.editsp_物料)
Spinner editsp_物料;

@BindView(R.id.editsp_点火模式)
Spinner editsp_点火模式;

@BindView(R.id.switch_点火控制)
SwitchButton switch_点火控制;


@BindView(R.id.button_搅拌点动)
EditText button_搅拌点动;//button_搅拌点动

@BindView(R.id.image_搅拌上升)
ImageView image_搅拌上升;

@BindView(R.id.button_搅拌下降)
ImageView button_搅拌下降;

@BindView(R.id.image_锅前倾)
ImageView image_锅前倾;

@BindView(R.id.image_锅后仰)
ImageView image_锅后仰;
/**
* 初始化弹窗
*/
public void Init_弹窗() {
Init_弹窗_事件();
Init_弹窗_物料();
}

/**
* 初始化弹框中的事件
*/
public void Init_弹窗_事件() {
switch_系统启停.setOnCheckedChangeListener(checkedChangeListener);
switch_超温停气.setOnCheckedChangeListener(checkedChangeListener);
switch_搅拌控制.setOnCheckedChangeListener(checkedChangeListener);

switch_抽油启停.setOnCheckedChangeListener(checkedChangeListener);
switch_备用气缸.setOnCheckedChangeListener(checkedChangeListener);

switch_点火控制.setOnCheckedChangeListener(checkedChangeListener);
editsp_点火模式.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String name =editsp_点火模式.getSelectedItem().toString();
if(name.equals("手动"))
{
ExecuteTheRecipe.WritePLC("点火手自动切换开关",true);
}else
{
ExecuteTheRecipe.WritePLC("点火手自动切换开关",false);
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
});


button_搅拌点动.setOnTouchListener(touchListener);
}


@BindView(R.id.PanWeight)
TextView PanWeight;//锅体的重量

@BindView(R.id.edit_设定重量)
EditText edit_设定重量;//设定重量

@BindView(R.id.edit_提前量)
EditText edit_提前量;//提前量
public ArrayList<BPA_MATERIAL> materials = new ArrayList<>();
public List<String> names = new ArrayList<>();

/**
* 初始化物料
*/
public void Init_弹窗_物料() {
materials.clear();
names.clear();
List<BPA_MATERIAL> bpa_materials = QueryDB.GetMaterialALL();
for (BPA_MATERIAL item : bpa_materials) {
materials.add(item);
names.add(item.name);
}
SetAdapter(editsp_物料, names);

List<String> ms = new ArrayList<>();
ms.add("手动");
ms.add("自动");
SetAdapter(editsp_点火模式, ms);
}
//endregion
}

+ 63
- 33
app/src/main/res/layout/fragment_make_good.xml View File

@@ -251,15 +251,18 @@
</RelativeLayout>
</RelativeLayout>

<TextView
<LinearLayout
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" />
android:layout_height="wrap_content">
<TextView
android:id="@+id/gongxumiaoshu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="步骤1 加油50g"
android:textColor="#797373"
android:textSize="14dp" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
@@ -269,8 +272,8 @@

<Button
android:id="@+id/btn_xtkz"
android:layout_width="120dp"
android:layout_height="45dp"
android:layout_width="160dp"
android:layout_height="55dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_btn_login_selected"
android:text="系统控制"
@@ -280,8 +283,8 @@
<Button
android:id="@+id/btn_hlkz"

android:layout_width="120dp"
android:layout_height="45dp"
android:layout_width="160dp"
android:layout_height="55dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_btn_login_selected"
android:text="火力控制"
@@ -290,9 +293,8 @@

<Button
android:id="@+id/btn_sjkz"

android:layout_width="120dp"
android:layout_height="45dp"
android:layout_width="160dp"
android:layout_height="55dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_btn_login_selected"
android:text="搅拌/升降控制"
@@ -301,8 +303,8 @@

<Button
android:id="@+id/btn_jykz"
android:layout_width="120dp"
android:layout_height="45dp"
android:layout_width="160dp"
android:layout_height="55dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_btn_login_selected"
android:text="进油控制"
@@ -322,6 +324,8 @@
android:layout_height="match_parent"
android:background="#BD25323F"
android:visibility="gone"
android:focusable="true"
android:clickable="true"
>
<RelativeLayout
android:layout_centerInParent="true"
@@ -361,6 +365,7 @@
</RelativeLayout>

<com.suke.widget.SwitchButton
android:id="@+id/switch_系统启停"
android:layout_marginLeft="20dp"
app:sb_uncheck_color="@color/app_color_blue"
app:sb_uncheckcircle_color="@color/app_color_blue"
@@ -387,6 +392,7 @@
</RelativeLayout>

<com.suke.widget.SwitchButton
android:id="@+id/switch_超温停气"
android:layout_marginLeft="20dp"
app:sb_uncheck_color="@color/app_color_blue"
app:sb_uncheckcircle_color="@color/app_color_blue"
@@ -405,6 +411,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#BD25323F"
android:focusable="true"
android:clickable="true"
android:visibility="gone"
>
<RelativeLayout
android:layout_centerInParent="true"
@@ -451,6 +460,7 @@
</RelativeLayout>

<Spinner
android:id="@+id/editsp_点火模式"
style="@style/commonSpinnerStyle"
android:layout_width="80dp"
android:layout_height="24dp"
@@ -462,16 +472,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/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_height="35dp"
android:layout_marginRight="15dp"
android:background="@drawable/bg_btn_login_selected"
android:text="点火复位"
@@ -745,6 +748,7 @@
</RelativeLayout>

<EditText
android:id="@+id/edit_温度修正"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
@@ -769,6 +773,7 @@
</RelativeLayout>

<EditText
android:id="@+id/edit_温度上限"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
@@ -802,6 +807,7 @@
</RelativeLayout>

<com.suke.widget.SwitchButton
android:id="@+id/switch_点火控制"
android:layout_marginLeft="20dp"
app:sb_uncheck_color="@color/app_color_blue"
app:sb_uncheckcircle_color="@color/app_color_blue"
@@ -816,7 +822,8 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="点火失败"
android:textSize="19dp"/>
android:textSize="19dp"
android:textColor="@color/purple_primary"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
@@ -832,7 +839,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#BD25323F"
android:visibility="gone">
android:focusable="true"
android:visibility="gone"
android:clickable="true">
<RelativeLayout
android:layout_centerInParent="true"
android:layout_width="600dp"
@@ -840,7 +849,6 @@
android:background="@drawable/silosbj">
<ImageView
android:id="@+id/close_kbkz"

android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
@@ -880,6 +888,7 @@
</RelativeLayout>

<com.suke.widget.SwitchButton
android:id="@+id/switch_搅拌控制"
android:layout_marginLeft="20dp"
app:sb_uncheck_color="@color/app_color_blue"
app:sb_uncheckcircle_color="@color/app_color_blue"
@@ -894,6 +903,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button_搅拌点动"
android:layout_width="180dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
@@ -915,6 +925,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button_搅拌上升"
android:layout_width="140dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
@@ -925,6 +936,7 @@
</RelativeLayout>

<ImageView
android:id="@+id/image_搅拌上升"
android:layout_width="30dp"
android:layout_height="match_parent"
android:src="@mipmap/status_y"/>
@@ -938,6 +950,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button_锅前倾"
android:layout_width="140dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
@@ -948,6 +961,8 @@
</RelativeLayout>

<ImageView
android:id="@+id/image_锅前倾"

android:layout_width="30dp"
android:layout_height="match_parent"
android:src="@mipmap/status_y"/>
@@ -965,6 +980,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button_搅拌下降"
android:layout_width="140dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
@@ -975,6 +991,8 @@
</RelativeLayout>

<ImageView
android:id="@+id/image_搅拌下降"

android:layout_width="30dp"
android:layout_height="match_parent"
android:src="@mipmap/status_y"/>
@@ -988,6 +1006,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button_锅后仰"
android:layout_width="140dp"
android:layout_height="45dp"
android:layout_marginRight="15dp"
@@ -998,6 +1017,7 @@
</RelativeLayout>

<ImageView
android:id="@+id/image_锅后仰"
android:layout_width="30dp"
android:layout_height="match_parent"
android:src="@mipmap/status_y"/>
@@ -1014,6 +1034,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#BD25323F"
android:focusable="true"
android:clickable="true"
android:visibility="gone">
<RelativeLayout
android:layout_centerInParent="true"
@@ -1060,6 +1082,7 @@
</RelativeLayout>

<TextView
android:id="@+id/PanWeight"
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -1086,6 +1109,7 @@
</RelativeLayout>

<Spinner
android:id="@+id/editsp_物料"
style="@style/commonSpinnerStyle"
android:layout_width="80dp"
android:layout_height="24dp"
@@ -1113,15 +1137,16 @@
</RelativeLayout>

<EditText
android:id="@+id/edit_设定重量"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入温度"
android:hint="请输入"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:textSize="14dp"
android:text="0"/>

<RelativeLayout
@@ -1137,18 +1162,20 @@
</RelativeLayout>

<EditText
android:id="@+id/edit_提前量"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入温度"
android:hint="请输入"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:textSize="14dp"
android:text="0"/>

<Button
android:id="@+id/button_出料"
android:layout_width="100dp"
android:layout_height="45dp"
android:layout_marginLeft="15dp"
@@ -1181,6 +1208,7 @@
</RelativeLayout>

<com.suke.widget.SwitchButton
android:id="@+id/switch_抽油启停"
android:layout_marginLeft="20dp"
app:sb_uncheck_color="@color/app_color_blue"
app:sb_uncheckcircle_color="@color/app_color_blue"
@@ -1207,6 +1235,8 @@
</RelativeLayout>

<com.suke.widget.SwitchButton
android:id="@+id/switch_备用气缸"

android:layout_marginLeft="20dp"
app:sb_uncheck_color="@color/app_color_blue"
app:sb_uncheckcircle_color="@color/app_color_blue"


Loading…
Cancel
Save