示例#1
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            if (Running == true)
            {
                //Lauf ist wurde beendet
                if (Run == "stopped")
                {
                    Run = "inactiv";

                    Console.WriteLine("Run had been finished");
                    log.Items.Insert(0, "Lauf beendet");
                    logTime.Items.Insert(0, "--:--");
                    logTime2.Items.Insert(0, "---");

                    Console.WriteLine("==========================");
                    log.Items.Insert(0, "=====================");
                    logTime.Items.Insert(0, "==:==");
                    logTime2.Items.Insert(0, "===");

                    //Abfrage von streamdata.php
                    WebClient wc         = new WebClient();
                    string    livetiming = wc.DownloadString("http://erzgebirgsschwimmcup.de/Livetiming/streamdata.php");
                    Console.WriteLine(livetiming);

                    //streamdata auswerten
                    string[] words         = livetiming.Split('?');
                    string   lane          = "0";
                    string   lane_1_meters = "0";
                    string   lane_2_meters = "0";
                    string   lane_3_meters = "0";
                    string   lane_4_meters = "0";
                    string   lane_1_time   = "0";
                    string   lane_2_time   = "0";
                    string   lane_3_time   = "0";
                    string   lane_4_time   = "0";
                    foreach (string word in words)
                    {
                        string[] words2 = word.Split('#');
                        foreach (string word2 in words2)
                        {
                            if (word2 == "1")
                            {
                                lane = "1";
                            }
                            if (word2 == "2")
                            {
                                lane = "2";
                            }
                            if (word2 == "3")
                            {
                                lane = "3";
                            }
                            if (word2 == "4")
                            {
                                lane = "4";
                            }
                            if (word2 == "50" || word2 == "100" || word2 == "200")
                            {
                                if (lane == "1")
                                {
                                    lane_1_meters = word2;
                                }
                                if (lane == "2")
                                {
                                    lane_2_meters = word2;
                                }
                                if (lane == "3")
                                {
                                    lane_3_meters = word2;
                                }
                                if (lane == "4")
                                {
                                    lane_4_meters = word2;
                                }
                            }

                            if (lane != "0" || word2 != "1" || word2 != "2" || word2 != "3" || word2 != "4" || word2 != "50" || word2 != "100" || word2 != "200")
                            {
                                if (lane == "1")
                                {
                                    lane_1_time = word2;
                                }
                                if (lane == "2")
                                {
                                    lane_2_time = word2;
                                }
                                if (lane == "3")
                                {
                                    lane_3_time = word2;
                                }
                                if (lane == "4")
                                {
                                    lane_4_time = word2;
                                }
                            }
                        }
                    }

                    Console.WriteLine("=====================");
                    Console.WriteLine("Run before:");
                    Console.WriteLine("=====================");
                    Console.WriteLine("Lane 1:");
                    Console.WriteLine("Meters: " + lane_1_meters);
                    Console.WriteLine("Time:   " + lane_1_time);
                    Console.WriteLine("=====================");
                    Console.WriteLine("Lane 2:");
                    Console.WriteLine("Meters: " + lane_2_meters);
                    Console.WriteLine("Time:   " + lane_2_time);
                    Console.WriteLine("=====================");
                    Console.WriteLine("Lane 3:");
                    Console.WriteLine("Meters: " + lane_3_meters);
                    Console.WriteLine("Time:   " + lane_3_time);
                    Console.WriteLine("=====================");
                    Console.WriteLine("Lane 4:");
                    Console.WriteLine("Meters: " + lane_4_meters);
                    Console.WriteLine("Time:   " + lane_4_time);
                    Console.WriteLine("=====================");

                    //streamdata auswerten
                    string[] words3 = livetiming.Split('#');
                    Wk_l   = "0";
                    Meters = "0";
                    int forcount = 0;
                    foreach (string word3 in words3)
                    {
                        forcount++;
                        if (forcount == 1)
                        {
                            Wk_l = word3;
                        }
                        if (forcount == 2)
                        {
                            int      forcount2 = 0;
                            string[] words4    = word3.Split('m');
                            foreach (string word4 in words4)
                            {
                                forcount2++;
                                if (forcount2 == 1)
                                {
                                    Meters = word4;
                                }
                            }
                        }
                    }

                    Console.WriteLine("");
                    Console.WriteLine("WK:      " + Wk_l);
                    Console.WriteLine("Strecke: " + Meters + "m");
                    Console.WriteLine("");
                    Console.WriteLine("=====================");

                    //Zeiten mit richtigen Metern in Array
                    string StrRuntimes = "";

                    if (lane_1_meters == Meters)
                    {
                        StrRuntimes = StrRuntimes + "#" + lane_1_time;
                        Console.WriteLine(StrRuntimes);
                    }

                    if (lane_2_meters == Meters)
                    {
                        StrRuntimes = StrRuntimes + "#" + lane_2_time;
                        Console.WriteLine(StrRuntimes);
                    }

                    if (lane_3_meters == Meters)
                    {
                        StrRuntimes = StrRuntimes + "#" + lane_3_time;
                        Console.WriteLine(StrRuntimes);
                    }

                    if (lane_4_meters == Meters)
                    {
                        StrRuntimes = StrRuntimes + "#" + lane_4_time;
                        Console.WriteLine(StrRuntimes);
                    }

                    string[] Runtimes = StrRuntimes.Split('#');

                    int TimeFast = 10000000;

                    foreach (string Time in Runtimes)
                    {
                        if (!String.IsNullOrEmpty(Time))
                        {
                            Console.WriteLine("Zeit:");
                            Console.WriteLine(Time);

                            //Sekunden berechnen
                            string Time_min_str = Time.Substring(0, 2);
                            string Time_sek_str = Time.Substring(3, 2);

                            int Time_min = Int32.Parse(Time_min_str);
                            int Time_sek = Int32.Parse(Time_sek_str);

                            if (Time_min == 1)
                            {
                                Time_sek = Time_sek + 60;
                            }

                            if (Time_min == 02)
                            {
                                Time_sek = Time_sek + 120;
                            }

                            if (Time_min == 03)
                            {
                                Time_sek = Time_sek + 180;
                            }

                            if (Time_sek <= TimeFast)
                            {
                                TimeFast = Time_sek;
                            }
                        }
                    }

                    Run_sek = TimeFast;
                }
                //während keinem Lauf
                if (Run == "inactiv")
                {
                    //Abfrage, ob Lauf wieder gestartet
                    WebClient wc2         = new WebClient();
                    string    livetimingD = wc2.DownloadString("http://erzgebirgsschwimmcup.de/Livetiming/livetime2.php");
                    if (livetimingD.Contains("Bahn"))
                    {
                        Run = "started";
                    }
                }

                //wenn Lauf gestartet:
                if (Run == "started")
                {
                    Run = "activ";
                    //Abfrage welche Strecke geschwommen wird
                    WebClient wc3         = new WebClient();
                    string    livetimingD = wc3.DownloadString("http://erzgebirgsschwimmcup.de/Livetiming/streamdata.php");
                    Console.WriteLine(livetimingD);
                    Console.WriteLine("Run has been started!");
                    Console.WriteLine("");

                    log.Items.Insert(0, "Lauf wurde gestartet");
                    logTime.Items.Insert(0, "00:00");
                    logTime2.Items.Insert(0, "0");

                    //Werte aktueller Lauf
                    string distance = Meters;

                    //Szenenwechsel berechnen

                    //für 50m Stecken
                    if (distance == "50")
                    {
                        T1         = Math.Round(Run_sek * 0.3);
                        T2         = Math.Round(Run_sek * 0.7);
                        Time1.Text = T1.ToString();
                        Time2.Text = T2.ToString();
                        Time3.Text = " ";
                        Time4.Text = " ";
                        Time5.Text = " ";
                        Time6.Text = " ";
                        Time7.Text = " ";
                        Time8.Text = " ";
                    }
                    if (distance == "100")
                    {
                        T1         = Math.Round(Run_sek * 0.15);
                        T2         = Math.Round(Run_sek * 0.35);
                        T3         = Math.Round(Run_sek * 0.65);
                        T4         = Math.Round(Run_sek * 0.85);
                        Time1.Text = T1.ToString();
                        Time2.Text = T2.ToString();
                        Time3.Text = T3.ToString();
                        Time4.Text = T4.ToString();
                        Time5.Text = " ";
                        Time6.Text = " ";
                        Time7.Text = " ";
                        Time8.Text = " ";
                    }
                    if (distance == "200")
                    {
                        T1         = Math.Round(Run_sek * 0.075);
                        T2         = Math.Round(Run_sek * 0.175);
                        T3         = Math.Round(Run_sek * 0.325);
                        T4         = Math.Round(Run_sek * 0.425);
                        T5         = Math.Round(Run_sek * 0.575);
                        T6         = Math.Round(Run_sek * 0.675);
                        T7         = Math.Round(Run_sek * 0.825);
                        T8         = Math.Round(Run_sek * 0.925);
                        Time1.Text = T1.ToString();
                        Time2.Text = T2.ToString();
                        Time3.Text = T3.ToString();
                        Time4.Text = T4.ToString();
                        Time5.Text = T5.ToString();
                        Time6.Text = T6.ToString();
                        Time7.Text = T7.ToString();
                        Time8.Text = T8.ToString();
                    }


                    Console.WriteLine(Run_sek);
                    log.Items.Insert(0, "Sekunden: " + Run_sek);
                    logTime.Items.Insert(0, "00:00");
                    logTime2.Items.Insert(0, "0");

                    progressBar.Maximum = Run_sek;

                    TimeCount  = 0;
                    Count      = 0;
                    Count2     = 0;
                    clock.Text = "00:00";

                    //Auslesen streamdata.php für WK
                    WebClient wc         = new WebClient();
                    string    livetiming = wc.DownloadString("http://erzgebirgsschwimmcup.de/Livetiming/streamdata.php");

                    //WK ermitteln
                    string[] words3 = livetiming.Split('#');
                    Wk_c   = "0";
                    Meters = "0";
                    int forcount = 0;
                    foreach (string word3 in words3)
                    {
                        forcount++;
                        if (forcount == 1)
                        {
                            Wk_c = word3;
                        }

                        if (forcount == 2)
                        {
                            int      forcount2 = 0;
                            string[] words4    = word3.Split('m');
                            foreach (string word4 in words4)
                            {
                                forcount2++;
                                if (forcount2 == 1)
                                {
                                    Meters_c = word4;
                                }
                            }
                        }
                    }
                    Console.WriteLine("WK:      " + Wk_c);
                    Console.WriteLine("WK (l):  " + Wk_l);

                    WkBox.Text = Wk_c;

                    DistanceBox.Text = Meters_c + "m";
                }

                //während des Laufes:
                if (Run == "activ")
                {
                    //timer hochzählen
                    TimeCount = TimeCount + 1;
                    Console.WriteLine(TimeCount);
                    Count = Count + 1;
                    string display;
                    string display2;
                    if (Count >= 60)
                    {
                        Count = 0;
                        Count2++;
                    }

                    if (Count < 10)
                    {
                        display = "0" + Count.ToString();
                    }
                    else
                    {
                        display = Count.ToString();
                    }

                    if (Count2 < 10)
                    {
                        display2 = "0" + Count2.ToString();
                    }
                    else
                    {
                        display2 = Count2.ToString();
                    }

                    string output = display2 + ":" + display;
                    clock.Text   = output;
                    TimeBox.Text = "" + TimeCount;



                    //wenn stichzeiten gleich aktueller Zeit Kamera wechseln
                    if (Wk_c == Wk_l)
                    {
                        if (TimeCount == T1)
                        {
                            Console.WriteLine("Change Scene to webcam 2");
                            log.Items.Insert(0, "Wechsle Szene zu Webcam 2");
                            logTime.Items.Insert(0, output);
                            logTime2.Items.Insert(0, TimeCount);

                            //OBS Anweisungen
                            SendKeys.Send("^M");

                            T1 = 0;
                        }
                        if (TimeCount == T2)
                        {
                            Console.WriteLine("Change Scene to webcam 1");
                            log.Items.Insert(0, "Wechsle Szene zu Webcam 1");
                            logTime.Items.Insert(0, output);
                            logTime2.Items.Insert(0, TimeCount);

                            //OBS Anweisungen
                            SendKeys.Send("^N");

                            T2 = 0;
                        }
                        if (TimeCount == T3)
                        {
                            Console.WriteLine("Change Scene to webcam 2");
                            log.Items.Insert(0, "Wechsle Szene zu Webcam 2");
                            logTime.Items.Insert(0, output);
                            logTime2.Items.Insert(0, TimeCount);

                            //OBS Anweisungen
                            SendKeys.Send("^M");

                            T3 = 0;
                        }
                        if (TimeCount == T4)
                        {
                            Console.WriteLine("Change Scene to webcam 1");
                            log.Items.Insert(0, "Wechsle Szene zu Webcam 1");
                            logTime.Items.Insert(0, output);
                            logTime2.Items.Insert(0, TimeCount);

                            //OBS Anweisungen
                            SendKeys.Send("^N");

                            T4 = 0;
                        }
                        if (TimeCount == T5)
                        {
                            Console.WriteLine("Change Scene to webcam 2");
                            log.Items.Insert(0, "Wechsle Szene zu Webcam 2");
                            logTime.Items.Insert(0, output);
                            logTime2.Items.Insert(0, TimeCount);

                            //OBS Anweisungen
                            SendKeys.Send("^M");

                            T5 = 0;
                        }
                        if (TimeCount == T6)
                        {
                            Console.WriteLine("Change Scene to webcam 1");
                            log.Items.Insert(0, "Wechsle Szene zu Webcam 1");
                            logTime.Items.Insert(0, output);
                            logTime2.Items.Insert(0, TimeCount);

                            //OBS Anweisungen
                            SendKeys.Send("^N");

                            T6 = 0;
                        }
                        if (TimeCount == T7)
                        {
                            Console.WriteLine("Change Scene to webcam 2");
                            log.Items.Insert(0, "Wechsle Szene zu Webcam 2");
                            logTime.Items.Insert(0, output);
                            logTime2.Items.Insert(0, TimeCount);

                            //OBS Anweisungen
                            SendKeys.Send("^M");

                            T7 = 0;
                        }
                        if (TimeCount == T8)
                        {
                            Console.WriteLine("Change Scene to webcam 1");
                            log.Items.Insert(0, "Wechsle Szene zu Webcam 1");
                            logTime.Items.Insert(0, output);
                            logTime2.Items.Insert(0, TimeCount);

                            //OBS Anweisungen
                            SendKeys.Send("^N");

                            T8 = 0;
                        }
                    }
                    //Lauffortschritt in Progressbar
                    if (TimeCount <= Run_sek)
                    {
                        progressBar.Value = TimeCount;
                    }

                    //Abfrage, ob Lauf beendet
                    WebClient wc2         = new WebClient();
                    string    livetimingD = wc2.DownloadString("http://erzgebirgsschwimmcup.de/Livetiming/livetime2.php");
                    if (!livetimingD.Contains("Bahn"))
                    {
                        Run = "stopped";
                    }
                }
            }
            else
            {
                textBox1.Text = "angehalten";
            }
        }
