Пример #1
0
 void _lt_CarMessageHandler(F1.Messages.IMessage msg)
 {
     Dispatcher.BeginInvoke(() =>
     {
         listBox1.Items.Add(msg.ToString());
     });
 }
Пример #2
0
        static void Main(string[] args)
        {
            F1 f1 = new F1();

            f1.print();
            F2 f2 = new F2();

            f2.print();
            F3 f3 = new F3();

            f3.print();
            F4 f4 = new F4();

            f4.print();
            F5 f5 = new F5();

            f5.print();
            F6 f6 = new F6();

            f6.print();
            F7 f7 = new F7();

            f7.print();
            F8 f8 = new F8();

            f8.print();
            F9 f9 = new F9();

            f9.print();
        }
        static void TestFold()
        {
            F1  pow2 = x => POW(x)(TWO);
            var list = MAP(RANGE(ONE)(FIVE))(pow2);

            print_int_list(list);
        }
Пример #4
0
        public void AddsNewDriver()
        {
            Driver driver = new F1("jabir", "f1", 76);

            //Assert
            Assert.IsNotNull(driver);
        }
Пример #5
0
        public void func(double[] f, F1 f1, F1 f2, F1 f3, int k, out double H, out double W, out double R)
        {
            H = W = R = 0;
            double s = 0, p = 1;

            for (int i = 0; i < k; i++)
            {
                s += f[i];
            }
            for (int i = 0; i < k; i++)
            {
                p += f[i];
            }
            for (int i = 0; i < k; i++)
            {
                H += f[i] * f1(f[i]);
            }
            H *= s;
            for (int i = 0; i < k; i++)
            {
                W += f[i] * f2(f[i]);
            }
            W *= p;
            for (int i = 0; i < k; i++)
            {
                R += f[i] * f3(f[i]);
            }
            R *= (p + s);
        }
Пример #6
0
        public void NewF1()
        {
            Driver driver = new F1("cobaille", "Muscle Car", 20);

            Assert.IsNotNull(driver);
            Assert.IsTrue(driver is F1);
        }
        /// <summary>
        /// Gets Besselian elements values for specified Juluan Day.
        /// </summary>
        /// <param name="jd">Julian Day of interest</param>
        /// <returns></returns>
        internal InstantBesselianElements GetInstantBesselianElements(double jd)
        {
            //if (jd < From || jd > To)
            //    throw new ArgumentException($"Polynomial Besselian elements valid only for Julian Day in range [{From} ... {To}].", nameof(jd));

            // difference, with t0, in step units
            double t = (jd - JulianDay0) / Step;

            return(new InstantBesselianElements()
            {
                X = X.Select((x, n) => x * Pow(t, n)).Sum(),
                Y = Y.Select((y, n) => y * Pow(t, n)).Sum(),
                L1 = L1.Select((l1, n) => l1 * Pow(t, n)).Sum(),
                L2 = L2.Select((l2, n) => l2 * Pow(t, n)).Sum(),
                D = D.Select((d, n) => d * Pow(t, n)).Sum(),
                Mu = To360(Mu.Select((mu, n) => mu * Pow(t, n)).Sum()),
                F1 = F1.Select((f1, n) => f1 * Pow(t, n)).Sum(),
                F2 = F2.Select((f2, n) => f2 * Pow(t, n)).Sum(),
                dX = Derivative(X, t),
                dY = Derivative(Y, t),
                dL1 = Derivative(L1, t),
                dL2 = Derivative(L2, t),
                dD = Derivative(D, t),
                dMu = Derivative(Mu, t)
            });
        }
        protected void btnadd_Click(object sender, EventArgs e)
        {
            string Doctor_image_name = "";

            string path = "";


            Doctor_image_name = Class1.GetRandomPassword(10) + ".jpg";
            F1.SaveAs(Request.PhysicalApplicationPath + "/Admin/DoctorImages/" + Doctor_image_name.ToString());
            path = "DoctorImages/" + Doctor_image_name.ToString();


            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "insert into DoctorTble(Name,Degree,Username,Email,DOB,Specialist,Department,Country,Address,Phone,ShortBio,Status,Image)values(@Name,@Degree,@Username,@Email,@DOB,@Specialist,@Department,@Country,@Address,@Phone,@ShortBio,@Status,@Image)";
            cmd.Parameters.AddWithValue("@Name", txt_Name.Text.Trim());
            cmd.Parameters.AddWithValue("@Degree", txt_Degree.Text.Trim());
            cmd.Parameters.AddWithValue("@Username", txtUsername.Text.Trim());
            cmd.Parameters.AddWithValue("@Email", txtEmail.Text.Trim());
            cmd.Parameters.AddWithValue("@DOB", DOB.Text.Trim());
            cmd.Parameters.AddWithValue("@Specialist", SpecialistDropDown.SelectedItem.Text);
            cmd.Parameters.AddWithValue("@Department", DepartmentCB.SelectedItem.Text);
            cmd.Parameters.AddWithValue("@Country", CountryCb.SelectedItem.Value);
            cmd.Parameters.AddWithValue("@Address", Address.Text.Trim());
            cmd.Parameters.AddWithValue("@Phone", Phone.Text.Trim());
            cmd.Parameters.AddWithValue("@ShortBio", txtBio.Text.Trim());
            cmd.Parameters.AddWithValue("@Status", DropDownStatus.SelectedItem.Value);
            cmd.Parameters.AddWithValue("@Image", path);
            cmd.ExecuteNonQuery();
            msg.Style.Add("display", "block");

            clear();
        }
        protected void btnadd_Click(object sender, EventArgs e)
        {
            string Bed_image_name = "";

            string path = "";


            Bed_image_name = Class1.GetRandomPassword(10) + ".jpg";
            F1.SaveAs(Request.PhysicalApplicationPath + "/Admin/BedImages/" + Bed_image_name.ToString());
            path = "BedImages/" + Bed_image_name.ToString();


            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "insert into tblBed(SeatNO,FloorNo,Rent_Day,Room,Status,Type,Image)values(@SeatNO,@FloorNo,@Rent_Day,@Room,@Status,@Type,@Image)";
            cmd.Parameters.AddWithValue("@SeatNO", Txtseatno.Text.Trim());
            cmd.Parameters.AddWithValue("@FloorNO", FloorCB.SelectedItem.Text);
            cmd.Parameters.AddWithValue("@Rent_Day", Renttx.Text.Trim());
            cmd.Parameters.AddWithValue("@Room", txtRoom.Text.Trim());
            cmd.Parameters.AddWithValue("@Status", StatusCB.SelectedItem.Text);
            cmd.Parameters.AddWithValue("@Type", TypeCB.SelectedItem.Text);
            cmd.Parameters.AddWithValue("@Image", path);
            cmd.ExecuteNonQuery();
            msg.Style.Add("display", "block");


            clear();
        }
