Browse Source

温度设置界面

茶饮新(现场)
fyf 1 year ago
parent
commit
ef24999b03
9 changed files with 507 additions and 9 deletions
  1. +6
    -1
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  2. +42
    -3
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  3. +51
    -0
      app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java
  4. +17
    -0
      app/src/main/java/com/bonait/bnframework/common/db/res/wdszMode.java
  5. +2
    -0
      app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java
  6. +196
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/wdsz_adapter.java
  7. +13
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_wdsz_fragment.java
  8. +11
    -4
      app/src/main/res/layout/fragment_jiaoyan_wdsz.xml
  9. +169
    -0
      app/src/main/res/layout/item/layout/wdsz_item.xml

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

@@ -244,7 +244,9 @@ public class ConfigData {
ConfigName.getInstance().IsUserDownOrder = ConfigUtil.read(ConfigName.getInstance().dishesCon, "IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder);
ConfigName.getInstance().Version = ConfigUtil.read(ConfigName.getInstance().dishesCon, "Version", ConfigName.getInstance().Version);
ConfigName.getInstance().HuoLi = ConfigUtil.read(ConfigName.getInstance().dishesCon, "HuoLi", ConfigName.getInstance().HuoLi);

ConfigName.getInstance().AutomaticHeating = ConfigUtil.read(ConfigName.getInstance().dishesCon, "AutomaticHeating", ConfigName.getInstance().AutomaticHeating);
ConfigName.getInstance().GT1_AutomaticHeating = ConfigUtil.read(ConfigName.getInstance().dishesCon, "GT1_AutomaticHeating", ConfigName.getInstance().GT1_AutomaticHeating);
ConfigName.getInstance().GT2_AutomaticHeating = ConfigUtil.read(ConfigName.getInstance().dishesCon, "GT2_AutomaticHeating", ConfigName.getInstance().GT2_AutomaticHeating);
}

/**
@@ -260,6 +262,9 @@ public class ConfigData {
ConfigUtil.write(ConfigName.getInstance().dishesCon, "IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "Version", ConfigName.getInstance().Version);
ConfigUtil.write(ConfigName.getInstance().dishesCon, "HuoLi", ConfigName.getInstance().HuoLi);
ConfigUtil.write(ConfigName.getInstance().dishesCon,"AutomaticHeating", ConfigName.getInstance().AutomaticHeating);
ConfigUtil.write(ConfigName.getInstance().dishesCon,"GT1_AutomaticHeating", ConfigName.getInstance().GT1_AutomaticHeating);
ConfigUtil.write(ConfigName.getInstance().dishesCon,"GT2_AutomaticHeating", ConfigName.getInstance().GT2_AutomaticHeating);
}

/**


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

@@ -387,7 +387,19 @@ public class ConfigName {
//温度监控
add(new Res_PLCADDRESS("温度控制", "-------------", 0, 0));
add(new Res_PLCADDRESS("水池温度", "VD352", 1, 0));
add(new Res_PLCADDRESS("水池温度设置", "VD360", 1, 1));
add(new Res_PLCADDRESS("水池温度上限", "VD360", 1, 1));
add(new Res_PLCADDRESS("水池温度下限", "VD368", 1, 1));
add(new Res_PLCADDRESS("水池温度加热", "M104.0", 1, 0));

add(new Res_PLCADDRESS("果糖左温度", "VD352", 1, 0));
add(new Res_PLCADDRESS("果糖左温度上限", "VD388", 1, 1));
add(new Res_PLCADDRESS("果糖左温度下限", "VD392", 1, 1));
add(new Res_PLCADDRESS("果糖左温度加热", "M104.0", 1, 0));

add(new Res_PLCADDRESS("果糖右温度", "VD352", 1, 0));
add(new Res_PLCADDRESS("果糖右温度上限", "VD396", 1, 1));
add(new Res_PLCADDRESS("果糖右温度下限", "VD400", 1, 1));
add(new Res_PLCADDRESS("果糖右温度加热", "M104.0", 1, 0));

//手动控制
add(new Res_PLCADDRESS("手动控制", "-------------", 0, 0));
@@ -604,7 +616,20 @@ public class ConfigName {
//温度监控
add(new Res_PLCADDRESS("温度控制", "-------------", 0, 0));
add(new Res_PLCADDRESS("水池温度", "VD352", 1, 0));
add(new Res_PLCADDRESS("水池温度设置", "VD360", 1, 1));
add(new Res_PLCADDRESS("水池温度上限", "VD360", 1, 1));
add(new Res_PLCADDRESS("水池温度下限", "VD368", 1, 1));
add(new Res_PLCADDRESS("水池温度加热", "VD352", 1, 0));

add(new Res_PLCADDRESS("果糖左温度", "VD352", 1, 0));
add(new Res_PLCADDRESS("果糖左温度上限", "VD388", 1, 1));
add(new Res_PLCADDRESS("果糖左温度下限", "VD392", 1, 1));
add(new Res_PLCADDRESS("果糖左温度加热", "VD352", 1, 0));

add(new Res_PLCADDRESS("果糖右温度", "VD352", 1, 0));
add(new Res_PLCADDRESS("果糖右温度上限", "VD396", 1, 1));
add(new Res_PLCADDRESS("果糖右温度下限", "VD400", 1, 1));
add(new Res_PLCADDRESS("果糖右温度加热", "VD352", 1, 0));


//手动控制
add(new Res_PLCADDRESS("手动控制", "-------------", 0, 0));
@@ -866,7 +891,6 @@ public class ConfigName {
public String versionSelectionEnum = "奶茶机";
//endregion


//region 主页
/**
* 主页流
@@ -889,4 +913,19 @@ public class ConfigName {
}
};
//endregion

//region 是否自动加热
/**
* 是否自动加热(水池)
*/
public Boolean AutomaticHeating=false;
/**
* 果糖1
*/
public Boolean GT1_AutomaticHeating=false;
/**
* 果糖2
*/
public Boolean GT2_AutomaticHeating=false;
//endregion
}

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

