Stream(ArrayList data, CorrectionFactor correctionFactor) { data.Add(new Snoop.Data.ClassSeparator(typeof(CorrectionFactor))); data.Add(new Snoop.Data.Double("Factor", correctionFactor.Factor)); data.Add(new Snoop.Data.Double("Temperature", correctionFactor.Temperature)); }
public void NewRequirement_InvalidKey_ThrowsAnExceptio(long id, double pas, double alpha) { WeightFraction PAS = new WeightFraction(pas); CorrectionFactor Alpha = new CorrectionFactor(alpha); Assert.Throws <InvalidKeyException>(() => { Requirement sr = new Requirement(id, PAS, Alpha, true); }); }
public void NewRequirement_ValidParameter_ExceptedPropertiesAndDefaultWeightIsOne(long id, double pas, double alpha, int n) { WeightFraction PAS = new WeightFraction(pas); CorrectionFactor Alpha = new CorrectionFactor(alpha); Requirement req = new Requirement(id, PAS, Alpha, true); // Weights are 1 by default req.PAS.Value.Should().Be(pas); req.Alpha.Value.Should().Be(alpha); req.Id.Should().Be(id); req.Weights[n].Value.Should().Be(1); // check complianceweight n-element as default value }
public Requirement(long id, WeightFraction pas, CorrectionFactor alpha, bool adequate) { if (id <= 0) { throw new InvalidKeyException(); } Id = id; PAS = pas; Alpha = alpha; Adequate = adequate; Weights = new Weights(Enumerable.Repeat((Weight) new DefaultWeight(), WEIGHTS_NUM).ToList()); }
public void CalculatePotentilRiskFactors_Scenario_CheckFactorsValue( double pas, double alpha, double prbia, double prbiaid, double prcompl) { WeightFraction PAS = new WeightFraction(pas); CorrectionFactor Alpha = new CorrectionFactor(alpha); Requirement req = new Requirement(101, PAS, Alpha, true, new int[38] { 3, 1, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, }); List <int> totals = new List <int>(new int[38] { 17, 13, 7, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, }); req.CalculatePotentialRisk(totals); R2(req.PotentialRiskBIA).Should().Be(prbia); R2(req.PotentialRiskBIAID).Should().Be(prbiaid); R2(req.PotentialRiskCOMPL).Should().Be(prcompl); }
CollectEvent(object sender, CollectorEventArgs e) { // cast the sender object to the SnoopCollector we are expecting Collector snoopCollector = sender as Collector; if (snoopCollector == null) { Debug.Assert(false); // why did someone else send us the message? return; } // see if it is a type we are responsible for Connector connector = e.ObjToSnoop as Connector; if (connector != null) { Utils.StreamWithReflection(snoopCollector.Data(), typeof(Connector), connector); return; } ConnectorManager connectorMgr = e.ObjToSnoop as ConnectorManager; if (connectorMgr != null) { Stream(snoopCollector.Data(), connectorMgr); return; } CorrectionFactor correctionFactor = e.ObjToSnoop as CorrectionFactor; if (correctionFactor != null) { Stream(snoopCollector.Data(), correctionFactor); return; } ElectricalSetting elecSetting = e.ObjToSnoop as ElectricalSetting; if (elecSetting != null) { Stream(snoopCollector.Data(), elecSetting); return; } GroundConductorSize groundConductorSize = e.ObjToSnoop as GroundConductorSize; if (groundConductorSize != null) { Stream(snoopCollector.Data(), groundConductorSize); return; } MEPModel mepModel = e.ObjToSnoop as MEPModel; if (mepModel != null) { Stream(snoopCollector.Data(), mepModel); return; } WireSize wireSize = e.ObjToSnoop as WireSize; if (wireSize != null) { Stream(snoopCollector.Data(), wireSize); return; } }
private void ExtractBolus(ICollection <DataRow> rows) { var exceptions = new ConcurrentQueue <Exception>(); Parallel.ForEach(rows, (row) => { try { Guid keyId = MemoryMappings.GetReadingHeaderKeyId(row["DOWNLOADKEYID"].ToString()); Guid userId = MemoryMappings.GetUserIdFromPatientInfo(MigrationVariables.CurrentSiteId, row["PATIENTKEYID"].ToString()); DateTime date = (row["READINGDATETIME"] is DBNull) ? new DateTime(1800, 1, 1) : mu.ParseFirebirdDateTime(row["READINGDATETIME"].ToString()); if (!keyId.Equals(Guid.Empty)) { Dictionary <string, string> bolusData = GetBolusData(row["METERSENT"].ToString()); var carb = new BolusCarb { Date = date, CarbValue = mu.ParseInt(bolusData["Carbs"]) }; var bgTar = new BGTarget { Date = date, TargetBG = mu.ParseInt(bolusData["Target BG"]) }; var ic = new InsulinCarbRatio { Date = date, ICRatio = mu.ParseInt(bolusData["IC Ratio"]) }; var cf = new CorrectionFactor { Date = date, CorrectionFactorValue = mu.ParseInt(bolusData["Correct"]) }; var iCorr = new InsulinCorrection { Date = date, InsulinCorrectionValue = mu.ParseInt(bolusData["Correction"]), InsulinCorrectionAbove = mu.ParseInt(bolusData["Correction Above"]) }; var bd = new BolusDelivery(); double dCarbs = mu.ParseDouble(bolusData["Carbs"]); double dIC = mu.ParseDouble(bolusData["IC Ratio"]); bd.ReadingKeyId = keyId; bd.UserId = userId; bd.StartDateTime = (row["READINGDATETIME"] is DBNull) ? new DateTime(1800, 1, 1) : mu.ParseFirebirdDateTime(row["READINGDATETIME"].ToString()); bd.AmountDelivered = mu.ParseDouble(bolusData["Total"]); bd.AmountSuggested = (dCarbs == 0.0) ? 0.0 : (dCarbs / dIC); bd.Duration = mu.ParseInt(bolusData["Extended Duration"]); bd.Type = "BolusDeliveryData"; bolusData.Remove("Carbs"); bolusData.Remove("Target BG"); bolusData.Remove("IC Ratio"); bolusData.Remove("Correct"); bolusData.Remove("Correction"); bolusData.Remove("Correct Above"); for (int i = 0; i < bolusData.Count; i++) { bd.BolusDeliveryDatas.Add(new BolusDeliveryData { Date = date, Name = bolusData.ElementAt(i).Key, Value = (String.IsNullOrEmpty(bolusData.ElementAt(i).Value)) ? String.Empty : bolusData.ElementAt(i).Value.Trim() }); } bd.BGTarget = bgTar; bd.BolusCarb = carb; bd.InsulinCarbRatio = ic; bd.InsulinCorrection = iCorr; bd.CorrectionFactor = cf; BolusDeliveries.Add(bd); } else { var primeKey = $"{row["DOWNLOADKEYID"].ToString()}-{row["SEQ"].ToString()}"; MappingStatistics.LogFailedMapping("METERREADING", primeKey, "BOLUSDELIVERY", typeof(BolusDelivery), String.Empty, "Failed to map BOLUS reading, unable to parse key id."); } } catch (Exception e) { exceptions.Enqueue(e); } }); if (exceptions.Count > 0) { throw new AggregateException(exceptions); } }
public Requirement(long id, WeightFraction pas, CorrectionFactor alpha, bool adequate, int[] weights) : this(id, pas, alpha, adequate) { InitializeWeightsWithIntArray(weights); }
private void 系数设定ToolStripMenuItem1_Click(object sender, EventArgs e) { CorrectionFactor correctionFactor = new CorrectionFactor(); correctionFactor.Show(); }