| | |
| | | private TaskingService taskingService; |
| | | private S7objectMachine s7objectMachine; |
| | | public Machine thisMachine; |
| | | |
| | | public MachineLamination(Machine machine, MachineMapper machineMapper, TaskingService taskingService){ |
| | | this.thisMachine = machine; |
| | | this.machineMapper = machineMapper; |
| | | this.taskingService = taskingService; |
| | | } |
| | | |
| | | public void plcStart() { |
| | | public void plcStart()throws Exception { |
| | | Machine machine=machineMapper.selectById(thisMachine.getId()); |
| | | if (s7objectMachine==null){ |
| | | s7objectMachine=new S7objectMachine(machine.getIp(),machine.getPort(),machine.getFileName(), EPlcType.S1200); |
| | | s7objectMachine.start(); |
| | | } |
| | | |
| | | S7objectMachine s7objectMachine = new S7objectMachine(machine.getIp(), machine.getPort(), machine.getFileName(), EPlcType.S1200); |
| | | s7objectMachine.readData();//按照json文件读取内容 |
| | | PlcParameterObject plcParameterObject = s7objectMachine.PlcMesObject; |
| | | if (plcParameterObject == null) { |
| | | s7objectMachine.plccontrol.closeS7client(); |
| | | return; |
| | | } |
| | | try { |
| | | PlcParameterInfo plcRequest =plcParameterObject.getPlcParameter("plcRequest");//请求字 |
| | | PlcParameterInfo mesSend =plcParameterObject.getPlcParameter("mesSend");//发送字 |
| | | PlcParameterInfo lengthOutOfService =plcParameterObject.getPlcParameter("length");//长 |
| | |
| | | return; |
| | | } |
| | | if("1".equals(plcReport.getValue())&&"0".equals(mesConfirm.getValue())){ |
| | | |
| | | |
| | | int finishCount=taskingService.finishMachineTask(machine); |
| | | log.info("3、任务完成"); |
| | | if(finishCount>0){//有任务 |
| | |
| | | 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()); |
| | | } |
| | | } |
| | | } |