Пример #10
0
            private void ProcessBlock()
            {
                var a = _digest[0];
                var b = _digest[1];
                var c = _digest[2];
                var d = _digest[3];
                var e = _digest[4];
                var f = _digest[5];
                var g = _digest[6];
                var h = _digest[7];

                for (var i = 0; i < 64; i++)
                {
                    var t1 = F1.Compile()(e, f, g, h, i, _w);
                    var t2 = F2.Compile()(a, b, c);
                    h = g;
                    g = f;
                    f = e;
                    e = d + t1;
                    d = c;
                    c = b;
                    b = a;
                    a = t1 + t2;
                }

                _digest[0] += a;
                _digest[1] += b;
                _digest[2] += c;
                _digest[3] += d;
                _digest[4] += e;
                _digest[5] += f;
                _digest[6] += g;
                _digest[7] += h;
            }
Пример #11
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((F4.GetHashCode() * 397) ^ F1.GetHashCode());
     }
 }
 public void Should_map_delegate3()
 {
     F1 f = Method1;
     var o = new DynamicObject(f);
     var r = new DynamicObjectMapper().Map<F1>(o);
     var x = r(5);
 }
Пример #13
0
 private void A1_Tick(object sender, EventArgs e)
 {
     PS3.Extension.WriteString(0x004eb39c, "^5S^7pec Ops ^5M^7od Menu ^5B^7y ^5M^7rNiato - ^5M^7ain ^5M^7enu\n\n^2-->^5Host Menu\nClient 1 Menu\nReset Menu\nAccount Menu\nTeleport Menu\nVision Menu\nCredit Menu\n\n\n^3Client 0 : ^2" + textBox1.Text + "\n^3Client 1 : ^2" + textBox2.Text + "^5");
     if (Key_IsDown((uint)0) == "X")
     {
         HostMenuMain.Stop();
         B1.Start();
     }
     if (Key_IsDown((uint)0) == "R1")
     {
         HostMenuMain.Stop();
         Client1.Start();
     }
     if (Key_IsDown((uint)0) == "R3 + L3")
     {
         HostMenuMain.Stop();
         B1.Stop();
         B2.Stop();
         B3.Stop();
         B4.Stop();
         B5.Stop();
         Client1.Stop();
         C1.Stop();
         C2.Stop();
         C3.Stop();
         C4.Stop();
         ResetMenu.Stop();
         D1.Stop();
         D2.Stop();
         D3.Stop();
         D4.Stop();
         D5.Stop();
         AccountMenu.Stop();
         E1.Stop();
         E2.Stop();
         E3.Stop();
         E4.Stop();
         E5.Stop();
         TeleportMenu.Stop();
         F1.Stop();
         F2.Stop();
         F3.Stop();
         F4.Stop();
         VisionMenu.Stop();
         G1.Stop();
         G2.Stop();
         G3.Stop();
         G4.Stop();
         G5.Stop();
         G6.Stop();
         OtherMenu.Stop();
         H1.Stop();
         PS3.Extension.WriteString(0x004eb39c, "^5Menu ^1Closed");
         simpleButton2.Enabled           = true;
         toolStripStatusLabel2.Text      = "Not Started !";
         toolStripStatusLabel2.ForeColor = Color.Red;
         simpleButton3.Enabled           = false;
     }
 }
