| | |
| | | import HslCommunication.Profinet.Siemens.SiemensPLCS; |
| | | import HslCommunication.Profinet.Siemens.SiemensS7Net; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasDevp; |
| | |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.Task; |
| | |
| | | private SiemensS7Net siemensS7Net; |
| | | private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>(); |
| | | private short heartBeatVal = 1; |
| | | 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(210);add(211); |
| | | add(300); |
| | | }}; |
| | | |
| | | public boolean charge0; |
| | | public boolean charge1; |
| | | public boolean charge2; |
| | | |
| | | public SiemensDevpThread(DevpSlave slave) { |
| | | this.slave = slave; |
| | |
| | | } |
| | | } |
| | | |
| | | //读条码 |
| | | Thread.sleep(100); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.100",(short)(barcodeSize*8)); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < barcodeSize; i++) { |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 充电信号位 |
| | | Thread.sleep(100); |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB102.50", (short)1); |
| | | if (result3.IsSuccess) { |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, 0, 1); |
| | | charge0 = status[0]; |
| | | charge1 = status[1]; |
| | | charge2 = status[2]; |
| | | } |
| | | |
| | | if (result.IsSuccess && result0.IsSuccess && result1.IsSuccess) { |
| | | |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 充电控制 |
| | | * @param index 充电桩序号 0 开始 |
| | | * @param open true 开始充电;false 结束充电 |
| | | */ |
| | | public boolean charge(int index, boolean 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; |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | siemensS7Net.ConnectClose(); |