From 73bc0656dc15cd9cc95c6f4f51949ef0437088ce Mon Sep 17 00:00:00 2001 From: cl <418351270@qq.com> Date: 星期五, 23 二月 2024 09:28:13 +0800 Subject: [PATCH] 修改数据采集 --- guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java | 66 +++++++++----------------------- 1 files changed, 19 insertions(+), 47 deletions(-) diff --git a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java index aa181db..752c2ad 100644 --- a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java +++ b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/callback/OP050Callback.java @@ -43,7 +43,7 @@ import java.util.List; @Component -public class OP050Callback implements SubscriptionCallback { +public class OP050Callback{ public MiloService miloService; @@ -126,42 +126,7 @@ this.productionOrderRecordsService = productionOrderRecordsService; this.productionOrderBatchInfoService = productionOrderBatchInfoService; } - @Override - public void onSubscribe(String identifier, Object value) { - String ecpStr = "";//寮傚父璁板綍鏍囪 - try { - //蹇冭烦 - if(null != value && identifier.equals(OPCElement.OP050_F_HEART_BEAT)){ - if( "false".equals(value.toString())) - { - ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_F_HEART_BEAT,true); - miloService.writeToOpcUa(entity); - } - } - //PLC杩涚珯 - else if(null != value && identifier.equals(OPCElement.OP050_J_PLC_START)){ - if("true".equals(value.toString())){ - handleOrder(); - } - } - //PLC鍑虹珯 - else if(null != value && identifier.equals(OPCElement.OP050_J_PLC_FINISH)){ - if("true".equals(value.toString())){ - handleMaterial(); - handleFinsh(); - handleInfo(); - } - }else{ - System.out.println("鍊兼病鏈夊彉"); - } - } catch (Exception e) { - ecpStr ="鍑虹幇寮傚父锛�" + logUtil.getTrace(e); - }finally { - if(!"".equals(ecpStr)){ - logger.info(ecpStr+"\r\n"); - } - } - } + //PC璇诲伐鍗� public void handleOrder() throws Exception { @@ -199,6 +164,15 @@ logger.info("handleFinsh PC澶勭悊寮�濮嬶紒"); + + Object copSfcCode = miloService. + readFromOpcUa(OPCElement.OP050_S_SFC_CODE_COP) + .getValue(); + Object bopSfcCode = miloService. + readFromOpcUa(OPCElement.OP050_S_SFC_CODE_BOP) + .getValue(); + + Object object = miloService. readFromOpcUa(OPCElement.OP050_S_PRODUCT_STATE_CODE) .getValue(); @@ -206,6 +180,10 @@ if(null != object){ S_PRODUCT_STATE_CODE = object.toString(); } + + + ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_J_PC_FINISH,true); + miloService.writeToOpcUa(entity);//鍐橮C瀹屾垚 PassingStationCollectionParam param = new PassingStationCollectionParam(); param.setWorkOrderNo(S_ORDER_CODE); @@ -219,12 +197,7 @@ passingStationCollectionService.add(param); - Object copSfcCode = miloService. - readFromOpcUa(OPCElement.OP050_S_SFC_CODE_COP) - .getValue(); - Object bopSfcCode = miloService. - readFromOpcUa(OPCElement.OP050_S_SFC_CODE_BOP) - .getValue(); + if(null != copSfcCode && null != bopSfcCode){ //鏍规嵁鍒嗘�绘垚缂栫爜锛屽皢EOP鐗╂枡鏁版嵁缁戝畾鍏崇郴淇敼涓烘�绘垚缂栫爜 @@ -245,7 +218,7 @@ logger.info("bopSfcCode:"+bopSfcCode); //鏌ヨCOP鍜孊OP鏄惁鍚堟牸 - PassingStationCollectionParam passingStationCollectionParam = new PassingStationCollectionParam(); + /* PassingStationCollectionParam passingStationCollectionParam = new PassingStationCollectionParam(); passingStationCollectionParam.setSfcCode(S_SFC_CODE); List<PassingStationCollectionResult> passingStationCollectionResultList = passingStationCollectionService.findListBySpec(passingStationCollectionParam); @@ -270,10 +243,9 @@ productionOrderRecordsParam.setWhetherPass("2"); productionOrderRecordsService.update(productionOrderRecordsParam); } - } + }*/ - ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_J_PC_FINISH,true); - miloService.writeToOpcUa(entity);//鍐橮C瀹屾垚 + logger.info("handleFinsh PC澶勭悊瀹屾垚锛�"); } public void handleMaterial() { -- Gitblit v1.9.3