Пример #14
0
        public void GivenIWantToKnowTheNumberOfFormulaOneRacesIn(int season)
        {
            var requestBaseUrl  = request.BaseUrl;
            var responseBaseUrl = response.BaseUrl;

            client = new F1CircuitsClient(new InMemoryCache(), new JsonSerializer(), new ErrorLogger());
            f1     = client.GetF1BySeason(season);
        }
 protected virtual void CriticalStep()
 {
     F1.TryActivate();
     if (F1.IsActivated)
     {
         ViolateInvariant = true;
     }
 }
Пример #16
0
 public XElement ToXml()
 {
     return(new XElement(this.GetType().ToString(),
                         new XAttribute("Enabled", Enabled.ToString(CultureInfo.InvariantCulture)),
                         new XAttribute("F1", F1.ToString(CultureInfo.InvariantCulture)),
                         new XAttribute("F2", F2.ToString(CultureInfo.InvariantCulture))
                         ));
 }
Пример #17
0
        int z = 0; //flag


        private void recountBtn_Click(object sender, EventArgs e)
        {
            I1 -= 0.09;
            I2 -= 0.09;
            I3 -= 0.09;
            I4 -= 0.09;
            I5 -= 0.09;
            I6 -= 0.09;

            I1tb.Text = I1.ToString();
            I2tb.Text = I2.ToString();
            I3tb.Text = I3.ToString();
            I4tb.Text = I4.ToString();
            I5tb.Text = I5.ToString();
            I6tb.Text = I6.ToString();

            U2 = I2 * EU * IV / ((IV + I2 + I1) * (I2 + I3 + I4 + I5 - Math.Pow(I2, 2) / (IV + I2 + I1) - Math.Pow((I4 + I5), 2) / (I4 + I5 + I6)));
            U1 = U2 * I2 / (IV + I2 + I1) + EU * IV / (IV + I2 + I1);
            U3 = U2 * (I4 + I5) / (I4 + I5 + I6);
            U1 = Math.Round(U1, 3);
            U2 = Math.Round(U2, 3);
            U3 = Math.Round(U3, 3);

            U1label.Text = "U1 = " + U1.ToString();
            U2label.Text = "U2 = " + U2.ToString();
            U3label.Text = "U3 = " + U3.ToString();

            if (z == 1)
            {
                F1 = Math.Round(Math.Pow(U11 - U1, 2), 3);
            }
            if (z == 2)
            {
                F1 = Math.Round(Math.Pow(U22 - U2, 2), 3);
            }
            if (z == 3)
            {
                F1 = Math.Round(Math.Pow(U33 - U3, 2), 3);
            }

            if (F1 < F)
            {
                FTB.Text = F1.ToString();
                F        = F1;
                logsRTB.AppendText("Целевая функция уменьшается F=" + F1.ToString() + "\n");
                logsRTB.ScrollToCaret();
            }
            else
            {
                logsRTB.AppendText("Целевая функция увеличилась F=" + F1.ToString() + "\n");
                logsRTB.ScrollToCaret();
                recountBtn.Enabled = false;
            }
            Fz = 0;

            calculateGrad();
            calculateHessian();
        }
Пример #18
0
    //100 punti, FA TUTTO IL LAVORO
    static void DrawHelper()
    {
        int scelta = r.Next(1, 4);
        int nextPx = 0, nextPy = 0; //DEVONO ESSERE INIZIALIZZATI



        // Console.WriteLine(scelta);  DEBUG

        //PARTE IN CUI SCEGLIE IL PUNTO SUCCESSIVO BASANDOSI SULLA DISTANZA
        switch (scelta)
        {
        case 1:
        {
            nextPx = ((p1x + X) / DISTANCE_FRACTION);
            nextPy = ((p1y + Y) / DISTANCE_FRACTION);
            break;
        }

        case 2:
        {
            nextPx = ((p2x + X) / DISTANCE_FRACTION);
            nextPy = ((p2y + Y) / DISTANCE_FRACTION);
            break;
        }

        case 3:
        {
            nextPx = ((p3x + X) / DISTANCE_FRACTION);
            nextPy = ((p3y + Y) / DISTANCE_FRACTION);
            break;
        }

        default:
        {
            Console.WriteLine("error");
            break;
        }
        }
        //Console.WriteLine(nextPx + "; " + nextPy +";\n");  DEBUG


        //LOCK PER GESTIRE IL MULTITHREADING
        lock (F1)
        {
            Graphics g = F1.CreateGraphics();

            g.FillRectangle((Brush)Brushes.Azure, nextPx, nextPy, 2, 2);
        }


        i = i + 1;
        if (i < 100)
        {
            DrawHelper();
            // Console.WriteLine("Done {0}", i);  DEBUG
        }
    }
Пример #19
0
            private void CriticalStep()
            {
                F1.TryActivate();

                if (F1.IsActivated)
                {
                    ViolateInvariant = true;
                }
            }
