Exemplo n.º 1
0
        public MorphologicalAnalysis(XmlNode nodAnalysis, BudgetSegregation bs)
            : base(nodAnalysis)
        {
            OutputFolder = ProjectManager.Project.GetAbsoluteDir(nodAnalysis.SelectSingleNode("Folder").InnerText);
            Spreadsheet  = ProjectManager.Project.GetAbsolutePath(nodAnalysis.SelectSingleNode("Spreadsheet").InnerText);
            BS           = bs;

            XmlNode nodDuration = nodAnalysis.SelectSingleNode("Duration");

            _DisplayUnits_Duration = (UnitsNet.Units.DurationUnit)Enum.Parse(typeof(UnitsNet.Units.DurationUnit), nodDuration.Attributes["units"].InnerText);
            _DisplayUnits_Volume   = ProjectManager.Project.Units.VolUnit;
            _DisplayUnits_Mass     = UnitsNet.Units.MassUnit.Kilogram;

            _duration   = Duration.From(double.Parse(nodDuration.InnerText, CultureInfo.InvariantCulture), DisplayUnits_Duration);
            _porosity   = decimal.Parse(nodAnalysis.SelectSingleNode("Porosity").InnerText, CultureInfo.InvariantCulture);
            _density    = decimal.Parse(nodAnalysis.SelectSingleNode("Density").InnerText, CultureInfo.InvariantCulture);
            _competency = decimal.Parse(nodAnalysis.SelectSingleNode("Competency").InnerText, CultureInfo.InvariantCulture);
            //_DataVolumeUnits = ProjectManager.Project.Units.VolUnit;

            double minFluxValue = double.Parse(nodAnalysis.SelectSingleNode("MinimumFluxVolume").InnerText, CultureInfo.InvariantCulture);

            BoundaryFlux = Volume.From(minFluxValue, ProjectManager.Project.Units.VolUnit);

            Units = new BindingList <MorphologicalUnit>();
            LoadMorphologicalUnitData();
        }
Exemplo n.º 2
0
        public static void ToTimeSpanShouldNotRoundToMillisecond(double value, Units.DurationUnit unit)
        {
            Duration duration = Duration.From(value, unit);
            TimeSpan timeSpan = duration.ToTimeSpan();

            AssertEx.EqualTolerance(duration.Milliseconds, timeSpan.TotalMilliseconds, 1e-10);
        }
        public double GetTimeResult(string prevUnit, double prevValue, string newUnit)
        {
            var    prevTime     = Duration.From(prevValue, GetTimeUnit(prevUnit));
            double newTimeValue = prevTime.As(GetTimeUnit(newUnit));
            double result       = newTimeValue;

            return(result);
        }
Exemplo n.º 4
0
        public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
        {
            var quantity00 = Duration.From(1, DurationUnit.Day);

            AssertEx.EqualTolerance(1, quantity00.Days, DaysTolerance);
            Assert.Equal(DurationUnit.Day, quantity00.Unit);

            var quantity01 = Duration.From(1, DurationUnit.Hour);

            AssertEx.EqualTolerance(1, quantity01.Hours, HoursTolerance);
            Assert.Equal(DurationUnit.Hour, quantity01.Unit);

            var quantity02 = Duration.From(1, DurationUnit.JulianYear);

            AssertEx.EqualTolerance(1, quantity02.JulianYears, JulianYearsTolerance);
            Assert.Equal(DurationUnit.JulianYear, quantity02.Unit);

            var quantity03 = Duration.From(1, DurationUnit.Microsecond);

            AssertEx.EqualTolerance(1, quantity03.Microseconds, MicrosecondsTolerance);
            Assert.Equal(DurationUnit.Microsecond, quantity03.Unit);

            var quantity04 = Duration.From(1, DurationUnit.Millisecond);

            AssertEx.EqualTolerance(1, quantity04.Milliseconds, MillisecondsTolerance);
            Assert.Equal(DurationUnit.Millisecond, quantity04.Unit);

            var quantity05 = Duration.From(1, DurationUnit.Minute);

            AssertEx.EqualTolerance(1, quantity05.Minutes, MinutesTolerance);
            Assert.Equal(DurationUnit.Minute, quantity05.Unit);

            var quantity06 = Duration.From(1, DurationUnit.Month30);

            AssertEx.EqualTolerance(1, quantity06.Months30, Months30Tolerance);
            Assert.Equal(DurationUnit.Month30, quantity06.Unit);

            var quantity07 = Duration.From(1, DurationUnit.Nanosecond);

            AssertEx.EqualTolerance(1, quantity07.Nanoseconds, NanosecondsTolerance);
            Assert.Equal(DurationUnit.Nanosecond, quantity07.Unit);

            var quantity08 = Duration.From(1, DurationUnit.Second);

            AssertEx.EqualTolerance(1, quantity08.Seconds, SecondsTolerance);
            Assert.Equal(DurationUnit.Second, quantity08.Unit);

            var quantity09 = Duration.From(1, DurationUnit.Week);

            AssertEx.EqualTolerance(1, quantity09.Weeks, WeeksTolerance);
            Assert.Equal(DurationUnit.Week, quantity09.Unit);

            var quantity10 = Duration.From(1, DurationUnit.Year365);

            AssertEx.EqualTolerance(1, quantity10.Years365, Years365Tolerance);
            Assert.Equal(DurationUnit.Year365, quantity10.Unit);
        }
