| | |
| | | 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 ; |
| | | } |