Пример #20
0
 public Vector F(Vector alfa)
 {
     if (alfa.Length == Constants.DIMENSION_COUNT)
     {
         Vector res = new Vector(Constants.DIMENSION_COUNT);
         for (int i = 0; i < Constants.APROXIMATION_FIRST; i++)
         {
             res[0] += F1[i](alfa[0]) * p[i](alfa[2]);
             res[2] += F3[i](alfa[0]) * p[i](alfa[2]);
         }
         res[1] = 0;
         return(res);
     }
     else
     {
         throw new Exception("Error while evaluating F Vector; Reason: Support only 3D!!!");
     }
 }
Пример #21
0
            public override void Update()
            {
                ViolateInvariant = false;
                F1.TryActivate();

                if (F1.IsActivated)
                {
                    ViolateInvariant = true;
                }
            }
Пример #22
0
        public void DriftControl_AddsNewSegmentToList()
        {
            Driver  driver  = new F1("jabir", "f1", 76);
            Segment segment = new Segment("S turn", GroundType.sand);

            driver.DrivenSegments.Add(segment);

            //Assert
            Assert.AreEqual(1, driver.DrivenSegments.Count);
        }
Пример #23
0
        public override int GetHashCode()
        {
            int prime  = 31;
            int result = 1;

            result = prime * result + ((F1 == null) ? 0 : F1.GetHashCode());
            result = prime * result + F2;
            result = prime * result + ((F3 == null) ? 0 : F3.GetHashCode());
            return(result);
        }
Пример #24
0
        public void PointsCalculator_AddPointsIfAsphalt()
        {
            Driver  driver  = new F1("cobaille", "Muscle Car", 20);
            Segment segment = new Segment("S turn", GroundType.asphalt);

            driver.Performence = 50;
            driver.PointsCalculator(driver, segment);

            Assert.AreEqual(80, driver.Performence);
        }
Пример #25
0
        public void PointsCalculator_RemovePointsIfSand()
        {
            Driver  driver  = new F1("cobaille", "Muscle Car", 20);
            Segment segment = new Segment("S turn", GroundType.sand);

            driver.Performence = 50;
            driver.PointsCalculator(driver, segment);

            Assert.AreEqual(30, driver.Performence);
        }
Пример #26
0
        public void SpeedCalculator_AddsSpeedInList()
        {
            Driver  driver  = new F1("cobaille", "Muscle Car", 20);
            Segment segment = new Segment("straight line", GroundType.asphalt);
            Weather weather = Weather.Sun;

            driver.SpeedCalculator(driver, segment, weather);

            Assert.AreEqual(1, driver.TimeSpentOnSegment.Count);
        }
Пример #27
0
        private void formRestore(string key)
        {
            F1.tryGetIngredients(key, out string[,] ingredient_values);
            int rows = ingredient_values.GetUpperBound(0);

            for (int i = 0; i < rows; i++)
            {
                button_plus_Click(null, EventArgs.Empty);
            }
        }
Пример #28
0
        public void Run()
        {
            Function f         = new F1();
            int      dimension = 2;

            new GeneticAlgorithmRunner <GAParametersChromosome>(new GeneticAlgorithmBuilder <GAParametersChromosome>(
                                                                    new GAParameterOptimizationProblem(f, dimension),
                                                                    new GAParameterCrossoverOperator(0.75),
                                                                    new GAParameterMutationOperator(0.1)
                                                                    ).SetElitismRate(0.01).SetPopulationSize(100).SetFitnessValueTreshold(0).Build()).Run();
        }
Пример #29
0
        public void SegmentTimeCalculator()
        {
            int time = 35;

            Driver driver = new F1("jabir", "f1", 76);

            driver.TimeSpentOnSegment.Add(time);

            //Assert
            Assert.AreEqual(1, driver.TimeSpentOnSegment.Count);
        }
Пример #30
0
        public void Drot(DoubleMatrix1D x, DoubleMatrix1D y, double c, double s)
        {
            x.CheckSize(y);
            DoubleMatrix1D tmp = x.Copy();

            x.Assign(F1.Mult(c));
            x.Assign(y, F2.PlusMult(s));

            y.Assign(F1.Mult(c));
            y.Assign(tmp, F2.MinusMult(s));
        }
Пример #31
0
        public void RemovePoints()
        {
            Driver driver     = new F1("jabir", "f1", 76);
            int    percentage = 10;

            driver.Performence = 80;

            driver.RemovePoints(driver, percentage);

            Assert.AreEqual(70, driver.Performence);
        }
