| | |
| | | @JSONField(serialize = false) |
| | | protected Integer ugMaxRtuSameTime ;//同时升级RTU最大个数 |
| | | @JSONField(serialize = false) |
| | | private Boolean openNoUpgrade ;//阀开(泵开)不执行升级 |
| | | @JSONField(serialize = false) |
| | | private Integer lastOpenMaxGoOn ;//阀开(泵开)状态设置以来持续最长时间(秒钟),超过这个时间认为状态无效(这个时长取决于工作报间隔) |
| | | |
| | | public String setupDt ;//设置时间(yyyy-mm-dd HH:MM:SS) |
| | |
| | | /** |
| | | * 初始化配置信息 |
| | | */ |
| | | public void initOption(Integer lastOpenMaxGoOn, Integer failTryTimes, Integer ugMaxRtuSameTime) { |
| | | public void initOption(Boolean openNoUpgrade, |
| | | Integer lastOpenMaxGoOn, |
| | | Integer failTryTimes, |
| | | Integer ugMaxRtuSameTime) { |
| | | this.openNoUpgrade = openNoUpgrade; |
| | | this.lastOpenMaxGoOn = lastOpenMaxGoOn; |
| | | this.failTryTimes = failTryTimes; |
| | | this.ugMaxRtuSameTime = ugMaxRtuSameTime; |
| | |
| | | * @param code |
| | | * @param callbackCom |
| | | */ |
| | | public void trigger(String rtuAddr, String code, String protocolName, Short protocolVersion, Callback callbackCom){ |
| | | public void trigger(String rtuAddr, String code, String protocolName, Short protocolVersion, Callback callbackCom, Object ...objects){ |
| | | if(this.upgradeRtus != null && this.upgradeRtus.size() > 0 |
| | | && this.taskVo.rtuAddrList != null && this.taskVo.rtuAddrList.size() > 0){ |
| | | UpgradeRtu ugRtu = this.upgradeRtus.get(rtuAddr) ; |
| | |
| | | //当前RTU已经升级完成,无需再升级 |
| | | return; |
| | | }else{ |
| | | if(this.openNoUpgrade){ |
| | | //首先判断是否是阀门打开状态 |
| | | RtuStatus rtuStatus = RtuStatusDealer.oneStatus(rtuAddr) ; |
| | | if(rtuStatus != null |
| | | && rtuStatus.valveOpenTrueCloseFalse != null |
| | | && rtuStatus.valveOpenTrueCloseFalse.booleanValue() == true |
| | | && rtuStatus.valveStatusLastTimeStamp != null){ |
| | | //有状态,并且是阀开(泵开) |
| | | Long now = System.currentTimeMillis() ; |
| | | Long gap = now - rtuStatus.valveStatusLastTimeStamp ; |
| | | if(gap < this.lastOpenMaxGoOn){ |
| | | //这时采纳阀门打开状态,进而不能升级 |
| | | ugRtu.isOver = true ; |
| | | ugRtu.state = UpgradeRtu.STATE_FAILOPEN ; |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(UpgradeUnit.confVo.ugMaxRtuAtOnce > 0){ |
| | | //设置了同时升级的RTU最大数量的限制 |
| | | if(ugRtu.state == UpgradeRtuDev.STATE_OFFLINE){ |
| | | //初始态,说明升级任务设置以来,该RTU第一次上行数据 |
| | | if(this.curUgRunningRtuTotal <= UpgradeUnit.confVo.ugMaxRtuAtOnce){ |
| | | //当前正在升级的RTU数量还未受限 |
| | | ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom) ; |
| | | ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom, objects) ; |
| | | }else{ |
| | | //同时升级的RTU数量受限,等待下次机会 |
| | | //但先表明一下状态 |
| | |
| | | //根据上面逻辑, 说明必然在线了 |
| | | if(this.curUgRunningRtuTotal <= UpgradeUnit.confVo.ugMaxRtuAtOnce){ |
| | | //当前正在升级的RTU数量还未受限 |
| | | ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom) ; |
| | | ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom, objects) ; |
| | | }else{ |
| | | //同时升级的RTU数量受限,等待下次机会 |
| | | return ; |
| | | } |
| | | }else{ |
| | | //RTU已经处于升级过程中 |
| | | ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom) ; |
| | | ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom, objects) ; |
| | | } |
| | | }else{ |
| | | //没有设置同时升级的RTU最大数量的限制 |
| | | ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom) ; |
| | | ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom, objects) ; |
| | | } |
| | | } |
| | | } |