コード例 #1
0
        public void StateTest_Get_Has_Members_Expectations()
        {
            // Arrange
            var instance = new DriverModule();

            ((NancyModule)(instance)).ModelBinderLocator = null;
        }
コード例 #2
0
        public static void Main()
        {
            //Gamepad for input
            GameController _gamepad = new GameController(UsbHostDevice.GetInstance());

            //Create the DriverModule object by giving it the port you plugged it in to.
            DriverModule driver = new DriverModule(CTRE.HERO.IO.Port5);

            //these just act as shorter names for the driveLow and pullUp states
            bool driveLow = DriverModule.OutputState.driveLow;
            bool pullUp   = DriverModule.OutputState.pullUp;

            while (true)
            {
                //When the 'X' button is pressed, enable outputs
                if (_gamepad.GetButton(1) == true)
                {
                    driver.Set(1, driveLow);
                    driver.Set(2, driveLow);
                }
                else
                {
                    driver.Set(1, pullUp);
                    driver.Set(2, pullUp);
                }

                System.Threading.Thread.Sleep(10);
            }
        }
コード例 #3
0
ファイル: SideBarWidget.xaml.cs プロジェクト: TheSmoun/TMTVO
        public void FadeIniRatingGains()
        {
            if (Active)
            {
                return;
            }

            module  = (LiveStandingsModule)API.Instance.FindModule("LiveStandings");
            drivers = (DriverModule)API.Instance.FindModule("DriverModule");
            Mode    = SideBarMode.iRating;
            SideBarTitle title = new SideBarTitle(ParentWindow);

            title.VerticalAlignment = VerticalAlignment.Top;
            LayoutRoot.Children.Add(title);
            elements.Add(title);
            title.FadeIn("LIVE iRATING GAINS");

            for (int i = 0; i < Math.Min(drivers.DriversCount, 22); i++)
            {
                LiveStandingsItem item = module.FindDriverByPos(i + 1);
                if (item != null)
                {
                    SpeedElement se = new SpeedElement(ParentWindow, SpeedElement.SpeedElementMode.iRating);
                    se.VerticalAlignment = VerticalAlignment.Top;
                    se.Margin            = new Thickness(0, (i + 1) * 36, 0, 0);
                    LayoutRoot.Children.Add(se);
                    elements.Add(se);
                    se.FadeIn(i + 1, item, (i + 1) * 25);
                }
            }

            Active = true;
        }
コード例 #4
0
        public void Create_Default()
        {
            // Arrange
            var instance = new DriverModule();

            // Assert
            Assert.Fail("No expectation defined");
        }
コード例 #5
0
        public void Display_Driver()
        {
            // Arrange
            var instance = new DriverModule();

            // Assert
            Assert.Fail("No expectation defined");
        }
コード例 #6
0
 protected void ControlsToData()
 {
     if (_driverModule == null)
     {
         _driverModule = new DriverModule();
     }
     _driverModule.fileName = edtFileName.GetValue <string>();
     _driverModule.installationDirectory = edtInstallationDirectory.GetValue <string>();
 }
コード例 #7
0
        public void Default_driver()
        {
            // Arrange
            var instance = new DriverModule();

            ((NancyModule)(instance)).ModelValidationResult = ModelValidationResult.Valid;

            // Assert
            Assert.IsNotNull(((NancyModule)(instance)).Get);
        }
コード例 #8
0
        public void Editing_Driver_NotEqualTo_Null()
        {
            // Arrange
            var instance = new DriverModule();

            ((NancyModule)(instance)).ModelValidationResult = ModelValidationResult.Valid;

            // Assert
            Assert.IsNotNull(((NancyModule)(instance)).Post);
        }
コード例 #9
0
        public void StateTest_Get_Assert_NotEqualTo_Null()
        {
            // Arrange
            var instance = new DriverModule();

            ((NancyModule)(instance)).ModelValidationResult = ModelValidationResult.Valid;
            ((NancyModule)(instance)).Response = null;

            // Assert
            Assert.IsNotNull(((NancyModule)(instance)).Get);
        }