Пример #32
0
        public MainMenuScene()
        {
            var bg = MGSprite.MGSpriteWithFilename("images/menu_bg");
            AddChild(bg);
            bg.Anchor = new Vector2(0, 1);

            MGSprite nbackSprite = MGSprite.MGSpriteWithFilename("images/back2");
            MGSprite sbackSprite = MGSprite.MGSpriteWithFilename("images/back1");
            var backMenuitem = MGMenuItemSprite.itemFromNormalSprite(nbackSprite, sbackSprite, null, (sender) => { Control.SharedControl().ReplaceScene(Control.SceneType.StartSceneType); AudioMgr.PlayAudio(1); });
            MGMenu backbtn = MGMenu.menuWithItems(backMenuitem);
            AddChild(backbtn);
            backbtn.Position = new Vector2(218 + 355 / 2f, 349 + 63 - 316 / 2f);

            f1 = new F1();
            AddChild(f1);

            f1.IsTouchEnable = true;

            var grassland = MGSprite.MGSpriteWithFilename("images/grassland-x465-y635-w901-h133");
            AddChild(grassland); grassland.Position = new Vector2(465 + 901 / 2f, 133 / 2f);
        }
        private void CarMessageHandler(F1.Messages.IMessage msg)
        {
            CarBaseMessage carMsg = (CarBaseMessage)msg;

            MainStateDS.MainRow row = GetCarRow(carMsg.CarId);

            switch (CurrentEventType)
            {
                case F1.Enums.EventType.NoEvent:
                    break;
                case F1.Enums.EventType.Practice:
                    DispatchPracticeHAndler(carMsg, row);
                    break;
                case F1.Enums.EventType.Qualifying:
                    DispatchQualyHAndler(carMsg, row);
                    break;
                case F1.Enums.EventType.Race:
                    DispatchRaceHAndler(carMsg, row);
                    break;
            }
        }
Пример #34
0
 void _lt_ControlMessageHandler(F1.Messages.IMessage msg)
 {
 }
Пример #35
0
        void _lt_CarMessageHandler(F1.Messages.IMessage msg)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (MainViewModel.ProgressText.Contains("Connecting"))
                {
                    MainViewModel.ProgressIsVisible = false;
                }

                F1.Messages.ICarMessage carMsg = (F1.Messages.ICarMessage)msg;
                ViewModel.CarViewModel carViewModel = null;

                int oldPosition = 0;

                try
                {
                    carViewModel = MainViewModel.Cars.First(car => car.CarId == carMsg.CarId);
                    oldPosition = carViewModel.TablePosition;
                }
                catch (InvalidOperationException)
                {
                    //check for it in our invisible car list
                    try
                    {
                        carViewModel = _invisibleCars.First(car => car.CarId == carMsg.CarId);
                        carViewModel.IsDataEstimationEnabled = MainViewModel.IsDataEstimationEnabled;
                        oldPosition = carViewModel.TablePosition;
                    }
                    catch (InvalidOperationException)
                    {
                        //not there so create new
                        carViewModel = new ViewModel.CarViewModel();
                        carViewModel.CarId = carMsg.CarId;
                        carViewModel.Position = 0;
                        carViewModel.TablePosition = 0;
                        carViewModel.IsDataEstimationEnabled = MainViewModel.IsDataEstimationEnabled;
                        _invisibleCars.Add(carViewModel);
                    }
                }

                UpdateCar(carViewModel, carMsg);
                UpdatePositionInList(oldPosition, carViewModel);
            });
        }
