Esempio n. 1
0
        public bool PointAvailable(int index)
        {
            int ind = index;

            if (((DivePoints[ind].Depth < DivePoints[ind - 1].Depth) && ((DivePoints[ind].Depth - DivePoints[ind - 1].Depth) / (DivePoints[ind - 1].Time - DivePoints[ind].Time) > 18)) || (DivePoints[ind - 1].Time >= DivePoints[ind].Time))
            {
                return(false);
            }
            else
            {
                List <DivePoint>  myDivePoint       = new List <DivePoint>();
                CompartmentParams compartmentParams = new CompartmentParams(DivePoints[0].Gas.Helium);
                double            FGas            = 1 - DivePoints[0].Gas.Oxygen;
                PointParams       truePointParams = new PointParams();
                truePointParams.pCurrent = new double[17];
                for (int i = 0; i < truePointParams.pCurrent.Length; i++)
                {
                    truePointParams.pCurrent[i] = pressureAmbient(FGas, 0, pressureSeaLevel);
                }
                int      count          = index;
                int      j              = 0;
                double   airConsumption = 0;
                double   vConsumption   = 30;
                double[] check          = new double[17];
                double   max            = 0;
                while (count > 0)
                {
                    compartmentParams = new CompartmentParams(DivePoints[j].Gas.Helium);
                    FGas = 1 - DivePoints[j].Gas.Oxygen;
                    double vRate = (DivePoints[j + 1].Depth - DivePoints[j].Depth) / (DivePoints[j + 1].Time - DivePoints[j].Time);
                    airConsumption += findAirConsumption(vConsumption, DivePoints[j + 1].Time - DivePoints[j].Time, DivePoints[j].Depth, DivePoints[j + 1].Depth);
                    for (int i = 0; i < truePointParams.pCurrent.Length; i++)
                    {
                        truePointParams.pCurrent[i] = pressureAtoB(pressureAmbient(FGas, DivePoints[j].Depth, pressureSeaLevel), FGas, vRate, DivePoints[j + 1].Time - DivePoints[j].Time, Kf(compartmentParams.compartment.paramT[i]), truePointParams.pCurrent[i]);
                    }
                    j     += 1;
                    count -= 1;
                }
                for (int i = 0; i < truePointParams.pCurrent.Length; i++)
                {
                    check[i] = truePointParams.pCurrent[i] - pressureInCompartment(compartmentParams.compartment.paramM0[i], compartmentParams.compartment.paramdM[i], DivePoints[ind].Depth);
                    if (check[i] > max)
                    {
                        max = check[i];
                    }
                }
                if (max > 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Esempio n. 2
0
        public void GetAscentByIndex(int index)
        {
            List <DivePoint>  myDivePoint       = new List <DivePoint>();
            CompartmentParams compartmentParams = new CompartmentParams(DivePoints[0].Gas.Helium);
            double            FGas                  = 1 - DivePoints[0].Gas.Oxygen;
            PointParams       truePointParams       = new PointParams();
            PointParamsAscent truePointParamsAscent = new PointParamsAscent();

            truePointParams.pCurrent = new double[17];
            for (int i = 0; i < truePointParams.pCurrent.Length; i++)
            {
                truePointParams.pCurrent[i] = pressureAmbient(FGas, 0, pressureSeaLevel);
            }
            int    count          = index;
            int    j              = 0;
            double airConsumption = 0;
            double vConsumption   = 30;

            while (count > 0)
            {
                compartmentParams = new CompartmentParams(DivePoints[j].Gas.Helium);
                FGas = 1 - DivePoints[j].Gas.Oxygen;
                double vRate = (DivePoints[j + 1].Depth - DivePoints[j].Depth) / (DivePoints[j + 1].Time - DivePoints[j].Time);
                airConsumption += findAirConsumption(vConsumption, DivePoints[j + 1].Time - DivePoints[j].Time, DivePoints[j].Depth, DivePoints[j + 1].Depth);
                for (int i = 0; i < truePointParams.pCurrent.Length; i++)
                {
                    truePointParams.pCurrent[i] = pressureAtoB(pressureAmbient(FGas, DivePoints[j].Depth, pressureSeaLevel), FGas, vRate, DivePoints[j + 1].Time - DivePoints[j].Time, Kf(compartmentParams.compartment.paramT[i]), truePointParams.pCurrent[i]);
                }
                j     += 1;
                count -= 1;
            }
            compartmentParams = new CompartmentParams(DivePoints[j].Gas.Helium);
            FGas = 1 - DivePoints[j].Gas.Oxygen;
            double depthTo3 = maxDepthTo3(truePointParams.pCurrent, compartmentParams.compartment.paramM0, compartmentParams.compartment.paramdM, pressureSeaLevel);

            truePointParams.airConsumption = airConsumption;
            truePointParams.Gas            = DivePoints[j].Gas;
            double lastDepth = DivePoints[j].Depth;
            double lastTime  = DivePoints[j].Time;

            truePointParamsAscent = ascentUp(truePointParams, pressureSeaLevel, depthTo3, lastTime, lastDepth);
            for (int i = 0; i < truePointParamsAscent.depth.Count; i++)
            {
                DivePoint dv = new DivePoint(truePointParamsAscent.time[i], truePointParamsAscent.depth[i]);
                myDivePoint.Add(dv);
            }
            DivePoints.RemoveRange(index + 1, DivePoints.Count - 1 - index);
            DivePoints.AddRange(myDivePoint);
        }
Esempio n. 3
0
        public string EmergencyAscentMessage(int index)
        {
            string            emergencyMessage = "";
            Air               air               = new Air();
            List <DivePoint>  myDivePoint       = new List <DivePoint>();
            CompartmentParams compartmentParams = new CompartmentParams(DivePoints[0].Gas.Helium);
            double            FGas              = 1 - DivePoints[0].Gas.Oxygen;

            double[]      check         = new double[17];
            double[]      d             = new double[17];
            List <string> st            = new List <string> {
            };
            double      em              = 0;
            double      maxD            = 0;
            double      timeEm          = 0;
            PointParams truePointParams = new PointParams();

            truePointParams.pCurrent = new double[17];
            for (int i = 0; i < truePointParams.pCurrent.Length; i++)
            {
                truePointParams.pCurrent[i] = pressureAmbient(FGas, 0, pressureSeaLevel);
                Console.WriteLine("первое давление = " + truePointParams.pCurrent[i]);
            }
            int    count          = index;
            int    j              = 0;
            double airConsumption = 0;
            double vConsumption   = 30;

            while (count > 0)
            {
                compartmentParams = new CompartmentParams(DivePoints[j].Gas.Helium);
                FGas = 1 - DivePoints[j].Gas.Oxygen;
                double vRate = (DivePoints[j + 1].Depth - DivePoints[j].Depth) / (DivePoints[j + 1].Time - DivePoints[j].Time);
                airConsumption += findAirConsumption(vConsumption, DivePoints[j + 1].Time - DivePoints[j].Time, DivePoints[j].Depth, DivePoints[j + 1].Depth);
                for (int i = 0; i < truePointParams.pCurrent.Length; i++)
                {
                    truePointParams.pCurrent[i] = pressureAtoB(pressureAmbient(FGas, DivePoints[j].Depth, pressureSeaLevel), FGas, vRate, DivePoints[j + 1].Time - DivePoints[j].Time, Kf(compartmentParams.compartment.paramT[i]), truePointParams.pCurrent[i]);
                    Console.WriteLine("давление после шага номер " + j + " = " + truePointParams.pCurrent[i]);
                }
                j     += 1;
                count -= 1;
            }
            compartmentParams = new CompartmentParams(DivePoints[j].Gas.Helium);
            FGas = 1 - DivePoints[j].Gas.Oxygen;
            for (int i = 0; i < truePointParams.pCurrent.Length; i++)
            {
                truePointParams.pCurrent[i] = pressureAtoB(pressureAmbient(FGas, DivePoints[j].Depth, pressureSeaLevel), FGas, -18, DivePoints[j].Depth / 18, Kf(compartmentParams.compartment.paramT[i]), truePointParams.pCurrent[i]);
                check[i] = truePointParams.pCurrent[i] - pressureInCompartment(compartmentParams.compartment.paramM0[i], compartmentParams.compartment.paramdM[i], 0);
                if (check[i] > em)
                {
                    em = check[i];
                }
            }
            compartmentParams = new CompartmentParams(air.Helium);
            FGas = 1 - air.Oxygen;
            if (em > 0)
            {
                for (int i = 0; i < truePointParams.pCurrent.Length; i++)
                {
                    d[i] = (truePointParams.pCurrent[i] - compartmentParams.compartment.paramM0[i]) / compartmentParams.compartment.paramM0[i];
                    if (d[i] > maxD)
                    {
                        maxD = d[i];
                    }
                }
                string s = "Декомпрессионные параметры в барокамере:\n";
                maxD = Math.Ceiling(maxD);
                if (maxD % 3 != 0)
                {
                    maxD = maxD - (maxD % 3) + 3;
                }
                while (maxD > 0)
                {
                    timeEm = maxTimeToStop(truePointParams.pCurrent, compartmentParams.compartment.paramM0, compartmentParams.compartment.paramM0, pressureAmbient(FGas, maxD, 10), maxD, KF(compartmentParams.compartment.paramT));
                    for (int i = 0; i < truePointParams.pCurrent.Length; i++)
                    {
                        truePointParams.pCurrent[i] = pressurePoint(pressureAmbient(FGas, maxD, 10), truePointParams.pCurrent[i], Kf(compartmentParams.compartment.paramT[i]), timeEm);
                    }
                    string str = "";
                    str = $"поместить на {timeEm} минут при давлении {maxD / 10 + 1} Бар ";
                    st.Add(str);
                    maxD = maxD - 3;
                }

                emergencyMessage = s + string.Join("\n", st);
            }
            else
            {
                emergencyMessage = "Экстренное всплытие не требует декомпрессионных обязательств";
            }

            return(emergencyMessage);
        }
Esempio n. 4
0
        private PointParamsAscent ascentUp(PointParams previousStep, double pressureSeaLevel, double depthTo3, double timeBeforeAscent, double lastDepth)
        {
            CompartmentParams compartmentParams = new CompartmentParams(previousStep.Gas.Helium);
            PointParams       pointParams;

            pointParams.pCurrent = new double[17];
            for (int i = 0; i < pointParams.pCurrent.Length; i++)
            {
                pointParams.pCurrent[i] = previousStep.pCurrent[i];
            }
            PointParamsAscent ascentParams;

            ascentParams.depth = new List <double>();
            ascentParams.time  = new List <double>();
            double timeBeforeStepAscent = timeBeforeAscent;
            int    vRate          = -10;
            int    number         = 1;
            double vAscent        = 18;
            double vOnDepth       = 9;
            double airConsumption = (double)previousStep.airConsumption;
            double timeToStop     = 0;
            double FGas           = 1 - (double)previousStep.Gas.Oxygen;
            double depthCurrent   = lastDepth;
            double depthNext      = depthTo3;

            ascentParams.airConsumption = airConsumption;
            while (depthNext > 0)
            {
                double t = (depthNext - depthCurrent) / vRate;
                for (int i = 0; i < pointParams.pCurrent.Length; i++)
                {
                    pointParams.pCurrent[i] = pressureAtoB(pressureAmbient(FGas, depthCurrent, pressureSeaLevel), FGas, vRate, t, Kf(compartmentParams.compartment.paramT[i]), pointParams.pCurrent[i]);
                }
                airConsumption += findAirConsumption(vAscent, t, depthCurrent, depthNext);
                timeToStop      = maxTimeToStop(pointParams.pCurrent, compartmentParams.compartment.paramM0, compartmentParams.compartment.paramdM, pressureAmbient(FGas, depthNext, pressureSeaLevel), depthNext, KF(compartmentParams.compartment.paramT));
                if (timeToStop > 0)
                {
                    for (int i = 0; i < pointParams.pCurrent.Length; i++)
                    {
                        pointParams.pCurrent[i] = pressurePoint(pressureAmbient(FGas, depthNext, pressureSeaLevel), pointParams.pCurrent[i], Kf(compartmentParams.compartment.paramT[i]), timeToStop);
                    }
                    airConsumption += findAirConsumption(vOnDepth, timeToStop, depthNext, depthNext);
                    double d = depthNext;
                    ascentParams.depth.Add(d);
                    ascentParams.time.Add(timeBeforeStepAscent + t);
                    ascentParams.depth.Add(d);
                    ascentParams.time.Add(timeBeforeStepAscent + t + timeToStop);
                    timeBeforeStepAscent += t + timeToStop;
                    depthCurrent          = depthNext;
                    depthNext            -= 3;
                    number += 1;
                }
                else
                {
                    double d = depthNext;
                    depthNext            -= 3;
                    timeBeforeStepAscent += t;
                }
            }
            ascentParams.depth.Add(0);
            ascentParams.time.Add(timeBeforeStepAscent + 0.3);
            ascentParams.airConsumption = airConsumption;
            return(ascentParams);
        }