@@ -17,12 +17,14 @@ import com.bonait.bnframework.common.db.res.ResGoodsRecipe;
import com.bonait.bnframework.common.db.res.SilosLsjyMode;
import com.bonait.bnframework.common.db.res.StatusMode;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.db.res.wdszMode;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.helper.mode.OrderA;
import com.bonait.bnframework.common.helper.mode.ResultA;
import com.bonait.bnframework.modules.home.adapter.lc_adapter;
import com.bonait.bnframework.modules.home.adapter.lsjy_adapter;
import com.bonait.bnframework.modules.home.adapter.sp_adapter;
import com.bonait.bnframework.modules.home.adapter.wdsz_adapter;

import java.util.ArrayList;
import java.util.HashMap;
@@ -325,4 +327,53 @@ public class DataBus {
}
}
//endregion

//region 温度设置
public ArrayList<wdszMode> wdszModes = new ArrayList<wdszMode>();
public wdsz_adapter wdszAdapter=null;
public void GetWdsz()
{
try {
wdszModes=new ArrayList<>();

List<String> names=new ArrayList<>();
if (ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) {
names.add("水池温度");
}else
{
names.add("水池温度");
names.add("果糖左温度");
names.add("果糖右温度");
}
for (String item:names)
{
wdszMode mode=new wdszMode();
mode.name=item;
mode.temp=0;
Object sx=ExecuteTheRecipe.getListingValue(item+"上限");
mode.tempup=sx==null?0:(int)sx;
Object xx=ExecuteTheRecipe.getListingValue(item+"下限");
mode.tempdown=xx==null?0:(int)xx;

if(item.equals("水池温度"))
{
mode.autoheat=ConfigName.getInstance().AutomaticHeating;
} else if (item.equals("果糖左温度")) {
mode.autoheat=ConfigName.getInstance().GT1_AutomaticHeating;
}else if (item.equals("果糖右温度")) {
mode.autoheat=ConfigName.getInstance().GT2_AutomaticHeating;
}
wdszModes.add(mode);
}


if (wdszAdapter!=null)
{
wdszAdapter.refresh();
}
} catch (Exception e) {
e.printStackTrace();
}
}
//endregion
}

+ 17
- 0
app/src/main/java/com/bonait/bnframework/common/db/res/wdszMode.java View File