Пример #36
0
        void _lt_SystemMessageHandler(F1.Messages.IMessage msg)
        {
            var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                MainViewModel.ProgressIsVisible = false;

                if(IsPreventDeviceFromLockScreenEnabled)
                {
                    RequestDisplay();
                }

                if (msg is F1.Messages.System.Copyright)
                {
                    F1.Messages.System.Copyright system = (F1.Messages.System.Copyright)msg;
                    MainViewModel.Copyright = system.Message;
                }

                if (msg is F1.Messages.System.EventId)
                {
                    F1.Messages.System.EventId eventId = (F1.Messages.System.EventId)msg;
                    MainViewModel.EventType = eventId.EventType;
                }

                if (msg is F1.Messages.System.TrackStatus)
                {
                    F1.Messages.System.TrackStatus trackStatus = (F1.Messages.System.TrackStatus)msg;
                    MainViewModel.TrackStatusColor = trackStatus.Status;
                    MainViewModel.TrackStatusMessage = trackStatus.Message;
                }

                if (msg is F1.Messages.System.Commentary)
                {
                    F1.Messages.System.Commentary commentary = (F1.Messages.System.Commentary)msg;

                    CommentViewModel commentViewModel = new CommentViewModel();
                    commentViewModel.Comment = commentary.Message;
                    MainViewModel.Comments.Add(commentViewModel);
                    MainViewModel.LastComment = commentary.Message;
                }

                if (msg is F1.Messages.System.TimeStamp)
                {
                    F1.Messages.System.TimeStamp time = (F1.Messages.System.TimeStamp)msg;
                    MainViewModel.EventTimeElapsed = time.Time;
                }

                if (msg is F1.Messages.System.WeatherSessionClock)
                {
                    F1.Messages.System.WeatherSessionClock weather = (F1.Messages.System.WeatherSessionClock)msg;

                    if (weather.TimeStr == "")
                    {
                        MainViewModel.AllowTimeEstimation = true;

                        //start the timer
                        if (_timer == null)
                        {
                            _timer = new Timer(SessionTimerCallback, null, 0, 1000);
                        }
                    }
                    else
                    {
                        //stop the timer
                        if (_timer != null)
                        {
                            _timer.Dispose();
                            _timer = null;
                        }

                        //set correct remaining time
                        MainViewModel.AllowTimeEstimation = false;
                        MainViewModel.LastCorrectRemainingTime = weather.Time;
                    }
                }

                if (msg is F1.Messages.System.EndOfSession)
                {
                    if (_timer != null)
                    {
                        _timer.Dispose();
                        _timer = null;
                    }

                    MainViewModel.AllowTimeEstimation = false;
                    MainViewModel.LastCorrectRemainingTime = TimeSpan.Zero;

                    ReleaseDisplay();
                }

                if (msg is F1.Messages.System.WeatherAirTemperature)
                {
                    F1.Messages.System.WeatherAirTemperature weather = (F1.Messages.System.WeatherAirTemperature)msg;
                    MainViewModel.WeatherAirTemperature = weather.Temperature;
                }

                if (msg is F1.Messages.System.WeatherHumidity)
                {
                    F1.Messages.System.WeatherHumidity weather = (F1.Messages.System.WeatherHumidity)msg;
                    MainViewModel.WeatherHumidity = weather.Humidity;
                }

                if (msg is F1.Messages.System.WeatherPressure)
                {
                    F1.Messages.System.WeatherPressure weather = (F1.Messages.System.WeatherPressure)msg;
                    MainViewModel.WeatherPressure = weather.Pressure;
                }

                if (msg is F1.Messages.System.WeatherTrackTemperature)
                {
                    F1.Messages.System.WeatherTrackTemperature weather = (F1.Messages.System.WeatherTrackTemperature)msg;
                    MainViewModel.WeatherTrackTemperature = weather.Temperature;
                }

                if (msg is F1.Messages.System.WeatherWetTrack)
                {
                    F1.Messages.System.WeatherWetTrack weather = (F1.Messages.System.WeatherWetTrack)msg;
                    MainViewModel.WeatherIsWet = weather.IsWet;
                }

                if (msg is F1.Messages.System.WeatherWindDirection)
                {
                    F1.Messages.System.WeatherWindDirection weather = (F1.Messages.System.WeatherWindDirection)msg;
                    MainViewModel.WeatherWindDirection = weather.WindDirection;
                }

                if (msg is F1.Messages.System.WeatherWindSpeed)
                {
                    F1.Messages.System.WeatherWindSpeed weather = (F1.Messages.System.WeatherWindSpeed)msg;
                    MainViewModel.WeatherWindSpeed = weather.Speed;
                }

                if (msg is F1.Messages.System.Speed)
                {
                    F1.Messages.System.Speed speed = (F1.Messages.System.Speed)msg;

                    switch (speed.Column)
                    {
                        case F1.Messages.System.Speed.ColumnType.FastestSector1:
                            {
                                MainViewModel.SpeedSector1.Clear();

                                foreach (var pair in speed.FastestSectors)
                                {
                                    if (MainViewModel.DriversNames.ContainsKey(pair.Driver))
                                    {
                                        pair.Driver = MainViewModel.DriversNames[pair.Driver];
                                    }

                                    MainViewModel.SpeedSector1.Add(new SpeedViewModel() { DriverName = pair.Driver, Speed = pair.Speed });
                                }
                                break;
                            }

                        case F1.Messages.System.Speed.ColumnType.FastestSector2:
                            {
                                MainViewModel.SpeedSector2.Clear();

                                foreach (var pair in speed.FastestSectors)
                                {
                                    if (MainViewModel.DriversNames.ContainsKey(pair.Driver))
                                    {
                                        pair.Driver = MainViewModel.DriversNames[pair.Driver];
                                    }

                                    MainViewModel.SpeedSector2.Add(new SpeedViewModel() { DriverName = pair.Driver, Speed = pair.Speed });
                                }
                                break;
                            }

                        case F1.Messages.System.Speed.ColumnType.FastestSector3:
                            {
                                MainViewModel.SpeedSector3.Clear();

                                foreach (var pair in speed.FastestSectors)
                                {
                                    if (MainViewModel.DriversNames.ContainsKey(pair.Driver))
                                    {
                                        pair.Driver = MainViewModel.DriversNames[pair.Driver];
                                    }

                                    MainViewModel.SpeedSector3.Add(new SpeedViewModel() { DriverName = pair.Driver, Speed = pair.Speed });
                                }
                                break;
                            }

                        case F1.Messages.System.Speed.ColumnType.FastestInTrap:
                            {
                                MainViewModel.SpeedTrap.Clear();

                                foreach (var pair in speed.FastestSectors)
                                {
                                    if (MainViewModel.DriversNames.ContainsKey(pair.Driver))
                                    {
                                        pair.Driver = MainViewModel.DriversNames[pair.Driver];
                                    }

                                    MainViewModel.SpeedTrap.Add(new SpeedViewModel() { DriverName = pair.Driver, Speed = pair.Speed });
                                }
                                break;
                            }

                        case F1.Messages.System.Speed.ColumnType.FastestDriverName:
                            MainViewModel.FastestDriverName = speed.MetaData;
                            break;

                        case F1.Messages.System.Speed.ColumnType.FastestDriverNumber:
                            MainViewModel.FastestDriverNumber = speed.MetaData;
                            break;

                        case F1.Messages.System.Speed.ColumnType.FastestLapNumber:
                            MainViewModel.FastestLapNumber = speed.MetaData;
                            break;

                        case F1.Messages.System.Speed.ColumnType.FastestLapTime:
                            MainViewModel.FastestLapTime = speed.MetaData;
                            break;
                    }
                }
            });
        }
