public void Example1() { StandardMeasure<Mass> initialWgt = new StandardMeasure<Mass>(75.0); StandardMeasure<Mass> gainedWgt = new StandardMeasure<Mass>(2.5, Mass.HectoGram); StandardMeasure<Mass> newWgt = initialWgt + gainedWgt; Measure<Mass> newWgtInGram = newWgt[Mass.Gram]; Measure<Mass> initialWgtInGram = newWgtInGram - gainedWgt; Console.WriteLine("Initial weight: {0}", initialWgtInGram); Measure<Length> height = new Measure<Length>(30.0, Length.CentiMeter); StandardMeasure<Area> area = (StandardMeasure<Area>)0.02; StandardMeasure<Volume> vol; ArithmeticOperations.Times(height, area, out vol); var maxVol = new StandardMeasure<Volume>(10.0, Volume.Liter); if (vol < maxVol) { Console.WriteLine("Calculated volume is within limits, actual volume: {0}", vol[Volume.Liter]); } #if NUNIT24 Assert.Ignore(); #else Assert.Pass(); #endif }
private MeasureModel mapMeasureToMeasureModel(Measure measure) { MeasureModel measureModel = new MeasureModel(); measureModel.MeasureId = measure.measureid; measureModel.Type = measure.type; return measureModel; }
/// <summary> /// Method returning a valid MDX query if the param Measure is equal to OrderCount else an invalid MDX statement /// </summary> /// <param name="year">a calendar year without the 'CY'</param> /// <param name="measure"></param> /// <returns></returns> public string GetSelectMdxWithTwoParams(int year, Measure measure) { if (measure== Measure.OrderCount) return string.Format("SELECT [Measures].[Reseller Order Count] ON 0, [Date].[Calendar Year].[CY {0}] ON 1 FROM [Adventure Works]", year); else return "Incorrect Query"; }
private Measure CalcAvg(List<Measure> measureList) { var avgMeasure = new Measure(); foreach (var measure in measureList) { avgMeasure.GeneratorAmperage += measure.GeneratorAmperage; avgMeasure.GeneratorVoltage += measure.GeneratorVoltage; avgMeasure.GeneratorWattage += measure.GeneratorWattage; avgMeasure.GridAmperage += measure.GridAmperage; avgMeasure.GridVoltage += measure.GridVoltage; avgMeasure.OutputWattage += measure.OutputWattage; } //constant values int counter = measureList.Count; int lastIndex = measureList.Count - 1; avgMeasure.DateTime = currentMeasureTime; avgMeasure.PlantId = measureList[lastIndex].PlantId; avgMeasure.PrivateInverterId = measureList[lastIndex].PrivateInverterId; avgMeasure.SystemStatus = measureList[lastIndex].SystemStatus; avgMeasure.Temperature = measureList[lastIndex].Temperature; //calc average avgMeasure.GeneratorAmperage = avgMeasure.GeneratorAmperage / counter; avgMeasure.GeneratorVoltage = avgMeasure.GeneratorVoltage / counter; avgMeasure.GeneratorWattage = avgMeasure.GeneratorWattage / counter; avgMeasure.GridAmperage = avgMeasure.GridAmperage / counter; avgMeasure.GridVoltage = avgMeasure.GridVoltage / counter; avgMeasure.OutputWattage = avgMeasure.OutputWattage / counter; return avgMeasure; }
public void Indexer_SameQuantityNonGenericInterface_YieldsValidMeasureOBject() { var expected = new Measure<Volume>(5000.0, Volume.Liter); IMeasure meas = new StandardMeasure<Volume>(5.0); var actual = meas[Volume.Liter]; MeasureAssert.MeasuresAreEqual(expected, actual); }
public void GetAmount_UsingIUnit_ValidConversion() { var expected = AmountConverter.ToAmountType(500.0); var instance = new Measure<Length>(5.0, Length.Meter); var actual = instance.GetAmount(Length.CentiMeter); Assert.AreEqual(expected, actual); }
public Measure Convert(Measure measure) { //Actual conversions are relaxed about the units. At the end we should come out fine. return numeratorconverters .Concat(denominatorConverters) .Aggregate(measure, (m, edge) => edge.Convert(m)); }
public void AConversionFromMassToEnergy() { var m = new Measure(89875517873681764, U.Joule); var m2 = ug.Convert(m, U.Kilogram); m2.Unit.IsEqualTo(U.Kilogram); m2.Value.IsEqualTo(1); }
public void Power_LengthRaisedWith3_ReturnsVolume() { var expected = new Volume(1.0, Volume.CubicDeciMeter); var len = new Measure<Length>(1.0, Length.DeciMeter); Volume actual; ArithmeticOperations.Power(len, 3, out actual); MeasureAssert.AmountsAreEqual(expected, actual); }
public void Temp_Comparison_Yeah() { Type t = typeof(int); string ts = t.FullName; const int count = 10000; long time1, time2; using (var m = new Measure()) { for (int i = 0; i < count; i++) { bool equal = (t == typeof(long)); } time1 = m.ElapsedTicks; } using (var m = new Measure()) { for(int i = 0; i < count; i++) { bool equal = (ts == "System.Int64"); } time2 = m.ElapsedTicks; } Assert.NotEqual(time1, time2); }
public void CreateMeasures(IEnumerable<LoadMeasureModel> measures, Guid batchId) { var batch = Uow.Batches.Get(batchId); foreach (var measure in measures) { var sequence = CalculateSequence(measure.StandardId, batch.CreatedDate, measure.CreatedDate.GetValueOrDefault()); var standardItem = Uow.StandardItems.Get(x => x.Sequence == sequence && x.StandardGeneticLine.GeneticLineId == batch.GeneticLineId && x.StandardGeneticLine.StandardId == measure.StandardId); if (standardItem == null) { throw new ApplicationException("No se encontro ningun standard item para los valores indicados"); } var newMeasure = new Measure() { Id = Guid.NewGuid(), BatchId = batchId, CreatedDate = _clock.Now.Date, StandardItemId = standardItem.Id, Value = measure.Value.GetValueOrDefault() }; Uow.Measures.Add(newMeasure); } Uow.Commit(); }
public void AddMeasure(Measure measure) { if (_inputList == null) { _inputList = new List<Measure>(); } _inputList.Add(measure); }
public void AddMeasure(Measure measure) { if (!_measures.ContainsKey(measure.PrivateInverterId)) { _measures.Add(measure.PrivateInverterId, new List<Measure>()); } _measures[measure.PrivateInverterId].Add(measure); }
public void TheGraphSupportsConversionOverSeveralEdges() { var m = new Measure(1.0m, U.Inch); var m2 = ug.Convert(m, U.Meter); m2.Value.IsEqualTo(0.0254m); m2.Unit.Equals(U.Meter); }
/// <summary> /// Animates the control of a vertex to a given position. /// </summary> /// <param name="control">Vertex control which should be animated to its new position</param> /// <param name="coord">New vertex position coordinates</param> public void AddVertexData(IGraphControl control, Measure.Point coord) { if (double.IsNaN(coord.X) || double.IsNaN(coord.Y)) throw new GX_InvalidDataException("AddVertexData() -> NaN coordinated has been supplied! Correct coordinates was expected."); if (!VertexStorage.ContainsKey(control)) VertexStorage.Add(control, coord); else throw new GX_GeneralException("AddVertexData() -> Same control can't be loaded in animation list twice!"); }
public void MultiplicationWithNumber() { var m1 = new Measure(6.0m, Meter); var m2 = 3 * m1; var m3 = m1 * 3; m2.IsEqualTo(new Measure(18.0m, Meter)); m3.IsEqualTo(new Measure(18.0m, Meter)); }
protected LengthTypeFacet( DatatypeImpl _super ) : base(_super) { measure = _super.GetMeasure(); if(measure==null) // TODO: localization throw new DatatypeException("unapplicable facet"); }
public void TheConversionProvidesWorkingMeasure() { var m = new Measure(1.0m, U.Inch); var m2 = ug[U.Inch].Conversions[0].ApplyConversion(m); m2.Value.IsEqualTo(2.54m); m2.Unit.Equals(U.Centimeter); }
public KitchenModule(ModelDoc2 _rootModel, Component2 _swRootComponent, SwAddin _swAddin, ModelDoc2 _swModel) { RootModel = _rootModel; swRootComponent = _swRootComponent; measure = RootModel.Extension.CreateMeasure(); swAddin = _swAddin; swModel = _swModel; rootName = Path.GetFileNameWithoutExtension(RootModel.GetPathName()); }
public Measure ApplyConversion(Measure m) { if (measureBasedConversion) { var result = fromToToMeasures(m); return new Measure(result.Value, result.Unit); } return new Measure(fromToTo(m.Value), m.Unit * unitOperator); }
public void MeasuresCanBeDivided() { var m1 = new Measure(6.0m, Meter); var m2 = new Measure(2.0m, Second); var m3 = m1 / m2; m3.Value.IsEqualTo(3.0m); m3.Unit.IsEqualTo(Meter / Second); }
public void AConversionCanBeSet() { AdHocConfig.Use(c => { c.Unit(U.Inch).IsPhysicalUnit(U._LENGTH); c.Unit(U.Centimeter).IsPhysicalUnit(U._LENGTH) .ConvertValueBased(U.Inch, v => v*0.393700787m, v => v*2.54m); }); var m = new Measure(1.0m, U.Inch); m.ConvertTo(U.Centimeter).Value.IsEqualTo(2.54m); }
public void MeasuresCanBeMultiplied() { var m1 = new Measure(2.0m, Meter); var m2 = new Measure(6.0m, Second); var m3 = m1*m2; m3.Value.IsEqualTo(12.0m); m3.Unit.IsEqualTo(Meter * Second); }
public void DefaultConfigIsOverridablePerUnit() { AdHocConfig.Use(c => { c.SetMeasurePrecision(1); c.Unit(U.Nanosecond).HasPrecision(0); }); var m = new Measure(1.15m, U.Second); m.Value.IsEqualTo(1.2m); var m2 = new Measure(1.15m, U.Nanosecond); m2.Value.IsEqualTo(1.0m); }
public void TimeMeasureAdditionsNonStandardUnitWithStandardMeasure() { PerformTiming(() => { var val = new Measure<Length>(0.0, Length.CentiMeter); for (double i = 0.0; i < no; ++i) { val += new StandardMeasure<Length>(i); } return val; }); }
public void TimeMeasureAdditionsStandardUnitWithStandardMeasure() { PerformTiming(() => { var val = new Measure<Mass>(0.0); for (double i = 0.0; i < no; ++i) { val += new StandardMeasure<Mass>(i); } return val; }); }
private static void FromMySqlNeverAgain() { var dbcontext = new SupermarketContext(); var mySqlContx = new SupermarketModel(); using (mySqlContx) { var products = mySqlContx.Products.OrderBy(e => e.ID).ToList(); var vendors = mySqlContx.Vendors.ToList(); var mesuares = mySqlContx.Measures.ToList(); using (dbcontext) { foreach (var mesuare in mesuares) { var newMeasure = new Measure() { ID = mesuare.ID, Name = mesuare.Name }; dbcontext.Measures.Add(newMeasure); } foreach (var vendor in vendors) { var newVendor = new Vendor() { ID = vendor.ID, Name = vendor.Name }; dbcontext.Vendors.Add(newVendor); } foreach (var product in products) { var some = new Product { BasePrice = product.BasePrice, Measure_ID = product.Measure_ID, Name = product.Name, Vendor_ID = product.Vendor_ID, }; dbcontext.Products.Add(some); } dbcontext.SaveChanges(); } } }
public override Style FromString(string stringValue) { stringValue = stringValue.Trim(); String[] arr = stringValue.Split(' '); if (arr.Length != 2) throw new Exception("Invalid style value: " + stringValue); name = arr[1]; String s = arr[0]; try { if (s.Contains("px")) { String v = s.Replace("px", ""); v = v.Replace(',', '.'); size = float.Parse(v, CultureInfo.InvariantCulture); measure = Measure.Pixels; } else if (s.Contains("%")) { String v = s.Replace("%", ""); v = v.Replace(',', '.'); size = float.Parse(v, CultureInfo.InvariantCulture); measure = Measure.Percent; } else if (s.Contains("sp")) { String v = s.Replace("sp", ""); v = v.Replace(',', '.'); size = float.Parse(v, CultureInfo.InvariantCulture); measure = Measure.ScreenPercent; } else if (s.Contains("mm")) { String v = s.Replace("mm", ""); v = v.Replace(',', '.'); size = float.Parse(v, CultureInfo.InvariantCulture); measure = Measure.Millimetre; } else throw new Exception("Unknown measure"); return this; } catch (Exception e) { throw new Exception("Invalid style value: " + stringValue, e); } }
public static List<Measure> GetAverageMeasures(int count, DateTime date, double averageWattage) { List<Measure> measures = new List<Measure>(); for (int i = 0; i < count; i++) { var measure = new Measure(); measure.OutputWattage = averageWattage; measure.DateTime = date.AddMinutes(i); measure.PrivateInverterId = 1; measure.PlantId = 1; measures.Add(measure); } return measures; }
public void TimeMeasureAdditionsNonStandardUnitWithStandardMeasure() { PerformTiming( () => { var val = new Measure<Length>(0.0, Length.CentiMeter); for (var i = 0.0; i < no; ++i) { val += new Length(i); } return val; }, 0.5 * no * (no - 1.0) * 100.0); }
public void PerformOnMeasure(Measure measure, ScoreRendererBase renderer) { }
private async Task <V2SearchResponse> UseHijackIndexAsync(V2SearchRequest request) { var operation = _operationBuilder.V2SearchWithHijackIndex(request); V2SearchResponse output; switch (operation.Type) { case IndexOperationType.Get: var documentResult = await Measure.DurationWithValueAsync( () => _hijackIndex.Documents.GetOrNullAsync <HijackDocument.Full>(operation.DocumentKey)); // If the request is excluding SemVer 2.0.0 packages and the document is SemVer 2.0.0, filter it // out. The must be done after fetching the document because some SemVer 2.0.0 packages are // SemVer 2.0.0 because of a dependency version or because of build metadata (e.g. 1.0.0+metadata). // Neither of these reasons is apparent from the request. Build metadata is not used for comparison // so if someone searchs for "version:1.0.0+foo" and the actual package version is "1.0.0" or // "1.0.0+bar" the document will still be returned. // // A request looking for a specific package version that is SemVer 2.0.0 due to dots in the // prerelease label (e.g. 1.0.0-beta.1) could no-op if the request is not including SemVer 2.0.0 // but that's not worth the effort since we can catch that case after fetching the document anyway. // It's more consistent with the search operation path to make the SemVer 2.0.0 filtering decision // solely based on the document data. // // Note that the prerelease filter is ignored here by design. This is legacy behavior from the // previous search implementation. var document = documentResult.Value; if (document != null && !request.IncludeSemVer2 && document.SemVerLevel == SemVerLevelKey.SemVer2) { document = null; } output = _responseBuilder.V2FromHijackDocument( request, operation.DocumentKey, document, documentResult.Duration); _telemetryService.TrackV2GetDocumentWithHijackIndex(documentResult.Duration); break; case IndexOperationType.Search: var result = await Measure.DurationWithValueAsync(() => _hijackIndex.Documents.SearchAsync <HijackDocument.Full>( operation.SearchText, operation.SearchParameters)); output = _responseBuilder.V2FromHijack( request, operation.SearchText, operation.SearchParameters, result.Value, result.Duration); _telemetryService.TrackV2SearchQueryWithHijackIndex(result.Duration); break; case IndexOperationType.Empty: output = _responseBuilder.EmptyV2(request); break; default: throw UnsupportedOperation(operation); } return(output); }
public bool RemoveMeasure(Measure measure) { RemoveObservers(measure); return(measures.Remove(measure)); }
private void Init() { try { _highSymbolList = new List <Symbol>(); _lowSymbolList = new List <Symbol>(); XmlReaderSettings readerSettings = new XmlReaderSettings(); // readerSettings.ProhibitDtd = false; readerSettings.DtdProcessing = DtdProcessing.Ignore; XmlReader xmlReader = XmlReader.Create(_filename, readerSettings); // XmlReader xmlReader = XmlReader.Create(_filename); while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { switch (xmlReader.Name) { case "work-title": _workTitle = xmlReader.ReadString(); break; case "creator": _creator = xmlReader.ReadString(); break; case "divisions": _divisions = xmlReader.ReadString(); break; case "fifths": _fifths = xmlReader.ReadString(); break; case "beats": _beats = xmlReader.ReadString(); break; case "beat-type": _beatType = xmlReader.ReadString(); break; case "clef": _clef = xmlReader.GetAttribute("number"); break; case "sign": _sign = xmlReader.ReadString(); break; case "line": _line = xmlReader.ReadString(); break; case "step": _step = xmlReader.ReadString(); break; case "octave": _octave = xmlReader.ReadString(); break; case "duration": _duration = xmlReader.ReadString(); break; case "type": _type = xmlReader.ReadString(); break; case "accidental": _accidental = xmlReader.ReadString(); break; case "staff": _staff = xmlReader.ReadString(); break; case "stem": _stem = xmlReader.ReadString(); break; case "beam": _beamNum = xmlReader.GetAttribute("number"); if (_beamNum.Equals("1")) { _beam = xmlReader.ReadString(); } break; case "rest": // 休止符,由于休止符是self closing <rest /> 的,所以放在这里 _symbol = new Rest(); _symbol.SetChord(false); break; case "chord": // 和弦,由于和弦也是self closing <chord /> 的,所以也放在这里 _isChord = true; break; } } else if (xmlReader.NodeType == XmlNodeType.EndElement) { if (xmlReader.Name.Equals("time")) { // 节拍 _beat = new Beat(_beats, _beatType); _measureBeat = new Beat(_beats, _beatType); } if (xmlReader.Name.Equals("clef")) { // 谱号 if (_clef.Equals("1")) { _highHead = new Head(_fifths, _sign, _line); _measureHighHead = new Head(_fifths, _sign, _line); SetHighStandard(); } else if (_clef.Equals("2")) { _lowHead = new Head(_fifths, _sign, _line); _measureLowHead = new Head(_fifths, _sign, _line); SetLowStandard(); } } if (xmlReader.Name.Equals("pitch")) { // 音高 _symbol = new Note(_step, _octave); _symbol.SetChord(_isChord); _isChord = false; } if (xmlReader.Name.Equals("dot")) { _symbol.SetDot(1); // 附点 } if (xmlReader.Name.Equals("note")) { // 音符,包括音符及休止符 _symbol.SetDuration(_divisions, _duration); _symbol.SetType(_type); bool isNote = _symbol is Note; if (isNote) { ((Note)_symbol).SetAccidental(_accidental); _accidental = ""; if (_stem.Equals("up")) { ((Note)_symbol).SetUpOrDown(true); } else if (_stem.Equals("down")) { ((Note)_symbol).SetUpOrDown(false); } } if (_staff.Equals("1")) { if (isNote) { SetShift((Note)_symbol, _highStandardStep, _highStandardOctave); SetBeam(_highSymbolList); SetBeam(_highSymbolMeasure); } if (_symbol.IsChord()) { SetChord(_highSymbolList); SetChord(_highSymbolMeasure); } else { _symbol.SetStartTime(_highTime); _symbol.SetStopTime((_highTime += _symbol.GetDuration())); _highSymbolList.Add(_symbol); _highSymbolMeasure.Add(_symbol); } } else { if (isNote) { SetShift((Note)_symbol, _lowStandardStep, _lowStandardOctave); SetBeam(_lowSymbolList); SetBeam(_lowSymbolMeasure); } if (_symbol.IsChord()) { SetChord(_lowSymbolList); SetChord(_lowSymbolMeasure); } else { _symbol.SetStartTime(_lowTime); _symbol.SetStopTime((_lowTime += _symbol.GetDuration())); _lowSymbolList.Add(_symbol); _lowSymbolMeasure.Add(_symbol); } } } if (xmlReader.Name.Equals("measure")) // 小节结束 { // 整合这一个小节中的乐符 int maxCount = ArrangeMeasure(); // 存入小节 Measure measure = new Measure(_measureSymbolList); measure.SetMaxCount(maxCount); if (_measureBeat == null) { measure.SetHasBeat(false); } else { measure.SetHasBeat(true); measure.SetBeat(GetBeat()); } if (_measureHighHead == null || _measureLowHead == null) { measure.SetHasHead(false); } else { measure.SetHasHead(true); measure.SetHead(GetHighHead(), GetLowHead()); } _measureList.Add(measure); // 将相应List清零,下一个小节再重新赋值 _highSymbolMeasure = new List <Symbol>(); _lowSymbolMeasure = new List <Symbol>(); _measureSymbolList = new List <List <List <Symbol> > >(); _measureBeat = null; _measureHighHead = null; _measureLowHead = null; } } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
public ISet <Measure> supportedMeasures() { // pass all measures here so that the calculation is run to get the correct error message return(ImmutableSet.copyOf(Measure.extendedEnum().lookupAllNormalized().values())); }
public void TestOnTrueResult(int[] input, int numberOfClasses, double expectedResult) { var entropy = Measure.CalcEntropy(input, numberOfClasses); Assert.True(Math.Abs(expectedResult - entropy) < Epsilon); }
/// <summary> /// Returns the absolute position of this object in the measure /// </summary> /// <param name="measure"></param> /// <returns></returns> public double GetAbsolutePosition(Measure measure) { return(measure.AbsolutePosition + Position.Relative * measure.TimingPoint.MeasureDuration); }
private void LayoutStrings(Measure[] nutStringPos, Measure[] bridgeStringPos) { var stringLines = VisualElements.OfType <StringLine>(); if (NumberOfStrings == 1) { ConstructString(Strings[0], nutStringPos[0], bridgeStringPos[0]); } else if (ScaleLengthMode != ScaleLengthType.Multiple) { var trebleStr = ConstructString(Strings[0], nutStringPos[0], bridgeStringPos[0]); var bassStr = ConstructString(Strings[NumberOfStrings - 1], nutStringPos[NumberOfStrings - 1], bridgeStringPos[NumberOfStrings - 1]); var maxHeight = Measure.Max(trebleStr.Bounds.Height, bassStr.Bounds.Height); AdjustStringVerticalPosition(trebleStr, maxHeight); AdjustStringVerticalPosition(bassStr, maxHeight); var nutLine = Line.FromPoints(trebleStr.P1.ToVector(), bassStr.P1.ToVector()); var bridgeLine = Line.FromPoints(trebleStr.P2.ToVector(), bassStr.P2.ToVector()); var twelfthFret = new LayoutLine(PointM.Average(trebleStr.P1, trebleStr.P2), PointM.Average(bassStr.P1, bassStr.P2)); //create the remaining strings by distributing them equally between the outer strings for (int i = 1; i < NumberOfStrings - 1; i++) { var nutPos = nutLine.GetPointForX(nutStringPos[i].NormalizedValue); var bridgePos = bridgeLine.GetPointForX(bridgeStringPos[i].NormalizedValue); var createdString = AddVisualElement(new StringLine(Strings[i], PointM.FromVector(nutPos, nutStringPos[i].Unit), PointM.FromVector(bridgePos, bridgeStringPos[i].Unit))); //strings distributed equally between the outer strings (which are tapered/angled) do not have their centers aligned //so we correct the string length (at bridge) so that its center is aligned with the twelfth fret var middle = createdString.GetIntersection(twelfthFret); var distFromNut = PointM.Distance(createdString.P1, middle); var distFromBridge = PointM.Distance(createdString.P2, middle); var stringCenterOffset = Measure.Abs(distFromNut - distFromBridge); if (!CompensateFretPositions && stringCenterOffset > Measure.Mm(0.05)) { //adjust the end of the string so that it's center is above the 12th fret createdString.P2 = createdString.P1 + (createdString.Direction * distFromNut * 2); } Strings[i].RecalculateLengths();//store the physical length of the string } } else { for (int i = 0; i < NumberOfStrings; i++) { ConstructString(Strings[i], nutStringPos[i], bridgeStringPos[i]); } //*** Adjust strings position for multiscale var maxPerpHeight = Measure.FromNormalizedValue(stringLines.Max(l => l.Bounds.Height.NormalizedValue), UnitOfMeasure.Mm); foreach (var strLine in stringLines) { AdjustStringVerticalPosition(strLine, maxPerpHeight); } } //calculate starting fret position if different from 0 (nut) foreach (var str in Strings) { if (str.StartingFret != 0) { var startingFretPosRatio = GetEqualTemperedFretPosition(str.StartingFret); var stringVector = str.PlaceFretsRelativeToString ? str.LayoutLine.Direction * -1 : new Vector(0, 1); var startingFretPos = str.LayoutLine.P2 + (stringVector * str.CalculatedLength * startingFretPosRatio); if (!str.PlaceFretsRelativeToString) { startingFretPos = str.LayoutLine.SnapToLine(startingFretPos, LineSnapDirection.Horizontal); } str.LayoutLine.P1 = startingFretPos; str.RecalculateLengths(); } } for (int i = 0; i < NumberOfStrings - 1; i++) { AddVisualElement(new StringCenter(Strings[i + 1].LayoutLine, Strings[i].LayoutLine)); } }
public void Calculate(Measure measure) { var service = GetServiceForType(measure.measureType); service.Calculate(measure); }
/// <summary> /// Generatets the cost quality measure description. /// </summary> /// <param name="measure">The measure.</param> /// <param name="hasAllAudiences">if set to <c>true</c> [has all audiences].</param> /// <returns></returns> public static CostQualityMeasureDescription GeneratetCostQualityMeasureDescription(Measure measure, bool hasAllAudiences = true) { var cqmd = new CostQualityMeasureDescription() { MeasureId = measure.Id, MeasuresName = measure.MeasureCode, MeasureSource = measure.Source, SelectedTitle = measure.MeasureTitle.Selected == SelectedMeasuretitleEnum.Plain ? measure.MeasureTitle.Plain : measure.MeasureTitle.Clinical, PlainTitle = measure.MeasureTitle.Plain, ClinicalTitle = measure.MeasureTitle.Clinical, MeasureDescription = measure.Description, MoreInformation = measure.MoreInformation, URL = measure.Url, URLTitle = measure.UrlTitle, DataSourceURL = "http://www.qualityindicators.ahrq.gov", DataSourceURLTitle = "AHRQ Quality Indicator", SelectedTitleConsumer = measure.ConsumerPlainTitle, PlainTitleConsumer = measure.ConsumerPlainTitle, MeasureDescriptionConsumer = measure.ConsumerDescription, Heading = GetCqdHeading(measure), PeerRates = GetCqdPeerRate(measure) }; return(cqmd); }
public IEnumerator Benchmark10KLight() { yield return(Measure.Frames().MeasurementCount(240).WarmupCount(50).Run()); }
public async Task Add(Measure obj) { db.Measures.Add(obj.Data); await db.SaveChangesAsync(); }
/// <summary> /// Measures a cell created with this frame. /// </summary> /// <param name="measureContext">The context used to measure the cell.</param> /// <param name="cellView">The cell to measure.</param> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> /// <param name="size">The cell size upon return, padding included.</param> /// <param name="padding">The cell padding.</param> public abstract void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding);
private void EndGCRecorderAndMeasure(int iterations) { m_GCRecorder.enabled = false; Measure.Custom(m_SampleGroupGC, (double)m_GCRecorder.sampleBlockCount / iterations); }
public static void CelsiusToBytes(Measure <Celsius> value, byte[] bytes, int offset) { Dpt9.DoubleToBytes((double)value.Value, bytes, offset); }
/// <summary> /// Measure all cells in this state view. /// </summary> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> public void MeasureCells(ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength) { Debug.Assert(RootCellView != null); RootCellView.Measure(collectionWithSeparator, referenceContainer, separatorLength); CellSize = RootCellView.CellSize; ActualCellSize = RegionHelper.InvalidSize; Debug.Assert(RegionHelper.IsValid(CellSize)); }
/// <summary> /// Measures a cell created with this frame. /// </summary> /// <param name="measureContext">The context used to measure the cell.</param> /// <param name="cellView">The cell to measure.</param> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> /// <param name="size">The cell size upon return, padding included.</param> /// <param name="padding">The cell padding.</param> public virtual void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding) { ILayoutContainerCellView ContainerCellView = cellView as ILayoutContainerCellView; Debug.Assert(ContainerCellView != null); ILayoutNodeStateView ChildStateView = ContainerCellView.ChildStateView; Debug.Assert(ChildStateView != null); ChildStateView.MeasureCells(collectionWithSeparator, referenceContainer, separatorLength); Debug.Assert(RegionHelper.IsValid(ChildStateView.CellSize)); size = ChildStateView.CellSize; measureContext.UpdatePadding(LeftMargin, RightMargin, ref size, out padding); Debug.Assert(RegionHelper.IsValid(size)); }
protected override void UpdateListView() { ListView.Clear(); ListView.Columns.Add(Localizer.LS(LSID.Date), 120, HorizontalAlignment.Left); ListView.Columns.Add(Localizer.LS(LSID.Type), 100, HorizontalAlignment.Left); ListView.Columns.Add(Localizer.LS(LSID.Value), 100, HorizontalAlignment.Right); ListView.Columns.Add(Localizer.LS(LSID.Note), 250, HorizontalAlignment.Left); ListView.Columns.Add(Localizer.LS(LSID.WaterVolume), 100, HorizontalAlignment.Right); ListView.Columns.Add("% change", 100, HorizontalAlignment.Right); ListView.Columns.Add("period change", 100, HorizontalAlignment.Right); ListView.Columns.Add("Temp (°C)", 60, HorizontalAlignment.Right); ListView.Columns.Add("NO3 (mg/l)", 60, HorizontalAlignment.Right); ListView.Columns.Add("GH (°d)", 60, HorizontalAlignment.Right); ListView.Columns.Add("KH (°d)", 60, HorizontalAlignment.Right); ListView.Columns.Add("pH", 60, HorizontalAlignment.Right); ListView.Columns.Add("CO2", 60, HorizontalAlignment.Right); ListView.Columns.Add("NHtot", 60, HorizontalAlignment.Right); ListView.Columns.Add("PO4", 60, HorizontalAlignment.Right); if (fAquarium != null) { var events = new List <IEventEntity>(); events.AddRange(fModel.QueryNotes(fAquarium.Id)); events.AddRange(fModel.QueryMaintenances(fAquarium.Id)); events.AddRange(fModel.QueryMeasures(fAquarium.Id)); events.AddRange(fModel.QueryTransfers(fAquarium.Id)); events.Sort((x, y) => { return(x.Timestamp.CompareTo(y.Timestamp)); }); DateTime dtPrev = ALCore.ZeroDate; double prevVolume = 0.0d, curVolume = 0.0d; string prevTime = string.Empty, curTime; foreach (IEventEntity evnt in events) { curTime = ALCore.GetTimeStr(evnt.Timestamp); if (!prevTime.Equals(curTime)) { prevTime = curTime; } if (evnt is Maintenance) { Maintenance mnt = (Maintenance)evnt; double changeValue = mnt.Value; switch (mnt.Type) { case MaintenanceType.Restart: case MaintenanceType.AquariumStarted: case MaintenanceType.AquariumStopped: prevVolume = curVolume; curVolume = changeValue; break; default: int factor = ALData.MaintenanceTypes[(int)mnt.Type].WaterChangeFactor; if (factor != 0) { prevVolume = curVolume; } curVolume += (changeValue * factor); break; } double chngPercent = (changeValue / curVolume) * 100.0d; int days = -1; if (mnt.Type >= MaintenanceType.Restart && mnt.Type <= MaintenanceType.WaterReplaced) { if (!ALCore.IsZeroDate(dtPrev)) { days = (mnt.Timestamp.Date - dtPrev).Days; } dtPrev = mnt.Timestamp.Date; } string strType = Localizer.LS(ALData.MaintenanceTypes[(int)mnt.Type].Name); string strDays = (days >= 0) ? days.ToString() : string.Empty; var item = ListView.AddItemEx(mnt, curTime, strType, ALCore.GetDecimalStr(mnt.Value), mnt.Note, ALCore.GetDecimalStr(curVolume), ALCore.GetDecimalStr(chngPercent), strDays ); } if (evnt is Measure) { Measure msr = (Measure)evnt; var item = ListView.AddItemEx(msr, curTime, Localizer.LS(LSID.Measure), string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, ALCore.GetDecimalStr(msr.Temperature, 2, true), ALCore.GetDecimalStr(msr.NO3, 2, true), ALCore.GetDecimalStr(msr.GH, 2, true), ALCore.GetDecimalStr(msr.KH, 2, true), ALCore.GetDecimalStr(msr.pH, 2, true), ALCore.GetDecimalStr(msr.CO2, 2, true), ALCore.GetDecimalStr(msr.NH, 2, true), ALCore.GetDecimalStr(msr.PO4, 2, true) ); } if (evnt is Note) { Note note = (Note)evnt; var item = ListView.AddItemEx(note, curTime, Localizer.LS(LSID.Event), string.Empty, note.Event, string.Empty, string.Empty, string.Empty ); } if (evnt is Transfer) { Transfer transfer = (Transfer)evnt; if (ALCore.IsInhabitant(transfer.ItemType)) { string strType = Localizer.LS(ALData.TransferTypes[(int)transfer.Type]); var itemRec = fModel.GetRecord(transfer.ItemType, transfer.ItemId); string itName = (itemRec == null) ? string.Empty : itemRec.ToString(); var item = ListView.AddItemEx(transfer, curTime, strType, transfer.Quantity.ToString(), itName, string.Empty, string.Empty, string.Empty ); } } } } }
public async Task RegisterUserSensor_WhenValidParametersArePassed() { //Arrange var contextOptions = new DbContextOptionsBuilder <DormitorySystemContext>() .UseInMemoryDatabase("RegisterUserSensor_WhenValidParametersArePassed") .Options; var seedUsersMock = new Mock <ISeedUsers>(); var seedApiDataMock = new Mock <ISeedApiData>(); var measure = new Measure { Id = 1, MeasureType = "test" }; var sensorType = new SensorType { Id = 1, Name = "Test" }; var sampleSensor = new SampleSensor { Id = Guid.Parse("00000000-0000-0000-0000-000000000002"), Tag = "Test Sensor", Description = "Test Sensor", MinPollingInterval = 20, MeasureId = measure.Id, ValueCurrent = 50, SensorTypeId = sensorType.Id, IsOnline = true }; var userSensor = new UserSensor { Id = Guid.Parse("00000000-0000-0000-0000-000000000001"), CreatedOn = DateTime.Now, isDeleted = false, SampleSensorId = sampleSensor.Id, PollingInterval = 100, SendNotification = true, IsPrivate = false }; var editedSensor = new UserSensor { Id = Guid.Parse("00000000-0000-0000-0000-000000000001"), CreatedOn = DateTime.Now, isDeleted = false, SampleSensorId = sampleSensor.Id, PollingInterval = 200, SendNotification = false, IsPrivate = false }; //Act using (var actContext = new DormitorySystemContext(contextOptions, seedUsersMock.Object, seedApiDataMock.Object)) { actContext.Measures.Add(measure); actContext.SensorTypes.Add(sensorType); actContext.SampleSensors.Add(sampleSensor); actContext.UserSensors.Add(userSensor); actContext.SaveChanges(); } //Assert using (var assertContext = new DormitorySystemContext(contextOptions, seedUsersMock.Object, seedApiDataMock.Object)) { var service = new SensorService(assertContext); var result = await service.EditSensorAsync(editedSensor); Assert.AreEqual(1, assertContext.UserSensors.Count()); Assert.AreEqual(200, result.PollingInterval); } }
private void InitData(string id) { this.currentMeasure = BusinessFactory <MeasureBusiness> .Instance.FindById(id); }
/// <summary> /// Measures a cell created with this frame. /// </summary> /// <param name="measureContext">The context used to measure the cell.</param> /// <param name="cellView">The cell to measure.</param> /// <param name="collectionWithSeparator">A collection that can draw separators around the cell.</param> /// <param name="referenceContainer">The cell view in <paramref name="collectionWithSeparator"/> that contains this cell.</param> /// <param name="separatorLength">The length of the separator in <paramref name="collectionWithSeparator"/>.</param> /// <param name="size">The cell size upon return, padding included.</param> /// <param name="padding">The cell padding.</param> public virtual void Measure(ILayoutMeasureContext measureContext, ILayoutCellView cellView, ILayoutCellViewCollection collectionWithSeparator, ILayoutCellView referenceContainer, Measure separatorLength, out Size size, out Padding padding) { size = measureContext.MeasureSymbolSize(Symbol); measureContext.UpdatePadding(LeftMargin, RightMargin, ref size, out padding); Debug.Assert(RegionHelper.IsValid(size)); }
public Measure Convert(Measure measure) { return(edges.Aggregate(measure, (m, edge) => edge.ApplyConversion(m))); }