@@ -0,0 +1,17 @@
package com.bonait.bnframework.common.db.res;

/**
* 温度设置
*/
public class wdszMode {
//名称
public String name;
//上限
public int tempup;
//下限
public int tempdown;
//当前温度
public int temp;
//自动加热
public boolean autoheat;
}

+ 2
- 0
app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java View File

@@ -358,6 +358,8 @@ public class MainNavigateTabBar extends LinearLayout implements View.OnClickList
{
//刷新料仓
DataBus.getInstance().GetSilosLsjy();
//刷新温度控制
DataBus.getInstance().GetWdsz();
}
}



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

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

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

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

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.business.MainInit;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.db.res.SilosLsjyMode;
import com.bonait.bnframework.common.db.res.wdszMode;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.suke.widget.SwitchButton;

import java.util.List;

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

private final LayoutInflater mLayoutInflater;

private Context context;

public List<wdszMode> wdszModes = DataBus.getInstance().wdszModes;

public wdsz_adapter(Context context) {
this.context = context;
mLayoutInflater = LayoutInflater.from(context);
}

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

}

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
try {
if (holder instanceof WDSZViewHolder) {
WDSZViewHolder myViewHolder = (WDSZViewHolder) holder;
wdszMode goodsMake= wdszModes.get(position);

myViewHolder.name.setText(goodsMake.name+"");
myViewHolder.edittext_sx.setText(goodsMake.tempup+"");
myViewHolder.edittext_xx.setText(goodsMake.tempdown+"");
myViewHolder.temp.setText(goodsMake.temp+"");
myViewHolder.control_switch.setChecked(goodsMake.autoheat);

myViewHolder.control_switch.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(SwitchButton view, boolean isChecked) {
if(goodsMake.name.equals("水池温度"))
{
ConfigName.getInstance().AutomaticHeating=goodsMake.autoheat;
} else if (goodsMake.name.equals("果糖左温度")) {
ConfigName.getInstance().GT1_AutomaticHeating=goodsMake.autoheat;
}else if (goodsMake.name.equals("果糖右温度")) {
ConfigName.getInstance().GT2_AutomaticHeating=goodsMake.autoheat;
}
ConfigData.getInstance().SavePZ();

if(!isChecked) //关闭加热
{
ExecuteTheRecipe.WritePLC(goodsMake.name+"加热",false,null);
}
}
});

myViewHolder.save_value.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int up = Integer.parseInt((myViewHolder.edittext_sx.getText().toString().isEmpty() ? "0" : myViewHolder.edittext_sx.getText().toString()));
if (up <= 0) {
ToastUtils.error("温度上限不能小于0!请调整后重试.");
return;
}

int down = Integer.parseInt((myViewHolder.edittext_xx.getText().toString().isEmpty() ? "0" : myViewHolder.edittext_xx.getText().toString()));
if (up <= 0) {
ToastUtils.error("温度下限不能小于0!请调整后重试.");
return;
}

if(up<=down)
{
ToastUtils.error("温度上限不能小于等于温度下限!请调整后重试.");
return;
}

ExecuteTheRecipe.WritePLC(goodsMake.name+"上限",up,null);
ExecuteTheRecipe.WritePLC(goodsMake.name + "下限", down, new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info(goodsMake.name+"保存成功!");
}

@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error(goodsMake.name+"保存失败!");
}
});
}
});
}
} 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 {
wdszModes.clear();
wdszModes = DataBus.getInstance().wdszModes;
notifyDataSetChanged();
} catch (Exception e) {

}
}
});
}
}

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

public static class WDSZViewHolder extends RecyclerView.ViewHolder {
/**
* 名称
*/
TextView name;
/**
* 温度上限
*/
EditText edittext_sx;
/**
* 温度下限
*/
EditText edittext_xx;
/**
* 当前温度
*/
TextView temp;
/**
* 自动加热
*/
SwitchButton control_switch;
/**
* 保存值
*/
Button save_value;
public WDSZViewHolder(View view) {
super(view);
name = (TextView) view.findViewById(R.id.name);
edittext_sx=(EditText) view.findViewById(R.id.edittext_sx);
edittext_xx=(EditText) view.findViewById(R.id.edittext_xx);
temp = (TextView) view.findViewById(R.id.temp);
control_switch = (SwitchButton)view.findViewById(R.id.control_switch);
save_value=(Button) view.findViewById(R.id.save_value);
}
}
}