Пример #37
0
        void _lt_ControlMessageHandler(F1.Messages.IMessage msg)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (MainViewModel.ProgressText.Contains("Connecting"))
                {
                    MainViewModel.ProgressIsVisible = false;
                }

                if (msg is F1.Messages.Control.AuthorizationProblem)
                {
                    MessageBox.Show("Please check credentials or try again later.", "Connection problem", MessageBoxButton.OK);
                }
            });
        }
Пример #38
0
        void _lt_ControlMessageHandler(F1.Messages.IMessage msg)
        {
            var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {
                MainViewModel.ProgressIsVisible = false;

                if(msg.Type == F1.Enums.SystemPacketType.ControlType)
                {
                    MessageDialog dlg = new MessageDialog("Please check credentials or try again later.");
                    await dlg.ShowAsync();
                }
            });
        }
Пример #39
0
        void _lt_CarMessageHandler(F1.Messages.IMessage msg)
        {
            var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    MainViewModel.ProgressIsVisible = false;

                    F1.Messages.ICarMessage carMsg = (F1.Messages.ICarMessage)msg;
                    ViewModels.CarViewModel carViewModel = null;

                    int oldPosition = 0;

                    try
                    {
                        carViewModel = MainViewModel.Cars.First(car => car.CarId == carMsg.CarId);
                        oldPosition = carViewModel.TablePosition;
                    }
                    catch (InvalidOperationException)
                    {
                        //check for it in our invisible car list
                        try
                        {
                            carViewModel = _invisibleCars.First(car => car.CarId == carMsg.CarId);
                            carViewModel.IsDataEstimationEnabled = MainViewModel.IsDataEstimationEnabled;
                            oldPosition = carViewModel.TablePosition;
                        }
                        catch (InvalidOperationException)
                        {
                            //not there so create new
                            carViewModel = new ViewModels.CarViewModel();
                            carViewModel.CarId = carMsg.CarId;
                            carViewModel.Position = 0;
                            carViewModel.TablePosition = 0;
                            carViewModel.IsDataEstimationEnabled = MainViewModel.IsDataEstimationEnabled;
                            _invisibleCars.Add(carViewModel);
                        }
                    }

                    UpdateCar(carViewModel, carMsg);
                    UpdatePositionInList(oldPosition, carViewModel);
                });
        }
