Ejemplo n.º 1
0
        private void CalculateB_Click(object sender, EventArgs e)
        {
            FillLanguage();
            TireAmmount = 1;
            List <double> entry = Entry();
            List <double> exit  = Exit();

            try {
                ChooseWorkerLabel.Hide();
                double oxygenTank  = apparatuses[worker.getApparatus()].getPressure() * apparatuses[worker.getApparatus()].getVolume() * 10;
                double trackOxygen = entry[1] + exit[1];
                double lenght      = entry[0] + exit[0];
                double time        = entry[2] + exit[2];
                if (oxygenTank > trackOxygen)
                {
                    PathLengthB.Text     += " " + Math.Round(lenght, 2, MidpointRounding.ToEven) + " m";
                    TimeForPathB.Text    += " " + Math.Round(time, 2, MidpointRounding.ToEven) + " min";
                    OxygenOnEntryB.Text  += " " + Math.Round(oxygenTank, 2, MidpointRounding.ToEven) + " l";
                    OxygenOnExitB.Text   += " " + Math.Round(oxygenTank - trackOxygen, 2, MidpointRounding.ToEven) + " l";
                    OxygenForEntryB.Text += " " + Math.Round(entry[1], 2, MidpointRounding.ToEven) + " l";
                    TimeForEntryB.Text   += " " + Math.Round(entry[2], 2, MidpointRounding.ToEven) + " min";
                    OxygenForExitB.Text  += " " + Math.Round(exit[1], 2, MidpointRounding.ToEven) + " l";
                    TimeForExitB.Text    += " " + Math.Round(exit[2], 2, MidpointRounding.ToEven) + " min";
                    double remainingTime = (oxygenTank - trackOxygen) / worker.getOxygenConsumption();
                    RemainingTimeB.Text += " " + Math.Round(remainingTime, 2, MidpointRounding.ToEven) + " min";
                }
                else if (language)
                {
                    ChooseWorkerLabel.Text = "Не достатъчен кислород";
                }
                else if (!language)
                {
                    ChooseWorkerLabel.Text = "Not enough Oxygen";
                }
            }
            catch (Exception ex)
            {
                ChooseWorkerLabel.Show();
                if (language)
                {
                    ChooseWorkerLabel.Text = "Моля изберете спасител";
                }
                else
                {
                    ChooseWorkerLabel.Text = "Please choose a worker";
                }
            }
        }
Ejemplo n.º 2
0
        private List <double> Exit()
        {
            List <double> res    = new List <double>();
            int           lenght = 0;
            int           sLenght;
            double        oxygen = 0;
            double        oxygenConsumption;
            double        time = 0;
            double        speed;

            try {
                for (int i = 0; i < segments.Count; i++)
                {
                    lenght           += segments[i].getLenght();
                    sLenght           = segments[i].getLenght();
                    speed             = worker.getSpeed() * ((worker.getWeight() - apparatuses[worker.getApparatus()].getWeight()) / worker.getWeight());
                    speed            *= segments[i].getExitSpeed();
                    speed            *= TireAmmount;
                    oxygenConsumption = worker.getOxygenConsumption() * segments[i].getExitOxygen();
                    if (segments[i].getHeight() < worker.getHeight())
                    {
                        speed *= 0.8;
                    }

                    if (segments[i].getLuggage() > 0)
                    {
                        speed = speed * ((worker.getWeight() - segments[i].getLuggage()) / worker.getWeight());
                    }

                    if (segments[i].getObstacles() > 0)
                    {
                        time        += segments[i].getObstacles();
                        oxygen      += segments[i].getObstacles() * worker.getOxygenConsumption();
                        TireAmmount += segments[i].getObstacles() * 0.02;
                    }

                    int rest = sLenght % 100;

                    for (int j = 0; j < sLenght / 100; j++)
                    {
                        if (TireAmmount > 0.4)
                        {
                            oxygen      += ((100 / speed) * oxygenConsumption) / TireAmmount;
                            time        += 100 / speed;
                            TireAmmount -= worker.getTireRate();
                        }
                        else
                        {
                            time        += 20;
                            TireAmmount += 0.4;
                            oxygen      += ((100 / speed) * oxygenConsumption) / TireAmmount;
                            time        += 100 / speed;
                            TireAmmount -= worker.getTireRate();
                        }
                    }
                    oxygen += ((rest / speed) * oxygenConsumption) / TireAmmount;
                    time   += rest / speed;
                }
                res.Add(lenght);
                res.Add(oxygen);
                res.Add(time);
            }
            catch (Exception e)
            {
                ChooseWorkerLabel.Show();
                if (language)
                {
                    ChooseWorkerLabel.Text = "Моля изберете спасител";
                }
                else
                {
                    ChooseWorkerLabel.Text = "Please choose a worker";
                }
            }

            return(res);
        }