| | |
| | | Integer offset3 = getOffsetBySiteId2(siteId); |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2)); // 工作号 |
| | | |
| | | staProtocol.setStaNo((short) siemensS7Net.getByteTransform().TransInt32(result.Content, offset + offset2 + 12)); // 目标站 |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, offset + offset2 + 12)); // 目标站 |
| | | |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result.Content, offset + offset3, 2); |
| | | staProtocol.setAutoing(status[0]); // 自动 |
| | | staProtocol.setAutoing(!status[0]); // 自动 |
| | | boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result.Content, offset + offset3 - 4, 3); |
| | | |
| | | staProtocol.setLoading(status1[0]); // 有物 |
| | | staProtocol.setLoading(!status1[0]); // 有物 |
| | | if(staProtocol.isLoading()){ |
| | | staProtocol.setInEnable(false); // 可入 |
| | | staProtocol.setOutEnable(false);// 可出 |
| | |
| | | } |
| | | } |
| | | } |
| | | // BasRgvMapService basRgvMapService = SpringUtils.getBean(BasRgvMapService.class); |
| | | //RGV小车1 |
| | | BasRgvMapService basRgvMapService = SpringUtils.getBean(BasRgvMapService.class); |
| | | // RGV小车1 |
| | | // Thread.sleep(100); |
| | | // OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB50.200",(short)10); |
| | | // OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB101.",(short)27); |
| | | // if (result3.IsSuccess) { |
| | | // BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result3.Content, 0)); |
| | | // if (!Cools.isEmpty(basRgvMap)){ |
| | | // Integer siteId = 1; |
| | | // StaProtocol staProtocol = station.get(siteId); |
| | | // if (null == staProtocol) { |
| | | // staProtocol = new StaProtocol(); |
| | | // staProtocol.setSiteId(siteId); |
| | | // station.put(siteId, staProtocol); |
| | | // Integer siteId1 = 1; |
| | | // Integer siteId2 = 2; |
| | | // StaProtocol staProtocol1 = station.get(siteId1); |
| | | // StaProtocol staProtocol2 = station.get(siteId1); |
| | | // |
| | | // if (null == staProtocol1) { |
| | | // staProtocol1 = new StaProtocol(); |
| | | // staProtocol1.setSiteId(siteId1); |
| | | // station.put(siteId1, staProtocol1); |
| | | // } |
| | | // staProtocol.setAutoing(true); |
| | | // staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 8))); |
| | | // if (null == staProtocol2) { |
| | | // staProtocol2 = new StaProtocol(); |
| | | // staProtocol2.setSiteId(siteId2); |
| | | // station.put(siteId2, staProtocol2); |
| | | // |
| | | // } |
| | | // String pos = String.valueOf(getRgvPosI(siemensS7Net.getByteTransform().TransInt32(result.Content, 4))); |
| | | // staProtocol1.setAutoing(siemensS7Net.getByteTransform().TransInt16(result.Content, 2) == 2); |
| | | // staProtocol2.setAutoing(siemensS7Net.getByteTransform().TransInt16(result.Content, 2) == 2); |
| | | // staProtocol1.setNearbySta(pos); |
| | | // staProtocol1.setStaNo((short) siemensS7Net.getByteTransform().TransInt32(result.Content, 8)); |
| | | // staProtocol2.setStaNo((short) siemensS7Net.getByteTransform().TransInt32(result.Content, 8)); |
| | | // staProtocol1.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, 16)); |
| | | // staProtocol2.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, 20)); |
| | | // boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result.Content, 24, 2); |
| | | // staProtocol1.setLoading(status1[0]); |
| | | // staProtocol2.setLoading(status1[1]); |
| | | // // staProtocol.setNearbySta(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result3.Content, 8))); |
| | | // } |
| | | // } |
| | | //RGV小车2 |
| | |
| | | } |
| | | } |
| | | } |
| | | public Integer getRgvPosI(Integer pos) { |
| | | if (pos == null) return 0; |
| | | |
| | | // key: 站点号 value: 基准物理位置 |
| | | Map<Integer, Integer> posMap = new HashMap<>(); |
| | | posMap.put(1004, 6534); |
| | | posMap.put(1007, 33634); |
| | | posMap.put(1010, 75174); |
| | | posMap.put(1014, 102124); |
| | | posMap.put(1018, 138224); |
| | | posMap.put(1021, 178034); |
| | | posMap.put(1024, 219684); |
| | | posMap.put(1028, 246724); |
| | | posMap.put(1031, 288194); |
| | | posMap.put(1035, 315204); |
| | | int tolerance = 50; // 允许误差范围 |
| | | |
| | | for (Map.Entry<Integer, Integer> entry : posMap.entrySet()) { |
| | | int site = entry.getKey(); |
| | | int basePos = entry.getValue(); |
| | | if (Math.abs(pos - basePos) <= tolerance) { |
| | | return site; |
| | | } |
| | | } |
| | | |
| | | return 0; // 没匹配到站点 |
| | | } |
| | | |
| | | /** |
| | | * 心跳 |