Пример #40
0
        private void UpdateCar(ViewModels.CarViewModel car, F1.Messages.ICarMessage msg)
        {
            if (msg is F1.Messages.Car.CarDriver)
            {
                F1.Messages.Car.CarDriver carDriver = (F1.Messages.Car.CarDriver)msg;
                if (carDriver.Name != "")
                {
                    car.DriverName = carDriver.Name;

                    try
                    {
                        MainViewModel.DriversNames.Add(Converters.DriverNameConverter.Shorten(carDriver.Name), carDriver.Name);
                    }
                    catch (ArgumentException)
                    {
                        //such key already exists
                    }
                }
                car.DriverNameColor = GetColor(msg.Colour);
            }

            if (msg is F1.Messages.Car.CarInterval)
            {
                F1.Messages.Car.CarInterval carInt = (F1.Messages.Car.CarInterval)msg;
                car.SetInterval(carInt.Interval, carInt.IntervalType, GetColor(msg.Colour));
                MainViewModel.UpdateGaps(car.TablePosition);
            }

            if (msg is F1.Messages.Car.CarLapTime)
            {
                F1.Messages.Car.CarLapTime carLapTime = (F1.Messages.Car.CarLapTime)msg;
                car.SetLapTime(carLapTime.LapTime, carLapTime.LapTimeType, GetColor(msg.Colour));
            }

            if (msg is F1.Messages.Car.CarLapCount)
            {
                F1.Messages.Car.CarLapCount lapCount = (F1.Messages.Car.CarLapCount)msg;
                car.LapCountSet = lapCount.LapCount;
                car.LapCountColor = GetColor(msg.Colour);
            }

            if (msg is F1.Messages.Car.CarPitCount)
            {
                F1.Messages.Car.CarPitCount pitCount = (F1.Messages.Car.CarPitCount)msg;
                car.PitCountSet = pitCount.Count;
                car.PitCountColor = GetColor(msg.Colour);
            }

            if (msg is F1.Messages.Car.CarSectorTime1)
            {
                F1.Messages.Car.CarSectorTime1 sect1 = (F1.Messages.Car.CarSectorTime1)msg;
                car.SetSector1Time(sect1.SectorTime, sect1.SectorTimeType, GetColor(msg.Colour));
            }

            if (msg is F1.Messages.Car.CarSectorTime2)
            {
                F1.Messages.Car.CarSectorTime2 sect2 = (F1.Messages.Car.CarSectorTime2)msg;
                car.SetSector2Time(sect2.SectorTime, sect2.SectorTimeType, GetColor(msg.Colour));
            }

            if (msg is F1.Messages.Car.CarSectorTime3)
            {
                F1.Messages.Car.CarSectorTime3 sect3 = (F1.Messages.Car.CarSectorTime3)msg;
                car.SetSector3Time(sect3.SectorTime, sect3.SectorTimeType, GetColor(msg.Colour));
            }

            if (msg is F1.Messages.Car.CarNumber)
            {
                F1.Messages.Car.CarNumber carNum = (F1.Messages.Car.CarNumber)msg;
                car.CarNumberSet = carNum.Number;
                car.CarNumberColor = GetColor(msg.Colour);
            }

            if (msg is F1.Messages.Car.PracticeBestLapTime)
            {
                F1.Messages.Car.PracticeBestLapTime lapTime = (F1.Messages.Car.PracticeBestLapTime)msg;
                car.SetBestPracticeLapTime(lapTime.BestLap, lapTime.BestLapType, GetColor(msg.Colour));
                car.BestPracticeLapTimeColor = GetColor(lapTime.Colour);
            }

            if (msg is F1.Messages.Car.QualifyPeriodTime1)
            {
                F1.Messages.Car.QualifyPeriodTime1 q1Time = (F1.Messages.Car.QualifyPeriodTime1)msg;
                car.SetQ1Time(q1Time.SectorTime, q1Time.SectorTimeType, GetColor(msg.Colour));
            }

            if (msg is F1.Messages.Car.QualifyPeriodTime2)
            {
                F1.Messages.Car.QualifyPeriodTime2 q2Time = (F1.Messages.Car.QualifyPeriodTime2)msg;
                car.SetQ2Time(q2Time.SectorTime, q2Time.SectorTimeType, GetColor(msg.Colour));
            }

            if (msg is F1.Messages.Car.QualifyPeriodTime3)
            {
                F1.Messages.Car.QualifyPeriodTime3 q3Time = (F1.Messages.Car.QualifyPeriodTime3)msg;
                car.SetQ3Time(q3Time.SectorTime, q3Time.SectorTimeType, GetColor(msg.Colour));
            }

            if (msg is F1.Messages.Car.CarPosition)
            {
                F1.Messages.Car.CarPosition carPos = (F1.Messages.Car.CarPosition)msg;

                car.Position = carPos.Position;

                if (msg.Colour != F1.Messages.CarColours.Unknown)
                {
                    car.PositionColor = GetColor(msg.Colour);
                }
            }

            if (msg is F1.Messages.Car.CarPositionUpdate)
            {
                F1.Messages.Car.CarPositionUpdate carPos = (F1.Messages.Car.CarPositionUpdate)msg;

                if (carPos.Position >= 0)
                {
                    //car.Position = carPos.Position;
                    car.TablePosition = carPos.Position;
                }

                if (msg.Colour != F1.Messages.CarColours.Unknown)
                {
                    car.PositionColor = GetColor(msg.Colour);
                }
            }

            if (msg is F1.Messages.Car.CarGap)
            {
                F1.Messages.Car.CarGap carGap = (F1.Messages.Car.CarGap)msg;
                car.SetGap(carGap.Gap, carGap.GapType);
                car.GapColor = GetColor(msg.Colour);
            }
        }
Пример #41
0
        private Color GetColor(F1.Messages.CarColours color)
        {
            switch (color)
            {
                case F1.Messages.CarColours.Black:
                    return Colors.Black;

                case F1.Messages.CarColours.Cyan:
                    return Color.FromArgb(255, 0, 255, 255);

                case F1.Messages.CarColours.Green:
                    return Color.FromArgb(255, 0, 255, 0);

                case F1.Messages.CarColours.Grey:
                    return Colors.Gray;

                case F1.Messages.CarColours.Magenta:
                    return Color.FromArgb(255, 255, 0, 255);

                case F1.Messages.CarColours.Red:
                    return Colors.Red;

                case F1.Messages.CarColours.White:
                    return Color.FromArgb(255, 255, 255, 255);

                case F1.Messages.CarColours.Yellow:
                    return Color.FromArgb(255, 255, 255, 0);

                default:
                    return Colors.Orange;
            }
        }
Пример #42
0
 public static double Integrate1D(F1 f, double lower, double upper, int pieces)
 {
     PDF pdf = (v) => f(v[0]);
     double[] tmp = new double[] { };
     return Integrate1D(pdf, lower, upper, pieces, tmp);
 }