From cac2bc92bc8d87724ca38a17e6434266201c2d2c Mon Sep 17 00:00:00 2001 From: fyf Date: Thu, 5 Oct 2023 17:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E9=80=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/ExecuteTheRecipe.java | 320 ++++++++- .../common/constant/ConfigName.java | 679 ++++++++++-------- .../bnframework/common/constant/DataBus.java | 44 ++ .../common/db/res/SilosLsjyMode.java | 20 + .../bnframework/common/helper/ByteHelper.java | 13 + .../common/modbus/ModbusTcpServer.java | 53 +- .../common/tabbar/MainNavigateTabBar.java | 12 + .../BottomNavigationMainActivity.java | 106 ++- .../modules/home/adapter/lsjy_adapter.java | 183 +++++ .../from/fragment/JiaoYan_dzcjy_fragment.java | 67 +- .../from/fragment/JiaoYan_lsjy_fragment.java | 300 +++++++- .../res/layout/fragment_jiaoyan_dzcjy.xml | 4 +- .../main/res/layout/fragment_jiaoyan_lsjy.xml | 418 ++++++++++- .../main/res/layout/item/layout/lsjy_item.xml | 130 ++++ app/src/main/res/mipmap-xxhdpi/image1.jpg | Bin 13784 -> 0 bytes app/src/main/res/mipmap-xxhdpi/image1.png | Bin 0 -> 37322 bytes app/src/main/res/mipmap-xxhdpi/image2.jpg | Bin 103753 -> 0 bytes app/src/main/res/mipmap-xxhdpi/image2.png | Bin 0 -> 20912 bytes app/src/main/res/mipmap-xxhdpi/image3.jpg | Bin 137669 -> 0 bytes app/src/main/res/mipmap-xxhdpi/image3.png | Bin 0 -> 25008 bytes app/src/main/res/mipmap-xxhdpi/image4.jpg | Bin 90236 -> 0 bytes app/src/main/res/mipmap-xxhdpi/image4.png | Bin 0 -> 18430 bytes 22 files changed, 1954 insertions(+), 395 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/common/db/res/SilosLsjyMode.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/adapter/lsjy_adapter.java create mode 100644 app/src/main/res/layout/item/layout/lsjy_item.xml delete mode 100644 app/src/main/res/mipmap-xxhdpi/image1.jpg create mode 100644 app/src/main/res/mipmap-xxhdpi/image1.png delete mode 100644 app/src/main/res/mipmap-xxhdpi/image2.jpg create mode 100644 app/src/main/res/mipmap-xxhdpi/image2.png delete mode 100644 app/src/main/res/mipmap-xxhdpi/image3.jpg create mode 100644 app/src/main/res/mipmap-xxhdpi/image3.png delete mode 100644 app/src/main/res/mipmap-xxhdpi/image4.jpg create mode 100644 app/src/main/res/mipmap-xxhdpi/image4.png diff --git a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java index 362856ba..d1fdf37d 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -15,8 +15,12 @@ import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; import com.bonait.bnframework.common.db.mode.BPA_SILOS; import com.bonait.bnframework.common.helper.ByteHelper; +import com.bonait.bnframework.common.helper.I.IReadCallBack; +import com.bonait.bnframework.common.helper.I.IRun; +import com.bonait.bnframework.common.helper.I.IRunT; import com.bonait.bnframework.common.helper.I.IThread; import com.bonait.bnframework.common.helper.I.IWriteCallBack; +import com.bonait.bnframework.common.helper.RTrig; import com.bonait.bnframework.common.helper.ThreadManager; import com.bonait.bnframework.common.modbus.ModbusTcpServer; import com.bonait.bnframework.common.utils.AlertDialogUtils; @@ -51,6 +55,11 @@ public class ExecuteTheRecipe { */ public static HashMap ListeningValue = new HashMap(); + /** + * 实时状态 + */ + public static ConcurrentHashMap IoStatus = new ConcurrentHashMap(); + /** * 外部界面 */ @@ -71,6 +80,28 @@ public class ExecuteTheRecipe { * 当前工序的index */ static int Index_select=0; + + /** + * 扫码信息 + */ + public static String Code = ""; + /** + * 接收到扫码信息,返回 + */ + public static IRunT OnScanTheCodeInformationT; + /** + * 配料完成通知 + */ + public static IRun OnChargeMixtureCompleteNotify; + /** + * 通道配料完成通知 + */ + public static IRun OnChargeMixtureComNotPar; + /** + * 按钮按下通知 + */ + public static IRun OnIngredientButtonPressedNotify; + //endregion //region 强制结束 @@ -809,20 +840,6 @@ public class ExecuteTheRecipe { } } - new Thread(new Runnable() { - @Override - public void run() { - try { - WritePLC("初始化",true,null); - Thread.sleep(500); - WritePLC("初始化",false,null); - } catch (InterruptedException e) { - ToastUtils.info("异常信息:" + e.getMessage()); - } - } - }).start(); - - ThreadManager.Get().StartLong("PLC设备数据监听", true, new IThread() { @Override public void Run() throws InterruptedException { @@ -835,7 +852,39 @@ public class ExecuteTheRecipe { ListeningValue.put(key, val); } } + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + Thread.sleep(100); + } + + @Override + public void RunComplete() throws InterruptedException { + + } + }); + + ThreadManager.Get().StartLong("PLC设备数据监听-扫码信息", true, new IThread() { + @Override + public void Run() throws InterruptedException { + try { + ReadCode(); + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + Thread.sleep(100); + } + + @Override + public void RunComplete() throws InterruptedException { + + } + }); + ThreadManager.Get().StartLong("PLC设备数据监听-实时状态", true, new IThread() { + @Override + public void Run() throws InterruptedException { + try { ReadPLCStatus(); } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); @@ -848,6 +897,22 @@ public class ExecuteTheRecipe { } }); + + ThreadManager.Get().StartLong("PLC设备数据监听-信号检测", true, new IThread() { + @Override + public void Run() throws InterruptedException { + try { + ChargeSignal(); + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + Thread.sleep(10); + } + @Override + public void RunComplete() throws InterruptedException { + + } + }); } //endregion @@ -873,6 +938,23 @@ public class ExecuteTheRecipe { } else if (plcaddress.address.toUpperCase().startsWith("VW"))//short { ModbusTcpServer.get().WriteShort(plcaddress.address, Short.parseShort(value.toString()), callback); + }else if (plcaddress.address.toUpperCase().startsWith("VR"))//float + { + ModbusTcpServer.get().WriteFloat(plcaddress.address, Float.parseFloat(value.toString()), callback); + }else if (plcaddress.address.toUpperCase().startsWith("V") && plcaddress.address.contains("."))//位 + { + String[] res = plcaddress.address.split("[.]"); + String firstAdd = res[0]; //VW100 + int endAdd = Integer.parseInt(res[1]); //1 //第几位 + ModbusTcpServer.get().ReadShort(firstAdd, 1, new IReadCallBack() { + @Override + public void onSuccess(short[] shorts) { + Short val=shorts[0]; + Short valk= ByteHelper.setBit(val,endAdd,(boolean) value); + ModbusTcpServer.get().WriteShort(firstAdd, valk, null); + } + }); + ModbusTcpServer.get().WriteFloat(plcaddress.address, Float.parseFloat(value.toString()), callback); } } } @@ -897,7 +979,6 @@ public class ExecuteTheRecipe { if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) { if (plcaddress.address.toUpperCase().startsWith("VD"))//int { - ModbusTcpServer.get().ReadInt(plcaddress.address, 1, ints -> { ReturnsVariable[0] = ints[0]; }); @@ -911,6 +992,20 @@ public class ExecuteTheRecipe { ModbusTcpServer.get().ReadShort(plcaddress.address, 1, val -> { ReturnsVariable[0] = val[0]; }); + } else if (plcaddress.address.toUpperCase().startsWith("VR"))//float + { + ModbusTcpServer.get().ReadFloat(plcaddress.address, 1, val -> { + ReturnsVariable[0] = val[0]; + }); + }else if (plcaddress.address.toUpperCase().startsWith("V") && plcaddress.address.contains("."))//位 + { + String[] res = plcaddress.address.split("[.]"); + String firstAdd = res[0].replace("V","VW"); //VW194 + int endAdd = Integer.parseInt(res[1]); //1 //第几位 + ModbusTcpServer.get().ReadbcStatus(firstAdd, 1, data -> { + byte status=data[0];//0x92 + ReturnsVariable[0] = ByteHelper.getBit(status,endAdd)==1; + }); } } } @@ -921,10 +1016,6 @@ public class ExecuteTheRecipe { } } - /** - * 实时状态 - */ - public static ConcurrentHashMap IoStatus = new ConcurrentHashMap(); /** * 获取实时状态 @@ -970,31 +1061,112 @@ public class ExecuteTheRecipe { return ListeningValue.get(name); } + /** + * 获取校准值系数 + * + * @param ch 要获取的通道号 + * @return + */ + public static float getCalibrationValueXS(int ch) { + if (!ListeningValue.containsKey("出料系数"+ch)) + return 1.0F; + float k=Float.parseFloat(ListeningValue.get(ch).toString()); + return k==0?1.0F:k; + } + /** * 读取状态 */ public static void ReadPLCStatus() { try { - if (ConfigName.getInstance().PlcIsConnect) { - ModbusTcpServer.get().ReadStatus("VW354", 1, 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); - } - }); + if (ConfigName.getInstance().PLC_Address.containsKey("实时状态")) { + BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get("实时状态"); + if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) { + ModbusTcpServer.get().ReadStatus(plcaddress.address, 4, (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); + } + }); + } + } + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } finally { + } + } + + /** + * 读取扫码信息 + */ + public static void ReadCode() { + try { + if (ConfigName.getInstance().PLC_Address.containsKey("扫码数据")) { + BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get("扫码数据"); + if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) { + ModbusTcpServer.get().ReadString(plcaddress.address, 40, (data) -> { + + if (!Code.equals(data)) { + if (!data.isEmpty() && OnScanTheCodeInformationT != null) { + ToastUtils.error("当前扫码信息:" + data); + } + Code = data; + } + }); + } } } catch (Exception ex) { ToastUtils.error("异常信息:" + ex.getMessage()); } finally { } } + + /** + * 信号检测 + */ + public static void ChargeSignal() { + try { + + //配料完成 M0.3 + CompleteListen("配料完成", OnChargeMixtureCompleteNotify); + + //按钮状态 M0.5 + CompleteListen( "按钮启动", OnIngredientButtonPressedNotify); + + //校准校正完成信号 M0.7 + CompleteListen( "校准完成", OnChargeMixtureComNotPar); + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } finally { + } + } + + /** + * 完成信号监听 + * + * @param name 监听 KEY + * @param callback 执行委托 + */ + private static void CompleteListen(String name, IRun callback) { + if (ConfigName.getInstance().PLC_Address.containsKey(name)) { + BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name); + if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) { + ModbusTcpServer.get().ReadBool(plcaddress.address, 1, booleans -> { + RTrig.get(name).Start(booleans[0], () -> { + if (callback != null) + callback.Run(); + }); + }); + } + } + } //endregion //region 获取基础挡位变量 @@ -1025,4 +1197,86 @@ public class ExecuteTheRecipe { } } //endregion + + //region 电子称校验 + + /** + * 启动校验模式 + */ + public static boolean StartJiaoYanMode() + { + final boolean[] issucess1 = {false}; + final boolean[] issucess2 = {false}; + final boolean[] issucess3 = {false}; + + //写校准模式 + WritePLC("砝码校准模式", true, new IWriteCallBack() { + @Override + public void onSuccess() { + issucess1[0] =true; + } + + @Override + public void onFailure(String ErrorMsg) { + + } + }); + WritePLC("打开写保护", true, new IWriteCallBack() { + @Override + public void onSuccess() { + issucess2[0] =true; + } + @Override + public void onFailure(String ErrorMsg) { + + } + }); + + WritePLC("零点校准", true, new IWriteCallBack() { + @Override + public void onSuccess() { + issucess3[0] =true; + } + @Override + public void onFailure(String ErrorMsg) { + + } + }); + return issucess1[0] && issucess2[0]&& issucess3[0]; + } + + + /** + * 停止校验模式 + */ + public static boolean StopJiaoYanMode() + { + final boolean[] issucess1 = {false}; + final boolean[] issucess2 = {false}; + + //写校准模式 + WritePLC("砝码校准模式", false, new IWriteCallBack() { + @Override + public void onSuccess() { + issucess1[0] =true; + } + + @Override + public void onFailure(String ErrorMsg) { + + } + }); + WritePLC("打开写保护", false, new IWriteCallBack() { + @Override + public void onSuccess() { + issucess2[0] =true; + } + @Override + public void onFailure(String ErrorMsg) { + + } + }); + return issucess1[0] && issucess2[0]; + } + //endregion } diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java index 409717b1..01066304 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java @@ -244,136 +244,186 @@ public class ConfigName { */ public List PlcAddress_奶茶机 = new ArrayList() {{ - //硬件设备 初始化 - add(new Res_PLCADDRESS("硬件设备", "-------------", 0, 0)); - add(new Res_PLCADDRESS("初始化", "M10.0", 1, 1)); - add(new Res_PLCADDRESS("停止", "M10.1", 1, 1)); - add(new Res_PLCADDRESS("复位", "M10.2", 0, 1)); - - //搅拌模型 - add(new Res_PLCADDRESS("模型控制", "-------------", 0, 0)); - add(new Res_PLCADDRESS("搅拌", "M10.3", 0, 1)); - add(new Res_PLCADDRESS("搅拌速度", "VW102", 1, 1)); - - //翻转正转模型 - add(new Res_PLCADDRESS("翻转正转", "M10.4", 0, 1)); - add(new Res_PLCADDRESS("翻转反转", "M10.5", 0, 1)); - add(new Res_PLCADDRESS("转动速度", "VW104", 1, 1)); - - - //加热模型 - add(new Res_PLCADDRESS("加热", "M10.6", 0, 1)); - add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1)); - - //主料 - add(new Res_PLCADDRESS("主料", "M17.4", 0, 1)); - - //抽水放水 - add(new Res_PLCADDRESS("炒锅抽水", "M10.7", 0, 1)); - add(new Res_PLCADDRESS("炒锅放水", "M11.0", 0, 1)); - - - //出菜模型 - add(new Res_PLCADDRESS("出菜", "M11.5", 0, 1)); - - - //位置动作 - add(new Res_PLCADDRESS("原点位", "M11.4", 0, 1)); - add(new Res_PLCADDRESS("倒菜位", "M12.7", 0, 1)); - add(new Res_PLCADDRESS("抽料位", "M11.7", 0, 1)); - add(new Res_PLCADDRESS("清洗位", "M13.0", 0, 1)); - add(new Res_PLCADDRESS("炒菜位1", "M12.0", 0, 1)); - add(new Res_PLCADDRESS("炒菜位2", "M12.1", 0, 1)); - add(new Res_PLCADDRESS("炒菜位3", "M12.2", 0, 1)); - - add(new Res_PLCADDRESS("出餐启动", "M11.5", 0, 1)); - add(new Res_PLCADDRESS("炒锅清洗", "M11.6", 0, 1)); - - //液体料模型 - add(new Res_PLCADDRESS("料仓校准", "-------------", 0, 0)); - add(new Res_PLCADDRESS("校准时间", "VW112", 1, 1)); - add(new Res_PLCADDRESS("料仓1校准开关", "M12.3", 0, 1)); - add(new Res_PLCADDRESS("料仓1校准值", "VW114", 1, 1)); - add(new Res_PLCADDRESS("料仓2校准开关", "M12.4", 0, 1)); - add(new Res_PLCADDRESS("料仓2校准值", "VW116", 1, 1)); - add(new Res_PLCADDRESS("料仓3校准开关", "M12.5", 0, 1)); - add(new Res_PLCADDRESS("料仓3校准值", "VW118", 1, 1)); - add(new Res_PLCADDRESS("开始校正", "M12.6", 0, 1)); - - add(new Res_PLCADDRESS("料仓自动", "-------------", 0, 0)); - add(new Res_PLCADDRESS("料仓1需求值", "VW106", 1, 1)); - add(new Res_PLCADDRESS("料仓1下料", "M11.1", 0, 1)); - add(new Res_PLCADDRESS("料仓2需求值", "VW108", 1, 1)); - add(new Res_PLCADDRESS("料仓2下料", "M11.2", 0, 1)); - add(new Res_PLCADDRESS("料仓3需求值", "VW110", 1, 1)); - add(new Res_PLCADDRESS("料仓3下料", "M11.3", 0, 1)); - - add(new Res_PLCADDRESS("料仓手动", "-------------", 0, 0)); - add(new Res_PLCADDRESS("料仓1手动开关", "M13.1", 1, 1)); - add(new Res_PLCADDRESS("料仓2手动开关", "M13.2", 1, 1)); - add(new Res_PLCADDRESS("料仓3手动开关", "M13.3", 1, 1)); - - //上下限 - add(new Res_PLCADDRESS("位置上下限", "-------------", 0, 0)); - add(new Res_PLCADDRESS("原点位置下限", "VD150", 1, 1)); - add(new Res_PLCADDRESS("原点位置上限", "VD154", 1, 1)); - add(new Res_PLCADDRESS("洗锅位置下限", "VD158", 1, 1)); - add(new Res_PLCADDRESS("洗锅位置上限", "VD162", 1, 1)); - add(new Res_PLCADDRESS("倒菜位置下限", "VD166", 1, 1)); - add(new Res_PLCADDRESS("倒菜位置上限", "VD170", 1, 1)); - add(new Res_PLCADDRESS("抽调料位置下限", "VD174", 1, 1)); - add(new Res_PLCADDRESS("抽调料位置上限", "VD178", 1, 1)); - add(new Res_PLCADDRESS("1#炒制位置下限", "VD182", 1, 1)); - add(new Res_PLCADDRESS("1#炒制位置上限", "VD186", 1, 1)); - add(new Res_PLCADDRESS("2#炒制位置下限", "VD190", 1, 1)); - add(new Res_PLCADDRESS("2#炒制位置上限", "VD194", 1, 1)); - add(new Res_PLCADDRESS("3#炒制位置下限", "VD198", 1, 1)); - add(new Res_PLCADDRESS("3#炒制位置上限", "VD202", 1, 1)); - add(new Res_PLCADDRESS("炒锅工作范围下限", "VD206", 1, 1)); - add(new Res_PLCADDRESS("炒锅工作范围上限", "VD210", 1, 1)); - - //反馈信号 - add(new Res_PLCADDRESS("反馈信号", "-------------", 0, 0)); - add(new Res_PLCADDRESS("初始化完成", "M40.0", 1, 0)); - add(new Res_PLCADDRESS("设备急停", "M40.1", 1, 0)); - add(new Res_PLCADDRESS("原点位反馈", "M40.2", 1, 0)); - add(new Res_PLCADDRESS("抽料位反馈", "M40.3", 1, 0)); - add(new Res_PLCADDRESS("炒菜位1反馈", "M40.4", 1, 0)); - add(new Res_PLCADDRESS("炒菜位2反馈", "M40.5", 1, 0)); - add(new Res_PLCADDRESS("炒菜位3反馈", "M40.6", 1, 0)); - add(new Res_PLCADDRESS("倒菜位反馈", "M40.7", 1, 0)); - add(new Res_PLCADDRESS("投料位反馈", "M41.0", 1, 0)); - add(new Res_PLCADDRESS("清洗位反馈", "M41.1", 1, 0)); - add(new Res_PLCADDRESS("料仓1下料完成", "M41.2", 1, 0)); - add(new Res_PLCADDRESS("料仓2下料完成", "M41.3", 1, 0)); - add(new Res_PLCADDRESS("料仓3下料完成", "M41.4", 1, 0)); - add(new Res_PLCADDRESS("炒锅清洗反馈", "M41.5", 1, 0)); - add(new Res_PLCADDRESS("出餐启动反馈", "M41.6", 1, 0)); - add(new Res_PLCADDRESS("炒锅倒菜减速位", "M41.7", 1, 0)); - - //检测信号 - add(new Res_PLCADDRESS("监测信号", "-------------", 0, 0)); - add(new Res_PLCADDRESS("当前锅底温度", "VD300", 1, 0)); - add(new Res_PLCADDRESS("炒锅搅拌转速", "VD304", 1, 0)); - add(new Res_PLCADDRESS("当前加热档位", "VD308", 1, 0)); - add(new Res_PLCADDRESS("炒锅当前电压", "VD312", 1, 0)); - add(new Res_PLCADDRESS("炒锅当前电流", "VD316", 1, 0)); - add(new Res_PLCADDRESS("炒锅当前功率", "VD320", 1, 0)); - add(new Res_PLCADDRESS("搅拌频率", "VW324", 1, 0)); - add(new Res_PLCADDRESS("搅拌电机电流", "VW326", 1, 0)); - add(new Res_PLCADDRESS("搅拌电机电压", "VW328", 1, 0)); - add(new Res_PLCADDRESS("搅拌变频器温度", "VW330", 1, 0)); - add(new Res_PLCADDRESS("翻转频率", "VW332", 1, 0)); - add(new Res_PLCADDRESS("翻转电机电流", "VW334", 1, 0)); - add(new Res_PLCADDRESS("翻转电机电压", "VW336", 1, 0)); - add(new Res_PLCADDRESS("翻转变频器温度", "VW338", 1, 0)); - add(new Res_PLCADDRESS("编码器当前位值", "VD340", 1, 0)); - - //状态上报 - add(new Res_PLCADDRESS("状态上报", "-------------", 0, 0)); - add(new Res_PLCADDRESS("搅拌电机", "VW350", 1, 0)); - add(new Res_PLCADDRESS("翻转电机", "VW352", 1, 0)); - add(new Res_PLCADDRESS("炒锅", "VW354", 1, 0)); + //通道校准 + add(new Res_PLCADDRESS("通道校准", "-------------", 0, 0)); + add(new Res_PLCADDRESS("校准值1", "VW0", 1, 1)); + add(new Res_PLCADDRESS("校准值2", "VW2", 1, 1)); + add(new Res_PLCADDRESS("校准值3", "VW4", 1, 1)); + add(new Res_PLCADDRESS("校准值4", "VW6", 1, 1)); + add(new Res_PLCADDRESS("校准值5", "VW8", 1, 1)); + add(new Res_PLCADDRESS("校准值6", "VW10", 1, 1)); + add(new Res_PLCADDRESS("校准值7", "VW12", 1, 1)); + add(new Res_PLCADDRESS("校准值8", "VW14", 1, 1)); + add(new Res_PLCADDRESS("校准值9", "VW16", 1, 1)); + add(new Res_PLCADDRESS("校准值10", "VW18", 1, 1)); + add(new Res_PLCADDRESS("校准值11", "VW20", 1, 1)); + add(new Res_PLCADDRESS("校准值12", "VW22", 1, 1)); + add(new Res_PLCADDRESS("校准值13", "VW24", 1, 1)); + add(new Res_PLCADDRESS("校准值14", "VW26", 1, 1)); + add(new Res_PLCADDRESS("校准值15", "VW28", 1, 1)); + add(new Res_PLCADDRESS("校准值16", "VW30", 1, 1)); + add(new Res_PLCADDRESS("校准值17", "VW32", 1, 1)); + add(new Res_PLCADDRESS("校准值18", "VW34", 1, 1)); + add(new Res_PLCADDRESS("校准值19", "VW36", 1, 1)); + add(new Res_PLCADDRESS("校准值20", "VW38", 1, 1)); + + add(new Res_PLCADDRESS("通道1校准开关", "M2.0", 1, 1)); + add(new Res_PLCADDRESS("通道2校准开关", "M2.1", 1, 1)); + add(new Res_PLCADDRESS("通道3校准开关", "M2.2", 1, 1)); + add(new Res_PLCADDRESS("通道4校准开关", "M2.3", 1, 1)); + add(new Res_PLCADDRESS("通道5校准开关", "M2.4", 1, 1)); + add(new Res_PLCADDRESS("通道6校准开关", "M2.5", 1, 1)); + add(new Res_PLCADDRESS("通道7校准开关", "M2.6", 1, 1)); + add(new Res_PLCADDRESS("通道8校准开关", "M2.7", 1, 1)); + add(new Res_PLCADDRESS("通道9校准开关", "M3.0", 1, 1)); + add(new Res_PLCADDRESS("通道10校准开关", "M3.1", 1, 1)); + add(new Res_PLCADDRESS("通道11校准开关", "M3.2", 1, 1)); + add(new Res_PLCADDRESS("通道12校准开关", "M3.3", 1, 1)); + add(new Res_PLCADDRESS("通道13校准开关", "M3.4", 1, 1)); + add(new Res_PLCADDRESS("通道14校准开关", "M3.5", 1, 1)); + add(new Res_PLCADDRESS("通道15校准开关", "M3.6", 1, 1)); + add(new Res_PLCADDRESS("通道16校准开关", "M3.7", 1, 1)); + add(new Res_PLCADDRESS("通道17校准开关", "M4.0", 1, 1)); + add(new Res_PLCADDRESS("通道18校准开关", "M4.1", 1, 1)); + add(new Res_PLCADDRESS("通道19校准开关", "M4.2", 1, 1)); + add(new Res_PLCADDRESS("通道20校准开关", "M4.3", 1, 1)); + + add(new Res_PLCADDRESS("反转时间", "VW94", 0, 1)); + add(new Res_PLCADDRESS("基准时间", "VW98", 0, 1)); + + add(new Res_PLCADDRESS("通道校准", "M0.0", 0, 1)); + add(new Res_PLCADDRESS("校准完成", "M0.7", 1, 0)); + + add(new Res_PLCADDRESS("出料系数1", "VR400", 1, 1)); + add(new Res_PLCADDRESS("出料系数2", "VR404", 1, 1)); + add(new Res_PLCADDRESS("出料系数3", "VR408", 1, 1)); + add(new Res_PLCADDRESS("出料系数4", "VR412", 1, 1)); + add(new Res_PLCADDRESS("出料系数5", "VR416", 1, 1)); + add(new Res_PLCADDRESS("出料系数6", "VR420", 1, 1)); + add(new Res_PLCADDRESS("出料系数7", "VR424", 1, 1)); + add(new Res_PLCADDRESS("出料系数8", "VR428", 1, 1)); + add(new Res_PLCADDRESS("出料系数9", "VR432", 1, 1)); + add(new Res_PLCADDRESS("出料系数10", "VR436", 1, 1)); + add(new Res_PLCADDRESS("出料系数11", "VR440", 1, 1)); + add(new Res_PLCADDRESS("出料系数12", "VR444", 1, 1)); + add(new Res_PLCADDRESS("出料系数13", "VR448", 1, 1)); + add(new Res_PLCADDRESS("出料系数14", "VR452", 1, 1)); + add(new Res_PLCADDRESS("出料系数15", "VR456", 1, 1)); + add(new Res_PLCADDRESS("出料系数16", "VR460", 1, 1)); + add(new Res_PLCADDRESS("出料系数17", "VR464", 1, 1)); + add(new Res_PLCADDRESS("出料系数18", "VR468", 1, 1)); + add(new Res_PLCADDRESS("出料系数19", "VR472", 1, 1)); + add(new Res_PLCADDRESS("出料系数20", "VR476", 1, 1)); + + //模拟出料 + add(new Res_PLCADDRESS("模拟出料", "-------------", 0, 0)); + add(new Res_PLCADDRESS("需求值1", "VW100", 1, 1)); + add(new Res_PLCADDRESS("需求值2", "VW102", 1, 1)); + add(new Res_PLCADDRESS("需求值3", "VW104", 1, 1)); + add(new Res_PLCADDRESS("需求值4", "VW106", 1, 1)); + add(new Res_PLCADDRESS("需求值5", "VW108", 1, 1)); + add(new Res_PLCADDRESS("需求值6", "VW110", 1, 1)); + add(new Res_PLCADDRESS("需求值7", "VW112", 1, 1)); + add(new Res_PLCADDRESS("需求值8", "VW114", 1, 1)); + add(new Res_PLCADDRESS("需求值9", "VW116", 1, 1)); + add(new Res_PLCADDRESS("需求值10", "VW118", 1, 1)); + add(new Res_PLCADDRESS("需求值11", "VW120", 1, 1)); + add(new Res_PLCADDRESS("需求值12", "VW122", 1, 1)); + add(new Res_PLCADDRESS("需求值13", "VW124", 1, 1)); + add(new Res_PLCADDRESS("需求值14", "VW126", 1, 1)); + add(new Res_PLCADDRESS("需求值15", "VW128", 1, 1)); + add(new Res_PLCADDRESS("需求值16", "VW130", 1, 1)); + add(new Res_PLCADDRESS("需求值17", "VW132", 1, 1)); + add(new Res_PLCADDRESS("需求值18", "VW134", 1, 1)); + add(new Res_PLCADDRESS("需求值19", "VW136", 1, 1)); + add(new Res_PLCADDRESS("需求值20", "VW138", 1, 1)); + add(new Res_PLCADDRESS("配料启动", "M0.1", 0, 1)); + add(new Res_PLCADDRESS("手自切换", "M0.2", 1, 1)); + add(new Res_PLCADDRESS("配料完成", "M0.3", 1, 0)); + add(new Res_PLCADDRESS("按钮启动", "M0.5", 1, 0)); + + //出料算法补偿 + add(new Res_PLCADDRESS("出料算法补偿", "-------------", 0, 0)); + add(new Res_PLCADDRESS("低系数1", "VW44", 1, 1)); + add(new Res_PLCADDRESS("低系数2", "VW46", 1, 1)); + add(new Res_PLCADDRESS("低系数3", "VW48", 1, 1)); + add(new Res_PLCADDRESS("低系数4", "VW50", 1, 1)); + add(new Res_PLCADDRESS("低系数5", "VW52", 1, 1)); + add(new Res_PLCADDRESS("低系数6", "VW54", 1, 1)); + + add(new Res_PLCADDRESS("高系数1", "VW144", 1, 1)); + add(new Res_PLCADDRESS("高系数2", "VW146", 1, 1)); + add(new Res_PLCADDRESS("高系数3", "VW148", 1, 1)); + add(new Res_PLCADDRESS("高系数4", "VW150", 1, 1)); + add(new Res_PLCADDRESS("高系数5", "VW152", 1, 1)); + add(new Res_PLCADDRESS("高系数6", "VW154", 1, 1)); + + + add(new Res_PLCADDRESS("补偿1时间", "VW168", 1, 1)); + add(new Res_PLCADDRESS("补偿2时间", "VW170", 1, 1)); + add(new Res_PLCADDRESS("补偿3时间", "VW172", 1, 1)); + add(new Res_PLCADDRESS("补偿4时间", "VW174", 1, 1)); + add(new Res_PLCADDRESS("补偿5时间", "VW176", 1, 1)); + add(new Res_PLCADDRESS("补偿6时间", "VW178", 1, 1)); + + add(new Res_PLCADDRESS("通道1补偿开关", "V194.0", 1, 1)); + add(new Res_PLCADDRESS("通道2补偿开关", "V194.1", 1, 1)); + add(new Res_PLCADDRESS("通道3补偿开关", "V194.2", 1, 1)); + add(new Res_PLCADDRESS("通道4补偿开关", "V194.3", 1, 1)); + add(new Res_PLCADDRESS("通道5补偿开关", "V194.4", 1, 1)); + add(new Res_PLCADDRESS("通道6补偿开关", "V194.5", 1, 1)); + + //电子秤校验 + add(new Res_PLCADDRESS("电子秤校验", "-------------", 0, 0)); + add(new Res_PLCADDRESS("称当前重量", "VD344", 1, 0)); + add(new Res_PLCADDRESS("砝码值", "VW96", 1, 1)); + add(new Res_PLCADDRESS("砝码校准模式", "M1.0", 1, 1)); + add(new Res_PLCADDRESS("重量清零", "M1.1", 0, 1)); + add(new Res_PLCADDRESS("关闭写保护", "M1.2", 0, 1)); + add(new Res_PLCADDRESS("零点校准", "M1.3", 0, 1)); + add(new Res_PLCADDRESS("砝码值写入", "M1.4", 0, 1)); + add(new Res_PLCADDRESS("打开写保护", "M1.5", 0, 1)); + + //温度监控 + add(new Res_PLCADDRESS("温度控制", "-------------", 0, 0)); + add(new Res_PLCADDRESS("水池温度", "VD352", 1, 0)); + add(new Res_PLCADDRESS("水池温度设置", "VD360", 1, 1)); + + //手动控制 + add(new Res_PLCADDRESS("手动控制", "-------------", 0, 0)); + add(new Res_PLCADDRESS("M_外置仓1正转", "M50.0", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓2正转", "M50.1", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓3正转", "M50.2", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓4正转", "M50.3", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓5正转", "M50.4", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓6正转", "M50.5", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓1反转", "M50.6", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓2反转", "M50.7", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓3反转", "M51.0", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓4反转", "M51.1", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓5反转", "M51.2", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓6反转", "M51.3", 1, 1)); + add(new Res_PLCADDRESS("M_粉料通道1", "M51.4", 1, 1)); + add(new Res_PLCADDRESS("M_粉料通道2", "M51.5", 1, 1)); + add(new Res_PLCADDRESS("M_粉料通道3", "M51.6", 1, 1)); + add(new Res_PLCADDRESS("M_酱油通道", "M51.7", 1, 1)); + add(new Res_PLCADDRESS("M_醋通道", "M52.0", 1, 1)); + add(new Res_PLCADDRESS("M_猪油通道", "M52.1", 1, 1)); + add(new Res_PLCADDRESS("M_牛油通道", "M52.2", 1, 1)); + + add(new Res_PLCADDRESS("M_保温池进水阀", "M53.4", 1, 1)); + add(new Res_PLCADDRESS("M_保温池排水阀", "M53.5", 1, 1)); + add(new Res_PLCADDRESS("M_猪油管道保温", "M53.6", 1, 1)); + add(new Res_PLCADDRESS("M_牛油管道保温", "M53.7", 1, 1)); + add(new Res_PLCADDRESS("M_保温池加热", "M54.0", 1, 1)); + add(new Res_PLCADDRESS("M_三色灯-绿", "M54.1", 1, 1)); + add(new Res_PLCADDRESS("M_三色灯-红", "M54.2", 1, 1)); + + add(new Res_PLCADDRESS("扫码数据读取", "-------------", 0, 0)); + add(new Res_PLCADDRESS("扫码数据", "VW702", 1, 0)); + + add(new Res_PLCADDRESS("实时状态读取", "-------------", 0, 0)); + add(new Res_PLCADDRESS("实时状态", "VW500", 1, 0)); }}; /** * 奶茶机工序模型 @@ -411,195 +461,186 @@ public class ConfigName { */ public List PlcAddress_配料吧台 = new ArrayList() {{ - //硬件设备 初始化 - add(new Res_PLCADDRESS("硬件设备", "-------------", 0, 0)); - add(new Res_PLCADDRESS("初始化", "M10.0", 1, 1)); - add(new Res_PLCADDRESS("停止", "M10.1", 1, 1)); - add(new Res_PLCADDRESS("复位", "M10.2", 0, 1)); - - //搅拌模型 - add(new Res_PLCADDRESS("模型控制", "-------------", 0, 0)); - add(new Res_PLCADDRESS("搅拌", "M10.3", 0, 1)); - add(new Res_PLCADDRESS("搅拌速度", "VW102", 1, 1)); - - //翻转正转模型 - add(new Res_PLCADDRESS("翻转正转", "M10.4", 0, 1)); - add(new Res_PLCADDRESS("翻转反转", "M10.5", 0, 1)); - add(new Res_PLCADDRESS("转动速度", "VW104", 1, 1)); - - - //加热模型 - add(new Res_PLCADDRESS("加热", "M10.6", 0, 1)); - add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1)); - - //主料 - add(new Res_PLCADDRESS("主料", "M17.4", 0, 1)); - - //抽水放水 - add(new Res_PLCADDRESS("炒锅抽水", "M10.7", 0, 1)); - add(new Res_PLCADDRESS("炒锅放水", "M11.0", 0, 1)); - - - //出菜模型 - add(new Res_PLCADDRESS("出菜", "M11.5", 0, 1)); - - - //位置动作 - add(new Res_PLCADDRESS("原点位", "M11.4", 0, 1)); - add(new Res_PLCADDRESS("倒菜位", "M12.7", 0, 1)); - add(new Res_PLCADDRESS("抽料位", "M11.7", 0, 1)); - add(new Res_PLCADDRESS("清洗位", "M13.0", 0, 1)); - add(new Res_PLCADDRESS("炒菜位1", "M12.0", 0, 1)); - add(new Res_PLCADDRESS("炒菜位2", "M12.1", 0, 1)); - add(new Res_PLCADDRESS("炒菜位3", "M12.2", 0, 1)); - - add(new Res_PLCADDRESS("出餐启动", "M11.5", 0, 1)); - add(new Res_PLCADDRESS("炒锅清洗", "M11.6", 0, 1)); - - //液体料模型 - add(new Res_PLCADDRESS("料仓校准", "-------------", 0, 0)); - add(new Res_PLCADDRESS("校准时间", "VW112", 1, 1)); - add(new Res_PLCADDRESS("料仓1校准开关", "M12.3", 0, 1)); - add(new Res_PLCADDRESS("料仓1校准值", "VW114", 1, 1)); - add(new Res_PLCADDRESS("料仓2校准开关", "M12.4", 0, 1)); - add(new Res_PLCADDRESS("料仓2校准值", "VW116", 1, 1)); - add(new Res_PLCADDRESS("料仓3校准开关", "M12.5", 0, 1)); - add(new Res_PLCADDRESS("料仓3校准值", "VW118", 1, 1)); - add(new Res_PLCADDRESS("开始校正", "M12.6", 0, 1)); - - add(new Res_PLCADDRESS("料仓自动", "-------------", 0, 0)); - add(new Res_PLCADDRESS("料仓1需求值", "VW106", 1, 1)); - add(new Res_PLCADDRESS("料仓1下料", "M11.1", 0, 1)); - add(new Res_PLCADDRESS("料仓2需求值", "VW108", 1, 1)); - add(new Res_PLCADDRESS("料仓2下料", "M11.2", 0, 1)); - add(new Res_PLCADDRESS("料仓3需求值", "VW110", 1, 1)); - add(new Res_PLCADDRESS("料仓3下料", "M11.3", 0, 1)); - - add(new Res_PLCADDRESS("料仓手动", "-------------", 0, 0)); - add(new Res_PLCADDRESS("料仓1手动开关", "M13.1", 1, 1)); - add(new Res_PLCADDRESS("料仓2手动开关", "M13.2", 1, 1)); - add(new Res_PLCADDRESS("料仓3手动开关", "M13.3", 1, 1)); - - //上下限 - add(new Res_PLCADDRESS("位置上下限", "-------------", 0, 0)); - add(new Res_PLCADDRESS("原点位置下限", "VD150", 1, 1)); - add(new Res_PLCADDRESS("原点位置上限", "VD154", 1, 1)); - add(new Res_PLCADDRESS("洗锅位置下限", "VD158", 1, 1)); - add(new Res_PLCADDRESS("洗锅位置上限", "VD162", 1, 1)); - add(new Res_PLCADDRESS("倒菜位置下限", "VD166", 1, 1)); - add(new Res_PLCADDRESS("倒菜位置上限", "VD170", 1, 1)); - add(new Res_PLCADDRESS("抽调料位置下限", "VD174", 1, 1)); - add(new Res_PLCADDRESS("抽调料位置上限", "VD178", 1, 1)); - add(new Res_PLCADDRESS("1#炒制位置下限", "VD182", 1, 1)); - add(new Res_PLCADDRESS("1#炒制位置上限", "VD186", 1, 1)); - add(new Res_PLCADDRESS("2#炒制位置下限", "VD190", 1, 1)); - add(new Res_PLCADDRESS("2#炒制位置上限", "VD194", 1, 1)); - add(new Res_PLCADDRESS("3#炒制位置下限", "VD198", 1, 1)); - add(new Res_PLCADDRESS("3#炒制位置上限", "VD202", 1, 1)); - add(new Res_PLCADDRESS("炒锅工作范围下限", "VD206", 1, 1)); - add(new Res_PLCADDRESS("炒锅工作范围上限", "VD210", 1, 1)); - - //自动投料-平移轴 - add(new Res_PLCADDRESS("平移轴控制", "-------------", 0, 0)); - add(new Res_PLCADDRESS("平移-伺服当前值", "VD220", 1, 1)); - add(new Res_PLCADDRESS("平移-点动速度", "VD224", 1, 1)); - add(new Res_PLCADDRESS("平移-回原点速度", "VD228", 1, 1)); - add(new Res_PLCADDRESS("平移-定位运行速度", "VD232", 1, 1)); - - add(new Res_PLCADDRESS("平移-点动正转", "M14.0", 0, 1)); - add(new Res_PLCADDRESS("平移-点动反转", "M14.1", 0, 1)); - add(new Res_PLCADDRESS("平移-回原点", "M14.2", 0, 1)); - add(new Res_PLCADDRESS("平移-去1号位", "M14.3", 0, 1)); - add(new Res_PLCADDRESS("平移-去2号位", "M14.4", 0, 1)); - add(new Res_PLCADDRESS("平移-去3号位", "M14.5", 0, 1)); - add(new Res_PLCADDRESS("平移-去4号位", "M14.6", 0, 1)); - - add(new Res_PLCADDRESS("平移-1号位置值", "VD236", 1, 1)); - add(new Res_PLCADDRESS("平移-1#位置设定", "M15.0", 0, 1)); - add(new Res_PLCADDRESS("平移-2号位置值", "VD240", 1, 1)); - add(new Res_PLCADDRESS("平移-2#位置设定", "M15.1", 0, 1)); - add(new Res_PLCADDRESS("平移-3号位置值", "VD244", 1, 1)); - add(new Res_PLCADDRESS("平移-3#位置设定", "M15.2", 0, 1)); - add(new Res_PLCADDRESS("平移-4号位置值", "VD248", 1, 1)); - add(new Res_PLCADDRESS("平移-4#位置设定", "M15.3", 0, 1)); - - //自动投料-翻转轴 - add(new Res_PLCADDRESS("翻转轴控制", "-------------", 0, 0)); - add(new Res_PLCADDRESS("翻转-伺服当前值", "VD260", 1, 1)); - add(new Res_PLCADDRESS("翻转-点动速度", "VD264", 1, 1)); - add(new Res_PLCADDRESS("翻转-回原点速度", "VD268", 1, 1)); - add(new Res_PLCADDRESS("翻转-定位运行速度", "VD272", 1, 1)); - - add(new Res_PLCADDRESS("翻转-点动正转", "M16.0", 0, 1)); - add(new Res_PLCADDRESS("翻转-点动反转", "M16.1", 0, 1)); - add(new Res_PLCADDRESS("翻转-回原点", "M16.2", 0, 1)); - add(new Res_PLCADDRESS("翻转-去1号位", "M16.3", 0, 1)); - add(new Res_PLCADDRESS("翻转-去2号位", "M16.4", 0, 1)); - add(new Res_PLCADDRESS("翻转-去3号位", "M16.5", 0, 1)); - add(new Res_PLCADDRESS("翻转-去4号位", "M16.6", 0, 1)); - - add(new Res_PLCADDRESS("翻转-1号位置值", "VD276", 1, 1)); - add(new Res_PLCADDRESS("翻转-1#位置设定", "M17.0", 0, 1)); - add(new Res_PLCADDRESS("翻转-2号位置值", "VD280", 1, 1)); - add(new Res_PLCADDRESS("翻转-2#位置设定", "M17.1", 0, 1)); - add(new Res_PLCADDRESS("翻转-3号位置值", "VD284", 1, 1)); - add(new Res_PLCADDRESS("翻转-3#位置设定", "M17.2", 0, 1)); - add(new Res_PLCADDRESS("翻转-4号位置值", "VD288", 1, 1)); - add(new Res_PLCADDRESS("翻转-4#位置设定", "M17.3", 0, 1)); - add(new Res_PLCADDRESS("倒菜启动", "M17.4", 0, 1)); - add(new Res_PLCADDRESS("磁铁吸合", "M17.5", 0, 1)); - - //反馈信号 - add(new Res_PLCADDRESS("反馈信号", "-------------", 0, 0)); - add(new Res_PLCADDRESS("初始化完成", "M40.0", 1, 0)); - add(new Res_PLCADDRESS("设备急停", "M40.1", 1, 0)); - add(new Res_PLCADDRESS("原点位反馈", "M40.2", 1, 0)); - add(new Res_PLCADDRESS("抽料位反馈", "M40.3", 1, 0)); - add(new Res_PLCADDRESS("炒菜位1反馈", "M40.4", 1, 0)); - add(new Res_PLCADDRESS("炒菜位2反馈", "M40.5", 1, 0)); - add(new Res_PLCADDRESS("炒菜位3反馈", "M40.6", 1, 0)); - add(new Res_PLCADDRESS("倒菜位反馈", "M40.7", 1, 0)); - add(new Res_PLCADDRESS("投料位反馈", "M41.0", 1, 0)); - add(new Res_PLCADDRESS("清洗位反馈", "M41.1", 1, 0)); - add(new Res_PLCADDRESS("料仓1下料完成", "M41.2", 1, 0)); - add(new Res_PLCADDRESS("料仓2下料完成", "M41.3", 1, 0)); - add(new Res_PLCADDRESS("料仓3下料完成", "M41.4", 1, 0)); - add(new Res_PLCADDRESS("炒锅清洗反馈", "M41.5", 1, 0)); - add(new Res_PLCADDRESS("出餐启动反馈", "M41.6", 1, 0)); - add(new Res_PLCADDRESS("炒锅倒菜减速位", "M41.7", 1, 0)); - add(new Res_PLCADDRESS("平移轴在1号位", "M43.0", 1, 0)); - add(new Res_PLCADDRESS("平移轴在2号位", "M43.1", 1, 0)); - add(new Res_PLCADDRESS("平移轴在3号位", "M43.2", 1, 0)); - add(new Res_PLCADDRESS("平移轴在4号位", "M43.3", 1, 0)); - add(new Res_PLCADDRESS("翻转轴在1号位", "M44.0", 1, 0)); - add(new Res_PLCADDRESS("翻转轴在2号位", "M44.1", 1, 0)); - add(new Res_PLCADDRESS("翻转轴在3号位", "M44.2", 1, 0)); - add(new Res_PLCADDRESS("翻转轴在4号位", "M44.3", 1, 0)); - add(new Res_PLCADDRESS("倒菜完成", "M44.4", 1, 0)); - - //检测信号 - add(new Res_PLCADDRESS("监测信号", "-------------", 0, 0)); - add(new Res_PLCADDRESS("当前锅底温度", "VD300", 1, 0)); - add(new Res_PLCADDRESS("炒锅搅拌转速", "VD304", 1, 0)); - add(new Res_PLCADDRESS("当前加热档位", "VD308", 1, 0)); - add(new Res_PLCADDRESS("炒锅当前电压", "VD312", 1, 0)); - add(new Res_PLCADDRESS("炒锅当前电流", "VD316", 1, 0)); - add(new Res_PLCADDRESS("炒锅当前功率", "VD320", 1, 0)); - add(new Res_PLCADDRESS("搅拌频率", "VW324", 1, 0)); - add(new Res_PLCADDRESS("搅拌电机电流", "VW326", 1, 0)); - add(new Res_PLCADDRESS("搅拌电机电压", "VW328", 1, 0)); - add(new Res_PLCADDRESS("搅拌变频器温度", "VW330", 1, 0)); - add(new Res_PLCADDRESS("翻转频率", "VW332", 1, 0)); - add(new Res_PLCADDRESS("翻转电机电流", "VW334", 1, 0)); - add(new Res_PLCADDRESS("翻转电机电压", "VW336", 1, 0)); - add(new Res_PLCADDRESS("翻转变频器温度", "VW338", 1, 0)); - add(new Res_PLCADDRESS("编码器当前位值", "VD340", 1, 0)); - - //状态上报 - add(new Res_PLCADDRESS("状态上报", "-------------", 0, 0)); - add(new Res_PLCADDRESS("搅拌电机", "VW350", 1, 0)); - add(new Res_PLCADDRESS("翻转电机", "VW352", 1, 0)); - add(new Res_PLCADDRESS("炒锅", "VW354", 1, 0)); + //通道校准 + add(new Res_PLCADDRESS("通道校准", "-------------", 0, 0)); + add(new Res_PLCADDRESS("校准值1", "VW0", 1, 1)); + add(new Res_PLCADDRESS("校准值2", "VW2", 1, 1)); + add(new Res_PLCADDRESS("校准值3", "VW4", 1, 1)); + add(new Res_PLCADDRESS("校准值4", "VW6", 1, 1)); + add(new Res_PLCADDRESS("校准值5", "VW8", 1, 1)); + add(new Res_PLCADDRESS("校准值6", "VW10", 1, 1)); + add(new Res_PLCADDRESS("校准值7", "VW12", 1, 1)); + add(new Res_PLCADDRESS("校准值8", "VW14", 1, 1)); + add(new Res_PLCADDRESS("校准值9", "VW16", 1, 1)); + add(new Res_PLCADDRESS("校准值10", "VW18", 1, 1)); + add(new Res_PLCADDRESS("校准值11", "VW20", 1, 1)); + add(new Res_PLCADDRESS("校准值12", "VW22", 1, 1)); + add(new Res_PLCADDRESS("校准值13", "VW24", 1, 1)); + add(new Res_PLCADDRESS("校准值14", "VW26", 1, 1)); + add(new Res_PLCADDRESS("校准值15", "VW28", 1, 1)); + add(new Res_PLCADDRESS("校准值16", "VW30", 1, 1)); + add(new Res_PLCADDRESS("校准值17", "VW32", 1, 1)); + add(new Res_PLCADDRESS("校准值18", "VW34", 1, 1)); + add(new Res_PLCADDRESS("校准值19", "VW36", 1, 1)); + add(new Res_PLCADDRESS("校准值20", "VW38", 1, 1)); + + add(new Res_PLCADDRESS("通道1校准开关", "M2.0", 1, 1)); + add(new Res_PLCADDRESS("通道2校准开关", "M2.1", 1, 1)); + add(new Res_PLCADDRESS("通道3校准开关", "M2.2", 1, 1)); + add(new Res_PLCADDRESS("通道4校准开关", "M2.3", 1, 1)); + add(new Res_PLCADDRESS("通道5校准开关", "M2.4", 1, 1)); + add(new Res_PLCADDRESS("通道6校准开关", "M2.5", 1, 1)); + add(new Res_PLCADDRESS("通道7校准开关", "M2.6", 1, 1)); + add(new Res_PLCADDRESS("通道8校准开关", "M2.7", 1, 1)); + add(new Res_PLCADDRESS("通道9校准开关", "M3.0", 1, 1)); + add(new Res_PLCADDRESS("通道10校准开关", "M3.1", 1, 1)); + add(new Res_PLCADDRESS("通道11校准开关", "M3.2", 1, 1)); + add(new Res_PLCADDRESS("通道12校准开关", "M3.3", 1, 1)); + add(new Res_PLCADDRESS("通道13校准开关", "M3.4", 1, 1)); + add(new Res_PLCADDRESS("通道14校准开关", "M3.5", 1, 1)); + add(new Res_PLCADDRESS("通道15校准开关", "M3.6", 1, 1)); + add(new Res_PLCADDRESS("通道16校准开关", "M3.7", 1, 1)); + add(new Res_PLCADDRESS("通道17校准开关", "M4.0", 1, 1)); + add(new Res_PLCADDRESS("通道18校准开关", "M4.1", 1, 1)); + add(new Res_PLCADDRESS("通道19校准开关", "M4.2", 1, 1)); + add(new Res_PLCADDRESS("通道20校准开关", "M4.3", 1, 1)); + + add(new Res_PLCADDRESS("反转时间", "VW94", 0, 1)); + add(new Res_PLCADDRESS("基准时间", "VW98", 0, 1)); + + add(new Res_PLCADDRESS("通道校准", "M0.0", 0, 1)); + add(new Res_PLCADDRESS("校准完成", "M0.7", 1, 0)); + + add(new Res_PLCADDRESS("出料系数1", "VR400", 1, 1)); + add(new Res_PLCADDRESS("出料系数2", "VR404", 1, 1)); + add(new Res_PLCADDRESS("出料系数3", "VR408", 1, 1)); + add(new Res_PLCADDRESS("出料系数4", "VR412", 1, 1)); + add(new Res_PLCADDRESS("出料系数5", "VR416", 1, 1)); + add(new Res_PLCADDRESS("出料系数6", "VR420", 1, 1)); + add(new Res_PLCADDRESS("出料系数7", "VR424", 1, 1)); + add(new Res_PLCADDRESS("出料系数8", "VR428", 1, 1)); + add(new Res_PLCADDRESS("出料系数9", "VR432", 1, 1)); + add(new Res_PLCADDRESS("出料系数10", "VR436", 1, 1)); + add(new Res_PLCADDRESS("出料系数11", "VR440", 1, 1)); + add(new Res_PLCADDRESS("出料系数12", "VR444", 1, 1)); + add(new Res_PLCADDRESS("出料系数13", "VR448", 1, 1)); + add(new Res_PLCADDRESS("出料系数14", "VR452", 1, 1)); + add(new Res_PLCADDRESS("出料系数15", "VR456", 1, 1)); + add(new Res_PLCADDRESS("出料系数16", "VR460", 1, 1)); + add(new Res_PLCADDRESS("出料系数17", "VR464", 1, 1)); + add(new Res_PLCADDRESS("出料系数18", "VR468", 1, 1)); + add(new Res_PLCADDRESS("出料系数19", "VR472", 1, 1)); + add(new Res_PLCADDRESS("出料系数20", "VR476", 1, 1)); + + //模拟出料 + add(new Res_PLCADDRESS("模拟出料", "-------------", 0, 0)); + add(new Res_PLCADDRESS("需求值1", "VW100", 1, 1)); + add(new Res_PLCADDRESS("需求值2", "VW102", 1, 1)); + add(new Res_PLCADDRESS("需求值3", "VW104", 1, 1)); + add(new Res_PLCADDRESS("需求值4", "VW106", 1, 1)); + add(new Res_PLCADDRESS("需求值5", "VW108", 1, 1)); + add(new Res_PLCADDRESS("需求值6", "VW110", 1, 1)); + add(new Res_PLCADDRESS("需求值7", "VW112", 1, 1)); + add(new Res_PLCADDRESS("需求值8", "VW114", 1, 1)); + add(new Res_PLCADDRESS("需求值9", "VW116", 1, 1)); + add(new Res_PLCADDRESS("需求值10", "VW118", 1, 1)); + add(new Res_PLCADDRESS("需求值11", "VW120", 1, 1)); + add(new Res_PLCADDRESS("需求值12", "VW122", 1, 1)); + add(new Res_PLCADDRESS("需求值13", "VW124", 1, 1)); + add(new Res_PLCADDRESS("需求值14", "VW126", 1, 1)); + add(new Res_PLCADDRESS("需求值15", "VW128", 1, 1)); + add(new Res_PLCADDRESS("需求值16", "VW130", 1, 1)); + add(new Res_PLCADDRESS("需求值17", "VW132", 1, 1)); + add(new Res_PLCADDRESS("需求值18", "VW134", 1, 1)); + add(new Res_PLCADDRESS("需求值19", "VW136", 1, 1)); + add(new Res_PLCADDRESS("需求值20", "VW138", 1, 1)); + add(new Res_PLCADDRESS("配料启动", "M0.1", 0, 1)); + add(new Res_PLCADDRESS("手自切换", "M0.2", 1, 1)); + add(new Res_PLCADDRESS("配料完成", "M0.3", 1, 0)); + add(new Res_PLCADDRESS("按钮启动", "M0.5", 1, 0)); + + //出料算法补偿 + add(new Res_PLCADDRESS("出料算法补偿", "-------------", 0, 0)); + add(new Res_PLCADDRESS("低系数1", "VW44", 1, 1)); + add(new Res_PLCADDRESS("低系数2", "VW46", 1, 1)); + add(new Res_PLCADDRESS("低系数3", "VW48", 1, 1)); + add(new Res_PLCADDRESS("低系数4", "VW50", 1, 1)); + add(new Res_PLCADDRESS("低系数5", "VW52", 1, 1)); + add(new Res_PLCADDRESS("低系数6", "VW54", 1, 1)); + + add(new Res_PLCADDRESS("高系数1", "VW144", 1, 1)); + add(new Res_PLCADDRESS("高系数2", "VW146", 1, 1)); + add(new Res_PLCADDRESS("高系数3", "VW148", 1, 1)); + add(new Res_PLCADDRESS("高系数4", "VW150", 1, 1)); + add(new Res_PLCADDRESS("高系数5", "VW152", 1, 1)); + add(new Res_PLCADDRESS("高系数6", "VW154", 1, 1)); + + + add(new Res_PLCADDRESS("补偿1时间", "VW168", 1, 1)); + add(new Res_PLCADDRESS("补偿2时间", "VW170", 1, 1)); + add(new Res_PLCADDRESS("补偿3时间", "VW172", 1, 1)); + add(new Res_PLCADDRESS("补偿4时间", "VW174", 1, 1)); + add(new Res_PLCADDRESS("补偿5时间", "VW176", 1, 1)); + add(new Res_PLCADDRESS("补偿6时间", "VW178", 1, 1)); + + add(new Res_PLCADDRESS("通道1补偿开关", "V194.0", 1, 1)); + add(new Res_PLCADDRESS("通道2补偿开关", "V194.1", 1, 1)); + add(new Res_PLCADDRESS("通道3补偿开关", "V194.2", 1, 1)); + add(new Res_PLCADDRESS("通道4补偿开关", "V194.3", 1, 1)); + add(new Res_PLCADDRESS("通道5补偿开关", "V194.4", 1, 1)); + add(new Res_PLCADDRESS("通道6补偿开关", "V194.5", 1, 1)); + + //电子秤校验 + add(new Res_PLCADDRESS("电子秤校验", "-------------", 0, 0)); + add(new Res_PLCADDRESS("称当前重量", "VD344", 1, 0)); + add(new Res_PLCADDRESS("砝码值", "VW96", 1, 1)); + add(new Res_PLCADDRESS("砝码校准模式", "M1.0", 1, 1)); + add(new Res_PLCADDRESS("重量清零", "M1.1", 0, 1)); + add(new Res_PLCADDRESS("关闭写保护", "M1.2", 0, 1)); + add(new Res_PLCADDRESS("零点校准", "M1.3", 0, 1)); + add(new Res_PLCADDRESS("砝码值写入", "M1.4", 0, 1)); + add(new Res_PLCADDRESS("打开写保护", "M1.5", 0, 1)); + + //温度监控 + add(new Res_PLCADDRESS("温度控制", "-------------", 0, 0)); + add(new Res_PLCADDRESS("水池温度", "VD352", 1, 0)); + add(new Res_PLCADDRESS("水池温度设置", "VD360", 1, 1)); + + //手动控制 + add(new Res_PLCADDRESS("手动控制", "-------------", 0, 0)); + add(new Res_PLCADDRESS("M_外置仓1正转", "M50.0", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓2正转", "M50.1", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓3正转", "M50.2", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓4正转", "M50.3", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓5正转", "M50.4", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓6正转", "M50.5", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓1反转", "M50.6", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓2反转", "M50.7", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓3反转", "M51.0", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓4反转", "M51.1", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓5反转", "M51.2", 1, 1)); + add(new Res_PLCADDRESS("M_外置仓6反转", "M51.3", 1, 1)); + add(new Res_PLCADDRESS("M_粉料通道1", "M51.4", 1, 1)); + add(new Res_PLCADDRESS("M_粉料通道2", "M51.5", 1, 1)); + add(new Res_PLCADDRESS("M_粉料通道3", "M51.6", 1, 1)); + add(new Res_PLCADDRESS("M_酱油通道", "M51.7", 1, 1)); + add(new Res_PLCADDRESS("M_醋通道", "M52.0", 1, 1)); + add(new Res_PLCADDRESS("M_猪油通道", "M52.1", 1, 1)); + add(new Res_PLCADDRESS("M_牛油通道", "M52.2", 1, 1)); + + add(new Res_PLCADDRESS("M_保温池进水阀", "M53.4", 1, 1)); + add(new Res_PLCADDRESS("M_保温池排水阀", "M53.5", 1, 1)); + add(new Res_PLCADDRESS("M_猪油管道保温", "M53.6", 1, 1)); + add(new Res_PLCADDRESS("M_牛油管道保温", "M53.7", 1, 1)); + add(new Res_PLCADDRESS("M_保温池加热", "M54.0", 1, 1)); + add(new Res_PLCADDRESS("M_三色灯-绿", "M54.1", 1, 1)); + add(new Res_PLCADDRESS("M_三色灯-红", "M54.2", 1, 1)); + + add(new Res_PLCADDRESS("扫码数据读取", "-------------", 0, 0)); + add(new Res_PLCADDRESS("扫码数据", "VW702", 1, 0)); + + add(new Res_PLCADDRESS("实时状态读取", "-------------", 0, 0)); + add(new Res_PLCADDRESS("实时状态", "VW500", 1, 0)); }}; /** diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java index d0baac56..283c4c28 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java @@ -3,6 +3,7 @@ package com.bonait.bnframework.common.constant; import android.content.Intent; import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_ALERTLOG; import com.bonait.bnframework.common.db.mode.BPA_GOODS; @@ -13,12 +14,14 @@ import com.bonait.bnframework.common.db.mode.BPA_SUBORDER; import com.bonait.bnframework.common.db.res.MakeStatus; import com.bonait.bnframework.common.db.res.ResGoodsMake; 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.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 java.util.ArrayList; @@ -281,4 +284,45 @@ public class DataBus { */ public ArrayList Recipe=new ArrayList<>(); //endregion + + //region 流速校验 + public ArrayList SilosLsjy = new ArrayList(); + public lsjy_adapter lsjyAdapter=null; + /** + * 获取流速料仓数据 + */ + public void GetSilosLsjy() + { + try { + SilosLsjy=new ArrayList<>(); + //获取料仓数据 + ArrayList bpa_silos = QueryDB.GetSilosALL(); + //加载materials数据 + if (bpa_silos.size() > 0) { + for (BPA_SILOS silo : bpa_silos) { + List m = QueryDB.GetMaterialBySilosID(silo.id); + + SilosLsjyMode mode=new SilosLsjyMode(); + mode.num= silo.num; + mode.name= silo.name; + mode.materialName=m.size() > 0?m.get(0).name:"未设置"; + mode.xs= ExecuteTheRecipe.getCalibrationValueXS(silo.num)+""; + Object kg=ExecuteTheRecipe.getListingValue("通道"+silo.num+"校准开关"); + Object _val=ExecuteTheRecipe.getListingValue("校准值"+silo.num); + short val=_val==null?0:(short)_val; + String s = String.valueOf(val); + mode.jzkg= kg==null?false:(boolean) kg; + mode.Value= String.format("%.1f", (Double.parseDouble(s) / 10)); + SilosLsjy.add(mode); + } + } + if (lsjyAdapter!=null) + { + lsjyAdapter.refresh(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + //endregion } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/res/SilosLsjyMode.java b/app/src/main/java/com/bonait/bnframework/common/db/res/SilosLsjyMode.java new file mode 100644 index 00000000..8ac7475e --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/db/res/SilosLsjyMode.java @@ -0,0 +1,20 @@ +package com.bonait.bnframework.common.db.res; + +public class SilosLsjyMode { + //料仓编号:1、2、3 + public int num; + //料仓名称 + public String name; + //PLC控制信号量 + public String plcValue; + //PLC校准信号量 + public String plcjzValue; + //物料名称 + public String materialName; + //系数 + public String xs; + //校准开关 + public boolean jzkg; + //通道校准值 + public String Value; +} diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/ByteHelper.java b/app/src/main/java/com/bonait/bnframework/common/helper/ByteHelper.java index 67627bf7..a14dd7a2 100644 --- a/app/src/main/java/com/bonait/bnframework/common/helper/ByteHelper.java +++ b/app/src/main/java/com/bonait/bnframework/common/helper/ByteHelper.java @@ -133,4 +133,17 @@ public class ByteHelper { return bit; } + public static short setBit(short num, int position, boolean value) { + if (position < 0 || position > 15) { + return num; + } + if (value) { + num |= (1 << position); + } else { + num &= ~(1 << position); + } + + return num; + } + } diff --git a/app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpServer.java b/app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpServer.java index 758545ec..f4e69e04 100644 --- a/app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpServer.java +++ b/app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpServer.java @@ -384,9 +384,42 @@ public class ModbusTcpServer { try { ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length); byte[] data = res.getData(); - byte[] tempData = new byte[6]; + byte[] tempData = new byte[8]; tempData[0] = data[1]; tempData[1] = data[0]; + tempData[2] = data[3]; + tempData[3] = data[2]; + tempData[4] = data[5]; + tempData[5] = data[4]; + tempData[6] = data[7]; + tempData[7] = data[6]; + if (callback != null) callback.onSuccess(tempData); + } catch (InterruptedException e) { + MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); + } catch (ExecutionException e) { + MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); + } catch (ModbusTransportException e) { + MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); + } catch (ModbusInitException e) { + MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); + } catch (ModbusRespException e) { + MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); + } + } + /** + * 读取补偿算法 + * @param Address + * @param length + * @param callback + */ + public void ReadbcStatus(String Address, int length, IReadCallBack callback) { + int add = GetAddress(Address); + if (add < 0) return; + try { + ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length); + byte[] data = res.getData(); + byte[] tempData = new byte[1]; + tempData[0] = data[1]; if (callback != null) callback.onSuccess(tempData); } catch (InterruptedException e) { MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString()); @@ -401,6 +434,7 @@ public class ModbusTcpServer { } } + /*** *读取扫码数据 * @param Address the address @@ -413,11 +447,12 @@ public class ModbusTcpServer { try { ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length); byte[] data = res.getData(); - byte[] data1 = Arrays.copyOfRange(data, 0, 18); + byte[] data1 = Arrays.copyOfRange(data, 0, data.length); //36 GUID 18 Number String id = ""; try { - byte[] tempdata = new byte[18]; + byte[] tempdata = new byte[data.length]; + int index=0; for (int i = 0; i < data1.length; i++) { if (i % 2 == 0) { @@ -425,7 +460,13 @@ public class ModbusTcpServer { } else { tempdata[i - 1] = data1[i]; } + + if (data1[i]==0 && index==0) + { + index=i; + } } + id = new String(tempdata, "UTF-8").trim(); } catch (UnsupportedEncodingException ex) { } @@ -521,7 +562,7 @@ public class ModbusTcpServer { int add = GetAddress(Address); if (add < 0) return; try { - ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length); + ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length*2); byte[] data = res.getData(); float[] tempValues = new float[length]; for (int i = 0; i < length; i++) { @@ -529,7 +570,7 @@ public class ModbusTcpServer { for (int m = 0; m < 4; m++) { tempData[m] = data[i * 4 + m]; } - tempValues[i] = BytesToFloat(tempData, DataFormat.ABCD); + tempValues[i] = BytesToFloat(tempData, DataFormat.BADC); } if (tempValues.length == length) { if (callback != null) callback.onSuccess(tempValues); @@ -642,7 +683,7 @@ public class ModbusTcpServer { int add = GetAddress(Address); if (add < 0) return; int intBits = Float.floatToRawIntBits(Value); - short[] send = new short[]{(short) ((intBits >> 16) & 0xffff), (short) (intBits & 0xffff)}; + short[] send = IntToShorts(intBits); try { ModbusTcpHelper.get().syncWriteRegisters(1, add, send); diff --git a/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java b/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java index 87ac1cd5..d39e307c 100644 --- a/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java +++ b/app/src/main/java/com/bonait/bnframework/common/tabbar/MainNavigateTabBar.java @@ -19,6 +19,7 @@ import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentTransaction; import com.bonait.bnframework.R; +import com.bonait.bnframework.common.constant.DataBus; import java.util.ArrayList; import java.util.List; @@ -346,6 +347,17 @@ public class MainNavigateTabBar extends LinearLayout implements View.OnClickList if (index >= 0 && index < mViewHolderList.size()) { ViewHolder holder = mViewHolderList.get(index); showFragment(holder); + + + } + } + + public void SetDataResh(int index) + { + if(index==1)//校验 + { + //刷新料仓 + DataBus.getInstance().GetSilosLsjy(); } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java index 7d61e589..ded61cf7 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java @@ -6,16 +6,23 @@ import androidx.fragment.app.Fragment; import androidx.viewpager.widget.ViewPager; import android.os.Bundle; +import android.util.Log; import android.view.MenuItem; import android.widget.RelativeLayout; import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ConfigData; import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.MessageName; +import com.bonait.bnframework.common.helper.I.IThread; +import com.bonait.bnframework.common.helper.MessageLog; +import com.bonait.bnframework.common.helper.ThreadManager; import com.bonait.bnframework.common.message.MessageLooper; import com.bonait.bnframework.common.message.MessageManager; +import com.bonait.bnframework.common.modbus.ModbusTcpServer; import com.bonait.bnframework.common.tabbar.MainNavigateTabBar; +import com.bonait.bnframework.common.utils.NetworkUtils; import com.bonait.bnframework.modules.home.adapter.FragmentAdapter; import com.bonait.bnframework.modules.home.fragment.DingDanfragment; import com.bonait.bnframework.modules.home.fragment.GongnengFragment; @@ -63,6 +70,14 @@ public class BottomNavigationMainActivity extends BaseActivity { initFragment(); } + + @Override + protected void onDestroy() { + //关闭PLC连接 + ConfigData.getInstance().ColsePLC(); + super.onDestroy(); + } + private List fragmentList; /** * viewPager里添加fragment @@ -85,6 +100,73 @@ public class BottomNavigationMainActivity extends BaseActivity { viewPager.setCurrentItem(3); } + + /** + * 初始化 + */ + public void Init() + { + //1.同步时间 + NetworkUtils.SynchronizationTime(); + //主持 + ConfigData.getInstance().GetOrganize(this); + //判断连接环境 + ConfigData.getInstance().ToggleEnvironment(); + //2.初始化PLC + ReconnectModbus(); + //初始化阿里云连接 + //AliyunIOTManager.getInstance().OpenDev(this); + } + + + /** + * 重新连接plc + */ + public void ReconnectModbus() + { + try { + + ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() { + @Override + public void Run() throws InterruptedException { + try { + if(ConfigName.getInstance().PlcIsConnect) + { + //ping 不通 + boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address,1,1); + if(!status) //ping 不通 连接 + { + MessageLog.ShowInfo("PLC状态断开,尝试连接..."); + ConfigName.getInstance().PlcIsConnect=false; + } + }else + { + boolean status = ModbusTcpServer.ping2(ConfigName.getInstance().Address,1,1); + if(status) + { + MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!"); + ModbusTcpServer.ConnectPLC(); + }else + { + MessageLog.ShowInfo("PLC状态断开,尝试连接..."); + ConfigName.getInstance().PlcIsConnect=false; + } + } + Thread.sleep(10000); + } catch (Exception e) { + Log.i("PLC", "PLC重连接失败!"+e.getMessage()); + } + } + @Override + public void RunComplete() throws InterruptedException { + } + }); + }catch (Exception e) { + MessageLog.ShowInfo("重新连接Modbus异常," +e.getMessage()); + } + } + + /** * 配置bottom底部菜单栏监听器,手指点击底部菜单监听 */ @@ -92,29 +174,26 @@ public class BottomNavigationMainActivity extends BaseActivity { = new MainNavigateTabBar.OnTabSelectedListener() { @Override public void onTabSelected(MainNavigateTabBar.ViewHolder holder) { + int _postion=3; switch (holder.tag) { case "功能": - viewPager.setCurrentItem(0); + _postion=0; break; - case "校验": - viewPager.setCurrentItem(1); + case "校验":_postion=1; break; - case "订单": - viewPager.setCurrentItem(2); + case "订单":_postion=2; break; - case "管理": - viewPager.setCurrentItem(4); + case "管理":_postion=4; break; - case "设置": - viewPager.setCurrentItem(5); + case "设置":_postion=5; break; - case "我的": - viewPager.setCurrentItem(6); + case "我的":_postion=6; break; - case "": - viewPager.setCurrentItem(3); + case "":_postion=3; break; } + viewPager.setCurrentItem(_postion); + mNavigateTabBar.SetDataResh(_postion); } }; /** @@ -127,6 +206,7 @@ public class BottomNavigationMainActivity extends BaseActivity { @Override public void onPageSelected(int position) { mNavigateTabBar.setCurrentSelectedTab(position); + mNavigateTabBar.SetDataResh(position); } @Override public void onPageScrollStateChanged(int state) { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lsjy_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lsjy_adapter.java new file mode 100644 index 00000000..464cffd1 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/lsjy_adapter.java @@ -0,0 +1,183 @@ +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.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.db.res.SilosLsjyMode; +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 lsjy_adapter extends RecyclerView.Adapter { + + private final LayoutInflater mLayoutInflater; + + private Context context; + + public List mainGoods = DataBus.getInstance().SilosLsjy; + + public lsjy_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.lsjy_item, parent, false); + return new MyGoodLCViewHolder(inflate); + + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + try { + if (holder instanceof MyGoodLCViewHolder) { + MyGoodLCViewHolder myViewHolder = (MyGoodLCViewHolder) holder; + SilosLsjyMode goodsMake= mainGoods.get(position); + String name= "通道"+goodsMake.num+"(" +goodsMake.name+")"; + myViewHolder.name.setText(name+""); + myViewHolder.wlname.setText(goodsMake.materialName+""); + myViewHolder.edittext_xs.setText(goodsMake.xs+""); + myViewHolder.control_switch.setChecked(goodsMake.jzkg); + myViewHolder.edittext_tdzl.setText(goodsMake.Value+""); + + myViewHolder.control_switch.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(SwitchButton view, boolean isChecked) { + //boolean ischick= myViewHolder.control_switch.isChecked(); + DataBus.getInstance().SilosLsjy.get(position).jzkg=isChecked; + ExecuteTheRecipe.WritePLC("通道" + goodsMake.num+"校准开关", isChecked, null); + //goodsMake.jzkg=ischick; + //notifyDataSetChanged(); +// ExecuteTheRecipe.WritePLC("通道1校准开关",ischick,null); +// ToastUtils.info("写入地址:"+model.address+"成功!状态:"+(ischick?"打开":"关闭")); + } + }); + + myViewHolder.save_value.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String value = myViewHolder.edittext_tdzl.getText().toString(); + String value1=myViewHolder.edittext_xs.getText().toString(); + Short val = 0; + float xs= 1.0F; + try { + val = (short) Math.round((Double.parseDouble(value) * 10)); + xs=Float.parseFloat(value1); + } catch (Exception e) { + } + + ExecuteTheRecipe.WritePLC("出料系数"+goodsMake.num,xs,null); + ExecuteTheRecipe.WritePLC("校准值" + goodsMake.num, val, new IWriteCallBack() { + @Override + public void onSuccess() { + ToastUtils.info(name+"保存成功!"); + } + + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error(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 { + mainGoods.clear(); + mainGoods = DataBus.getInstance().SilosLsjy; + notifyDataSetChanged(); + } catch (Exception e) { + + } + } + }); + } + } + + @Override + public int getItemCount() { + return mainGoods.size(); + } + + public static class MyGoodLCViewHolder extends RecyclerView.ViewHolder { + /** + * 通道名称 + */ + TextView name; + /** + * 物料名称 + */ + TextView wlname; + /** + * 系数 + */ + EditText edittext_xs; + /** + * 校准开关 + */ + SwitchButton control_switch; + /** + * 通道重量 + */ + EditText edittext_tdzl; + /** + * 保存值 + */ + Button save_value; + public MyGoodLCViewHolder(View view) { + super(view); + name = (TextView) view.findViewById(R.id.name); + wlname = (TextView) view.findViewById(R.id.wlname); + edittext_xs=(EditText) view.findViewById(R.id.edittext_xs); + control_switch = (SwitchButton)view.findViewById(R.id.control_switch); + edittext_tdzl=(EditText) view.findViewById(R.id.edittext_tdzl); + save_value=(Button) view.findViewById(R.id.save_value); + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_dzcjy_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_dzcjy_fragment.java index 30013944..76358414 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_dzcjy_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_dzcjy_fragment.java @@ -12,14 +12,18 @@ import android.os.Message; import android.text.InputType; import android.view.LayoutInflater; import android.view.View; +import android.widget.Button; +import android.widget.EditText; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.base.BaseFragment; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.helper.I.IWriteCallBack; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.utils.NetworkUtils; import com.bonait.bnframework.common.utils.ToastUtils; @@ -27,12 +31,21 @@ import com.bonait.bnframework.modules.home.adapter.wl_adapter; import com.orhanobut.logger.Logger; import com.qmuiteam.qmui.widget.dialog.QMUIDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; +import com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout; +import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; public class JiaoYan_dzcjy_fragment extends BaseFragment { + @BindView(R.id.ldjz) + Button ldjz;//零点校准 + @BindView(R.id.edittext_zl) + EditText edittext_zl;//砝码重量 + @BindView(R.id.jzzl) + Button jzzl;//校正重量 + private Context context; @Override protected View onCreateView() { @@ -48,6 +61,7 @@ public class JiaoYan_dzcjy_fragment extends BaseFragment { context = getContext(); InitView(); } + /** * 初始化界面 */ @@ -56,14 +70,51 @@ public class JiaoYan_dzcjy_fragment extends BaseFragment { } -// @OnClick({R.id.add_wl}) -// public void onViewClicked(View view) { -// switch (view.getId()) { -// case R.id.add_wl: -// -// break; -// } -// } + boolean IsOpen=false; + @OnClick({R.id.ldjz,R.id.jzzl}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.ldjz://零点校准 + IsOpen= ExecuteTheRecipe.StartJiaoYanMode(); + if(IsOpen) + { + ToastUtils.info("开启零点校正成功!"); + }else + { + ToastUtils.error("开启零点校正失败,请检测plc连接!"); + } + break; + case R.id.jzzl://校正重量 + if(!IsOpen) + { + ToastUtils.info("请先点击[零点校正],进入校正模式!"); + return; + } + + String outres = edittext_zl.getText().toString().trim(); + if (!outres.equals("")) { + ExecuteTheRecipe.WritePLC("砝码值", Short.parseShort(outres), new IWriteCallBack() { + @Override + public void onSuccess() { + ExecuteTheRecipe.WritePLC("砝码值写入",true,null); + ToastUtils.info("校正重量成功!"); + } + + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error("校正重量失败!"); + } + }); + }else + { + ToastUtils.info("砝码值不能为空!"); + } + + ExecuteTheRecipe.StopJiaoYanMode(); + IsOpen=false; + break; + } + } //region 数据加载 diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java index eba95899..f8c0b15f 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java @@ -3,21 +3,53 @@ 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; +import android.os.Handler; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.base.BaseFragment; +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.helper.I.IRun; +import com.bonait.bnframework.common.helper.I.IWriteCallBack; +import com.bonait.bnframework.common.helper.WrapContentLinearLayoutManager; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.adapter.lsjy_adapter; import com.orhanobut.logger.Logger; +import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; public class JiaoYan_lsjy_fragment extends BaseFragment { + @BindView(R.id.Recy_Lsjy) + RecyclerView Recy_Lsjy;//流速校验 + + @BindView(R.id.zhongliang) + TextView zhongliang;//实时重量 + + @BindView(R.id.edittext_jzsj) + EditText edittext_jzsj;//校准时间 + + @BindView(R.id.edittext_fzsj) + EditText edittext_fzsj;//反转时间 + + @BindView(R.id.edittext_cl) + EditText edittext_cl;//出料重量 private Context context; @Override protected View onCreateView() { @@ -40,28 +72,280 @@ public class JiaoYan_lsjy_fragment extends BaseFragment { Initdata(); } + public int selectIndexSilos=-99; + + @OnClick({R.id.save_jzsj,R.id.save_fzsj + ,R.id.czql,R.id.save_czql,R.id.ksjz + ,R.id.kscl + }) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.save_jzsj://保存校准时间 + try { + String stime = edittext_jzsj.getText().toString(); + if (stime.equals("")) { + ToastUtils.info("校准基准时间不能为空!"); + return; + } + int ftime = 0; + try { + ftime = (int) Math.round((Double.parseDouble(stime) * 10)); + } catch (Exception e) { + ToastUtils.error("校准基准时间异常!" + e.getMessage()); + return; + } + ExecuteTheRecipe.WritePLC("基准时间", (short) ftime, new IWriteCallBack() { + @Override + public void onSuccess() { + ToastUtils.info("校准基准时间保存成功!"); + } + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error("校准基准时间保存失败!"); + } + }); + } catch (WindowManager.BadTokenException e) { + ToastUtils.error("校准基准时间保存配置异常!" + e.getMessage()); + } + break; + case R.id.save_fzsj://保存反转时间 + try { + String stime = edittext_fzsj.getText().toString(); + if (stime.equals("")) { + ToastUtils.info("反转时间不能为空!"); + return; + } + int ftime = 0; + try { + ftime = (int) Math.round((Double.parseDouble(stime) * 10)); + } catch (Exception e) { + ToastUtils.error("反转时间异常!" + e.getMessage()); + return; + } + ExecuteTheRecipe.WritePLC("反转时间", (short) ftime, new IWriteCallBack() { + @Override + public void onSuccess() { + ToastUtils.info("反转时间保存成功!"); + } + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error("反转时间保存失败!"); + } + }); + } catch (WindowManager.BadTokenException e) { + ToastUtils.error("反转时间保存配置异常!" + e.getMessage()); + } + break; + case R.id.czql://称重清零 + case R.id.save_czql: + ExecuteTheRecipe.WritePLC("重量清零", true, new IWriteCallBack() { + @Override + public void onSuccess() { + ToastUtils.info("清零成功!"); + } + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error("清零失败!"); + } + }); + break; + case R.id.ksjz://开始校准 + //切换手动 + //region 判断是否只勾选了一个料仓 + SelectSilos(); + //endregion + + ExecuteTheRecipe.WritePLC("手自切换", false, null); + ExecuteTheRecipe.WritePLC("通道校准", true, new IWriteCallBack() { + @Override + public void onSuccess() { + ToastUtils.info("启动通道校准成功!"); + } + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error("启动通道校准失败!"); + } + }); + break; + case R.id.kscl://开始出料 + String zltext = edittext_cl.getText().toString(); + if (zltext.equals("")) { + ToastUtils.warning("出料重量不能为空!"); + return; + } + double zl = 0; + try { + zl = Double.parseDouble(zltext); + } catch (Exception e) { + ToastUtils.warning("出料重量获取异常!" + e.getMessage()); + return; + } + + if(zl<=1) + { + ToastUtils.warning("出料重量至少大于1g!"); + return; + } -// @OnClick({R.id.add_wl}) -// public void onViewClicked(View view) { -// switch (view.getId()) { -// case R.id.add_wl: -// -// break; -// } -// } + //region 判断是否只勾选了一个料仓 + SelectSilos(); + //endregion + + if (selectIndexSilos==-88) + { + ToastUtils.warning("只能打开一个通道开关!"); + return; + } + + if (selectIndexSilos<=0) + { + ToastUtils.warning("请打开通道开关!"); + return; + } + + ExecuteTheRecipe.WritePLC("手自切换", true, null); + ExecuteTheRecipe.WritePLC("需求值" + selectIndexSilos, (short) ((int) (zl * 10)), new IWriteCallBack() { + @Override + public void onSuccess() { + ToastUtils.warning("需求值下发成功!开始配料......"); + ExecuteTheRecipe.WritePLC("配料启动", true, null); + } + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error("需求值下发失败!请稍后重试......"); + } + }); + break; + } + } + + /** + * 判断是否只勾选了一个料仓 + */ + public void SelectSilos() + { + //region 判断是否只勾选了一个料仓 + selectIndexSilos=-99; + for (SilosLsjyMode item:DataBus.getInstance().SilosLsjy) + { + if(item.jzkg) + { + if(selectIndexSilos==-99) + { + selectIndexSilos=item.num; + }else + { + selectIndexSilos=-88; + } + } + } + //endregion + } //region 数据加载 /** * 初始化数据加载 */ public void Initdata() { try { + //顶部料仓信息 + DataBus.getInstance().GetSilosLsjy(); + Recy_Lsjy.setLayoutManager(new WrapContentLinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL,false)); + DataBus.getInstance().lsjyAdapter = new lsjy_adapter(getContext()); + Recy_Lsjy.setAdapter(DataBus.getInstance().lsjyAdapter); + + //底部按钮信息 + Object obj= ExecuteTheRecipe.ReadPLC("基准时间"); + String time = obj==null?"0":obj.toString(); + //校准时间 + edittext_jzsj.setText(String.format("%.1f", (Double.parseDouble(time) / 10))); + Object obj1= ExecuteTheRecipe.ReadPLC("反转时间"); + String fztime = obj1==null?"0":obj1.toString(); + edittext_fzsj.setText(String.format("%.1f", (Double.parseDouble(fztime) / 10))); } catch (Exception e) { } } + + + /** + * 实时显示线程 + */ + public void Run() { + new Thread(new Runnable() { + @Override + public void run() { + while (ConfigName.getInstance().PlcIsConnect) { + try { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + try { + Object obj= ExecuteTheRecipe.ReadPLC("称当前重量"); + zhongliang.setText(String.valueOf((int)obj / 10.0) + " g"); + } catch (Exception e) { + ToastUtils.error("重量解析显示异常!" + e.getMessage()); + } + } + }); + Thread.sleep(50); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + }).start(); + + ExecuteTheRecipe.OnChargeMixtureComNotPar = new IRun() { + @Override + public void Run() { + if (selectIndexSilos > 0) { + final int kkk = selectIndexSilos; + try { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + try { + // 在2秒后执行按钮操作 + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + Object obj= ExecuteTheRecipe.ReadPLC("称当前重量"); + int val = (int)obj; + val=val<=0?0:val; + + ExecuteTheRecipe.WritePLC("校准值"+kkk,(short) val,null); + + String s = String.valueOf(val); + for (SilosLsjyMode item:DataBus.getInstance().SilosLsjy) + { + if(selectIndexSilos==item.num) + { + item.Value=String.format("%.1f", (Double.parseDouble(s) / 10)); + } + } + if (DataBus.getInstance().lsjyAdapter!=null) + { + DataBus.getInstance().lsjyAdapter.refresh(); + } + + } + }, 2000); + } catch (Exception e) { + ToastUtils.error("重量解析显示异常!" + e.getMessage()); + } + } + }); + } catch (Exception ex) { + Log.d("dsds", "Run: " + ex.getMessage()); + } + selectIndexSilos = -99; + } + } + }; + } //endregion @Override diff --git a/app/src/main/res/layout/fragment_jiaoyan_dzcjy.xml b/app/src/main/res/layout/fragment_jiaoyan_dzcjy.xml index ac9c078c..d07d65f3 100644 --- a/app/src/main/res/layout/fragment_jiaoyan_dzcjy.xml +++ b/app/src/main/res/layout/fragment_jiaoyan_dzcjy.xml @@ -29,7 +29,7 @@ android:layout_height="26dp" android:layout_centerInParent="true" android:background="@drawable/bg_btn_login_selected" - android:text="零点校准" + android:text="零点校正" android:textColor="@color/white" android:textSize="14dp" /> @@ -77,7 +77,7 @@ android:textAlignment="center" />