public async Task <PartResult> GetPartUploadInfoAsync(PartUpload partUpload) { using (var uplinkPartResult = await Task.Run(() => SWIG.storj_uplink.uplink_part_upload_info(partUpload._partUpload)).ConfigureAwait(false)) { var partResult = new PartResult(); if (uplinkPartResult.error != null && !string.IsNullOrEmpty(uplinkPartResult.error.message)) { partResult.Error = uplinkPartResult.error.message; } else { partResult.Part = Part.FromSWIG(uplinkPartResult.part); } return(partResult); } }
private void WritePrr(PartResult partResult) { Prr prr = new Prr(); prr.HEAD_NUM = 1; prr.RecordHeader.REC_LEN += 1; prr.SITE_NUM = partResult.SiteNumber; prr.RecordHeader.REC_LEN += 1; prr.PART_FLG = partResult.isSuccess ? (byte)0x00 : (byte)0x80;//0x00:pass; 0x80:fail prr.RecordHeader.REC_LEN += 1; prr.NUM_TEST = partResult.NumberOfTests; prr.RecordHeader.REC_LEN += 2; prr.HARD_BIN = partResult.HardBin.BinNum; prr.RecordHeader.REC_LEN += 2; prr.SOFT_BIN = partResult.SoftBin.BinNum; prr.TEST_T = (uint)partResult.Duration; prr.PART_ID = partResult.PartID.ToString(); prr.RecordHeader.REC_LEN += (ushort)(prr.PART_ID.Length); prr.RecordHeader.REC_LEN += (prr.PART_FIX == null) ? (ushort)1 : (ushort)prr.PART_FIX.Length; sfw.WriteRecord(prr); }
public List <PartResult> ResultParser(List <TestResult> testResults, ref uint partID) { List <PartResult> list = new List <PartResult>(); foreach (var col in testResults.GroupBy(x => x.SiteNumber)) { List <TestResult> items = col.ToList(); PartResult pr = new PartResult(); pr.SiteNumber = col.Key; pr.PartID = ++partID; pr.isSuccess = items.Any(x => x.PFFlag == false) ? false : true; pr.SoftBin = SoftBinParser(items); pr.HardBin = HardBinParser(pr.SoftBin); pr.Duration = (double)items.Sum(x => x.Duration); pr.NumberOfTests = (ushort)items.Count; pr.TestResults = items; list.Add(pr); } return(list); }
private PartResult Evaluate(Instance instance, long state) { var partResult = new PartResult(); for (var i = 0;; ++i) { var num = 1L << i; if (num > state) { break; } if ((state & num) != 0) { partResult.Price += instance.Items[i].Price; partResult.Weight += instance.Items[i].Weight; } } return(partResult); }