From b3b17b231e2f2840332ce6eb96f791865fdec6d5 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 14 四月 2025 16:38:16 +0800
Subject: [PATCH] 代码优化
---
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeUnit.java | 148 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 148 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeUnit.java
new file mode 100644
index 0000000..3abc7b6
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeUnit.java
@@ -0,0 +1,148 @@
+package com.dy.rtuMw.server.upgrade;
+
+import com.dy.common.mw.UnitAdapterInterface;
+import com.dy.common.mw.UnitCallbackInterface;
+import com.dy.common.mw.UnitInterface;
+import com.dy.common.softUpgrade.state.UpgradeTaskVo;
+import com.dy.common.util.Callback;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/11/4 14:16
+ * @Description
+ */
+public class UpgradeUnit implements UnitInterface {
+
+ private static UpgradeUnit instance = new UpgradeUnit() ;
+
+ public static UpgradeUnitAdapter adapter ;
+ public static UpgradeUnitConfigVo confVo ;
+
+ private static UpgradeManager manager ;
+
+ private UpgradeUnit(){} ;
+
+ public static UpgradeUnit getInstance(){
+ return instance ;
+ }
+
+ @Override
+ public void setAdapter(UnitAdapterInterface adapter) throws Exception {
+ if(adapter == null){
+ throw new Exception("RTU杩滅▼鍗囩骇妯″潡閫傞厤鍣ㄥ璞′笉鑳戒负绌猴紒") ;
+ }
+ UpgradeUnit.adapter = (UpgradeUnitAdapter)adapter ;
+ UpgradeUnit.confVo = UpgradeUnit.adapter.getConfig() ;
+ if(UpgradeUnit.confVo == null){
+ throw new Exception("RTU杩滅▼鍗囩骇妯″潡閰嶇疆瀵硅薄涓嶈兘涓虹┖锛�") ;
+ }
+ }
+
+ /**
+ * 鍒濆鍖�
+ */
+ @Override
+ public void start(UnitCallbackInterface callback) throws Exception {
+ if(confVo.enable){
+ manager = UpgradeManager.getInstance() ;
+ manager.initOption(confVo);
+ callback.call(null) ;
+ System.out.println("RTU杩滅▼鍗囩骇妯″潡鎴愬姛鍚姩");
+ }else{
+ System.out.println("RTU杩滅▼鍗囩骇妯″潡閰嶇疆涓嶅惎鍔�");
+ }
+
+ }
+
+ @Override
+ public void stop(UnitCallbackInterface callback) throws Exception {
+ forceOverUpgradeTask() ;
+ }
+
+
+
+ /**
+ * 璁剧疆鍗囩骇浠诲姟
+ * @param vo UpgradeTaskVo 鍗囩骇浠诲姟瀵硅薄
+ * @throws Exception
+ */
+ public void setUpgradeTask(UpgradeTaskVo vo) throws Exception {
+ if(manager != null ){
+ manager.setUpgradeTask(vo) ;
+ }
+ }
+
+ /**
+ * 缁撴潫褰撳墠鍗囩骇浠诲姟
+ * @throws Exception
+ * @return null锛氱粨鏉熶换鍔℃垚鍔燂紝鍚﹀垯杩斿洖澶辫触鍘熷洜
+ */
+ public String forceOverUpgradeTask() throws Exception {
+ if(manager != null ){
+ return manager.forceOverUpgradeTask() ;
+ }else{
+ return "閫氫俊涓棿浠跺唴閮ㄩ敊璇�" ;
+ }
+ }
+
+ /**
+ * RTU鏈変笂琛屾暟鎹簡锛岃Е鍙戜笅鍙戝崌绾ф暟鎹�
+ * @param rtuAddr
+ * @param code
+ * @param callback
+ */
+ public void trigger(String rtuAddr, String code, String protocolName, Short protocolVersion, Callback callback, Object ...objects){
+ if(manager != null ){
+ manager.trigger(rtuAddr, code, protocolName, protocolVersion, callback, objects);
+ }
+ }
+
+ ////////////////////////////////////////////////////
+ //
+ // 鏌ヨ鍗囩骇鐘舵�佷俊鎭�
+ //
+ ////////////////////////////////////////////////////
+ /**
+ * 褰撳墠鍗囩骇鐘舵��
+ * @return
+ public UpgradeState currentUpgradeState() {
+ if(manager != null ){
+ return manager.currentUpgradeState();
+ }
+ return null ;
+ }*/
+
+ /**
+ * Rtu鍗囩骇淇℃伅
+ * @param rtuAddr
+ * @return
+ public UpgradeRtuDev upgradeRtuInfo(String rtuAddr){
+ if(manager != null ){
+ return manager.upgradeInfos(rtuAddr);
+ }
+ return null ;
+ }*/
+
+ /**
+ * Rtu鍗囩骇淇℃伅
+ * @param rtuAddrList
+ * @return
+ public List<UpgradeRtuDev> upgradeRtuInfos(List<String> rtuAddrList){
+ if(manager != null ){
+ return manager.upgradeInfos(rtuAddrList);
+ }
+ return null ;
+ }*/
+
+ /**
+ * Rtu鍗囩骇淇℃伅
+ * @return
+ public List<UpgradeRtuDev> upgradeRtuInfoAll(){
+ if(manager != null ){
+ return manager.upgradeInfoAll();
+ }
+ return null ;
+ }*/
+
+}
+
--
Gitblit v1.8.0