コード例 #10
0
ファイル: F1ControlTabs.xaml.cs プロジェクト: TheSmoun/TMTVO
        public F1ControlTabs(IThemeWindow window, API api)
        {
            ThemeWindow = window;
            f1Window    = window as F1TVOverlay;

            this.api          = api;
            this.autoCommit   = true;
            this.driverUpdate = true;
            this.cameraUpdate = true;
            this.canUpdateDO1 = true;
            this.canUpdateDO2 = true;
            this.canUpdateFp  = true;

            InitializeComponent();

            CameraModule = api.FindModule("CameraModule") as CameraModule;
            DriverModule = api.FindModule("DriverModule") as DriverModule;
        }
コード例 #11
0
 private int getPoints(int pos) // (SOF/16)*(1-((x-1)/(y-1))) x=pos, y=count
 {
     return((int)Math.Floor((DriverModule.GetStrengthOfField() / 16F) * (1 - ((pos - 1F) / (DriverModule.Drivers.Count - 1F)))));
 }
コード例 #12
0
        public override void Update(ConfigurationSection rootNode, API api)
        {
            SessionType type = (api.FindModule("SessionTimer") as SessionTimerModule).SessionType;

            if (type != SessionType.LapRace && type != SessionType.TimeRace)
            {
                return;
            }

            if (liveStandings == null)
            {
                liveStandings = api.FindModule("LiveStandings") as LiveStandingsModule;
            }

            if (drivers == null)
            {
                drivers = api.FindModule("DriverModule") as DriverModule;
            }

            int driversCount = drivers.DriversCount;
            int notStarters  = liveStandings.Items.Count(d => d.Dns);

            if (lastDriversCount != driversCount)
            {
                matrix         = new double[driversCount, driversCount + 1];
                exponentialSoF = new double[driversCount];
                expectedScores = new double[driversCount];
                fudgeFactors   = new double[driversCount];
            }

            for (int i = 0; i < driversCount; i++)
            {
                LiveStandingsItem driverOpponent = liveStandings.FindDriverByPosNL(i + 1);
                if (driverOpponent == null)
                {
                    return;
                }

                matrix[i, 0]      = driverOpponent.Driver.IRating;
                exponentialSoF[i] = Math.Exp(-driverOpponent.Driver.IRating / log);
                fudgeFactors[i]   = driverOpponent.Dns ? 0 : (((driversCount - (notStarters / 2D)) / 2 - driverOpponent.Position) / 100);

                for (int j = 1; j <= driversCount; j++)
                {
                    LiveStandingsItem driverSelf = liveStandings.FindDriverByPosNL(j);
                    if (driverSelf == null)
                    {
                        return;
                    }

                    matrix[i, j] = calcMatrixEntry(driverOpponent.Driver.IRating, driverSelf.Driver.IRating);
                }
            }

            changeStarters.Clear();
            expChangeNonStarters.Clear();

            foreach (LiveStandingsItem driver in liveStandings.Items)
            {
                int    index         = driver.Position - 1;
                double expectedScore = -0.5D;
                for (int i = 1; i <= driversCount; i++)
                {
                    expectedScore += matrix[index, i];
                }

                expectedScores[index] = expectedScore;
                if (driver.Dns)
                {
                    expChangeNonStarters.Add(expectedScore);
                }
            }

            foreach (LiveStandingsItem driver in liveStandings.Items)
            {
                if (!driver.Dns)
                {
                    int    i      = driver.Position - 1;
                    double change = (driversCount - driver.Position - expectedScores[i] - fudgeFactors[i]) * 200D / (driversCount - notStarters);
                    changeStarters.Add(change);

                    driver.IRatingChange = (int)change;
                }
            }

            foreach (LiveStandingsItem driver in liveStandings.Items)
            {
                if (driver.Dns)
                {
                    int i = driver.Position - 1;

                    double sum = 0D;
                    foreach (double d in changeStarters)
                    {
                        sum += d;
                    }

                    double avg = 0;
                    foreach (double d in expChangeNonStarters)
                    {
                        avg += d;
                    }

                    avg /= expChangeNonStarters.Count;

                    double change = (-sum) / notStarters * expectedScores[i] / avg;
                    driver.IRatingChange = (int)change;
                }
            }

            lastDriversCount = driversCount;
        }