From 6c3fd0704033cb24284ce6764da1665e46d761dd Mon Sep 17 00:00:00 2001 From: fyf <11621@LAPTOP-04QQU0AO> Date: Mon, 21 Aug 2023 09:51:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=BA=E6=94=B9=E5=8A=A8=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=AB=98=E6=B1=A4=E4=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/bpa/app/BootInit.java | 41 ++++++++++++++++- .../com/example/bpa/service/DeviceData.java | 10 +++-- .../example/bpa/view/from/lsjy_activity.java | 18 ++++---- .../res/layout/from/layout/activity_lsjy.xml | 44 ++++++++++++++++++- 4 files changed, 99 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/example/bpa/app/BootInit.java b/app/src/main/java/com/example/bpa/app/BootInit.java index 9ef1a1d..b0ad84f 100644 --- a/app/src/main/java/com/example/bpa/app/BootInit.java +++ b/app/src/main/java/com/example/bpa/app/BootInit.java @@ -25,6 +25,8 @@ import com.example.bpa.service.BusinessServer; import com.example.bpa.view.mode.AlertLogEnum; import com.example.bpa.view.mode.UserLogEnum; +import java.util.ArrayList; + import pub.devrel.easypermissions.EasyPermissions; public class BootInit { @@ -153,7 +155,7 @@ public class BootInit { QueryDB.AddUser(user); //10个料仓+ 11 12 两个果糖料仓 if (QueryDB.GetSilosALL().size() == 0) { - for (int i = 0; i < 12; i++) { + for (int i = 0; i < 13; i++) { BPA_SILOS silo = new BPA_SILOS(); silo.id = java.util.UUID.randomUUID().toString(); silo.num = i + 1; @@ -172,6 +174,8 @@ public class BootInit { silo.name="酱油仓"; }else if (i==11) { silo.name="猪油仓"; + }else if (i==12) { + silo.name="高汤仓"; } QueryDB.AddSilos(silo); QueryDB.AddSilosAndMaterial(sm); @@ -180,6 +184,41 @@ public class BootInit { } } + public static void DeleteSilos() + { + ArrayList sol= QueryDB.GetSilosALL(); + for (BPA_SILOS item:sol) + { + QueryDB.DeleteSilos(item); + QueryDB.DeleteSilosAndMaterial(item.id); + } + for (int i = 0; i < 13; i++) { + BPA_SILOS silo = new BPA_SILOS(); + silo.id = java.util.UUID.randomUUID().toString(); + silo.num = i + 1; + silo.thrsoleValue=ConfigName.getInstance().SiloAlarmThreshold; + silo.warningValue=ConfigName.getInstance().SiloFeedThreshold; + BPA_SILOSANDMATERIAL sm = new BPA_SILOSANDMATERIAL(); + sm.silosID = silo.id; + sm.materialID = ""; + + if(i<6) + { + silo.name="外置仓"; + } else if (i>=6 && i<10) { + silo.name="粉料仓"; + }else if (i==10) { + silo.name="酱油仓"; + }else if (i==11) { + silo.name="猪油仓"; + }else if (i==12) { + silo.name="高汤仓"; + } + QueryDB.AddSilos(silo); + QueryDB.AddSilosAndMaterial(sm); + } + } + /** * 删除子订单表-重新生成新表 */ 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 78f41bc..eac9f79 100644 --- a/app/src/main/java/com/example/bpa/service/DeviceData.java +++ b/app/src/main/java/com/example/bpa/service/DeviceData.java @@ -182,7 +182,7 @@ public class DeviceData { * @param ch 需要写入的通道编号,1--10 */ public void setCalibrationValue(short value, int ch, IWriteCallBack callback) { - if (ch >= 1 && ch <= 12) { + if (ch >= 1 && ch <= 13) { String add = "VW" + (-2 + ch * 2); ModbusTcpServer.get().WriteShort(add, value, callback); } @@ -213,7 +213,7 @@ public class DeviceData { * @param ch 需要写入的通道编号,1--10 */ public void setDemandValue(short value, int ch, IWriteCallBack callback) { - if (ch >= 1 && ch <= 12) { + if (ch >= 1 && ch <= 13) { String add = "VW" + (298 + ch * 2); ModbusTcpServer.get().WriteShort(add, value, callback); } @@ -227,7 +227,7 @@ public class DeviceData { * @param ch 需要写入的通道编号,1--10 */ public void setChCalibrationSwitch(boolean value, int ch, IWriteCallBack callback) { - if (ch >= 1 && ch <= 12) { + if (ch >= 1 && ch <= 13) { String add=""; if(ch==9) { @@ -241,6 +241,10 @@ public class DeviceData { }else if(ch==12) { add="M3.3"; + } + else if(ch==13) + { + add="M3.4"; }else { add = ModbusTcpServer.get().getBitSingleAdd("M", 2, ch); diff --git a/app/src/main/java/com/example/bpa/view/from/lsjy_activity.java b/app/src/main/java/com/example/bpa/view/from/lsjy_activity.java index a5fc286..4d8f676 100644 --- a/app/src/main/java/com/example/bpa/view/from/lsjy_activity.java +++ b/app/src/main/java/com/example/bpa/view/from/lsjy_activity.java @@ -39,12 +39,12 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList */ TextView gongneng_title; //通道校准值 - EditText passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12; + EditText passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12,passwayText_13; //校准基准时间 EditText timeText; List editTextLists = new ArrayList(); //通道校准开关 - Switch Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10, Switch_11, Switch_12; + Switch Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10, Switch_11, Switch_12,Switch_13; List switchLists = new ArrayList(); //开始校准 Button StartButton; @@ -106,8 +106,9 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList passwayText_10 = findViewById(R.id.passwayText_10); passwayText_11 = findViewById(R.id.passwayText_11); passwayText_12 = findViewById(R.id.passwayText_12); + passwayText_13 = findViewById(R.id.passwayText_13); - editTextLists = Arrays.asList(passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12); + editTextLists = Arrays.asList(passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12, passwayText_13); //校准开关 Switch_1 = findViewById(R.id.Switch_1); @@ -122,7 +123,8 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList Switch_10 = findViewById(R.id.Switch_10); Switch_11 = findViewById(R.id.Switch_11); Switch_12 = findViewById(R.id.Switch_12); - switchLists = Arrays.asList(Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10, Switch_11, Switch_12); + Switch_13 = findViewById(R.id.Switch_13); + switchLists = Arrays.asList(Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10, Switch_11, Switch_12, Switch_13); //校准按钮 StartButton = findViewById(R.id.StartButton); @@ -149,7 +151,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList public void Initdata() { //初始化标准值数据 try { - for (int i = 0; i < 12; i++) { + for (int i = 0; i < 13; i++) { String s = String.valueOf(DeviceData.Get().getCalibrationValue(i + 1)); editTextLists.get(i).setText(String.format ("%.1f", (Double.parseDouble(s)/10))); } @@ -204,7 +206,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList } }); - for (int i = 0; i < 12; i++) { + for (int i = 0; i < 13; i++) { if (switchLists.get(i).isChecked() == true)//校准开关打开后,允许校准 { String value = editTextLists.get(i).getText().toString(); @@ -220,7 +222,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList } } //写开关状态 数值 - for (int i = 0; i < 12; i++) { + for (int i = 0; i < 13; i++) { String value = editTextLists.get(i).getText().toString(); Short val = 0; try { @@ -241,7 +243,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList break; case R.id.StartButton://开始校准 //写开关状态 数值 - for (int i = 0; i < 12; i++) { + for (int i = 0; i < 13; i++) { //1.写入开关状态 DeviceData.Get().setChCalibrationSwitch(switchLists.get(i).isChecked(), i + 1, new IWriteCallBack() { @Override diff --git a/app/src/main/res/layout/from/layout/activity_lsjy.xml b/app/src/main/res/layout/from/layout/activity_lsjy.xml index f7b334c..ba144f1 100644 --- a/app/src/main/res/layout/from/layout/activity_lsjy.xml +++ b/app/src/main/res/layout/from/layout/activity_lsjy.xml @@ -466,6 +466,45 @@ android:thumb="@drawable/switch_custom_thumb_selector" android:track="@drawable/switch_custom_track_selector"/> + + + + + + + + @@ -523,7 +562,7 @@