From d149739eceb92e59407184e301529c8171c48516 Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 17 Jul 2023 18:23:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0PLC=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- app/src/main/AndroidManifest.xml | 20 +- .../main/java/com/example/bpa/app/ICSApp.java | 11 + .../example/bpa/helper/ModbusTcpServer.java | 7 +- .../com/example/bpa/service/DeviceData.java | 322 +++++------------- .../com/example/bpa/service/ReheatServer.java | 2 - .../bpa/view/adapter/lc_item_adapter.java | 9 +- .../fragment/SystemCapabilitiesFragment.java | 7 +- .../example/bpa/view/from/dzcjy_activity.java | 117 ++----- .../example/bpa/view/from/lcsz_activity.java | 5 +- .../example/bpa/view/from/lsjy_activity.java | 107 +----- .../bpa/view/from/sdkz_new_Activity.java | 114 +++++++ .../com/example/bpa/view/mode/lcMode.java | 3 +- .../res/layout/from/layout/activity_dzcjy.xml | 223 +----------- .../res/layout/from/layout/activity_lsjy.xml | 24 +- .../layout/from/layout/activity_sdkz_new.xml | 95 ++++++ .../main/res/layout/item/layout/lc_item.xml | 10 + 17 files changed, 378 insertions(+), 700 deletions(-) create mode 100644 app/src/main/java/com/example/bpa/view/from/sdkz_new_Activity.java create mode 100644 app/src/main/res/layout/from/layout/activity_sdkz_new.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index bcf7264..369983e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3ae84eb..1023c01 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,21 +14,23 @@ - - - + + + @@ -122,13 +124,17 @@ android:exported="false" android:windowSoftInputMode="adjustPan|stateHidden" /> - + + - - \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/app/ICSApp.java b/app/src/main/java/com/example/bpa/app/ICSApp.java index 6e6a31b..0dcf606 100644 --- a/app/src/main/java/com/example/bpa/app/ICSApp.java +++ b/app/src/main/java/com/example/bpa/app/ICSApp.java @@ -132,6 +132,17 @@ public class ICSApp extends Application { 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="猪油仓"; + } QueryDB.AddSilos(silo); QueryDB.AddSilosAndMaterial(sm); } 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 31b22c8..dbe6b95 100644 --- a/app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java +++ b/app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java @@ -122,7 +122,7 @@ public class ModbusTcpServer { */ public String getBitSingleAdd(String Prefix, int startAdd, int num) { if (num > 0) { - int FirstAdd = num / 8; + int FirstAdd = num / 8; // int EndAdd = num % 8; if (EndAdd == 0) { FirstAdd--; @@ -227,17 +227,12 @@ public class ModbusTcpServer { BusinessServer.Get().Init(); //3.设置自动模式 DeviceData.Get().setHandOrAutoSwitch(true, null); - DeviceData.Get().setCleaningMode(false, null);//关闭自动清洗模式 //4.启动设备服务 DeviceServer.Get().Init(); //5.启动日志服务 LogServer.Get().Init(); //6.云订单服务 OrderServer.Get().Init(); - //7.加热服务 - ReheatServer.Get().Init(); - //8.扫码服务 - ScanCodeServer.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 f3a54df..2030d9d 100644 --- a/app/src/main/java/com/example/bpa/service/DeviceData.java +++ b/app/src/main/java/com/example/bpa/service/DeviceData.java @@ -30,27 +30,6 @@ public class DeviceData { public void testAddComm(int value) { testComms.offer(value); } - - public void TestInit() { - ThreadManager.Get().StartLong("TestInit", true, new IThread() { - @Override - public void Run() throws InterruptedException { - while (testComms.size() > 0) { - Thread.sleep(5000); - if (OnChargeMixtureComNotPar != null) { - OnChargeMixtureComNotPar.Run(testComms.poll()); - } - } - Thread.sleep(100); - } - - @Override - public void RunComplete() throws InterruptedException { - - } - }); - ; - } //----------------------------------------------------------------End 模拟测试 ---------------------------------------------------------------- //region 初始化 @@ -60,115 +39,38 @@ public class DeviceData { public void Run() throws InterruptedException { //获取校准值-增加两个果糖通道 - ModbusTcpServer.get().ReadShort("VW100", 12, (shorts) -> { + ModbusTcpServer.get().ReadShort("VW0", 12, (shorts) -> { for (int i = 0; i < shorts.length; i++) { CalibrationValue.put(i + 1, shorts[i]); } }); //获取称当前重量 - ModbusTcpServer.get().ReadInt("VD260", 9, ints -> { + ModbusTcpServer.get().ReadInt("VD356", 1, ints -> { for (int i = 0; i < ints.length; i++) { CallCurrentWeight.put(i + 1, ints[i]); } }); //获取校准基准时间 - ModbusTcpServer.get().ReadInt("VD124", 1, ints -> { - CalibrationReferenceTime = ints[0]; - }); - - //获取温度参数 - ModbusTcpServer.get().ReadInt("VD310", 3, ints -> { - FructoseTemperature1=ints[0]; - FructoseTemperature2=ints[1]; - WashTheTankTemperature=ints[2]; + ModbusTcpServer.get().ReadShort("VW26", 1, (shorts) -> { + CalibrationReferenceTime = shorts[0]; }); - //获取温度上下限 - ModbusTcpServer.get().ReadInt("VD388", 6, ints -> { - FructoseTemperature1_up=ints[0]; - FructoseTemperature1_down=ints[1]; - FructoseTemperature2_up=ints[2]; - FructoseTemperature2_down=ints[3]; - WashTheTankTemperature_up=ints[4]; - WashTheTankTemperature_down=ints[5]; + //获取温度参数 保温池温度、加热箱温度 + ModbusTcpServer.get().ReadInt("VD364", 2, ints -> { + BWX_FructoseTemperature=ints[0]; + JRX_FructoseTemperature=ints[1]; }); - //获取清洗参数 - ModbusTcpServer.get().ReadShort("VW140", 5, shorts -> { - DrainageTime = shorts[0]; - AddCleaningAgentTime = shorts[1]; - InletTime = shorts[2]; - CyclicCleaningTime = shorts[3]; - CleaningAndHeatingTime = shorts[4]; - }); - - //获取清洗参数 - ModbusTcpServer.get().ReadBool("M6.5", 1, booleans -> { + //获取校准模式 + ModbusTcpServer.get().ReadBool("M1.0", 1, booleans -> { WeightCalibrationMode = booleans[0]; }); - ModbusTcpServer.get().ReadBool("M6.5", 1, booleans -> { - WeightCalibrationMode = booleans[0]; - }); - //IoStatus - - //读取1号果糖机按钮状态 - ModbusTcpServer.get().ReadBool("M51.7", 1, booleans -> { - ReheatSwitch1 = booleans[0]; - }); - - //读取2号果糖机按钮状态 - ModbusTcpServer.get().ReadBool("M52.0", 1, booleans -> { - ReheatSwitch2 = booleans[0]; - }); - - //读取当前扫码信息 - ModbusTcpServer.get().ReadString("VW342", 20, (data) -> { - - if(!Code.equals(data)) - { - if(!data.isEmpty() && OnScanTheCodeInformationT!=null) - { - MessageLog.ShowInfo("当前扫码信息:"+data); - OnScanTheCodeInformationT.Run(data); - } - Code=data; - } - //1.查询订单信息 - //2.展示订单界面 - //3.制作订单信息 - //4.回馈订单信息 - }); - - //读取实时状态 - ModbusTcpServer.get().ReadStatus("VW382", 3, data -> { - for (int i = 0; i < data.length; i++) { - byte status=data[i];//0x92 - IoStatus.put(i*8+0, ByteHelper.getBit(status,0)==1); - IoStatus.put(i*8+1, ByteHelper.getBit(status,1)==1); - IoStatus.put(i*8+2, ByteHelper.getBit(status,2)==1); - IoStatus.put(i*8+3, ByteHelper.getBit(status,3)==1); - IoStatus.put(i*8+4, ByteHelper.getBit(status,4)==1); - IoStatus.put(i*8+5, ByteHelper.getBit(status,5)==1); - IoStatus.put(i*8+6, ByteHelper.getBit(status,6)==1); - IoStatus.put(i*8+7, ByteHelper.getBit(status,7)==1); - } - }); - //配料完成 M0.3 CompleteListen("M0.3", "配料完成", OnChargeMixtureCompleteNotify); - //清洗完成 M0.6 - CompleteListen("M0.6", "清洗完成", OnCleaningCompleteNotify); - - //去皮完成 M1.3 - CompleteListen("M1.3", "去皮完成", OnPeelingCompleteNotify); - - //扫码信号 M1.5 - //CompleteListen("M1.5", "扫码信号", OnScanTheCodeInformation); - Thread.sleep(10); } @@ -179,12 +81,7 @@ public class DeviceData { }); } //endregion - /** - * 扫码信息 - */ - public String Code=""; //region 完成信号监听 - /** * 完成信号监听 * @@ -207,26 +104,6 @@ public class DeviceData { * 配料完成通知 */ public IRun OnChargeMixtureCompleteNotify; - - /** - * 通道配料完成通知 - */ - public IRunT OnChargeMixtureComNotPar; - - /** - * 清洗完成通知 - */ - public IRun OnCleaningCompleteNotify; - - /** - * 去皮完成 - */ - public IRun OnPeelingCompleteNotify; - - /** - * 接收到扫码信息 - */ - public IRun OnScanTheCodeInformation; /** * 接收到扫码信息,返回 */ @@ -242,7 +119,7 @@ public class DeviceData { */ public void setCalibrationValue(short value, int ch, IWriteCallBack callback) { if (ch >= 1 && ch <= 12) { - String add = "VW" + (98 + ch * 2); + String add = "VW" + (-2 + ch * 2); ModbusTcpServer.get().WriteShort(add, value, callback); } } @@ -273,11 +150,7 @@ public class DeviceData { */ public void setDemandValue(short value, int ch, IWriteCallBack callback) { if (ch >= 1 && ch <= 10) { - String add = "VW" + (198 + ch * 2); - ModbusTcpServer.get().WriteShort(add, value, callback); - }else if(ch>=11 && ch<=12)//果糖需求 - { - String add = "VW" + (198 +20+ ch * 2); + String add = "VW" + (298 + ch * 2); ModbusTcpServer.get().WriteShort(add, value, callback); } } @@ -294,21 +167,20 @@ public class DeviceData { String add=""; if(ch==9) { - add="M03.0"; + add="M3.0"; }else if(ch==10) { - add="M03.1"; - }else if(ch==11)//果糖1 + add="M3.1"; + }else if(ch==11) { - add="M03.2"; - }else if(ch==12)//果糖2 + add="M3.2"; + }else if(ch==12) { - add="M03.3"; + add="M3.3"; }else { add = ModbusTcpServer.get().getBitSingleAdd("M", 2, ch); } - if (add.length() > 0) ModbusTcpServer.get().WriteBool(add, value, callback); } @@ -332,68 +204,39 @@ public class DeviceData { } //endregion - - /** - * 称去皮校准 - * - * @param value - * @param ch 设置称的通道号,ch1-ch8 - */ - public void setRemovePeelCalibration(boolean value, int ch, IWriteCallBack callback) { - if (ch >= 1 && ch <= 8) { - String add = ModbusTcpServer.get().getBitSingleAdd("M", 5, ch); - if (add.length() > 0) - ModbusTcpServer.get().WriteBool(add, value, callback); - } - } - - /** - * 砝码值写入 - * - * @param value - * @param ch 设置称的砝码通道号,ch1-ch8 - */ - public void setWeightValue(boolean value, int ch, IWriteCallBack callback) { - if (ch >= 1 && ch <= 8) { - String add = ModbusTcpServer.get().getBitSingleAdd("M", 15, ch); - if (add.length() > 0) - ModbusTcpServer.get().WriteBool(add, value, callback); - } - } - /** * 重量清零 */ public void setWeightClear(IWriteCallBack callback) { - ModbusTcpServer.get().WriteBool("M6.0", true, callback); + ModbusTcpServer.get().WriteBool("M1.1", true, callback); } /** * 关闭写保护 */ public void setCloseWriteProtect(IWriteCallBack callback) { - ModbusTcpServer.get().WriteBool("M6.1", true, callback); + ModbusTcpServer.get().WriteBool("M1.2", true, callback); } /** * 打开写保护 */ public void setOpenWriteProtect(IWriteCallBack callback) { - ModbusTcpServer.get().WriteBool("M6.4", true, callback); + ModbusTcpServer.get().WriteBool("M1.5", true, callback); } /** * 零点校准 */ public void setZeroPointCalibration(IWriteCallBack callback) { - ModbusTcpServer.get().WriteBool("M6.2", true, callback); + ModbusTcpServer.get().WriteBool("M1.3", true, callback); } /** * 砝码值写入 */ public void setWeightValueWrite(IWriteCallBack callback) { - ModbusTcpServer.get().WriteBool("M6.3", true, callback); + ModbusTcpServer.get().WriteBool("M1.4", true, callback); } /** @@ -405,7 +248,7 @@ public class DeviceData { * 砝码校准模式 */ public void setWeightCalibrationMode(Boolean value, IWriteCallBack callback) { - ModbusTcpServer.get().WriteBool("M6.5", value, callback); + ModbusTcpServer.get().WriteBool("M1.0", value, callback); } /** @@ -467,7 +310,6 @@ public class DeviceData { * 清洗模式 */ boolean CleaningMode; - /** * 获取清洗模式 * @@ -483,28 +325,6 @@ public class DeviceData { public void setStartCleaning(IWriteCallBack callback) { ModbusTcpServer.get().WriteBool("M0.5", true, callback); } - - /** - * 设置一键去皮 - */ - public void setOneClickPeeling(IWriteCallBack callback) { - ModbusTcpServer.get().WriteBool("M1.2", true, callback); - } - - /** - * 一键去皮完成状态 - */ - boolean OneClickPeelingComplete; - - /** - * 设置一键去皮完成状态 - * - * @param value - */ - public void setOneClickPeelingComplete(boolean value) { - OneClickPeelingComplete = value; - } - /** * 清洗完成 */ @@ -519,35 +339,6 @@ public class DeviceData { return CleaningComplete; } - //region 获取或设置-校准模式 - - /** - * 设置校准模式 - * - * @param value true:零点校准模式,false:清零去皮模式 - */ - public void setCalibrationMode(boolean value, IWriteCallBack callback) { - ModbusTcpServer.get().WriteBool("M1.4", value, callback); - } - - /** - * 校准模式 - */ - boolean CalibrationMode; - - /** - * 获取校准模式 - * - * @return true:零点校准模式,false:清零去皮模式 - */ - public boolean getCalibrationMode() { - return CalibrationMode; - } - - //endregion - - - /** * 称当前重量 */ @@ -573,8 +364,8 @@ public class DeviceData { * * @param value 需要写入的值 */ - public void setCalibrationReferenceTime(int value, IWriteCallBack callback) { - ModbusTcpServer.get().WriteInt("VD124", value, callback); + public void setCalibrationReferenceTime(short value, IWriteCallBack callback) { + ModbusTcpServer.get().WriteShort("VW26", value, callback); } /** @@ -890,22 +681,15 @@ public class DeviceData { return IoStatus.get(ch); } //endregion - /** - * 设置8路称校准砝码重量 - * - * @param value - */ - public void setCalibrationWeight(short value, IWriteCallBack callback) { - ModbusTcpServer.get().WriteShort("VW250", value, callback); - } + //region 设置出料口称重 /** * 设置称重9校准砝码重量 * * @param value */ public void setCalibrationWeight9(short value, IWriteCallBack callback) { - ModbusTcpServer.get().WriteShort("VW254", value, callback); + ModbusTcpServer.get().WriteShort("VW30", value, callback); } /** @@ -914,4 +698,54 @@ public class DeviceData { public void setCodeClear(IWriteCallBack callback) { ModbusTcpServer.get().WriteString("VW342", 20, callback); } + //endregion + + //region 获取或设置保温箱温度信息 + /** + * 保温箱 + */ + int BWX_FructoseTemperature=0; + /** + * 获取保温箱实际温度 + * + * @return + */ + public int getBWX_FructoseTemperature() { + return BWX_FructoseTemperature; + } + public void setBWX_FructoseTemperature(int value, IWriteCallBack callback) { + ModbusTcpServer.get().WriteInt("VD372", value, callback); + } + /** + * 设置保温箱加热启动停止 + * + * @param value true:启动,flase:停止 + */ + public void setBWXSwitch(boolean value, IWriteCallBack callback) { + ModbusTcpServer.get().WriteBool("M102.0", value, callback); + } + /** + * 加热箱 + */ + int JRX_FructoseTemperature=0; + /** + * 获取加热箱实际温度 + * + * @return + */ + public int getJRX_FructoseTemperature() { + return JRX_FructoseTemperature; + } + public void setJRX_FructoseTemperature(int value, IWriteCallBack callback) { + ModbusTcpServer.get().WriteInt("VD380", value, callback); + } + /** + * 设置加热箱加热启动停止 + * + * @param value true:启动,flase:停止 + */ + public void setJRXSwitch(boolean value, IWriteCallBack callback) { + ModbusTcpServer.get().WriteBool("M103.4", 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 bab7b03..1e92692 100644 --- a/app/src/main/java/com/example/bpa/service/ReheatServer.java +++ b/app/src/main/java/com/example/bpa/service/ReheatServer.java @@ -125,8 +125,6 @@ public class ReheatServer { public void RunComplete() throws InterruptedException { } }); - - } catch (Exception ex) { MessageLog.ShowInfo("错误信息:" + ex.getMessage()); } diff --git a/app/src/main/java/com/example/bpa/view/adapter/lc_item_adapter.java b/app/src/main/java/com/example/bpa/view/adapter/lc_item_adapter.java index f4321d7..c8df26e 100644 --- a/app/src/main/java/com/example/bpa/view/adapter/lc_item_adapter.java +++ b/app/src/main/java/com/example/bpa/view/adapter/lc_item_adapter.java @@ -52,6 +52,7 @@ public class lc_item_adapter extends RecyclerView.Adapter datamaps = new LinkedHashMap(); + EditText mode_out_realvalue; + //endregion @@ -75,6 +74,24 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis Initdata(); startListening(); } + + @Override + protected void onDestroy() { + DeviceData.Get().setWeightCalibrationMode(false, new IWriteCallBack() { + + @Override + public void onSuccess() { + + } + + @Override + public void onFailure(String ErrorMsg) { + + } + }); + super.onDestroy(); + } + //endregion //region 公共函数 @@ -89,44 +106,16 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis String msg = getIntent().getStringExtra("data"); gongneng_title.setText(msg); //edittext - materialweight_edit = this.findViewById(R.id.materialweight_edit); outweight_edit = this.findViewById(R.id.outweight_edit); //switch out_switch = this.findViewById(R.id.out_switch); - marialmode_switch = this.findViewById(R.id.marialmode_switch); //button - mwSave_button = this.findViewById(R.id.mwSave_button); owSave_button = this.findViewById(R.id.owSave_button); - materilwrite_button = this.findViewById(R.id.materilwrite_button); - calibration_button = this.findViewById(R.id.calibration_button); zeroweight_button = this.findViewById(R.id.zeroweight_button); outWrite_button = this.findViewById(R.id.outWrite_button); zerocalibration_button = this.findViewById(R.id.zerocalibration_button); - - values_spinner = this.findViewById(R.id.values_spinner); - allcalibration_button = this.findViewById(R.id.allcalibration_button); //edit - mode_1_realvalue = this.findViewById(R.id.mode_1_realvalue); - mode_2_realvalue = this.findViewById(R.id.mode_2_realvalue); - mode_3_realvalue = this.findViewById(R.id.mode_3_realvalue); - mode_4_realvalue = this.findViewById(R.id.mode_4_realvalue); - mode_5_realvalue = this.findViewById(R.id.mode_5_realvalue); - mode_6_realvalue = this.findViewById(R.id.mode_6_realvalue); - mode_7_realvalue = this.findViewById(R.id.mode_7_realvalue); - mode_8_realvalue = this.findViewById(R.id.mode_8_realvalue); mode_out_realvalue = this.findViewById(R.id.mode_out_realvalue); - - - datamaps.put("称重_1", 1); - datamaps.put("称重_2", 2); - datamaps.put("称重_3", 3); - datamaps.put("称重_4", 4); - datamaps.put("称重_5", 5); - datamaps.put("称重_6", 6); - datamaps.put("称重_7", 7); - datamaps.put("称重_8", 8); - - } /** @@ -139,36 +128,19 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis dzcjy_activity.this.finish(); } }); - mwSave_button.setOnClickListener(this); owSave_button.setOnClickListener(this); - materilwrite_button.setOnClickListener(this); - calibration_button.setOnClickListener(this); zeroweight_button.setOnClickListener(this); outWrite_button.setOnClickListener(this); zerocalibration_button.setOnClickListener(this); - allcalibration_button.setOnClickListener(this); out_switch.setOnCheckedChangeListener(this); - marialmode_switch.setOnCheckedChangeListener(this); - - } /** * 初始化数据 */ private void Initdata() { - marialmode_switch.setChecked(DeviceData.Get().getCalibrationMode()); out_switch.setChecked(DeviceData.Get().getWeightCalibrationMode()); - materialweight_edit.setText("0"); outweight_edit.setText("0"); - //spinner绑定map数据 - ArrayAdapter adapter = new ArrayAdapter( - this, - R.layout.spinner_text_item, - new ArrayList(datamaps.keySet())); - adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); - values_spinner.setAdapter(adapter); - } /** @@ -183,15 +155,7 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis runOnUiThread(new Runnable() { @Override public void run() { - mode_1_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(1))); - mode_2_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(2))); - mode_3_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(3))); - mode_4_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(4))); - mode_5_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(5))); - mode_6_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(6))); - mode_7_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(7))); - mode_8_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(8))); - mode_out_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(9)/10.0)); + mode_out_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(1)/10.0)); } }); @@ -219,28 +183,12 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis public void onClick(View v) { new Thread(() -> { switch (v.getId()) { - case R.id.mwSave_button://物料砝码值保存 - String mwres = materialweight_edit.getText().toString().trim(); - if (!mwres.equals("")) { - DeviceData.Get().setCalibrationWeight(Short.parseShort(mwres), null); - } - break; case R.id.owSave_button://出口砝码值保存 String outres = outweight_edit.getText().toString().trim(); if (!outres.equals("")) { DeviceData.Get().setCalibrationWeight9(Short.parseShort(outres), null); } break; - case R.id.materilwrite_button://物料砝码值写入 - String s = String.valueOf(values_spinner.getSelectedItem()); - Integer value = datamaps.get(s); - DeviceData.Get().setWeightValue(true, value, null); - break; - case R.id.calibration_button://物料校准 - String s2 = String.valueOf(values_spinner.getSelectedItem()); - Integer value2 = datamaps.get(s2); - DeviceData.Get().setRemovePeelCalibration(true, value2, null); - break; case R.id.zeroweight_button://重量清零 DeviceData.Get().setWeightClear(null); break; @@ -250,9 +198,6 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis case R.id.zerocalibration_button://零点校准 DeviceData.Get().setZeroPointCalibration(null); break; - case R.id.allcalibration_button://一件去皮 - DeviceData.Get().setOneClickPeeling(null); - break; } }).start(); @@ -268,20 +213,6 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { - case R.id.marialmode_switch://称重模块校准 - DeviceData.Get().setCalibrationMode(isChecked, new IWriteCallBack() { - @Override - public void onSuccess() { - - } - - @Override - public void onFailure(String ErrorMsg) { - - } - }); - - break; case R.id.out_switch://出口称重模块校准 DeviceData.Get().setWeightCalibrationMode(isChecked, new IWriteCallBack() { diff --git a/app/src/main/java/com/example/bpa/view/from/lcsz_activity.java b/app/src/main/java/com/example/bpa/view/from/lcsz_activity.java index b0bd233..c2f9bcb 100644 --- a/app/src/main/java/com/example/bpa/view/from/lcsz_activity.java +++ b/app/src/main/java/com/example/bpa/view/from/lcsz_activity.java @@ -117,11 +117,10 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList // } List m = QueryDB.GetMaterialBySilosID(silo.id); if (m.size() > 0) { - datas.add(new lcMode(silo.id, silo.num, m.get(0).name, "0", m.get(0).id, silo.warningValue, silo.thrsoleValue)); + datas.add(new lcMode(silo.id, silo.num, m.get(0).name, "0", m.get(0).id, silo.warningValue, silo.thrsoleValue,silo.name)); } else { - datas.add(new lcMode(silo.id, silo.num, "未设置", "0", "", silo.warningValue, silo.thrsoleValue)); + datas.add(new lcMode(silo.id, silo.num, "未设置", "0", "", silo.warningValue, silo.thrsoleValue,silo.name)); } - } } lc_item_adapter adapter = new lc_item_adapter(this, datas); 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 e158d93..e4aefd8 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 @@ -27,7 +27,7 @@ import java.util.List; /** * 流速校验 */ -public class lsjy_activity extends AppCompatActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener { +public class lsjy_activity extends AppCompatActivity implements View.OnClickListener { //region 变量 /** * 返回按钮 @@ -141,17 +141,6 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList StartButton.setOnClickListener(this); SaveButton.setOnClickListener(this); ClearText.setOnClickListener(this); - //switch -// Switch_1.setOnCheckedChangeListener(this); -// Switch_2.setOnCheckedChangeListener(this); -// Switch_3.setOnCheckedChangeListener(this); -// Switch_4.setOnCheckedChangeListener(this); -// Switch_5.setOnCheckedChangeListener(this); -// Switch_6.setOnCheckedChangeListener(this); -// Switch_7.setOnCheckedChangeListener(this); -// Switch_8.setOnCheckedChangeListener(this); -// Switch_9.setOnCheckedChangeListener(this); -// Switch_10.setOnCheckedChangeListener(this); } /** @@ -203,7 +192,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList return; } - DeviceData.Get().setCalibrationReferenceTime(ftime, new IWriteCallBack() { + DeviceData.Get().setCalibrationReferenceTime((short) ftime, new IWriteCallBack() { @Override public void onSuccess() { T.show(lsjy_activity.this, "校准时间写入成功"); @@ -292,96 +281,6 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList break; } } - - /** - * 本页面switch点击事件监听 - * - * @param - */ - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { -// switch (buttonView.getId()) { -// case R.id.Switch_1: -// SwitchClick(1, isChecked); -// break; -// case R.id.Switch_2: -// SwitchClick(2, isChecked); -// break; -// case R.id.Switch_3: -// SwitchClick(3, isChecked); -// break; -// case R.id.Switch_4: -// SwitchClick(4, isChecked); -// break; -// case R.id.Switch_5: -// SwitchClick(5, isChecked); -// break; -// case R.id.Switch_6: -// SwitchClick(6, isChecked); -// break; -// case R.id.Switch_7: -// SwitchClick(7, isChecked); -// break; -// case R.id.Switch_8: -// SwitchClick(8, isChecked); -// break; -// case R.id.Switch_9: -// SwitchClick(9, isChecked); -// break; -// case R.id.Switch_10: -// SwitchClick(10, isChecked); -// break; -// } - - } - - /** - * switch切换 - * - * @param index - * @param isChecked - */ - private void SwitchClick(int index, boolean isChecked) { - StringBuffer sb = new StringBuffer("PLC写入:"); - new Thread(new Runnable() { - public void run() { - if (isChecked) { //校准开关开启状态才会写入值 - String value = editTextLists.get(index - 1).getText().toString(); - DeviceData.Get().setCalibrationValue(Short.parseShort(value), index, new IWriteCallBack() { - @Override - public void onSuccess() { - sb.append("通道"); - sb.append(index); - sb.append("校准值写入成功;"); - } - - @Override - public void onFailure(String ErrorMsg) { - sb.append("通道"); - sb.append(index); - sb.append("校准值写入失败;"); - } - }); - } - DeviceData.Get().setChCalibrationSwitch(isChecked, index, new IWriteCallBack() { - @Override - public void onSuccess() { - sb.append("通道"); - sb.append(index); - sb.append("校准开关成功;"); - } - - @Override - public void onFailure(String ErrorMsg) { - sb.append("通道"); - sb.append(index); - sb.append("校准开关失败;"); - } - }); - } - }); - T.show(lsjy_activity.this, sb.toString()); - } //endregion //region 线程 @@ -399,7 +298,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList @Override public void run() { try { - zhongliang.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(9)/10.0)+" g"); + zhongliang.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(1)/10.0)+" g"); } catch (Exception e) { MessageLog.ShowInfo("重量解析显示异常!"+e.getMessage()); } diff --git a/app/src/main/java/com/example/bpa/view/from/sdkz_new_Activity.java b/app/src/main/java/com/example/bpa/view/from/sdkz_new_Activity.java new file mode 100644 index 0000000..72a2b4c --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/from/sdkz_new_Activity.java @@ -0,0 +1,114 @@ +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.CompoundButton; +import android.widget.ImageView; +import android.widget.Switch; +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; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class sdkz_new_Activity extends AppCompatActivity implements View.OnClickListener{ + + //region 变量 + /** + * 返回按钮 + */ + ImageView gongneng_fanhui; + /** + * 标题设置 + */ + TextView gongneng_title; + //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_sdkz_new); + Init(); + initEvents(); + } + + @Override + protected void onDestroy() { + + try { + //设置自动模式 + DeviceData.Get().setHandOrAutoSwitch(true, null); + } catch (Exception e) { + + } + super.onDestroy(); + } + //endregion + + //region 公共函数 + + /** + * 初始化 + */ + private void Init(){ + gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui); + gongneng_title = this.findViewById(R.id.gongneng_title); + + //通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据 + String msg = getIntent().getStringExtra("data"); + gongneng_title.setText(msg); + + //校准开关 + Initdata(); + } + + /** + * 初始化按钮事件 + */ + private void initEvents() { + gongneng_fanhui.setOnClickListener(this); + //switch + } + + /** + * 初始化数据加载 + */ + public void Initdata() { + try { + + //设置手动模式 + DeviceData.Get().setHandOrAutoSwitch(false, null); + } catch (Exception e) { + + } + } + //endregion + + //region 点击事件 + /** + * 本页面点击事件监听 + * + * @param v + */ + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.gongneng_fanhui://返回按钮 + this.finish(); + break; + } + } + //endregion +} \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/mode/lcMode.java b/app/src/main/java/com/example/bpa/view/mode/lcMode.java index ff0419a..1b1c4b6 100644 --- a/app/src/main/java/com/example/bpa/view/mode/lcMode.java +++ b/app/src/main/java/com/example/bpa/view/mode/lcMode.java @@ -12,7 +12,7 @@ public class lcMode extends BPA_SILOS { public String silosmargin; //物料ID public String materialId; - public lcMode(String id, int num,String materialName, String silosmargin,String materialId,int warningValue,int thrsoleValue) { + public lcMode(String id, int num,String materialName, String silosmargin,String materialId,int warningValue,int thrsoleValue,String name) { this.materialName = materialName; this.silosmargin = silosmargin; this.num = num; @@ -20,6 +20,7 @@ public class lcMode extends BPA_SILOS { this.materialId = materialId; this.warningValue=warningValue; this.thrsoleValue=thrsoleValue; + this.name=name; } diff --git a/app/src/main/res/layout/from/layout/activity_dzcjy.xml b/app/src/main/res/layout/from/layout/activity_dzcjy.xml index eec9062..0038794 100644 --- a/app/src/main/res/layout/from/layout/activity_dzcjy.xml +++ b/app/src/main/res/layout/from/layout/activity_dzcjy.xml @@ -83,95 +83,12 @@ - - - - - - -