懒羊羊
2023-08-30 bf6c368992d6901135dd07434854940288a4163c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package org.example.server.impl;
 
 
import org.example.opc.GlobalVariable;
import org.example.opc.OPCComm;
import org.example.opc.unit.DateTool;
import org.example.opc.unit.OPCUnit;
import org.example.server.ServerInterface;
 
 
public class ServerInterfaceImpl implements ServerInterface {
 
 
 
    private OPCComm opc = OPCComm.getInstance();
    @Override
    public void monitor() {
        String ecpStr = "";//异常记录标记
        try{
                String isPLCStart = OPCUnit.read(opc.getZYYSTART());//PLC开始
                if(isPLCStart.equals("true")){
                    String isFinish = OPCUnit.read(opc.getZYYEND());//PC下发完成
                    if(isFinish.equals("false")){
                        GlobalVariable.isSendValue = true;
                        OPCUnit.write(opc.getP1(), GlobalVariable.zyyMaxValue+""); //PC完成
                        GlobalVariable.textArea.append(DateTool.getLocalTimeForDate()+": "+"当前测得的燥音值为:"+ GlobalVariable.zyyValue +"\r\n");
                        GlobalVariable.textArea.append(DateTool.getLocalTimeForDate()+": "+"当前测得的燥音最大值为:"+ GlobalVariable.zyyMaxValue +"\r\n");
                    }else{
                        GlobalVariable.zyyMaxValue = 0;
                        GlobalVariable.isSendValue = false;
                    }
                }else{
                    GlobalVariable.zyyMaxValue = 0;
                    GlobalVariable.isSendValue = false;
                }
 
        }catch (Exception e) {
            ecpStr ="出现异常:" + e.getMessage();
        }finally {
            if(!"".equals(ecpStr)){
                GlobalVariable.textArea.append(ecpStr+"\r\n");
            }
        }
    }
 
 
 
}