#
luxiaotao1123
2022-11-14 8ee2064b48bf7e8beb1b88326fcbbc5f548d764f
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -43,10 +43,9 @@
    private int barcodeSize = 2;
    public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
        add(100);add(101);add(102);add(103);add(104);add(105);add(106);add(107);add(108);add(109);
        add(110);add(111);
        add(110);add(111);add(112);add(113);add(114);add(115);add(116);add(117);add(118);add(119);
        add(200);add(201);add(202);add(203);add(204);add(205);add(206);add(207);add(208);add(209);
        add(210);add(211);
        add(300);
        add(1000);add(2000);
    }};
    public boolean charge0;
@@ -115,7 +114,7 @@
    private void read() throws InterruptedException {
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) 50);
        if (result.IsSuccess) {
            for (int i = 0; i < 25; i++) {
            for (int i = 0; i < staNos.size(); i++) {
                Integer siteId = staNos.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
@@ -129,7 +128,7 @@
        Thread.sleep(200);
        OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 50);
        if (result0.IsSuccess) {
            for (int i = 0; i < 25; i++) {
            for (int i = 0; i < staNos.size(); i++) {
                Integer siteId = staNos.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
@@ -143,7 +142,7 @@
        Thread.sleep(200);
        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.0", (short) 50);
        if (result1.IsSuccess) {
            for (int i = 0; i < 25; i++) {
            for (int i = 0; i < staNos.size(); i++) {
                Integer siteId = staNos.get(i); // 站点编号
                boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1);
                StaProtocol staProtocol = station.get(siteId);
@@ -179,8 +178,8 @@
        // 充电信号位
        Thread.sleep(100);
        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB102.50", (short)1);
        if (result2.IsSuccess) {
            boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, 0, 1);
        if (result3.IsSuccess) {
            boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, 0, 1);
            charge0 = status[0];
            charge1 = status[1];
            charge2 = status[2];
@@ -269,10 +268,12 @@
     * @param open true 开始充电;false 结束充电
     */
    public boolean charge(int index, boolean open) {
        OperateResult write = siemensS7Net.Write("DB102.50." + index + 3, open);
        OperateResult write = siemensS7Net.Write("DB102.50." + (index + 3), open);
        if (!write.IsSuccess) {
            log.error("输送线plc编号={} {}号充电桩{}控制失败", slave.getId(), index + 1, open?"打开":"关闭");
            return false;
        } else {
            log.error("输送线plc编号={} {}号充电桩{}控制成功", slave.getId(), index + 1, open?"打开":"关闭");
        }
        return true;
    }