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"); } } } }