From fefd03a59b71afbdbd7c4e650b3690e31beaec2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Mon, 2 Sep 2024 16:36:20 +0800 Subject: [PATCH] =?UTF-8?q?plc=E9=80=9A=E8=AE=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnframework/business/PlcReadHelper.java | 181 +++++++++++++++++- .../newui/activity/MainHActivity.java | 1 - 2 files changed, 179 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/bonait/bnframework/business/PlcReadHelper.java b/app/src/main/java/com/bonait/bnframework/business/PlcReadHelper.java index 606842cc..3f397179 100644 --- a/app/src/main/java/com/bonait/bnframework/business/PlcReadHelper.java +++ b/app/src/main/java/com/bonait/bnframework/business/PlcReadHelper.java @@ -18,10 +18,185 @@ public class PlcReadHelper { } + public List PlcAddress_Wok= 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", 1, 1)); + + //搅拌模型 + add(new Res_PLCADDRESS("模型控制", "-------------", 0, 0)); + add(new Res_PLCADDRESS("搅拌", "M10.3", 1, 1)); + add(new Res_PLCADDRESS("搅拌速度", "VW102", 1, 1)); + + //翻转正转模型 + add(new Res_PLCADDRESS("翻转正转", "M10.4", 1, 1)); + add(new Res_PLCADDRESS("翻转反转", "M10.5", 1, 1)); + add(new Res_PLCADDRESS("转动速度", "VW104", 1, 1)); + + + //加热模型 + add(new Res_PLCADDRESS("加热", "M10.6", 1, 1)); + add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1)); + add(new Res_PLCADDRESS("温控开关", "M17.6", 1, 1)); + add(new Res_PLCADDRESS("暂停开关", "M17.7", 1, 1)); + + + //抽水放水 + add(new Res_PLCADDRESS("炒锅抽水", "M10.7", 1, 1)); + add(new Res_PLCADDRESS("炒锅放水", "M11.0", 1, 1)); + + + //出菜模型 + add(new Res_PLCADDRESS("出菜", "M11.5", 1, 1)); + + + //位置动作 + add(new Res_PLCADDRESS("原点位", "M11.4", 1, 1)); + add(new Res_PLCADDRESS("倒菜位", "M12.7", 1, 1)); + add(new Res_PLCADDRESS("抽料位", "M11.7", 1, 1)); + add(new Res_PLCADDRESS("维护位", "M20.0", 1, 1)); + add(new Res_PLCADDRESS("清洗位", "M13.0", 1, 1)); + add(new Res_PLCADDRESS("炒菜位1", "M12.0", 1, 1)); + add(new Res_PLCADDRESS("炒菜位高", "M12.1", 1, 1)); + add(new Res_PLCADDRESS("炒菜位2", "M12.1", 1, 1)); + add(new Res_PLCADDRESS("炒菜位低", "M12.2", 1, 1)); + add(new Res_PLCADDRESS("炒菜位3", "M12.2", 1, 1)); + + add(new Res_PLCADDRESS("出餐启动", "M11.5", 1, 1)); + add(new Res_PLCADDRESS("炒锅清洗", "M11.6", 1, 1)); + + //深度清洗功能 + add(new Res_PLCADDRESS("深度清洗功能", "-------------", 0, 0)); + add(new Res_PLCADDRESS("清洗抽水量", "VW122", 1, 1)); + add(new Res_PLCADDRESS("清洗时间", "VW1150", 1, 1)); + add(new Res_PLCADDRESS("倒水减速角度", "VW1152", 1, 1)); + add(new Res_PLCADDRESS("深度清洗", "M13.6", 1, 1)); + add(new Res_PLCADDRESS("编码器复位", "M13.7", 1, 1)); + + //液体料模型 + add(new Res_PLCADDRESS("料仓校准", "-------------", 0, 0)); + add(new Res_PLCADDRESS("校准时间", "VW112", 1, 1)); + add(new Res_PLCADDRESS("料仓1校准开关", "M12.3", 1, 1)); + add(new Res_PLCADDRESS("料仓1校准值", "VW114", 1, 1)); + add(new Res_PLCADDRESS("料仓2校准开关", "M12.4", 1, 1)); + add(new Res_PLCADDRESS("料仓2校准值", "VW116", 1, 1)); + add(new Res_PLCADDRESS("料仓3校准开关", "M12.5", 1, 1)); + add(new Res_PLCADDRESS("料仓3校准值", "VW118", 1, 1)); + add(new Res_PLCADDRESS("料仓4校准开关", "M13.5", 1, 1)); + add(new Res_PLCADDRESS("料仓4校准值", "VW120", 1, 1)); + add(new Res_PLCADDRESS("开始校正", "M12.6", 1, 1)); + + add(new Res_PLCADDRESS("料仓自动", "-------------", 0, 0)); + add(new Res_PLCADDRESS("料仓1需求值", "VW106", 1, 1)); + add(new Res_PLCADDRESS("料仓1下料", "M11.1", 1, 1)); + add(new Res_PLCADDRESS("料仓2需求值", "VW108", 1, 1)); + add(new Res_PLCADDRESS("料仓2下料", "M11.2", 1, 1)); + add(new Res_PLCADDRESS("料仓3需求值", "VW110", 1, 1)); + add(new Res_PLCADDRESS("料仓3下料", "M11.3", 1, 1)); + add(new Res_PLCADDRESS("料仓4需求值", "VW122", 1, 1)); + add(new Res_PLCADDRESS("料仓4下料", "M13.4", 1, 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("料仓4手动开关", "M10.7", 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("炒菜位高反馈", "M40.5", 1, 0)); + add(new Res_PLCADDRESS("炒菜位低反馈", "M40.6", 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("料仓4下料完成", "M42.0", 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("倒菜完成", "M44.4", 1, 0)); + add(new Res_PLCADDRESS("心跳位", "VW1000", 1, 1)); + + add(new Res_PLCADDRESS("温度模拟输入量", "-------------", 0, 0)); + add(new Res_PLCADDRESS("温度模拟量上限", "VW1050", 1, 1)); + add(new Res_PLCADDRESS("温度模拟量下限", "VW1052", 1, 1)); + add(new Res_PLCADDRESS("温度模拟量", "VW1054", 1, 1)); + add(new Res_PLCADDRESS("温度量程上限", "VD1060", 1, 1)); + add(new Res_PLCADDRESS("温度量程下限", "VD1056", 1, 1)); + + add(new Res_PLCADDRESS("电流模拟输入量", "-------------", 0, 0)); + add(new Res_PLCADDRESS("电流模拟量上限", "VW1070", 1, 1)); + add(new Res_PLCADDRESS("电流模拟量下限", "VW1072", 1, 1)); + add(new Res_PLCADDRESS("电流模拟量", "VW1074", 1, 1)); + add(new Res_PLCADDRESS("电流量程上限", "VD1080", 1, 1)); + add(new Res_PLCADDRESS("电流量程下限", "VD1076", 1, 1)); + add(new Res_PLCADDRESS("电流报警设置", "VW1092", 1, 1)); + add(new Res_PLCADDRESS("异常加热故障信息", "M42.1", 1, 1)); + + //检测信号 + 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)); + + }}; + + public LinkedHashMap PlcStatus=new LinkedHashMap<>(); LinkedHashMap>> addGroup =new LinkedHashMap<>(); public void Init(){ - List PlcAdd = ConfigName.getInstance().PlcAddress_Wok.stream().filter(p->p.isread==1).collect(Collectors.toList()); + List PlcAdd =PlcAddress_Wok.stream().filter(p->p.isread==1).collect(Collectors.toList()); if(PlcAdd!=null && PlcAdd.size()>0){ //地址转换对象 ExceptionServer es = new ExceptionServer(); @@ -102,7 +277,9 @@ public class PlcReadHelper { LinkedHashMap> result = new LinkedHashMap<>(); int groupNum=0; for(ReadModel value:data){ - if(!result.containsKey(groupNum) || result.get(groupNum).get(result.get(groupNum).size()-1).getModbusAddress()+1!=value.getModbusAddress()){ + String addStr = value.plcAddress.toUpperCase(); + int offset = addStr.contains("M")||addStr.contains("VW")?1:2; + if(!result.containsKey(groupNum) || result.get(groupNum).get(result.get(groupNum).size()-1).getModbusAddress()+offset!=value.getModbusAddress()){ groupNum++; } if(!result.containsKey(groupNum))result.put(groupNum,new ArrayList<>()); diff --git a/app/src/main/java/com/bonait/bnframework/newui/activity/MainHActivity.java b/app/src/main/java/com/bonait/bnframework/newui/activity/MainHActivity.java index dffd4068..c87b2fc3 100644 --- a/app/src/main/java/com/bonait/bnframework/newui/activity/MainHActivity.java +++ b/app/src/main/java/com/bonait/bnframework/newui/activity/MainHActivity.java @@ -142,7 +142,6 @@ public class MainHActivity extends BaseActivity { }else { PreferenceUtils.setInt("loginNum",loginNum+1); } - // PlcReadHelper plc = new PlcReadHelper(); // plc.Init(); // plc.read();