wu
2024-02-23 32ad564c6754c48f51982ccacd12e894e8a59f03
springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java
@@ -15,11 +15,37 @@
    // 用于存储应用程序的配置信息
    private Configuration config;
    private static InitUtil initUtil;
    // public static PlcParameterObject PlcMesObject;
    // public static PlcParameterObject PlcReadObject;
    // public static PlcParameterObject PlcframeObject;
    // 创建一个自定义的 S7 控制器消息处理器对象
    MessageHandler customS7Control = new MessageHandler();
    // 单例实例
    private static PLCAutoMes instance;
    private static String PlcMes = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath();
    private static String PlcRead = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath();
    private static String Plcframe = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath();
    private static String PlcParameter = PLCAutomaticParameterSettingReview2.class
            .getResource("/JsonFile/PlcParameter.json").getPath();
    private static String PlcSign = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcSign.json")
            .getPath();
    private static String PlcState = PLCAutomaticParameterSettingReview2.class.getResource("/JsonFile/PlcState.json")
            .getPath();
    private static String PlcAlarm = PLCAutoMes.class.getResource("/JsonFile/PlcAlarm.json").getPath();
    private static String PlcTest = PLCAutoMes.class.getResource("/JsonFile/PlcTest.json").getPath();
    // 调用initword方法
    public static PlcParameterObject plcParameterObject = initUtil.initword(PlcParameter);
    public static PlcBitObject plcPlcTest = initUtil.initbit(PlcTest);
    public static PlcBitObject  plcBitObject = initUtil.initbit(PlcSign);
    public static PlcParameterObject  plcStateObject= initUtil.initword(PlcState);
    public static PlcBitObject plcPlcAlarm = initUtil.initbit(PlcAlarm);
    public static PlcParameterObject PlcMesObject = initUtil.initword(PlcMes);
    public static PlcParameterObject PlcReadObject = initUtil.initword(PlcRead);
    public static PlcParameterObject PlcframeObject = initUtil.initword(Plcframe);
    // 私有构造函数
    public PLCAutoMes() throws IOException {
@@ -35,33 +61,21 @@
        return instance;
    }
    private static String jsonFilePath = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath();
    private static String jsonFilePath2 = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath();
    // 调用initword方法
    public static PlcParameterObject PlcMesObject = initUtil.initword(jsonFilePath);
    // 调用initbit方法
    public static PlcParameterObject PlcReadObject = initUtil.initword(jsonFilePath2);
    @Override
    public void run() {
        while (this != null) {
            try {
                Thread.sleep(1000);
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            // String jsonFilePath3 =
            // PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath();
            // System.out.println(jsonFilePath);
            // // 调用initbit方法
            // PlcParameterObject PlcframeObject= initUtil.initword(jsonFilePath3);
            PlcParameterObject PlcReadObjects=PlcReadObject;
            // readAndUpdateWordValues(PlcReadObject);
            // readAndUpdateWordValues(PlcMesObject);
            readAndUpdateWordValues(PlcReadObject);
            readAndUpdateWordValues(PlcMesObject);
            readAndUpdateWordValues(PlcframeObject);
            // readAndUpdateWordValues(PlcframeObject);
            // readAndUpdateWordValues(plcStateObject);