+ 13
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_wdsz_fragment.java View File

@@ -3,6 +3,8 @@ package com.bonait.bnframework.modules.home.fragment.from.fragment;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Context;
import android.os.Bundle;
@@ -11,14 +13,20 @@ import android.view.View;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.helper.WrapContentLinearLayoutManager;
import com.bonait.bnframework.modules.home.adapter.lsjy_adapter;
import com.bonait.bnframework.modules.home.adapter.wdsz_adapter;
import com.orhanobut.logger.Logger;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class JiaoYan_wdsz_fragment extends BaseFragment {


@BindView(R.id.Recy_wdsz)
RecyclerView Recy_wdsz;//温度设置
private Context context;
@Override
protected View onCreateView() {
@@ -58,6 +66,10 @@ public class JiaoYan_wdsz_fragment extends BaseFragment {
*/
public void Initdata() {
try {
DataBus.getInstance().GetWdsz();
Recy_wdsz.setLayoutManager(new WrapContentLinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL,false));
DataBus.getInstance().wdszAdapter = new wdsz_adapter(getContext());
Recy_wdsz.setAdapter(DataBus.getInstance().wdszAdapter);

} catch (Exception e) {



+ 11
- 4
app/src/main/res/layout/fragment_jiaoyan_wdsz.xml View File

@@ -10,10 +10,17 @@
android:layout_height="match_parent"
android:background="@color/main_background"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="wendu"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/Recy_wdsz"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="0dp">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
<!-- 物料信息管理 -->
</LinearLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

+ 169
- 0
app/src/main/res/layout/item/layout/wdsz_item.xml View File

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


<RelativeLayout
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@mipmap/listbj">

<TextView
android:layout_marginTop="60dp"
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="果糖-----左"
android:minWidth="140dp"
android:textAlignment="center"
android:textColor="@color/app_color_blue"
android:textSize="@dimen/text_size_16" />

<RelativeLayout
android:layout_marginTop="30dp"
android:layout_marginLeft="40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="温度上限:"
android:textAlignment="center" />
<EditText
android:id="@+id/edittext_sx"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="@drawable/input_bj"
android:hint="请输入"
android:inputType="number"
android:digits="0123456789"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:text="0"/>
</LinearLayout>
</RelativeLayout>

<RelativeLayout
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_marginLeft="40dp"
android:layout_height="wrap_content">
<LinearLayout
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="温度下限:"
android:textAlignment="center" />
<EditText
android:id="@+id/edittext_xx"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="@drawable/input_bj"
android:hint="请输入"
android:inputType="number"
android:digits="0123456789"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:text="0"/>
</LinearLayout>
</RelativeLayout>

<RelativeLayout
android:layout_marginTop="10dp"
android:layout_marginLeft="40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="当前温度:"
android:textAlignment="center" />
<TextView
android:id="@+id/temp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="33"
android:textAlignment="center"
android:textColor="@color/colorAccent"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="°C"
android:textAlignment="center"
android:textColor="@color/colorAccent"/>
</LinearLayout>
</RelativeLayout>

<RelativeLayout
android:layout_marginTop="10dp"
android:layout_marginLeft="40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="自动加热:"
android:textAlignment="center" />
<com.suke.widget.SwitchButton
android:layout_centerInParent="true"
app:sb_uncheck_color="@color/app_color_blue"
app:sb_uncheckcircle_color="@color/app_color_blue"
app:sb_button_color="@color/app_color_blue"
android:id="@+id/control_switch"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:focusable="true"
/>
</LinearLayout>
</RelativeLayout>

<RelativeLayout
android:layout_marginTop="10dp"
android:layout_marginBottom="80dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/save_value"
android:layout_width="100dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:background="@drawable/bg_btn_login_selected"
android:text="保存"
android:textColor="@color/white"
android:textSize="14dp" />
</RelativeLayout>

</LinearLayout>

</RelativeLayout>

</RelativeLayout>

Loading…
Cancel
Save