public PackageHelper(BinInfo info, IDownloadSender downloadSender) { _binInfo = info; DownloadSender = downloadSender; var rest = info.BinConfigFileLength % info.PackageBinLength; var fullPackageCount = info.BinConfigFileLength / info.PackageBinLength; var totalPackageCount = rest == 0 ? (ushort)fullPackageCount : (ushort)(fullPackageCount + 1); _package = new FirmwareUpdatePackage(totalPackageCount, info); _timerOutTimer = new Timer { Interval = _binInfo.TimeOut * 1000, Enabled = true }; _timerOutTimer.Elapsed += (sender, args) => { _isDownloading = false; DownloadSender.Received -= Received; DownloadInterrupt(new DownloadInterruptedEventArgs { Message = "等待回复超时。" }); _timerOutTimer.Stop(); }; }
public DownloadUnit(IReadOnlyCollection <BinInfo> binfileInfos, IDownloadSender downloadSender) { _packageHelpers = new PackageHelper[binfileInfos.Count]; var index = 0; foreach (var binInfo in binfileInfos) { _packageHelpers[index] = new PackageHelper(binInfo, downloadSender); index++; } }
public DownloadProcessControl(BinInfo[] binfileInfos, IDownloadSender downloadSender) { TotalFileDownloadMissions = binfileInfos.Length; _downloadUnints = new DownloadUnit[1]; _downloadUnints[0] = new DownloadUnit(binfileInfos, downloadSender); }