1、优化代码;2、修改长级测试中发现的bug;3、通信中间件配置文件配置项修改
| | |
| | | response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, SsoVo.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼è®¿é®åç¹ç»å½ç³»ç»å¼å¸¸"); |
| | | } |
| | | assert response != null; |
| | | return response.getBody(); |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼è®¿é®åç¹ç»å½ç³»ç»å¼å¸¸"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | }else { |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼æªå¾å°SsoCheckUrl"); |
| | | } |
| | |
| | | response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, SsoVo.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼è®¿é®åç¹ç»å½ç³»ç»å¼å¸¸"); |
| | | } |
| | | assert response != null; |
| | | return response.getBody(); |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼è®¿é®åç¹ç»å½ç³»ç»å¼å¸¸"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | }else { |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼æªå¾å°SsoCheckUrl"); |
| | | } |
| | |
| | | int len = ByteUtilUnsigned.byte2Byte(bs, ProtocolConstantV206V1.dataLenIndex); |
| | | return len + ProtocolConstantV206V1.lenHead2ctrl + ProtocolConstantV206V1.lenTail; |
| | | }else{ |
| | | int len = ByteUtilUnsigned.bytes2Short_BE(bs, ProtocolConstantV206V1.UG_dataLenIndex_start); |
| | | int len = ByteUtilUnsigned.bytes2Short_LE(bs, ProtocolConstantV206V1.UG_dataLenIndex_start); |
| | | return len + ProtocolConstantV206V1.UG_lenHead2Cmd + ProtocolConstantV206V1.UG_lenTail; |
| | | } |
| | | } |
| | |
| | | return "计ç®CRCæ¯:" + crcCompute + "ï¼ä¸ä¼ CRCæ¯" + crcInBs ; |
| | | } |
| | | }else{ |
| | | int crcCompute = (byte)new CRC16().CRC(bs, ProtocolConstantV206V1.ctrlIndex, bs.length - 3) ; |
| | | int crcInBs = ByteUtilUnsigned.bytes2Short_BE(bs, bs.length - 3) ; |
| | | short crcCompute = new CRC16().CRC(bs, 0, bs.length - 4) ; |
| | | short crcInBs = ByteUtil.bytes2Short_BE(bs,bs.length - 3) ; |
| | | //int crcInBs = ByteUtilUnsigned.bytes2Short_BE(bs, bs.length - 3) ; |
| | | if(crcCompute == crcInBs){ |
| | | return null ; |
| | | }else{ |
| | |
| | | isFail = true ; |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1.protocolName, rtuAddr, "严éé误ï¼åæRtuæ°æ®åºéï¼æ°æ®ä¸ºï¼" + upHex + (e.getMessage() == null?"":("ï¼åºéä¿¡æ¯ï¼" + e.getMessage())), e))} ; |
| | | } finally{ |
| | | callback.callback(rtuAddr, upCode, CodeV1.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddr); |
| | | if(upCode != null){ |
| | | //CRCéªè¯å¤±è´¥æ¶ï¼upCode为nullï¼æ¤æ¶ä¸è¿è¡åè° |
| | | callback.callback(rtuAddr, upCode, CodeV1.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddr); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | confirmCommand.isQuickSend = true ; |
| | | } |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | midRs.downCodeName = CodeV1.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = true ;//æ¯å¦æåºç |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | |
| | | if(para.param == null){ |
| | | throw new Exception("åæ°ä¸ºç©º") ; |
| | | } |
| | | if(para.param instanceof Com1601Vo){ |
| | | if(!(para.param instanceof Com1601Vo)){ |
| | | throw new Exception("åæ°ç±»åéCom1601Vo") ; |
| | | } |
| | | Com1601Vo vo = (Com1601Vo) para.param ; |
| | |
| | | midRs.downCodeName = CodeV1.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = true ;//æ¯å¦æåºç |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | |
| | | midRs.downCodeName = CodeV1.getCodeName(para.commandCode) ;//ä¸è¡å½ä»¤åè½ç åç§°; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = true ;//æ¯å¦æåºç |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | } |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | */ |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = false ;//主å¨ä¸æ¥ |
| | | midRs.reportOrResponse_trueOrFalse = true ;//å级çï¼ä¸è®¤ä¸ºæ¯å½ä»¤åºç |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | if(para.data != null && para.data.getSubData() != null){ |
| | |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = false ;//主å¨ä¸æ¥ |
| | | midRs.reportOrResponse_trueOrFalse = true ;//å级çï¼ä¸è®¤ä¸ºæ¯å½ä»¤åºç |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | if(para.data != null && para.data.getSubData() != null){ |
| | |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = false ;//主å¨ä¸æ¥ |
| | | midRs.reportOrResponse_trueOrFalse = true ;//å级çï¼ä¸è®¤ä¸ºæ¯å½ä»¤åºç |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | if(para.data != null && para.data.getSubData() != null){ |
| | |
| | | } |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | } |
| | | |
| | | public static byte[] createCrcTail4Ug(byte[] bsNoTail) throws Exception { |
| | | int crc = new CRC16().CRC(bsNoTail, 0, bsNoTail.length -1) ; |
| | | short crc = new CRC16().CRC(bsNoTail, 0, bsNoTail.length -1) ; |
| | | byte[] bytes = new byte[ProtocolConstantV206V1.UG_lenTail] ; |
| | | ByteUtilUnsigned.short2Bytes_BE(bytes, crc, 0); |
| | | ByteUtil.short2Bytes_BE(bytes, crc, 0); |
| | | bytes[2] = ProtocolConstantV206V1.P_Tail_Byte ; |
| | | return bytes ; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | callback.notify(new ValveStateInfo(cdData.stateVo.valveState.byteValue()== 1?false:true)); |
| | | } |
| | | } |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | callback.notify(new ValveStateInfo(false)); |
| | | } |
| | | } |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | */ |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | } |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | confirmCommand.isQuickSend = true ; |
| | | } |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | callback.notify(new ValveStateInfo(true)) ; |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | callback.notify(new ValveStateInfo(cdData.statePump.byteValue()== 1?true:false)); |
| | | } |
| | | } |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | } |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | callback.notify(new ValveStateInfo(true)); |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | callback.notify(new ValveStateInfo(false)); |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | confirmCommand.isQuickSend = true ; |
| | | } |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | } |
| | | } |
| | | |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | |
| | | public UpgradeState ugOverallState; |
| | | //å级任å¡RTUç¶æå表 |
| | | public List<UpgradeRtu> ugRtuStateList; |
| | | |
| | | public String toString(){ |
| | | return this.toString(null) ; |
| | | } |
| | | |
| | | public String toString(String logRtuAddr){ |
| | | StringBuilder sb = new StringBuilder() ; |
| | | sb.append("RTUè¿ç¨åçº§ç¶æï¼") ; |
| | | sb.append(" \nä»»å¡idï¼" + ugTaskId) ; |
| | | sb.append(" \n" + ugOverallState.toString()) ; |
| | | //sb.append(" \nåçº§çæ§å¶å¨æ»æ°ï¼" + ugRtuStateList.size()) ; |
| | | if(ugRtuStateList != null && ugRtuStateList.size() > 0){ |
| | | sb.append(" \nåçº§çæ§å¶å¨æ»æ°ï¼" + ugRtuStateList.size()) ; |
| | | sb.append(" \nå
¶ä¸ä¸ä¸ªæ§å¶å¨å级æ
åµï¼") ; |
| | | AtomicBoolean exist = new AtomicBoolean(false); |
| | | if(logRtuAddr != null){ |
| | | ugRtuStateList.stream().filter(ur -> ur.getRtuAddr().equals(logRtuAddr)).forEach(ur -> { |
| | | sb.append(" \n" + ur.toString()) ; |
| | | exist.set(true); |
| | | }) ; |
| | | } |
| | | if(!exist.get()){ |
| | | sb.append(" \n" + ugRtuStateList.get(0).toString()) ; |
| | | } |
| | | } |
| | | return sb.toString() ; |
| | | } |
| | | } |
| | |
| | | // s1ä¸å |
| | | s0 <<= 8; |
| | | s = s0 | s1; |
| | | return (short) s; |
| | | |
| | | return (short)s ; |
| | | } else { |
| | | throw new Exception("byte2Shortæ¶æ°ç»è¶ç"); |
| | | } |
| | |
| | | * @return CRC |
| | | */ |
| | | @SuppressWarnings("unused") |
| | | public int CRC(byte[] b, int startIndex, int endIndex) { |
| | | public short CRC(byte[] b, int startIndex, int endIndex) { |
| | | int crc = 0xFFFF; |
| | | for (int j = startIndex ; j <= endIndex; j++) { |
| | | crc = crc ^ ((b[j] + 256) % 256) ;//è½¬æ¢ææ ç¬¦å·æ°ï¼å 为ç»ç«¯å®ç°(Cè¯è¨ææ±ç¼è¯è¨)é½ç¨çæ¯æ ç¬¦å·æ° |
| | |
| | | } |
| | | } |
| | | } |
| | | return crc; |
| | | return (short)crc; |
| | | } |
| | | |
| | | |
| | |
| | | import com.dy.common.mw.protocol.CommandType; |
| | | import com.dy.common.softUpgrade.state.UpgradeTaskVo; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import org.springframework.core.env.Environment; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | |
| | | response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | } |
| | | return response.getBody(); |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | } |
| | | return response.getBody(); |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | } |
| | | } |
| | |
| | | //RTUè¿ç¨å级模å |
| | | UpgradeUnitConfigVo ugVo = new UpgradeUnitConfigVo(); |
| | | ugVo.enable = conf.getSetAttrBoolean(doc, "config.upgrade", "enable", null, null) ; |
| | | ugVo.noOneRtuUpgradeMaxDuration = conf.getSetAttrPlusInt(doc, "config.upgrade", "noOneRtuUpgradeMaxDuration", null, 5, 3600, null); |
| | | ugVo.noOneRtuUpgradeMaxDuration = ugVo.noOneRtuUpgradeMaxDuration * 1000 ;//åææ¯«ç§ |
| | | ugVo.failTryTimes = conf.getSetAttrPlusInt(doc, "config.upgrade", "failTryTimes", null, 0, 100, null); |
| | | ugVo.ugMaxRtuAtOnce = conf.getSetAttrPlusInt(doc, "config.upgrade", "ugMaxRtuAtOnce", null, 0, 1000000, null); |
| | | ugVo.rtuOffLineWaitDuration = conf.getSetAttrPlusInt(doc, "config.upgrade", "rtuOffLineWaitDuration", null, 1, 36000, null); |
| | | ugVo.rtuOffLineWaitDuration = ugVo.rtuOffLineWaitDuration + 1000;//åææ¯«ç§ |
| | | ugVo.rtuOffLineWaitDuration = ugVo.rtuOffLineWaitDuration * 1000;//åææ¯«ç§ |
| | | ugVo.notifyStateInterval = conf.getSetAttrPlusInt(doc, "config.upgrade", "notifyStateInterval", null, 1, 300, null); |
| | | ugVo.notifyStateInterval = ugVo.notifyStateInterval + 1000;//åææ¯«ç§ |
| | | ugVo.notifyStateInterval = ugVo.notifyStateInterval * 1000;//åææ¯«ç§ |
| | | ugVo.showStartInfo = showStartInfo ; |
| | | AdapterImp_UpgradeUnit ugAdap = new AdapterImp_UpgradeUnit(); |
| | | ugAdap.setConfig(ugVo); |
| | |
| | | }else{ |
| | | if(!this.task.taskIsOver){ |
| | | //åçº§ä»»å¡æªå®æ |
| | | //å·¥ä½1ï¼ç»è®¡å½åæ£å¨å级çRTUæ°éï¼ä¸ºåéåæ¶å级æ°éååå¤ |
| | | this.task.statisticsRunningRtuCount() ; |
| | | //å·¥ä½1ï¼å¤ææ¯å¦æ ä»»ä½ä¸ä¸ªRTUè¿è¡è¿å级ï¼å¹¶ä¸è¾¾å°æ¶éï¼å认为å½åå级任å¡å®æ |
| | | int temp = this.task.countNoOneRtuUpgrade() ; |
| | | if(temp == -1){ |
| | | this.task.taskIsOver = true ; |
| | | //ä»»å¡å·²ç»å®æ |
| | | this.stop(); |
| | | }else if(temp == 1){ |
| | | //å·¥ä½2ï¼ç»è®¡å½åæ£å¨å级çRTUæ°éï¼ä¸ºåæ¶å级æ°ééå¶ååå¤ |
| | | this.task.statisticsRunningRtuCount() ; |
| | | |
| | | //å·¥ä½2ï¼ç»è®¡éè¦å级ä½å½å离线RTUçæ
åµ |
| | | this.task.statisticsOffRtuCountAndSet() ; |
| | | //å·¥ä½3ï¼ç»è®¡éè¦å级ä½å½å离线RTUçæ
åµ |
| | | this.task.statisticsOffRtuCountAndSet() ; |
| | | |
| | | //å·¥ä½3ï¼ç»è®¡æ¯å¦å
¨é¨åçº§å®æ |
| | | this.task.taskIsOver = this.task.statisticsIsAllOver() ; |
| | | |
| | | //å·¥ä½4ï¼ç»è®¡æ¯å¦å
¨é¨åçº§å®æ |
| | | this.task.taskIsOver = this.task.statisticsIsAllOver() ; |
| | | }else if(temp == 0){ |
| | | //ä¸ä½ä¸º |
| | | } |
| | | if(this.task.taskIsOver){ |
| | | if(!this.task.taskOverType.equals(UpgradeTask.TaskOverType_Force)){ |
| | | //ä»»å¡ä¸æ¯å¼ºå¶ç»æç |
| | |
| | | this.task.taskOverDt = DateTime.yyyy_MM_dd_HH_mm_ss() ;//ä»»å¡å®ææ¶é´(yyyy-mm-dd HH:MM:SS) |
| | | } |
| | | //ä»»å¡å®æï¼æ§è¡æå䏿¬¡åçº§ç¶æéç¥ |
| | | //å·¥ä½4ï¼åçº§ç¶æéç¥ |
| | | if(!first){ |
| | | this.notifyUpgradeStatus() ; |
| | | } |
| | | //å·¥ä½5ï¼åçº§ç¶æéç¥ |
| | | //if(!first){ |
| | | // this.notifyUpgradeStatus() ; |
| | | //} |
| | | }else{ |
| | | //任塿ªå®æï¼ç»§ç»æ§è¡åçº§ç¶æéç¥ |
| | | //å·¥ä½4ï¼ åçº§ç¶æéç¥ |
| | | if(!first){ |
| | | this.notifyUpgradeStatus() ; |
| | | } |
| | | //å·¥ä½5ï¼ åçº§ç¶æéç¥ |
| | | //if(!first){ |
| | | // this.notifyUpgradeStatus() ; |
| | | //} |
| | | } |
| | | //å·¥ä½5ï¼åçº§ç¶æéç¥ |
| | | if(!first){ |
| | | this.notifyUpgradeStatus() ; |
| | | } |
| | | }else{ |
| | | //ä»»å¡å·²ç»å®æ |
| | |
| | | import com.dy.common.mw.protocol.CommandType; |
| | | import com.dy.common.softUpgrade.Com1601Vo; |
| | | import com.dy.common.softUpgrade.state.UpgradeRtu; |
| | | import com.dy.common.softUpgrade.state.UpgradeTaskVo; |
| | | import com.dy.common.util.Callback; |
| | | import com.dy.common.util.DateTime; |
| | | import lombok.Data; |
| | |
| | | public class UpgradeRtuDev extends UpgradeRtu { |
| | | |
| | | @JSONField(serialize = false) |
| | | private UpgradeTask task ; |
| | | private Integer failTryTimes ;//å级失败åï¼éæ°å¿è¯å级次æ°ï¼0表示ä¸éæ°å¿è¯å级 |
| | | |
| | | @JSONField(serialize = false) |
| | | public UpgradeTaskVo taskVo ;//å级任å¡å¼å¯¹è±¡ |
| | | |
| | | private UpgradeRtuDev(){ |
| | | } |
| | | |
| | | public UpgradeRtuDev(UpgradeTask task, String rtuAddr, int totalPackage) { |
| | | public UpgradeRtuDev(UpgradeTaskVo taskVo, Integer failTryTimes , String rtuAddr, int totalPackage) { |
| | | super(); |
| | | this.task = task ; |
| | | //this.task = task ; |
| | | this.taskVo = taskVo ; |
| | | this.failTryTimes = failTryTimes ; |
| | | this.rtuAddr = rtuAddr ; |
| | | this.state = STATE_UNSTART ; |
| | | this.totalPackage = totalPackage ; |
| | |
| | | this.isOver = false ; |
| | | } |
| | | |
| | | public UpgradeRtuDev(UpgradeTask task, String rtuAddr, int totalPackage, int state) { |
| | | public UpgradeRtuDev(UpgradeTaskVo taskVo, Integer failTryTimes, String rtuAddr, int totalPackage, int state) { |
| | | super(); |
| | | this.task = task ; |
| | | //this.task = task ; |
| | | this.taskVo = taskVo ; |
| | | this.failTryTimes = failTryTimes ; |
| | | this.rtuAddr = rtuAddr ; |
| | | this.state = state ; |
| | | this.totalPackage = totalPackage ; |
| | |
| | | callbackCom.call(createCommand1601(protocolName, protocolVersion)); |
| | | }else if(this.state == STATE_RUNNING){ |
| | | //å½åå级è¿ç¨ä¸ |
| | | if(code.equals(UpgradeCode.cd_1601)){ |
| | | if(code.equals(UpgradeCode.cd_9601)){ |
| | | //ä¸åé
ç½®è¿å |
| | | this.lastDownDt = DateTime.yyyy_MM_dd_HH_mm_ss() ; |
| | | callbackCom.call(createCommand1602(protocolName, protocolVersion, currentPackage, currentRamAddr, softData));//ä¸åæ°æ®å
æä»¤ |
| | | }else if(code.equals(UpgradeCode.cd_1602)){ |
| | | }else if(code.equals(UpgradeCode.cd_9602)){ |
| | | //ä¸åæ°æ®å
è¿å |
| | | currentPackage++ ; |
| | | currentRamAddr += RAMADDRADD ; |
| | |
| | | this.lastDownDt = DateTime.yyyy_MM_dd_HH_mm_ss() ; |
| | | callbackCom.call(createCommand1603(protocolName, protocolVersion));//ä¸åæ ¡éªæä»¤ |
| | | } |
| | | }else if(code.equals(UpgradeCode.cd_1603)){ |
| | | }else if(code.equals(UpgradeCode.cd_9603)){ |
| | | //ä¸åæ ¡éªè¿å |
| | | this.isOver = true ;//åçº§å®æ |
| | | this.state = STATE_SUCCESS ; |
| | |
| | | //å级æªå®æ |
| | | if(this.state == STATE_FAILONE || this.state == STATE_FAIL){ |
| | | //å·²ç»æ¯å级失败æ |
| | | if(this.reTryTimes < task.failTryTimes){ |
| | | if(this.reTryTimes < this.failTryTimes){ |
| | | //éè¯æ¬¡æ°æªè¾¾å°ä¸éï¼ç»§ç»éè¯ |
| | | this.reTryTimes += 1 ; |
| | | this.setStateAtCom1601Time(); |
| | |
| | | com.rtuResultSendWebUrl = Command.ignoreRtuResultSendWebUrl ; |
| | | |
| | | Com1601Vo vo = new Com1601Vo() ; |
| | | vo.softStoreAddr = this.task.taskVo.softStoreAddr ; |
| | | vo.softStartAddr = this.task.taskVo.softStartAddr ; |
| | | vo.totalByte = this.task.taskVo.softBytesCalculate ; |
| | | vo.softCrc = this.task.taskVo.softByteSrc16; |
| | | vo.softStoreAddr = this.taskVo.softStoreAddr ; |
| | | vo.softStartAddr = this.taskVo.softStartAddr ; |
| | | vo.totalByte = this.taskVo.softBytesCalculate ; |
| | | vo.softCrc = this.taskVo.softByteSrc16; |
| | | com.param = vo ; |
| | | return com ; |
| | | } |
| | |
| | | import com.dy.common.util.Callback; |
| | | import com.dy.common.util.DateTime; |
| | | import lombok.Data; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | |
| | | */ |
| | | @Data |
| | | public class UpgradeTask { |
| | | |
| | | private static final Logger log = LogManager.getLogger(UpgradeTask.class.getName()); |
| | | |
| | | protected static final String TaskOverType_Natural = "èªç¶" ; |
| | | protected static final String TaskOverType_Force = "强å¶" ; |
| | |
| | | protected byte[][] softFileDataGrp ;//以512åè为å使å级ç¨åºæ°æ®åç» |
| | | |
| | | @JSONField(serialize = false) |
| | | protected Map<String, UpgradeRtu> upgradeRtus;//åçº§ç¶æ |
| | | protected ConcurrentHashMap<String, UpgradeRtu> upgradeRtus;//åçº§ç¶æ |
| | | |
| | | public boolean taskIsOver = false ;//任塿¯å¦å®æ |
| | | public String taskOverType = "" ;//ä»»å¡å®ææ¹å¼ï¼èªç¶ï¼å¼ºå¶ï¼ |
| | |
| | | this.setupDtLong = System.currentTimeMillis() ; |
| | | this.taskVo = taskVo ; |
| | | |
| | | this.upgradeRtus = new HashMap<>(); |
| | | if(taskVo.softFileData64 != null && taskVo.softFileData64.trim().equals("")){ |
| | | this.upgradeRtus = new ConcurrentHashMap<>(); |
| | | if(taskVo.softFileData64 != null && !taskVo.softFileData64.trim().equals("")){ |
| | | taskVo.softFileData = Base64.getDecoder().decode(taskVo.softFileData64); |
| | | List<byte[]> listBytes = new HexFileParse().splitBytesByUnit512(taskVo.softFileData); |
| | | this.softFileDataGrp = listBytes.toArray(new byte[0][]); |
| | | for(String rtuAddr : this.taskVo.rtuAddrList){ |
| | | //æ¤æ¶ç¶æè®¾ç½®æç¦»çº¿ç¶æ |
| | | UpgradeRtuDev ugRtu = new UpgradeRtuDev(this, rtuAddr, this.softFileDataGrp.length, UpgradeRtuDev.STATE_OFFLINE) ; |
| | | this.upgradeRtus.put(rtuAddr, ugRtu) ; |
| | | try{ |
| | | for(String rtuAddr : this.taskVo.rtuAddrList){ |
| | | //æ¤æ¶ç¶æè®¾ç½®æç¦»çº¿ç¶æ |
| | | UpgradeRtuDev ugRtu = new UpgradeRtuDev(this.taskVo, this.failTryTimes, rtuAddr, this.softFileDataGrp.length, UpgradeRtuDev.STATE_OFFLINE) ; |
| | | this.upgradeRtus.put(rtuAddr, ugRtu) ; |
| | | } |
| | | }catch (Exception e){ |
| | | log.error(e); |
| | | } |
| | | } |
| | | } |
| | |
| | | //æ ¹æ®æ¹æ³setTaskçé»è¾ï¼åªè¦RTUå¨å级ä¹åï¼æ¤å¤ugRtuStateä¸å®ä¸ä¸ºnull |
| | | //为ä¿é©ï¼å®ç°ä¸é¢é»è¾ |
| | | if(taskVo.rtuAddrList.contains(rtuAddr)){ |
| | | ugRtu = new UpgradeRtuDev(this, rtuAddr, this.taskVo.softFileData.length) ; |
| | | ugRtu = new UpgradeRtuDev(this.taskVo, this.failTryTimes, rtuAddr, this.taskVo.softFileData.length) ; |
| | | upgradeRtus.put(rtuAddr, ugRtu) ; |
| | | }else{ |
| | | //rtuä¸å¨å级ä¹å |
| | |
| | | /////////////////////////////////////////////////////////// |
| | | //以䏿¹æ³ä¸ºå
鍿å¡ï¼ä¸å¯¹å¤æä¾æå¡ |
| | | /////////////////////////////////////////////////////////// |
| | | |
| | | /** |
| | | * ç»è®¡å½åæ£å¨å级çRTUæ°éï¼ä¸ºåéåæ¶å级æ°éååå¤ |
| | | * 夿æ¯å¦æ²¡ç¨ä»»ä½ä¸ä¸ªRTUè¿è¡è¿å级ï¼èä¸è¶
è¿äºæ¶é |
| | | * @return -1:æ ä¸RTUå级ä¸è¶
æ¶ï¼0ï¼æ RTUåçº§ä½æªè¶
æ¶çå¾
ï¼1æRTUå级æ£å¸¸æ§è¡ |
| | | */ |
| | | protected int countNoOneRtuUpgrade(){ |
| | | if(this.upgradeRtus == null || upgradeRtus.size() == 0){ |
| | | //å½å没æä»»ä½ä¸ä¸ªè®¾å¤è¿è¡è¿å级 |
| | | Long now = System.currentTimeMillis() ; |
| | | if(now - this.setupDtLong > UpgradeUnit.confVo.noOneRtuUpgradeMaxDuration){ |
| | | return -1 ; |
| | | } |
| | | }else{ |
| | | Collection<UpgradeRtu> col = this.upgradeRtus.values() ; |
| | | for(UpgradeRtu info : col){ |
| | | if(info.currentPackage > 0){ |
| | | //å½åæè®¾å¤è¿è¡è¿å级 |
| | | return 1 ; |
| | | } |
| | | } |
| | | Long now = System.currentTimeMillis() ; |
| | | if(now - this.setupDtLong > UpgradeUnit.confVo.noOneRtuUpgradeMaxDuration){ |
| | | return -1 ; |
| | | } |
| | | } |
| | | return 0 ; |
| | | } |
| | | |
| | | /** |
| | | * ç»è®¡å½åæ£å¨å级çRTUæ°éï¼ä¸ºåæ¶å级æ°ééå¶ååå¤ |
| | | */ |
| | | protected void statisticsRunningRtuCount(){ |
| | | int runningTotal = 0 ; |
| | |
| | | |
| | | public Boolean showStartInfo ; |
| | | public Boolean enable ;//æ¨¡åæ¯å¦å¯å¨ |
| | | public Integer noOneRtuUpgradeMaxDuration ;//å级任å¡è®¾ç½®åï¼æ²¡æè®¾å¤å级æå¤§æ¶é¿ï¼æ¯«ç§ï¼ï¼è¶
è¿è¿ä¸ªæ¶é¿ï¼è®¤ä¸ºå级任å¡å®æï¼åå¼èå´æ¯5åé~60åé |
| | | public Integer failTryTimes ;//å级失败åï¼éå¯¹çæ¯å¨çº¿è¿è¡äºå级ä¸åå½ä»¤ï¼ï¼éæ°å¿è¯å级次æ°ï¼0表示ä¸éæ°å¿è¯å级 |
| | | public Integer ugMaxRtuAtOnce;//为äºç¼è§£éä¿¡ä¸é´ä»¶çååï¼åæ¶æ¯æå级çRTUå°æ° |
| | | public Integer rtuOffLineWaitDuration;//rtu离线ï¼çå¾
å
¶åçº§çæ¶é¿(毫ç§)ï¼è¶
è¿è¿ä¸ªæ¶é´ï¼è®¾ç½®å
¶å级失败ï¼ä¸è®¾ç½®å级任å¡å®æ |
| | |
| | | |
| | | public UpgradeUnitConfigVo(){ |
| | | this.enable = false ; |
| | | this.noOneRtuUpgradeMaxDuration = 10 * 60 * 1000 ; |
| | | this.failTryTimes = 0 ; |
| | | this.ugMaxRtuAtOnce = Integer.MAX_VALUE ; |
| | | this.rtuOffLineWaitDuration = 10 * 60 * 60 * 1000 ; |
| | |
| | | package com.dy.rtuMw.web.comResult; |
| | | |
| | | import com.dy.common.contant.Constant; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.mw.protocol.Data; |
| | | import com.dy.rtuMw.server.ServerProperties; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | * @Author liurunyu |
| | | * @Date 2023/12/21 20:28 |
| | | * @LastEditTime 2023/12/21 20:28 |
| | | * @Description |
| | | * @Description éä¿¡ä¸é´ä»¶å¯¹å¤è¿è¡webè°ç¨ï¼æå½ä»¤ç»æåéåºå» |
| | | */ |
| | | @Component() |
| | | public class CommandResultDeal { |
| | |
| | | restTemplate.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8)); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8")); |
| | | headers.set(Constant.UserTokenKeyInHeader, ServerProperties.orgTag); |
| | | HttpEntity<?> httpEntity = new HttpEntity<>(data, headers); |
| | | ResponseEntity<WebResponseVo> response = null; |
| | | try { |
| | |
| | | package com.dy.rtuMw.web.webRequest; |
| | | |
| | | import com.dy.common.contant.Constant; |
| | | import com.dy.common.mw.protocol.Command; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.rtuMw.server.ServerProperties; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | restTemplate.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8)); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8")); |
| | | headers.set(Constant.UserTokenKeyInHeader, ServerProperties.orgTag); |
| | | HttpEntity<?> httpEntity = new HttpEntity<>(obj, headers); |
| | | ResponseEntity<BaseResponse> response = null; |
| | | try { |
| | |
| | | sendDingDingAlarmMsInterval: ææ¥è¦åçæ¶ï¼åééåéæ¶æ¯çé´éæ¶é¿ï¼åéï¼ |
| | | --> |
| | | <base |
| | | orgTag="sp" |
| | | isLowPower="false" |
| | | onlyDealRtus="" |
| | | onlyOneProtocol="false" |
| | | downComandMaxResendTimes="1" |
| | | commandSendInterval="10" |
| | | cachWaitResultTimeout="120" |
| | | offLineCachTimeout="86400" |
| | | lastUpDataTimeLive="500" |
| | | dbDataIdSuffix="0" |
| | | cacheUpDownDataWarnCount="100000" |
| | | cacheUpDownDataMaxCount="110000" |
| | | disconnectedByNoUpDataMinutes="3" |
| | | workReportDealOneByTimes="5" |
| | | intakeAlarmLossMinValue="1.0" |
| | | sendDingDingAlarmMsInterval="60" |
| | | orgTag="sp" |
| | | isLowPower="false" |
| | | onlyDealRtus="" |
| | | onlyOneProtocol="false" |
| | | downComandMaxResendTimes="1" |
| | | commandSendInterval="3" |
| | | cachWaitResultTimeout="120" |
| | | offLineCachTimeout="86400" |
| | | lastUpDataTimeLive="500" |
| | | dbDataIdSuffix="0" |
| | | cacheUpDownDataWarnCount="100000" |
| | | cacheUpDownDataMaxCount="110000" |
| | | disconnectedByNoUpDataMinutes="3" |
| | | workReportDealOneByTimes="5" |
| | | intakeAlarmLossMinValue="1.0" |
| | | sendDingDingAlarmMsInterval="60" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | synchroRtuClockTimepiecesï¼å½RTU䏿å¡å¨æ¶éç¸å·®ä¸å®æ¯«ç§ï¼é
ç½®æä»¶æ¯ç§éï¼åï¼è¿è¡æ ¡æ¶ |
| | | --> |
| | | <protocol |
| | | centerAddr="1" |
| | | synchroRtuClock="true" |
| | | synchroRtuClockTimepieces="300000" |
| | | centerAddr="1" |
| | | synchroRtuClock="true" |
| | | synchroRtuClockTimepieces="300000" |
| | | /> |
| | | |
| | | <!-- RTU 软件å级 |
| | | enable: æ¨¡åæ¯å¦å¯å¨ |
| | | noOneRtuUpgradeMaxDurationï¼å级任å¡è®¾ç½®åï¼æ ä¸è®¾å¤å级æå¤§æ¶é¿ï¼ç§ï¼ï¼è¶
è¿è¿ä¸ªæ¶é¿ï¼è®¤ä¸ºå级任å¡å®æï¼åå¼èå´æ¯5åé~60åé |
| | | failTryTimesï¼å级失败åï¼éå¯¹çæ¯å¨çº¿è¿è¡äºå级ä¸åå½ä»¤ï¼ï¼éæ°å¿è¯å级次æ°ï¼å½è®¾ç½®ä¸º0æ¶è¡¨ç¤ºä¸éæ°å¿è¯å级 |
| | | ugMaxRtuAtOnceï¼ä¸ºäºç¼è§£éä¿¡ä¸é´ä»¶çååï¼åæ¶æ¯æå级çRTUå°æ°ï¼å½è®¾ç½®ä¸º0æ¶è¡¨ç¤ºä¸åéå¶ |
| | | rtuOffLineWaitDuration: rtu离线ï¼çå¾
å
¶åçº§çæ¶é¿ï¼ç§ï¼ï¼è¶
è¿è¿ä¸ªæ¶é´ï¼è®¾ç½®å
¶å级失败ï¼ä¸è®¾ç½®å级任å¡å®æ |
| | | notifyStateInterval: åçº§ç¶æéç¥é´éï¼ç§ï¼ |
| | | --> |
| | | <upgrade enable="true" |
| | | noOneRtuUpgradeMaxDuration="600" |
| | | failTryTimes="1" |
| | | ugMaxRtuAtOnce="1000" |
| | | rtuOffLineWaitDuration="1200" |
| | |
| | | enableThreadPoolï¼æ¯å¦å¯ç¨çº¿ç¨æ± |
| | | --> |
| | | <support |
| | | short_maxThread="6" |
| | | short_minThread="6" |
| | | short_freeTimeout="60" |
| | | short_busyTimeout="5" |
| | | long_maxThread="6" |
| | | long_minThread="6" |
| | | long_freeTimeout="60" |
| | | long_busyTimeout="-1" |
| | | enableThreadPool="true" |
| | | short_maxThread="6" |
| | | short_minThread="6" |
| | | short_freeTimeout="60" |
| | | short_busyTimeout="5" |
| | | long_maxThread="6" |
| | | long_minThread="6" |
| | | long_freeTimeout="60" |
| | | long_busyTimeout="-1" |
| | | enableThreadPool="true" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | saveDbIntervalï¼Rtuç¶æåæ°æ®åºé´é(åé) |
| | | --> |
| | | <resource |
| | | rtuLogDir="rtuLogs/" |
| | | rtuLogFileMaxSize="100000" |
| | | rtuLogFileMaxCount="2" |
| | | monitorInterval="2" |
| | | saveDbInterval="10" |
| | | rtuLogDir="rtuLogs/" |
| | | rtuLogFileMaxSize="100000" |
| | | rtuLogFileMaxCount="2" |
| | | monitorInterval="2" |
| | | saveDbInterval="10" |
| | | /> |
| | | |
| | | |
| | |
| | | queueMaxSize: ç¼åéåèç¹æ°æå¤§æ°é |
| | | --> |
| | | <core |
| | | sleepBigBusy="100" |
| | | sleepSmallBusy="500" |
| | | queueWarnSize="100000" |
| | | queueMaxSize="300000" |
| | | sleepBigBusy="100" |
| | | sleepSmallBusy="500" |
| | | queueWarnSize="100000" |
| | | queueMaxSize="300000" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | sendDingDingAlarmMsInterval: ææ¥è¦åçæ¶ï¼åééåéæ¶æ¯çé´éæ¶é¿ï¼åéï¼ |
| | | --> |
| | | <base |
| | | orgTag="test" |
| | | isLowPower="false" |
| | | onlyDealRtus="" |
| | | onlyOneProtocol="false" |
| | | downComandMaxResendTimes="1" |
| | | commandSendInterval="10" |
| | | cachWaitResultTimeout="120" |
| | | offLineCachTimeout="86400" |
| | | lastUpDataTimeLive="500" |
| | | dbDataIdSuffix="0" |
| | | cacheUpDownDataWarnCount="100000" |
| | | cacheUpDownDataMaxCount="110000" |
| | | disconnectedByNoUpDataMinutes="3" |
| | | workReportDealOneByTimes="5" |
| | | intakeAlarmLossMinValue="1.0" |
| | | sendDingDingAlarmMsInterval="60" |
| | | orgTag="test" |
| | | isLowPower="false" |
| | | onlyDealRtus="" |
| | | onlyOneProtocol="false" |
| | | downComandMaxResendTimes="1" |
| | | commandSendInterval="3" |
| | | cachWaitResultTimeout="120" |
| | | offLineCachTimeout="86400" |
| | | lastUpDataTimeLive="500" |
| | | dbDataIdSuffix="0" |
| | | cacheUpDownDataWarnCount="100000" |
| | | cacheUpDownDataMaxCount="110000" |
| | | disconnectedByNoUpDataMinutes="3" |
| | | workReportDealOneByTimes="5" |
| | | intakeAlarmLossMinValue="1.0" |
| | | sendDingDingAlarmMsInterval="60" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | synchroRtuClockTimepiecesï¼å½RTU䏿å¡å¨æ¶éç¸å·®ä¸å®æ¯«ç§ï¼é
ç½®æä»¶æ¯ç§éï¼åï¼è¿è¡æ ¡æ¶ |
| | | --> |
| | | <protocol |
| | | centerAddr="1" |
| | | synchroRtuClock="true" |
| | | synchroRtuClockTimepieces="300000" |
| | | centerAddr="1" |
| | | synchroRtuClock="true" |
| | | synchroRtuClockTimepieces="300000" |
| | | /> |
| | | |
| | | <!-- RTU 软件å级 |
| | | enable: æ¨¡åæ¯å¦å¯å¨ |
| | | noOneRtuUpgradeMaxDurationï¼å级任å¡è®¾ç½®åï¼æ ä¸è®¾å¤å级æå¤§æ¶é¿ï¼ç§ï¼ï¼è¶
è¿è¿ä¸ªæ¶é¿ï¼è®¤ä¸ºå级任å¡å®æï¼åå¼èå´æ¯5åé~60åé |
| | | failTryTimesï¼å级失败åï¼éå¯¹çæ¯å¨çº¿è¿è¡äºå级ä¸åå½ä»¤ï¼ï¼éæ°å¿è¯å级次æ°ï¼å½è®¾ç½®ä¸º0æ¶è¡¨ç¤ºä¸éæ°å¿è¯å级 |
| | | ugMaxRtuAtOnceï¼ä¸ºäºç¼è§£éä¿¡ä¸é´ä»¶çååï¼åæ¶æ¯æå级çRTUå°æ°ï¼å½è®¾ç½®ä¸º0æ¶è¡¨ç¤ºä¸åéå¶ |
| | | rtuOffLineWaitDuration: rtu离线ï¼çå¾
å
¶åçº§çæ¶é¿ï¼ç§ï¼ï¼è¶
è¿è¿ä¸ªæ¶é´ï¼è®¾ç½®å
¶å级失败ï¼ä¸è®¾ç½®å级任å¡å®æ |
| | | notifyStateInterval: åçº§ç¶æéç¥é´éï¼ç§ï¼ |
| | | --> |
| | | <upgrade enable="true" |
| | | noOneRtuUpgradeMaxDuration="600" |
| | | failTryTimes="1" |
| | | ugMaxRtuAtOnce="1000" |
| | | rtuOffLineWaitDuration="1200" |
| | |
| | | enableThreadPoolï¼æ¯å¦å¯ç¨çº¿ç¨æ± |
| | | --> |
| | | <support |
| | | short_maxThread="6" |
| | | short_minThread="6" |
| | | short_freeTimeout="60" |
| | | short_busyTimeout="5" |
| | | long_maxThread="6" |
| | | long_minThread="6" |
| | | long_freeTimeout="60" |
| | | long_busyTimeout="-1" |
| | | enableThreadPool="true" |
| | | short_maxThread="6" |
| | | short_minThread="6" |
| | | short_freeTimeout="60" |
| | | short_busyTimeout="5" |
| | | long_maxThread="6" |
| | | long_minThread="6" |
| | | long_freeTimeout="60" |
| | | long_busyTimeout="-1" |
| | | enableThreadPool="true" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | saveDbIntervalï¼Rtuç¶æåæ°æ®åºé´é(åé) |
| | | --> |
| | | <resource |
| | | rtuLogDir="rtuLogs/" |
| | | rtuLogFileMaxSize="100000" |
| | | rtuLogFileMaxCount="2" |
| | | monitorInterval="2" |
| | | saveDbInterval="10" |
| | | rtuLogDir="rtuLogs/" |
| | | rtuLogFileMaxSize="100000" |
| | | rtuLogFileMaxCount="2" |
| | | monitorInterval="2" |
| | | saveDbInterval="10" |
| | | /> |
| | | |
| | | |
| | |
| | | queueMaxSize: ç¼åéåèç¹æ°æå¤§æ°é |
| | | --> |
| | | <core |
| | | sleepBigBusy="100" |
| | | sleepSmallBusy="500" |
| | | queueWarnSize="100000" |
| | | queueMaxSize="300000" |
| | | sleepBigBusy="100" |
| | | sleepSmallBusy="500" |
| | | queueWarnSize="100000" |
| | | queueMaxSize="300000" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | sendDingDingAlarmMsInterval: ææ¥è¦åçæ¶ï¼åééåéæ¶æ¯çé´éæ¶é¿ï¼åéï¼ |
| | | --> |
| | | <base |
| | | orgTag="ym" |
| | | isLowPower="false" |
| | | onlyDealRtus="" |
| | | onlyOneProtocol="false" |
| | | downComandMaxResendTimes="1" |
| | | commandSendInterval="10" |
| | | cachWaitResultTimeout="120" |
| | | offLineCachTimeout="86400" |
| | | lastUpDataTimeLive="500" |
| | | dbDataIdSuffix="0" |
| | | cacheUpDownDataWarnCount="100000" |
| | | cacheUpDownDataMaxCount="110000" |
| | | disconnectedByNoUpDataMinutes="3" |
| | | workReportDealOneByTimes="5" |
| | | intakeAlarmLossMinValue="1.0" |
| | | sendDingDingAlarmMsInterval="60" |
| | | orgTag="ym" |
| | | isLowPower="false" |
| | | onlyDealRtus="" |
| | | onlyOneProtocol="false" |
| | | downComandMaxResendTimes="1" |
| | | commandSendInterval="3" |
| | | cachWaitResultTimeout="120" |
| | | offLineCachTimeout="86400" |
| | | lastUpDataTimeLive="500" |
| | | dbDataIdSuffix="0" |
| | | cacheUpDownDataWarnCount="100000" |
| | | cacheUpDownDataMaxCount="110000" |
| | | disconnectedByNoUpDataMinutes="3" |
| | | workReportDealOneByTimes="5" |
| | | intakeAlarmLossMinValue="1.0" |
| | | sendDingDingAlarmMsInterval="60" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | synchroRtuClockTimepiecesï¼å½RTU䏿å¡å¨æ¶éç¸å·®ä¸å®æ¯«ç§ï¼é
ç½®æä»¶æ¯ç§éï¼åï¼è¿è¡æ ¡æ¶ |
| | | --> |
| | | <protocol |
| | | centerAddr="1" |
| | | synchroRtuClock="true" |
| | | synchroRtuClockTimepieces="300000" |
| | | centerAddr="1" |
| | | synchroRtuClock="true" |
| | | synchroRtuClockTimepieces="300000" |
| | | /> |
| | | |
| | | <!-- RTU 软件å级 |
| | | enable: æ¨¡åæ¯å¦å¯å¨ |
| | | noOneRtuUpgradeMaxDurationï¼å级任å¡è®¾ç½®åï¼æ ä¸è®¾å¤å级æå¤§æ¶é¿ï¼ç§ï¼ï¼è¶
è¿è¿ä¸ªæ¶é¿ï¼è®¤ä¸ºå级任å¡å®æï¼åå¼èå´æ¯5åé~60åé |
| | | failTryTimesï¼å级失败åï¼éå¯¹çæ¯å¨çº¿è¿è¡äºå级ä¸åå½ä»¤ï¼ï¼éæ°å¿è¯å级次æ°ï¼å½è®¾ç½®ä¸º0æ¶è¡¨ç¤ºä¸éæ°å¿è¯å级 |
| | | ugMaxRtuAtOnceï¼ä¸ºäºç¼è§£éä¿¡ä¸é´ä»¶çååï¼åæ¶æ¯æå级çRTUå°æ°ï¼å½è®¾ç½®ä¸º0æ¶è¡¨ç¤ºä¸åéå¶ |
| | | rtuOffLineWaitDuration: rtu离线ï¼çå¾
å
¶åçº§çæ¶é¿ï¼ç§ï¼ï¼è¶
è¿è¿ä¸ªæ¶é´ï¼è®¾ç½®å
¶å级失败ï¼ä¸è®¾ç½®å级任å¡å®æ |
| | | notifyStateInterval: åçº§ç¶æéç¥é´éï¼ç§ï¼ |
| | | --> |
| | | <upgrade enable="true" |
| | | noOneRtuUpgradeMaxDuration="600" |
| | | failTryTimes="1" |
| | | ugMaxRtuAtOnce="1000" |
| | | rtuOffLineWaitDuration="1200" |
| | |
| | | enableThreadPoolï¼æ¯å¦å¯ç¨çº¿ç¨æ± |
| | | --> |
| | | <support |
| | | short_maxThread="6" |
| | | short_minThread="6" |
| | | short_freeTimeout="60" |
| | | short_busyTimeout="5" |
| | | long_maxThread="6" |
| | | long_minThread="6" |
| | | long_freeTimeout="60" |
| | | long_busyTimeout="-1" |
| | | enableThreadPool="true" |
| | | short_maxThread="6" |
| | | short_minThread="6" |
| | | short_freeTimeout="60" |
| | | short_busyTimeout="5" |
| | | long_maxThread="6" |
| | | long_minThread="6" |
| | | long_freeTimeout="60" |
| | | long_busyTimeout="-1" |
| | | enableThreadPool="true" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | saveDbIntervalï¼Rtuç¶æåæ°æ®åºé´é(åé) |
| | | --> |
| | | <resource |
| | | rtuLogDir="rtuLogs/" |
| | | rtuLogFileMaxSize="100000" |
| | | rtuLogFileMaxCount="2" |
| | | monitorInterval="2" |
| | | saveDbInterval="10" |
| | | rtuLogDir="rtuLogs/" |
| | | rtuLogFileMaxSize="100000" |
| | | rtuLogFileMaxCount="2" |
| | | monitorInterval="2" |
| | | saveDbInterval="10" |
| | | /> |
| | | |
| | | |
| | |
| | | queueMaxSize: ç¼åéåèç¹æ°æå¤§æ°é |
| | | --> |
| | | <core |
| | | sleepBigBusy="100" |
| | | sleepSmallBusy="500" |
| | | queueWarnSize="100000" |
| | | queueMaxSize="300000" |
| | | sleepBigBusy="100" |
| | | sleepSmallBusy="500" |
| | | queueWarnSize="100000" |
| | | queueMaxSize="300000" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | onlyDealRtus="" |
| | | onlyOneProtocol="false" |
| | | downComandMaxResendTimes="1" |
| | | commandSendInterval="10" |
| | | commandSendInterval="3" |
| | | cachWaitResultTimeout="120" |
| | | offLineCachTimeout="86400" |
| | | lastUpDataTimeLive="500" |
| | |
| | | |
| | | <!-- RTU 软件å级 |
| | | enable: æ¨¡åæ¯å¦å¯å¨ |
| | | noOneRtuUpgradeMaxDurationï¼å级任å¡è®¾ç½®åï¼æ ä¸è®¾å¤å级æå¤§æ¶é¿ï¼ç§ï¼ï¼è¶
è¿è¿ä¸ªæ¶é¿ï¼è®¤ä¸ºå级任å¡å®æï¼åå¼èå´æ¯5åé~60åé |
| | | failTryTimesï¼å级失败åï¼éå¯¹çæ¯å¨çº¿è¿è¡äºå级ä¸åå½ä»¤ï¼ï¼éæ°å¿è¯å级次æ°ï¼å½è®¾ç½®ä¸º0æ¶è¡¨ç¤ºä¸éæ°å¿è¯å级 |
| | | ugMaxRtuAtOnceï¼ä¸ºäºç¼è§£éä¿¡ä¸é´ä»¶çååï¼åæ¶æ¯æå级çRTUå°æ°ï¼å½è®¾ç½®ä¸º0æ¶è¡¨ç¤ºä¸åéå¶ |
| | | rtuOffLineWaitDuration: rtu离线ï¼çå¾
å
¶åçº§çæ¶é¿ï¼ç§ï¼ï¼è¶
è¿è¿ä¸ªæ¶é´ï¼è®¾ç½®å
¶å级失败ï¼ä¸è®¾ç½®å级任å¡å®æ |
| | | notifyStateInterval: åçº§ç¶æéç¥é´éï¼ç§ï¼ |
| | | --> |
| | | <upgrade enable="true" |
| | | noOneRtuUpgradeMaxDuration="600" |
| | | failTryTimes="1" |
| | | ugMaxRtuAtOnce="1000" |
| | | rtuOffLineWaitDuration="1200" |
| | |
| | | public class DownData { |
| | | |
| | | public void parseData(byte[] bs){ |
| | | if(bs != null && bs.length >= ProtocolConstantV206V1.lenHead2Code){ |
| | | if(bs != null && bs.length > 0){ |
| | | if(bs.length >= (ProtocolConstantV206V1.ctrlIndex) |
| | | && bs[0] == ProtocolConstantV206V1.P_Head_Byte |
| | | && bs[2] == ProtocolConstantV206V1.P_Head_Byte){ |
| | |
| | | //åºè¯¥æ¯é¾è·¯æ£æµæ°æ® |
| | | } |
| | | private void dealUpgrade(byte[] bs){ |
| | | String cdPre = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.codeIndex, 1); |
| | | String cdPre = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.UG_codeIndex, 1); |
| | | if(cdPre.equals("16")){ |
| | | //å级åè½ç |
| | | UpHeartBeat.upHeartBeat = false ;//ä¸ä¸è¡å¿è·³ |
| | | if(bs.length >= ProtocolConstantV206V1.lenHead2Code + 1){ |
| | | String cdSuf = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.codeIndex + 1, 1); |
| | | if(bs.length >= ProtocolConstantV206V1.UG_lenHead2Cmd + 1){ |
| | | String cdSuf = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.UG_codeIndex + 1, 1); |
| | | String cd = cdPre + cdSuf; |
| | | if(cd.equals("1601")){ |
| | | //å级é
ç½® |
| | |
| | | protected static byte[] creatHead4Upgrade(String rtuAddr, String preCode, String sufCode)throws Exception { |
| | | byte[] bsHead = new byte[12] ; |
| | | byte index = 0 ; |
| | | bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ; |
| | | bsHead[index] = ProtocolConstantV206V1.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = 0 ;//帧é¿åº¦ |
| | |
| | | bsHead[index] = 0 ;//帧é¿åº¦ |
| | | |
| | | index++ ; |
| | | bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ; |
| | | bsHead[index] = ProtocolConstantV206V1.UG_P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = ByteUtil.hex2Bytes(preCode)[0]; //åè½ç å |
| | |
| | | import com.dy.common.mw.protocol.CommandType; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | |
| | | response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | } |
| | | return response.getBody(); |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | } |
| | | return response.getBody(); |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404; |
| | | import com.dy.common.mw.protocol.p206V202404.downVos.ComCdXyVo; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | |
| | | response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | } |
| | | return response.getBody(); |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | } |
| | | return response.getBody(); |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | package com.dy.pipIrrMwTestWeb.rtuLog; |
| | | |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | |
| | | response = restTemplate.exchange(fullUrl, HttpMethod.GET, httpEntity, BaseResponse.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | } |
| | | return response.getBody(); |
| | | if(response == null){ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼ä¸é´ä»¶è°ç¨å¼å¸¸"); |
| | | }else{ |
| | | return response.getBody(); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.dy.pipIrrRemote.rtuUpgrage; |
| | | |
| | | import com.dy.common.contant.Constant; |
| | | import com.dy.common.multiDataSource.DataSourceContext; |
| | | import com.dy.common.softUpgrade.state.UpgradeInfo; |
| | | import com.dy.common.softUpgrade.state.UpgradeRtu; |
| | | import com.dy.common.softUpgrade.state.UpgradeState; |
| | |
| | | import com.dy.pipIrrGlobal.pojoUg.UgRtuTask; |
| | | import io.swagger.v3.oas.annotations.Hidden; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | */ |
| | | @Hidden //ä¸å
¬å¼æ¥å£ï¼å
¶åªæéä¿¡ä¸é´ä»¶è°ç¨ |
| | | @PostMapping(path = "/receive") |
| | | public BaseResponse<Boolean> receive(@RequestBody UpgradeInfo info){ |
| | | log.info("æ¥æ¶å°çRTUè¿ç¨åçº§ç¶ææ°æ®ä¸ºï¼{}", info.toString()); |
| | | public BaseResponse<Boolean> receive(@RequestBody UpgradeInfo info, HttpServletRequest req, HttpServletResponse rep){ |
| | | log.info("æ¥æ¶å°çRTUè¿ç¨åçº§ç¶ææ°æ®ä¸ºï¼{}", info.toString("532328000214")); |
| | | //è¿è¡æåº |
| | | //Comparator<UpgradeRtu> comparator = Comparator.comparing(UpgradeRtu::getRtuAddr, Comparator.naturalOrder()); |
| | | //info.ugRtuStateList = info.ugRtuStateList.stream().sorted(comparator).collect(Collectors.toList()); |
| | | |
| | | //éä¿¡ä¸é´ä»¶ä¼ è¿æ¥çæºætagï¼ä»¥ç¨äºæ¥æ¾æ°æ®æº |
| | | String token = req.getHeader(Constant.UserTokenKeyInHeader); |
| | | DataSourceContext.set(token); |
| | | |
| | | if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){ |
| | | if(info.ugRtuStateList.size() < 10){ |
| | | for (UpgradeRtu rtuVo : info.ugRtuStateList) { |