diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7861794..2a62593 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -28,6 +28,9 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:targetApi="31">
+
diff --git a/app/src/main/java/com/example/bpa/app/Main.java b/app/src/main/java/com/example/bpa/app/Main.java
index 6c5864f..0505963 100644
--- a/app/src/main/java/com/example/bpa/app/Main.java
+++ b/app/src/main/java/com/example/bpa/app/Main.java
@@ -218,6 +218,7 @@ public class Main {
ConfigName.getInstance().user.account = ConfigUtil.read(ConfigName.getInstance().dishesCon, "username", ConfigName.getInstance().user.account);
ConfigName.getInstance().user.pass = ConfigUtil.read(ConfigName.getInstance().dishesCon, "password", ConfigName.getInstance().user.pass);
ConfigName.getInstance().IsUserDownOrder = ConfigUtil.read(ConfigName.getInstance().dishesCon, "IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder);
+ ConfigName.getInstance().AutomaticHeating = ConfigUtil.read(ConfigName.getInstance().dishesCon, "AutomaticHeating", ConfigName.getInstance().AutomaticHeating);
ConfigName.getInstance().Version = ConfigUtil.read(ConfigName.getInstance().dishesCon, "Version", ConfigName.getInstance().Version);
}
@@ -233,8 +234,9 @@ public class Main {
ConfigUtil.write(ConfigName.getInstance().dishesCon,"username", ConfigName.getInstance().user.account);
ConfigUtil.write(ConfigName.getInstance().dishesCon,"password", ConfigName.getInstance().user.pass);
ConfigUtil.write(ConfigName.getInstance().dishesCon,"IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder);
- ConfigUtil.write(ConfigName.getInstance().dishesCon,"IsUserDownOrder", ConfigName.getInstance().IsUserDownOrder);
+ ConfigUtil.write(ConfigName.getInstance().dishesCon,"AutomaticHeating", ConfigName.getInstance().AutomaticHeating);
ConfigUtil.write(ConfigName.getInstance().dishesCon,"Version", ConfigName.getInstance().Version);
+
}
/**
diff --git a/app/src/main/java/com/example/bpa/config/ConfigName.java b/app/src/main/java/com/example/bpa/config/ConfigName.java
index f46251e..046e16d 100644
--- a/app/src/main/java/com/example/bpa/config/ConfigName.java
+++ b/app/src/main/java/com/example/bpa/config/ConfigName.java
@@ -114,7 +114,14 @@ public class ConfigName {
/**
* 是否手动下单
*/
- public Boolean IsUserDownOrder=false;
+ public Boolean IsUserDownOrder=true;
+ //endregion
+
+ //region 是否自动加热
+ /**
+ * 是否自动加热
+ */
+ public Boolean AutomaticHeating=false;
//endregion
//region 系统设置表
diff --git a/app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java b/app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java
index dbe6b95..4e53b92 100644
--- a/app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java
+++ b/app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java
@@ -233,6 +233,8 @@ public class ModbusTcpServer {
LogServer.Get().Init();
//6.云订单服务
OrderServer.Get().Init();
+ //7.自动加热服务
+ ReheatServer.Get().Init();
}
@Override
diff --git a/app/src/main/java/com/example/bpa/service/DeviceData.java b/app/src/main/java/com/example/bpa/service/DeviceData.java
index 5c2aac8..812b7e7 100644
--- a/app/src/main/java/com/example/bpa/service/DeviceData.java
+++ b/app/src/main/java/com/example/bpa/service/DeviceData.java
@@ -725,22 +725,34 @@ public class DeviceData {
//region 获取或设置保温箱温度信息
/**
- * 保温箱
+ * 水箱
*/
int BWX_FructoseTemperature=0;
/**
- * 获取保温箱实际温度
+ * 水箱
+ */
+ int BWX_FructoseTemperature_sz=0;
+ /**
+ * 获取水箱实际温度
*
* @return
*/
public int getBWX_FructoseTemperature() {
return BWX_FructoseTemperature;
}
+ /**
+ * 获取水箱实际温度保温温度
+ *
+ * @return
+ */
+ public int getBWX_FructoseTemperatureSZ() {
+ return BWX_FructoseTemperature_sz;
+ }
public void setBWX_FructoseTemperature(int value, IWriteCallBack callback) {
ModbusTcpServer.get().WriteInt("VD372", value, callback);
}
/**
- * 设置保温箱加热启动停止
+ * 设置水箱加热启动停止
*
* @param value true:启动,flase:停止
*/
@@ -751,6 +763,10 @@ public class DeviceData {
* 加热箱
*/
int JRX_FructoseTemperature=0;
+ /**
+ * 加热箱
+ */
+ int JRX_FructoseTemperature_sz=0;
/**
* 获取加热箱实际温度
*
@@ -759,6 +775,14 @@ public class DeviceData {
public int getJRX_FructoseTemperature() {
return JRX_FructoseTemperature;
}
+ /**
+ * 获取加热箱实际温度
+ *
+ * @return
+ */
+ public int getJRX_FructoseTemperatureSZ() {
+ return JRX_FructoseTemperature_sz;
+ }
public void setJRX_FructoseTemperature(int value, IWriteCallBack callback) {
ModbusTcpServer.get().WriteInt("VD380", value, callback);
}
@@ -768,7 +792,7 @@ public class DeviceData {
* @param value true:启动,flase:停止
*/
public void setJRXSwitch(boolean value, IWriteCallBack callback) {
- ModbusTcpServer.get().WriteBool("M103.4", value, callback);
+ ModbusTcpServer.get().WriteBool("M103.1", value, callback);
}
//endregion
diff --git a/app/src/main/java/com/example/bpa/service/ReheatServer.java b/app/src/main/java/com/example/bpa/service/ReheatServer.java
index 1e92692..e586139 100644
--- a/app/src/main/java/com/example/bpa/service/ReheatServer.java
+++ b/app/src/main/java/com/example/bpa/service/ReheatServer.java
@@ -3,6 +3,7 @@ package com.example.bpa.service;
import com.example.bpa.Model.IRun;
import com.example.bpa.Model.IThread;
import com.example.bpa.Model.IWriteCallBack;
+import com.example.bpa.config.ConfigName;
import com.example.bpa.config.DataBus;
import com.example.bpa.helper.MessageLog;
import com.example.bpa.helper.ModbusTcpServer;
@@ -45,79 +46,38 @@ public class ReheatServer {
ThreadManager.Get().StartLong("加热服务", true, new IThread() {
@Override
public void Run() throws InterruptedException {
- if (DataBus.getInstance().PlcIsConnect)
+ if (DataBus.getInstance().PlcIsConnect && ConfigName.getInstance().AutomaticHeating)
{
- if(DeviceData.Get().getFructoseTemperature1_up()>0 && DeviceData.Get().getFructoseTemperature1_down()>0 )
+ //1.温度值低于设置值,加热
+ //2.温度高于设置值,停止加热
+ int sx_temp=DeviceData.Get().getBWX_FructoseTemperature();//水箱温度
+ int sx_temp_sz=DeviceData.Get().getBWX_FructoseTemperatureSZ();//水箱温度设置值
+
+ int jrx_temp=DeviceData.Get().getJRX_FructoseTemperature();//加热箱温度
+ int jrx_temp_sz=DeviceData.Get().getJRX_FructoseTemperatureSZ();//加热箱温度设置值
+
+ if(sx_temp_sz>0)
{
- if(DeviceData.Get().getFructoseTemperature1_up()>DeviceData.Get().getFructoseTemperature1_down())
+ if(sx_temp>=sx_temp_sz)
+ {
+ DeviceData.Get().setBWXSwitch(false,null);
+ }else
{
- //温度低于最小值 加热
- if(DeviceData.Get().getFructoseTemperature1()=DeviceData.Get().getFructoseTemperature1_up())
- {
- if(DeviceData.Get().getReheatSwitch1()==true)
- {
- DeviceData.Get().setReheatSwitch1(false, new IWriteCallBack() {
- @Override
- public void onSuccess() {
- }
- @Override
- public void onFailure(String ErrorMsg) {
- }
- });
- }
- }
+ DeviceData.Get().setBWXSwitch(true,null);
}
}
- if(DeviceData.Get().getFructoseTemperature2_up()>0 && DeviceData.Get().getFructoseTemperature2_down()>0 )
+ if(jrx_temp_sz>0)
{
- if(DeviceData.Get().getFructoseTemperature2_up()>DeviceData.Get().getFructoseTemperature2_down())
+ if(jrx_temp>=jrx_temp_sz)
{
- //温度低于最小值 加热
- if(DeviceData.Get().getFructoseTemperature2()=DeviceData.Get().getFructoseTemperature2_up())
- {
- if(DeviceData.Get().getReheatSwitch2()==true)
- {
- DeviceData.Get().setReheatSwitch2(false, new IWriteCallBack() {
- @Override
- public void onSuccess() {
- }
- @Override
- public void onFailure(String ErrorMsg) {
- }
- });
- }
- }
+ DeviceData.Get().setJRXSwitch(false,null);
+ }else
+ {
+ DeviceData.Get().setJRXSwitch(true,null);
}
}
}
-
Thread.sleep(2000);
}
diff --git a/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java b/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java
index f400071..a01d087 100644
--- a/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java
+++ b/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java
@@ -34,6 +34,7 @@ import com.example.bpa.helper.T;
import com.example.bpa.helper.WrapContentLinearLayoutManager;
import com.example.bpa.message.MessageLooper;
import com.example.bpa.message.MessageManager;
+import com.example.bpa.service.DeviceData;
import com.example.bpa.view.adapter.maingoods_adapter;
import com.example.bpa.view.adapter.makegood_adapter;
import com.example.bpa.view.adapter.order_adapter;
@@ -67,6 +68,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl
* 自动控制按钮
*/
ImageView image_zdkz;
+ /**
+ * 当前温度
+ */
+ TextView wendu1, wendu2;
/**
* 界面实例
*/
@@ -93,6 +98,9 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl
makesp=view.findViewById(R.id.makesp);
nohelp=view.findViewById(R.id.nohelp);
image_zdkz=view.findViewById(R.id.image_zdkz);
+ wendu1 = view.findViewById(R.id.wendu1);
+ wendu2 = view.findViewById(R.id.wendu2);
+
if( ConfigName.getInstance().IsUserDownOrder)
{
makesp.setVisibility(View.VISIBLE);
@@ -107,6 +115,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl
Initdata();//初始化数据
RegisterMessage();//消息中心事件接收
initEvents();
+ startListening();
}
/**
* 初始化按钮事件
@@ -278,18 +287,33 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl
Activity activity=null;
public void RegisterMessage()
{
-// MessageManager.getInstance().registerMessageReceiver(this, MessageName.Common.name(), new MessageLooper.OnMessageListener() {
-// @Override
-// public void onMessage(Object msg) {
-// activity.runOnUiThread(new Runnable() {
-// @Override
-// public void run() {
-// DataBus.getInstance().UpdateMainGoods();//更新商品
-// goodadapter.notifyDataSetChanged();
-// }
-// });
-// }
-// });
+
+ }
+
+ /**
+ * 监听外部数据变化
+ */
+ private void startListening() {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ wendu1.setText(String.valueOf(DeviceData.Get().getBWX_FructoseTemperature()) + "°C");
+ wendu2.setText(String.valueOf(DeviceData.Get().getJRX_FructoseTemperature()) + "°C");
+ }
+ });
+ Thread.sleep(1000);
+
+ } catch (Exception e) {
+
+ }
+ }
+ }
+ }).start();
}
//endregion
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/bpa/view/fragment/SystemCapabilitiesFragment.java b/app/src/main/java/com/example/bpa/view/fragment/SystemCapabilitiesFragment.java
index f9ac765..42b52d3 100644
--- a/app/src/main/java/com/example/bpa/view/fragment/SystemCapabilitiesFragment.java
+++ b/app/src/main/java/com/example/bpa/view/fragment/SystemCapabilitiesFragment.java
@@ -27,6 +27,7 @@ import com.example.bpa.view.from.lcsz_activity;
import com.example.bpa.view.from.lsjy_activity;
import com.example.bpa.view.from.sdkz_new_Activity;
import com.example.bpa.view.from.wdgl_activity;
+import com.example.bpa.view.from.wdgl_new_Activity;
import com.example.bpa.view.from.wlgl_activity;
import com.example.bpa.view.from.yfcl_activity;
import com.example.bpa.view.from.yfpf_activity;
@@ -72,7 +73,7 @@ public class SystemCapabilitiesFragment extends Fragment {
menuModes.add(new MenuMode("料仓管理", R.mipmap.lcsz));
menuModes.add(new MenuMode("订单管理", R.mipmap.ddgl));
menuModes.add(new MenuMode("手动控制", R.mipmap.sdkz));
-// menuModes.add(new MenuMode("温度管理", R.mipmap.wdkz));
+ menuModes.add(new MenuMode("温度管理", R.mipmap.wdkz));
menuModes.add(new MenuMode("电子秤校验", R.mipmap.dzcjy));
menuModes.add(new MenuMode("流速校验", R.mipmap.lsjy));
@@ -131,7 +132,7 @@ public class SystemCapabilitiesFragment extends Fragment {
intent = new Intent(view.getContext(), sdkz_new_Activity.class);
break;
case "温度管理":
- intent = new Intent(view.getContext(), wdgl_activity.class);
+ intent = new Intent(view.getContext(), wdgl_new_Activity.class);
break;
case "饮料配方管理":
default:
diff --git a/app/src/main/java/com/example/bpa/view/fragment/setting/ovarparameter.java b/app/src/main/java/com/example/bpa/view/fragment/setting/ovarparameter.java
index ce4ece8..fef833a 100644
--- a/app/src/main/java/com/example/bpa/view/fragment/setting/ovarparameter.java
+++ b/app/src/main/java/com/example/bpa/view/fragment/setting/ovarparameter.java
@@ -24,7 +24,7 @@ import java.util.Arrays;
public class ovarparameter extends Fragment {
- Switch Switch_1;
+ Switch Switch_1,Switch_2;
/**
* 界面实例
*/
@@ -49,7 +49,9 @@ public class ovarparameter extends Fragment {
public void Init()
{
Switch_1 = view.findViewById(R.id.Switch_1);
+ Switch_2= view.findViewById(R.id.Switch_2);
Switch_1.setChecked(ConfigName.getInstance().IsUserDownOrder);
+ Switch_2.setChecked(ConfigName.getInstance().AutomaticHeating);
}
/**
* 初始化按钮事件
@@ -66,6 +68,17 @@ public class ovarparameter extends Fragment {
Main.getInstance().SavePZ();
}
});
+
+ /**
+ * 设置是否是否自动加热
+ */
+ Switch_2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ ConfigName.getInstance().AutomaticHeating=b;
+ Main.getInstance().SavePZ();
+ }
+ });
}
//endregion
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/bpa/view/from/wdgl_new_Activity.java b/app/src/main/java/com/example/bpa/view/from/wdgl_new_Activity.java
new file mode 100644
index 0000000..175ec3c
--- /dev/null
+++ b/app/src/main/java/com/example/bpa/view/from/wdgl_new_Activity.java
@@ -0,0 +1,198 @@
+package com.example.bpa.view.from;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.example.bpa.Model.IWriteCallBack;
+import com.example.bpa.R;
+import com.example.bpa.helper.T;
+import com.example.bpa.service.DeviceData;
+
+public class wdgl_new_Activity extends AppCompatActivity implements View.OnClickListener {
+
+ //region 变量
+ /**
+ * 返回按钮
+ */
+ ImageView gongneng_fanhui;
+ /**
+ * 标题设置
+ */
+ TextView gongneng_title;
+ /**
+ * 温度上限
+ */
+ EditText sc_bw, jrx_bw;
+ /**
+ * 当前温度
+ */
+ TextView wendu1, wendu2;
+ /**
+ * 保存按钮
+ */
+ Button mwSave_button1, mwSave_button2;
+ //endregion
+
+ //region 私有函数
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ this.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_wdgl_new);
+ Init();
+ initEvents();
+ startListening();
+ }
+ //endregion
+
+ //region 公共函数
+
+ /**
+ * 初始化
+ */
+ private void Init() {
+ gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
+ gongneng_title = this.findViewById(R.id.gongneng_title);
+ sc_bw = this.findViewById(R.id.sc_bw);
+ jrx_bw = this.findViewById(R.id.jrx_bw);
+
+
+ wendu1 = this.findViewById(R.id.wendu1);
+ wendu2 = this.findViewById(R.id.wendu2);
+
+ mwSave_button1 = this.findViewById(R.id.mwSave_button1);
+ mwSave_button2 = this.findViewById(R.id.mwSave_button2);
+
+
+ //通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
+ String msg = getIntent().getStringExtra("data");
+ gongneng_title.setText(msg);
+
+ Initdata();
+ }
+
+ /**
+ * 初始化按钮事件
+ */
+ private void initEvents() {
+ gongneng_fanhui.setOnClickListener(this);
+ mwSave_button1.setOnClickListener(this);
+ mwSave_button2.setOnClickListener(this);
+ }
+
+ /**
+ * 监听外部数据变化
+ */
+ private void startListening() {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ wendu1.setText(String.valueOf(DeviceData.Get().getBWX_FructoseTemperature()) + "°C");
+ wendu2.setText(String.valueOf(DeviceData.Get().getJRX_FructoseTemperature()) + "°C");
+ }
+ });
+ Thread.sleep(1000);
+
+ } catch (Exception e) {
+
+ }
+ }
+ }
+ }).start();
+ }
+
+ /**
+ * 初始化数据加载
+ */
+ public void Initdata() {
+ try {
+ wendu1.setText(String.valueOf(DeviceData.Get().getBWX_FructoseTemperature()));
+ wendu2.setText(String.valueOf(DeviceData.Get().getJRX_FructoseTemperature()));
+
+ sc_bw.setText(String.valueOf(DeviceData.Get().getBWX_FructoseTemperatureSZ()));
+ jrx_bw.setText(String.valueOf(DeviceData.Get().getJRX_FructoseTemperatureSZ()));
+
+ } catch (Exception e) {
+
+ }
+ }
+ //endregion
+
+ //region 点击事件
+
+ /**
+ * 本页面点击事件监听
+ *
+ * @param v
+ */
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.gongneng_fanhui://返回按钮
+ this.finish();
+ break;
+ case R.id.mwSave_button1://按钮1
+ try {
+ int up = Integer.parseInt((sc_bw.getText().toString().isEmpty() ? "0" : sc_bw.getText().toString()));
+ if (up <= 0) {
+ T.show(this, "温度不能小于0!请调整后重试.");
+ return;
+ }
+
+ DeviceData.Get().setBWX_FructoseTemperature(up, new IWriteCallBack() {
+ @Override
+ public void onSuccess() {
+ T.show(wdgl_new_Activity.this, "保存成功.");
+ }
+
+ @Override
+ public void onFailure(String ErrorMsg) {
+ T.show(wdgl_new_Activity.this, "保存失败.");
+ }
+ });
+ } catch (Exception e) {
+ T.show(this, "异常信息:" + e.getMessage());
+ }
+ break;
+ case R.id.mwSave_button2://按钮2
+ try {
+ int up = Integer.parseInt((jrx_bw.getText().toString().isEmpty() ? "0" : jrx_bw.getText().toString()));
+ if (up <= 0) {
+ T.show(this, "温度不能小于0!请调整后重试.");
+ return;
+ }
+
+ DeviceData.Get().setJRX_FructoseTemperature(up, new IWriteCallBack() {
+ @Override
+ public void onSuccess() {
+ T.show(wdgl_new_Activity.this, "保存成功.");
+ }
+
+ @Override
+ public void onFailure(String ErrorMsg) {
+ T.show(wdgl_new_Activity.this, "保存失败.");
+ }
+ });
+ } catch (Exception e) {
+ T.show(this, "异常信息:" + e.getMessage());
+ }
+ break;
+ }
+ }
+
+ //endregion
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 4d5dbb8..00ea086 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -81,6 +81,7 @@
android:layout_marginRight="10dp"
android:src="@mipmap/zzz"/>
+ android:background="@drawable/qs_switch"
+ android:text="允许手动下单"
+ android:layout_margin="5dp"/>
+
+
+
+
diff --git a/app/src/main/res/layout/from/layout/activity_wdgl_new.xml b/app/src/main/res/layout/from/layout/activity_wdgl_new.xml
new file mode 100644
index 0000000..2383e7c
--- /dev/null
+++ b/app/src/main/res/layout/from/layout/activity_wdgl_new.xml
@@ -0,0 +1,264 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/from/layout/fragment_home.xml b/app/src/main/res/layout/from/layout/fragment_home.xml
index 1821080..290bc46 100644
--- a/app/src/main/res/layout/from/layout/fragment_home.xml
+++ b/app/src/main/res/layout/from/layout/fragment_home.xml
@@ -164,6 +164,45 @@
+
+
+
+
+
+
+
+
+