| | |
| | | public class S7object extends Thread { |
| | | public S7control plccontrol; // PLC通讯类实例 |
| | | private EPlcType plcType = EPlcType.S1200; // 西门子PLC类型 |
| | | private String ip = "192.168.10.1"; // plc ip地址 |
| | | private String ip = "192.168.20.2"; // plc ip地址 |
| | | private int port = 102; // plc 端口号 |
| | | |
| | | |
| | |
| | | private S7object() { |
| | | if (plccontrol == null) { |
| | | plccontrol = new S7control(plcType, ip, port, 0, 0); |
| | | String PlcLoadGlass = System.getProperty("user.dir") + "/JsonFile/PlcCacheVerticalGlass.json"; |
| | | |
| | | String PlcLoadGlass = S7object.class.getResource("/JsonFile/PlcCacheVerticalGlass.json").getPath(); |
| | | //log.info(PLCAutoMes.class.getResource("").getPath()); |
| | | PlcMesObject = InitUtil.initword(PlcLoadGlass); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | byte[] getplcvlues = plccontrol.readByte(PlcMesObject.getPlcAddressBegin(), PlcMesObject.getPlcAddressLength()); |
| | | PlcMesObject.setPlcParameterList(getplcvlues); |
| | | |
| | | if (getplcvlues != null) { |
| | | PlcMesObject.setPlcParameterList(getplcvlues); |
| | | } |
| | | } |
| | | } |
| | | } |