|  |  |  | 
|---|
|  |  |  | import com.zy.core.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.core.model.DevpSlave; | 
|---|
|  |  |  | import com.zy.core.model.Task; | 
|---|
|  |  |  | import com.zy.core.model.protocol.StaError1; | 
|---|
|  |  |  | import com.zy.core.model.protocol.StaProtocol; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | 
|---|
|  |  |  | private SiemensS7Net siemensS7Net; | 
|---|
|  |  |  | private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>(); | 
|---|
|  |  |  | private short heartBeatVal = 1; | 
|---|
|  |  |  | private StaError1 staError1; | 
|---|
|  |  |  | //    public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{ | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //    }}; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 心跳 | 
|---|
|  |  |  | //                heartbeat(); | 
|---|
|  |  |  | Thread.sleep(300); | 
|---|
|  |  |  | Thread.sleep(100); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BasRgvMapService basRgvMapService = SpringUtils.getBean(BasRgvMapService.class); | 
|---|
|  |  |  | //RGV小车1 | 
|---|
|  |  |  | Thread.sleep(100); | 
|---|
|  |  |  | //        Thread.sleep(100); | 
|---|
|  |  |  | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB50.200",(short)10); | 
|---|
|  |  |  | if (result3.IsSuccess) { | 
|---|
|  |  |  | BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result3.Content, 0)); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //RGV小车2 | 
|---|
|  |  |  | Thread.sleep(100); | 
|---|
|  |  |  | //        Thread.sleep(100); | 
|---|
|  |  |  | OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB50.212",(short)10); | 
|---|
|  |  |  | if (result4.IsSuccess) { | 
|---|
|  |  |  | BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result4.Content, 0)); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //RGV小车3 | 
|---|
|  |  |  | Thread.sleep(100); | 
|---|
|  |  |  | //        Thread.sleep(100); | 
|---|
|  |  |  | OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB50.224",(short)10); | 
|---|
|  |  |  | if (result5.IsSuccess) { | 
|---|
|  |  |  | BasRgvMap basRgvMap = basRgvMapService.selectByRgvNo((int) siemensS7Net.getByteTransform().TransInt16(result5.Content, 0)); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | OperateResultExOne<byte[]> resultErr2 = siemensS7Net.Read("DB13.2", (short) (staNoSize*4)); | 
|---|
|  |  |  | if (resultErr.IsSuccess) { | 
|---|
|  |  |  | if (resultErr2.IsSuccess) { | 
|---|
|  |  |  | for (int i = 0; i < staNoSize; i++) { | 
|---|
|  |  |  | Integer siteId = staNos.get(i); // 站点编号 | 
|---|
|  |  |  | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr.Content, i*4, 1); | 
|---|
|  |  |  | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr2.Content, i*4, 1); | 
|---|
|  |  |  | StaProtocol staProtocol = station.get(siteId); | 
|---|
|  |  |  | staProtocol.setBreakerErr(status[0]); | 
|---|
|  |  |  | staProtocol.setInfraredErr(status[1]); | 
|---|
|  |  |  | 
|---|
|  |  |  | staProtocol.setUpcontactErr(status[7]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OperateResultExOne<byte[]> resultErr3 = siemensS7Net.Read("DB13.400", (short) 3); | 
|---|
|  |  |  | if (resultErr3.IsSuccess) { | 
|---|
|  |  |  | if (staError1 == null){ | 
|---|
|  |  |  | staError1 = new StaError1(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr3.Content, 0, 3); | 
|---|
|  |  |  | staError1.setEMERGENCY_Stop_Core(status[0]); | 
|---|
|  |  |  | staError1.setEMERGENCY_STOP1(status[1]); | 
|---|
|  |  |  | staError1.setEMERGENCY_STOP2(status[2]); | 
|---|
|  |  |  | staError1.setEMERGENCY_STOP3(status[3]); | 
|---|
|  |  |  | staError1.setEMERGENCY_STOP4(status[4]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | staError1.setDoor_EMERGENCY_STOP1(status[5]); | 
|---|
|  |  |  | staError1.setDoor_EMERGENCY_STOP2(status[6]); | 
|---|
|  |  |  | staError1.setDoor_EMERGENCY_STOP3(status[7]); | 
|---|
|  |  |  | staError1.setDoor_EMERGENCY_STOP4(status[8]); | 
|---|
|  |  |  | staError1.setDoor_EMERGENCY_STOP5(status[9]); | 
|---|
|  |  |  | staError1.setDoor_EMERGENCY_STOP6(status[10]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | staError1.setDoor_Open_Err1(status[11]); | 
|---|
|  |  |  | staError1.setDoor_Open_Err1(status[12]); | 
|---|
|  |  |  | staError1.setDoor_Open_Err1(status[13]); | 
|---|
|  |  |  | staError1.setDoor_Open_Err1(status[14]); | 
|---|
|  |  |  | staError1.setDoor_Open_Err1(status[15]); | 
|---|
|  |  |  | staError1.setDoor_Open_Err1(status[16]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | Thread.sleep(200); | 
|---|
|  |  |  | write1 = siemensS7Net.Write("DB100." + (index*6+4), staProtocol.getStaNo().shortValue());    // 目标站 | 
|---|
|  |  |  | if(write.IsSuccess && write1.IsSuccess){ | 
|---|
|  |  |  | log.error("写入输送线命令成功。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else { | 
|---|