| | |
| | | package com.zy.core.thread.impl; |
| | | |
| | | import HslCommunication.Profinet.Siemens.SiemensPLCS; |
| | | import HslCommunication.Profinet.Siemens.SiemensS7Net; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.BasDevp; |
| | |
| | | import com.zy.core.network.entity.ZyStationStatusEntity; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @SuppressWarnings("InfiniteLoopStatement") |
| | | public void run() { |
| | | this.connect(); |
| | | |
| | | //设备读取 |
| | | Thread readThread = new Thread(() -> { |
| | | while (true) { |
| | | try { |
| | | readStatus(); |
| | | Thread.sleep(200); |
| | | } catch (Exception e) { |
| | | log.error("StationThread Fail", e); |
| | | } |
| | | } |
| | | }); |
| | | readThread.start(); |
| | | |
| | | while (true) { |
| | | try { |
| | | int step = 1; |
| | |
| | | step = task.getStep(); |
| | | } |
| | | switch (step) { |
| | | // 读数据 |
| | | case 1: |
| | | readStatus(); |
| | | break; |
| | | case 2: |
| | | sendCommand((StationCommand) task.getData()); |
| | | break; |
| | |
| | | |
| | | @Override |
| | | public boolean connect() { |
| | | SiemensS7Net siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, deviceConfig.getIp()); |
| | | zyStationConnectDriver = new ZyStationConnectDriver(siemensS7Net, deviceConfig); |
| | | zyStationConnectDriver = new ZyStationConnectDriver(deviceConfig); |
| | | new Thread(zyStationConnectDriver).start(); |
| | | DeviceConnectPool.put(SlaveType.Devp, deviceConfig.getDeviceNo(), zyStationConnectDriver); |
| | | return true; |
| | |
| | | return commandResponse; |
| | | } |
| | | |
| | | @Override |
| | | public Map<Integer, StationProtocol> getStatusMap() { |
| | | Map<Integer, StationProtocol> map = new HashMap<>(); |
| | | for (StationProtocol stationProtocol : statusList) { |
| | | map.put(stationProtocol.getStationId(), stationProtocol); |
| | | } |
| | | return map; |
| | | } |
| | | } |