Exemplo n.º 5
0
 public void FromValueAndUnit()
 {
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Day).Days, DaysTolerance);
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Hour).Hours, HoursTolerance);
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Microsecond).Microseconds, MicrosecondsTolerance);
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Millisecond).Milliseconds, MillisecondsTolerance);
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Minute).Minutes, MinutesTolerance);
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Month).Months, MonthsTolerance);
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Nanosecond).Nanoseconds, NanosecondsTolerance);
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Second).Seconds, SecondsTolerance);
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Week).Weeks, WeeksTolerance);
     Assert.AreEqual(1, Duration.From(1, DurationUnit.Year).Years, YearsTolerance);
 }
Exemplo n.º 6
0
 public void FromValueAndUnit()
 {
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Day).Days, DaysTolerance);
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Hour).Hours, HoursTolerance);
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Microsecond).Microseconds, MicrosecondsTolerance);
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Millisecond).Milliseconds, MillisecondsTolerance);
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Minute).Minutes, MinutesTolerance);
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Month30).Months30, Months30Tolerance);
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Nanosecond).Nanoseconds, NanosecondsTolerance);
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Second).Seconds, SecondsTolerance);
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Week).Weeks, WeeksTolerance);
     AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Year365).Years365, Years365Tolerance);
 }
Exemplo n.º 7
0
            private static Duration WorkoutDuration(Dictionary <string, string> element)
            {
                var hasValue = element.TryGetValue("duration", out var valueStr);

                element.TryGetValue("durationUnit", out var unitStr);

                if (!hasValue)
                {
                    return(Duration.Zero);
                }

                var value = valueStr.SafeParse(0);
                var unit  = Duration.ParseUnit(unitStr);

                return(Duration.From(value, unit));
            }
Exemplo n.º 8
0
        public MorphologicalAnalysis(string name, DirectoryInfo outputFolder, BudgetSegregation bs)
            : base(name)
        {
            OutputFolder = outputFolder;
            Spreadsheet  = new FileInfo(Path.Combine(OutputFolder.FullName, "Morphological.xml"));
            BS           = bs;

            _DisplayUnits_Duration = UnitsNet.Units.DurationUnit.Hour;
            _DisplayUnits_Volume   = ProjectManager.Project.Units.VolUnit;
            _DisplayUnits_Mass     = UnitsNet.Units.MassUnit.Kilogram;

            _duration   = Duration.From(1, DisplayUnits_Duration);
            _porosity   = 0.26m;
            _density    = 2.65m;
            _competency = 1m;
            //_DataVolumeUnits = ProjectManager.Project.Units.VolUnit;

            Units = new BindingList <MorphologicalUnit>();
            LoadMorphologicalUnitData();
            ImposeMinimumFlux();
        }
Exemplo n.º 9
0
 public void TestFromInvalidDuration()
 {
     Duration duration = (Duration)3;
     var      newDate  = duration.From(new DateTime(1976, 12, 16));
 }
Exemplo n.º 10
0
        public void TestFromMonth()
        {
            Duration duration = Duration.Month;

            Assert.AreEqual(new DateTime(1976, 12, 16), duration.From(new DateTime(1976, 11, 16)));
        }
Exemplo n.º 11
0
        public void TestFromWeek()
        {
            Duration duration = Duration.Week;

            Assert.AreEqual(new DateTime(1976, 12, 16), duration.From(new DateTime(1976, 12, 9)));
        }
Exemplo n.º 12
0
        public void TestFromDay()
        {
            Duration duration = Duration.Day;

            Assert.AreEqual(new DateTime(1976, 12, 16), duration.From(new DateTime(1976, 12, 15)));
        }