| | |
| | | } |
| | | |
| | | /** |
| | | * 根据PLC按钮测试信号,发送启动申请到测试系统 |
| | | * 根据PLC按钮测试、完成、暂停信号,更新testMast表中status值,交由WMS系统处理 |
| | | */ |
| | | @Transactional |
| | | public void startTest() { |
| | | public void packTest() { |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | if(null != devpThread){ |
| | | for (int i = 0; i < 48; i++){ |
| | | int olsStatus = 0;//testMast表原来status数据状态 |
| | | int newStatus = 0;//testMast表待修改的status数据状态 |
| | | short newSingle = 0; //PLC地址待修改的新值 |
| | | switch (devpThread.startSignal[i]){//根据信号查找testMast表中对应状态条件,olsStatus,newStatus根据实际流程调整 |
| | | case 1://启动复核信号 |
| | | olsStatus = 2; |
| | | newStatus = 3; |
| | | newSingle = 2;//测试复核,寄存器地址,1===>>2 |
| | | break; |
| | | case 3://完成测试信号 |
| | | olsStatus = 3; |
| | | newStatus = 5; |
| | | newSingle = 0;//测试完成,寄存器地址清零,3===>>0 |
| | | break; |
| | | case 5://暂停信号 |
| | | olsStatus = 5;//plc给出暂停信号 |
| | | newStatus = 6;//WCS收到暂停信号后,更新testMast |
| | | newSingle = 6;//暂停测试,寄存器地址,5===>>6 |
| | | break; |
| | | } |
| | | |
| | | TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>() |
| | | .eq("channel",(i+1)).eq("status",0));//查找原来的状态 |
| | | .eq("channel",(i+1)).eq("status",olsStatus));//查找原来的状态 |
| | | if(null != testMast && devpThread.startSignal[i] == 1){ |
| | | testMast.setStatus(3); |
| | | testMast.setStatus(newStatus); |
| | | testMast.setModiTime(new Date()); |
| | | if(!testMastService.update(testMast,new EntityWrapper<TestMast>() |
| | | .eq("channel",(i+1)).eq("status",0))){ |
| | | .eq("channel",(i+1)).eq("status",olsStatus))){ |
| | | throw new CoolException("更新产品测试状态失败"); |
| | | } |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i*2);//寄存器地址 |
| | | staProtocol.setStaNo((short)2);//修改PLC寄存器地址值,从1改为2 |
| | | staProtocol.setStaNo((short)newSingle);//修改PLC寄存器地址值,从1改为2 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | if(!result){ |
| | | throw new CoolException("启动测试信号失败===>>" + i); |
| | | throw new CoolException("更新测试信号失败===>>" + i); |
| | | } else { |
| | | devpThread.startSignal[i] = newSingle; |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("启动测试 ===>> 启动测试失败", e); |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据PLC按钮测试信号,发送启动申请到测试系统 |
| | | */ |
| | | @Transactional |
| | | public void finishTest() { |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | if(null != devpThread){ |
| | | for (int i = 0; i < 48; i++){ |
| | | TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>() |
| | | .eq("channel",(i+1)).eq("status",0));//查找原来的状态,根据业务逻辑修改 |
| | | if(null != testMast && devpThread.startSignal[i] == 3){ |
| | | testMast.setStatus(3); |
| | | testMast.setModiTime(new Date()); |
| | | if(!testMastService.update(testMast,new EntityWrapper<TestMast>() |
| | | .eq("channel",(i+1)).eq("status",0))){ |
| | | throw new CoolException("更新产品测试状态失败"); |
| | | } |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i*2);//寄存器地址 |
| | | staProtocol.setStaNo((short)0);//修改PLC寄存器地址值,从3改为0 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | if(!result){ |
| | | throw new CoolException("完成测试信号失败===>>" + i); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("完成测试 ===>> 完成测试失败", e); |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |