| | |
| | | package com.example.springboot.component; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | import com.example.springboot.entity.device.PlcParameterObject; |
| | | |
| | | import com.example.springboot.entity.device.PlcBitObject; |
| | | import com.example.springboot.entity.device.PlcParameterObject; |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import static com.example.springboot.component.InitUtil.readAndUpdateBitValues; |
| | | import static com.example.springboot.component.InitUtil.readAndUpdateWordValues; |
| | | |
| | | public class PLCAutoMes extends Thread { |
| | | |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | | private static InitUtil initUtil; |
| | | public static PlcParameterObject plcParameterObject; |
| | | // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | MessageHandler customS7Control = new MessageHandler(); |
| | | ; |
| | | |
| | | |
| | | // 单例实例 |
| | | private static PLCAutoMes instance; |
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | |
| | | String jsonFilePath = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath(); |
| | | |
| | | String jsonFilePath2 = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath(); |
| | | // String jsonFilePath3 = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath(); |
| | | // System.out.println(jsonFilePath); |
| | | |
| | | String jsonFilePath = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcParameter.json").getPath(); |
| | | // String jsonFilePath2 = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcSign.json").getPath(); |
| | | //String jsonFilePath4 = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcState.json").getPath(); |
| | | //System.out.println(jsonFilePath4); |
| | | // 调用initword方法 |
| | | PlcParameterObject PlcMesObject= initUtil.initword(jsonFilePath); |
| | | // 调用initbit方法 |
| | | PlcParameterObject PlcReadObject= initUtil.initword(jsonFilePath2); |
| | | plcParameterObject = initUtil.initword(jsonFilePath); |
| | | |
| | | // List<String> addresses = new ArrayList<>(); |
| | | // addresses.add("conveyorVelocity(AutoFAST)"); |
| | | // addresses.add("A02ID"); |
| | | // addresses.add("conveyorVelocity(Manual)"); |
| | | // |
| | | // PlcParameterObject paramObject = PLCAutomaticParameterSettingReview2.plcParameterObject; |
| | | // |
| | | // |
| | | // |
| | | // List<String> address = paramObject.getAddressListByCodeId(addresses); |
| | | // System.out.println(address); |
| | | |
| | | |
| | | //PLCAutomaticParameterSettingReview2 plc ; |
| | | |
| | | // String jsonFilePath = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath(); |
| | | // |
| | | // String jsonFilePath2 = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath(); |
| | | // // String jsonFilePath3 = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath(); |
| | | // // System.out.println(jsonFilePath); |
| | | // |
| | | // // 调用initword方法 |
| | | // PlcMesObject= initUtil.initword(jsonFilePath); |
| | | // // 调用initbit方法 |
| | | // PlcParameterObject PlcReadObject= initUtil.initword(jsonFilePath2); |
| | | // // 调用initbit方法 |
| | | // PlcParameterObject PlcframeObject= initUtil.initword(jsonFilePath3); |
| | | readAndUpdateWordValues(PlcReadObject); |
| | | readAndUpdateWordValues(PlcMesObject); |
| | | // readAndUpdateWordValues(PlcReadObject); |
| | | // readAndUpdateWordValues(PlcMesObject); |
| | | // readAndUpdateWordValues(PlcframeObject); |
| | | |
| | | |
| | | |
| | | |
| | | // readAndUpdateWordValues(plcStateObject); |
| | | int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex(); |
| | | //System.out.println(index); |
| | | PlcMesObject.getPlcParameter("AddStart").getAddress(index); |
| | | //System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index)); |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("FeedID"); |
| | | addresses.add("AddStart"); |
| | | //System.out.println(addresses); |
| | | //System.out.println(PlcMesObject.getPlcParameterValues(addresses)); |
| | | List<String> addresses2 = new ArrayList<>(); |
| | | addresses2.add("FeedID"); |
| | | addresses2.add("FeedCarStatus"); |
| | | // int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex(); |
| | | // //System.out.println(index); |
| | | // PlcMesObject.getPlcParameter("AddStart").getAddress(index); |
| | | // //System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index)); |
| | | // List<String> addresses = new ArrayList<>(); |
| | | // addresses.add("FeedID"); |
| | | // addresses.add("AddStart"); |
| | | // //System.out.println(addresses); |
| | | // //System.out.println(PlcMesObject.getPlcParameterValues(addresses)); |
| | | // List<String> addresses2 = new ArrayList<>(); |
| | | // addresses2.add("FeedID"); |
| | | // addresses2.add("FeedCarStatus"); |
| | | |
| | | System.out.println(PlcReadObject.getPlcParameterValues(addresses2)); |
| | | // System.out.println(PlcReadObject.getPlcParameterValues(addresses2)); |
| | | |
| | | |
| | | |