luxiaotao1123
2020-12-24 78e0773dba0613bf4fb18a20e0cef5086e1b834f
#newVersion
1个文件已修改
13 ■■■■■ 已修改文件
src/main/java/com/zy/core/thread/MelsecDevpThread.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/MelsecDevpThread.java
@@ -37,6 +37,9 @@
    private MelsecMcNet melsecMcNet;
    private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
    private short heartBeatVal = 1;
    public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
        add(101);add(102);add(103);add(104);add(105);add(106);add(107);
    }};
    public MelsecDevpThread(DevpSlave slave) {
        this.slave = slave;
@@ -99,13 +102,15 @@
    private void read() throws InterruptedException {
        OperateResultExOne<byte[]> result = melsecMcNet.Read("DB100.0", (short) 40);
        if (result.IsSuccess) {
            for (int i = 1; i <= 8; i++) {
                StaProtocol staProtocol = station.get(i);
            for (int i = 1; i <= 7; i++) {
                Integer siteId = staNos.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
                    staProtocol = new StaProtocol();
                    staProtocol.setSiteId(i);
                    station.put(i, staProtocol);
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                staProtocol.setWorkNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i-1)*2));     // 工作号
                staProtocol.setStaNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i-1)*2+20));   // 目标站
            }