| | |
| | | //public static Long machineId = 6L; |
| | | public List<Map> sendRecords = new ArrayList<>(); |
| | | public Machine thisMachine; |
| | | |
| | | public MachineMarking(Machine machine,MachineMapper machineMapper, TaskingService taskingService){ |
| | | this.thisMachine = machine; |
| | | this.machineMapper = machineMapper; |
| | | this.taskingService = taskingService; |
| | | } |
| | | |
| | | public void plcStart() { |
| | | //Long machineId=12L; |
| | | public void plcStart()throws Exception { |
| | | Machine machine=machineMapper.selectById(thisMachine.getId()); |
| | | // S7objectMachine s7objectMachine=new S7objectMachine(machine.getIp(),machine.getPort(),"PlcMarking", EPlcType.S1500); |
| | | // s7objectMachine.start(); |
| | | if (s7objectMachine==null){ |
| | | s7objectMachine=new S7objectMachine(machine.getIp(),machine.getPort(),machine.getFileName(), EPlcType.S1500); |
| | | s7objectMachine.start(); |
| | | } |
| | | S7objectMachine s7objectMachine = new S7objectMachine(machine.getIp(), machine.getPort(), machine.getFileName(), EPlcType.S1500); |
| | | s7objectMachine.readData();//按照json文件读取内容 |
| | | PlcParameterObject plcParameterObject = s7objectMachine.PlcMesObject; |
| | | if (plcParameterObject == null) { |
| | | s7objectMachine.plccontrol.closeS7client(); |
| | | return; |
| | | } |
| | | try { |
| | | PlcParameterInfo plcRequest =plcParameterObject.getPlcParameter("plcRequest");//请求字 |
| | | PlcParameterInfo plcRequestID =plcParameterObject.getPlcParameter("plcRequestID");//请求ID |
| | | PlcParameterInfo mesSend =plcParameterObject.getPlcParameter("mesSend");//发送字 |
| | |
| | | return; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | s7objectMachine.plccontrol.closeS7client(); |
| | | log.info("逻辑处理异常:设备id【{}】", machine.getId()); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | while (true) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | plcStart(); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | log.info("{}", e.getMessage()); |
| | | } |
| | | } |
| | | } |