示例#2
0
        public void CalculatePerformance(double pressure, double temperature, double velocity, double commandedThrottle)
        {
            if (Tt7 == 0)
            {
                mainThrottle = commandedThrottle;
            }
            else
            {
                mainThrottle = Math.Min(commandedThrottle * 1.5, 1.0);
                abThrottle   = Math.Max(commandedThrottle - 0.667, 0);
            }

            p0 = pressure * 1000;          //freestream
            t0 = temperature;

            gamma_c = CalculateGamma(t0, 0);
            Cp_c    = CalculateCp(t0, 0);
            Cv_c    = Cp_c / gamma_c;
            R_c     = Cv_c * (gamma_c - 1);


            M0 = velocity / Math.Sqrt(gamma_c * R_c * t0);

            T1 = t0 * (1 + 0.5 * (gamma_c - 1) * M0 * M0);      //inlet
            P1 = p0 * Math.Pow(T1 / t0, gamma_c / (gamma_c - 1)) * TPR;

            double prat3 = CPR;
            double prat2 = FPR;
            double k     = FPR / CPR;
            double p     = Math.Pow(k, (gamma_c - 1) / eta_c / gamma_c);

            for (int i = 0; i < 20; i++)    //use iteration to calculate CPR
            {
                P2 = prat2 * P1;
                P3 = prat3 * P1;
                T2 = T1 * Math.Pow(prat2, (gamma_c - 1) / gamma_c / eta_c); //fan
                T3 = T1 * Math.Pow(prat3, (gamma_c - 1) / gamma_c / eta_c); //compressor

                T4 = (Tt4 - T3) * mainThrottle + T3;                        //burner
                P4 = P3;
                ff = Cp_c * (T4 - T3) / (Cp_c * (T4 - T3) + h_f);           //fuel fraction

                Cp_t = CalculateCp(T4, ff);

                T5 = T4 * TTR;      //turbine
                double x = prat3;

                prat3  = (1 + ff) * Cp_t * (T4 - T5) / T1 / Cp_c + 1 + BPR;
                prat3 /= 1 + BPR * p;
                prat3  = Math.Pow(prat3, eta_c * gamma_c / (gamma_c - 1));
                prat2  = k * prat3;

                if (Math.Abs(x - prat3) < 0.01)
                {
                    break;
                }
            }

            gamma_t = CalculateGamma(T5, ff);//gas parameters
            Cp_t    = CalculateCp(T5, ff);
            Cv_t    = Cp_t / gamma_t;
            R_t     = Cv_t * (gamma_t - 1);

            P5 = P4 * Math.Pow((1 - 1 / eta_t * (1 - TTR)), gamma_t / (gamma_t - 1));

            if (exhaustMixer && BPR > 0)                      //exhaust mixer
            {
                double Cp6 = (Cp_c * BPR + Cp_t) / (1 + BPR); //Cp of mixed flow -- kind of
                T6      = T5 * Cp_t / Cp6 * (1 + BPR * Cp_c * T2 / Cp_t / T5) / (1 + BPR);
                P6      = (P5 + BPR * 0.98 * P2) / (1 + BPR);
                ff     /= (1 + ff + BPR);
                gamma_t = CalculateGamma(T6, ff);//gas parameters
                Cp_t    = CalculateCp(T6, ff);
                Cv_t    = Cp_t / gamma_t;
                R_t     = Cv_t * (gamma_t - 1);
            }
            else
            {
                T6 = T5;
                P6 = P5;
            }


            if (Tt7 > 0)
            {
                T7 = (Tt7 - T6) * abThrottle * 3 + T6;//afterburner
            }
            else
            {
                T7 = T6;
            }

            P7 = P6;                                                     //rayleigh loss?

            ff_ab    = ff + Cp_t * (T7 - T6) / (Cp_t * (T7 - T6) + h_f); //fuel fraction
            gamma_ab = CalculateGamma(T7, ff_ab);                        //gas parameters
            Cp_ab    = CalculateCp(T7, ff_ab);
            Cv_ab    = Cp_ab / gamma_ab;
            R_ab     = Cv_ab * (gamma_ab - 1);

            //Nozzle code is from NASA
            double P8 = P7;
            double T8 = T7;

            double p8, V8, A8;
            double epr = P8 / P1;
            double etr = T8 / T1;

            double area8max = .75 * Math.Sqrt(etr) / epr;//ratio of nozzle area to ref area

            A8 = area8max * Aref;
            if (exhaustMixer && BPR > 0)
            {
                A8 *= (1 + BPR);
            }
            double eair = P8 * Math.Sqrt(gamma_ab / R_ab / T8) *
                          Math.Pow((.5 + .5 * gamma_ab), .5 * (1 + gamma_ab) / (1 - gamma_ab));//corrected mass flow per area

            mdot = eair * A8;
            double npr  = P8 / p0;
            double fac1 = (gamma_ab - 1.0) / gamma_ab;

            V8     = Math.Sqrt(2.0 * R_c / fac1 * T8 * eta_n * (1.0 - Math.Pow(1.0 / npr, fac1))); //exit velocity
            p8     = (npr <= 1.893) ? p0 : .52828 * P8;
            thrust = V8 * mdot + (p8 - p0) * A8;

            if (BPR > 0 && FPR > 1 && exhaustMixer == false)
            {
                fac1 = (gamma_c - 1) / gamma_c; //fan thrust from NASA
                double snpr   = P2 / p0;
                double ues    = Math.Sqrt(2.0 * R_c / fac1 * T2 * eta_n * (1.0 - Math.Pow(1.0 / snpr, fac1)));
                double pfexit = (snpr <= 1.893) ? p0 : .52828 * P2; //exit pressure of fan
                thrust += BPR * ues * mdot / (1 + ff_ab) + (pfexit - p0) * BPR * Aref;
            }


            double netthrust = thrust - mdot / (1 + ff_ab) * (1 + (exhaustMixer ? 0 : BPR)) * (velocity);//ram drag

            Isp = thrust / (mdot * ff_ab * 9.81);

            debugstring  = "";
            debugstring += "TTR:\t" + TTR.ToString("F3") + "\r\n";
            debugstring += "CPR:\t" + prat3.ToString("F3") + "\r\n";
            debugstring += "M0:\t" + M0.ToString("F3") + "\r\n";
            debugstring += "p0: " + p0.ToString("F2") + "\tt0: " + t0.ToString("F2") + "\r\n";
            debugstring += "P1: " + P1.ToString("F2") + "\tT1: " + T1.ToString("F2") + "\r\n";
            debugstring += "P2: " + P2.ToString("F2") + "\tT2: " + T2.ToString("F2") + "\r\n";
            debugstring += "P3: " + P3.ToString("F2") + "\tT3: " + T3.ToString("F2") + "\r\n";
            debugstring += "P4: " + P4.ToString("F2") + "\tT4: " + T4.ToString("F2") + "\r\n";
            debugstring += "P5: " + P5.ToString("F2") + "\tT5: " + T5.ToString("F2") + "\r\n";
            debugstring += "P6: " + P6.ToString("F2") + "\tT6: " + T6.ToString("F2") + "\r\n";
            debugstring += "P7: " + P7.ToString("F2") + "\tT7: " + T7.ToString("F2") + "\r\n";
            debugstring += "EPR: " + epr.ToString("F2") + "\tETR: " + etr.ToString("F2") + "\r\n";

            debugstring += "FF: " + ff.ToString("P") + "\t";
            debugstring += "FF_AB: " + ff_ab.ToString("P") + "\r\n";
            debugstring += "V8: " + V8.ToString("F2") + "\tA8: " + A8.ToString("F2") + "\r\n";
            debugstring += "Thrust: " + (thrust / 1000).ToString("F1") + "\tmdot: " + mdot.ToString("F2") + "\r\n";
            debugstring += "NetThrust: " + (netthrust / 1000).ToString("F1") + "\tSFC: " + (3600 / Isp).ToString("F3") + "\r\n";
            //Debug.Log(debugstring);
        }