Example #1
0
        public DiveParameters GetDiveParameters()
        {
            var diveParams = new DiveParameters();
            var levels     = new List <DiveLevel>(DiveLevels.Length);
            var decoLevels = new List <DiveLevel>(DecoLevels.Length);

            diveParams.DiveConfig.AlgoSubType     = Enum.Parse <Zhl16Algorithm.SubType>(Algorythm);
            diveParams.DiveConfig.MinDecoTime     = Enum.Parse <MinDecoTimeStep>(MinDecoStopTime);
            diveParams.DiveConfig.BottomRmv       = RmvBottom;
            diveParams.DiveConfig.DecoRmv         = RmvDeco;
            diveParams.DiveConfig.GradFactorHigh  = GradFactorHigh * 0.01;
            diveParams.DiveConfig.GradFactorLow   = GradFactorLow * 0.01;
            diveParams.DiveConfig.MaxAscentSpeed  = AscentSpeed;
            diveParams.DiveConfig.MaxDescentSpeed = DescentSpeed;
            diveParams.DiveConfig.SafeStopDepth   = SafetyStopDepth;
            diveParams.DiveConfig.SafeStopTime    = SafetyStopTime;

            foreach (var levelModel in DiveLevels.Where(l => l.IsValid && l.UseLevel))
            {
                levels.Add(new DiveLevel
                {
                    DepthFactor = new DepthFactor(levelModel.Depth.Value, WaterDensity),
                    Time        = levelModel.Time.Value,
                    Gas         = levelModel.Gas.GetGas(),
                });
            }

            foreach (var levelModel in DecoLevels.Where(l => l.IsValid && l.UseLevel))
            {
                decoLevels.Add(new DiveLevel
                {
                    DepthFactor = new DepthFactor(levelModel.Depth ?? 0, WaterDensity),
                    Gas         = levelModel.Gas.GetGas(),
                });
            }

            diveParams.DecoLevels   = decoLevels;
            diveParams.Levels       = levels;
            diveParams.IntervalTime = Interval ?? 0;

            return(diveParams);
        }
        public IEnumerable <string> GetDiveParamsInfo()
        {
            var hasDecoLevels = DecoLevels?.Count() > 0;

            var infoBlocks = new List <string>
            {
                string.Format("Depth:  {0} m", Math.Round(Levels.Max(l => l.Depth), 1)),
                string.Format("Time:  {0} min", Math.Round(Levels.Sum(l => l.Time), 1)),
                string.Format("Interval:  {0}", IntervalTime < double.Epsilon ? "first dive" : Math.Round(IntervalTime) + " mins"),
                string.Format("Gases:  level {0}", string.Join(", ", Levels.Select(l => l.Gas.Name)) +
                              (hasDecoLevels ? ";  deco " + string.Join(", ", DecoLevels.Select(l => l.Gas.Name)) : string.Empty)),
                string.Format("Water:  {0}", Levels.First().DepthFactor.WaterDensity <= DivingMath.FreshWaterDensity ? "fresh" : "salt"),
                string.Format("Interval:  {0} min", Math.Round(IntervalTime)),
                string.Format("RMV:  {0}/{1} lt/min", Math.Round(DiveConfig.BottomRmv), Math.Round(DiveConfig.DecoRmv)),
                string.Format("Algo:  ZHL-16{0}", DiveConfig.AlgoSubType),
                string.Format("GF:  {0}/{1}", Math.Round(DiveConfig.GradFactorLow * 100.0), Math.Round(DiveConfig.GradFactorHigh * 100.0))
            };

            infoBlocks.RemoveAll(b => string.IsNullOrEmpty(b));
            return(infoBlocks);
        }