예제 #1
0
        private static void Main(string[] args)
        {
            var iracing = new SdkWrapper {
                TelemetryUpdateFrequency = 15
            };

            iracing.TelemetryUpdated += OnTelemetryUpdated;

            driver = new ArduinoDriver(ArduinoModel.UnoR3, "COM4", true);

            Console.CursorVisible = false;

            const byte DataPin  = 12;
            const byte ClockPin = 11;
            const byte LatchPin = 10;

            driver.Send(new PinModeRequest(DataPin, PinMode.Output));
            driver.Send(new PinModeRequest(LatchPin, PinMode.Output));
            driver.Send(new PinModeRequest(ClockPin, PinMode.Output));


            driver.Send(new DigitalWriteRequest(LatchPin, DigitalValue.Low));
            var response = driver.Send(new ShiftOutRequest(DataPin, ClockPin, BitOrder.LSBFIRST, 115));

            driver.Send(new DigitalWriteRequest(LatchPin, DigitalValue.High));

            Console.WriteLine($"{response.Value} = {Convert.ToString(response.Value, 2).PadLeft(8, '0')}");

            iracing.Start();
        }
예제 #2
0
        public iRacingSLI()
        {
            InitializeComponent();
            this.Text  = "iRacing SLI v" + Version;
            cfg        = new configHandler(console);
            connection = new connectionHelper(console);
            connection.setupConnection(startConnection, cboPorts, cfg);
            brk = new brakeVibe();

            int top  = Convert.ToInt16(cfg.readSetting("Top", "100")) > -3000 ? Convert.ToInt16(cfg.readSetting("Top", "100")) : 100;
            int left = Convert.ToInt16(cfg.readSetting("Left", "100")) > -3000 ? Convert.ToInt16(cfg.readSetting("Left", "100")) : 100;

            this.SetDesktopLocation(top, left);
            this.cboSpdUnit.SelectedIndex = Convert.ToInt16(cfg.readSetting("spdUnit", "0"));
            this.trkIntensity.Value       = Convert.ToInt16(cfg.readSetting("intensity", "0"));
            this.chkTelem.Checked         = Convert.ToBoolean(cfg.readSetting("telemEnable", "True"));
            this.chkBrake.Checked         = Convert.ToBoolean(cfg.readSetting("brakeEnable", "False"));
            this.groupBox1.Enabled        = this.chkBrake.Checked;
            this.trkTol.Value             = Convert.ToInt16(cfg.readSetting("brakeTol", "35"));
            this.trkSens.Value            = Convert.ToInt16(cfg.readSetting("brakeSens", "3"));

            console("Start iRacingSDK Wrapper");
            wrapper = new SdkWrapper();
            wrapper.EventRaiseType           = SdkWrapper.EventRaiseTypes.CurrentThread;
            wrapper.TelemetryUpdateFrequency = 20;

            wrapper.Connected          += wrapper_Connected;
            wrapper.Disconnected       += wrapper_Disconnected;
            wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
            wrapper.TelemetryUpdated   += wrapper_TelemetryUpdated;

            wrapper.Start();
            ticker      = 39;
            prevLapTime = 0;
        }
        public iROBSceneChangerForm()
        {
            InitializeComponent();
            this.Text = Application.ProductName + " " + Application.ProductVersion;
            this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

            // Create a new instance of the SdkWrapper object
            wrapper = new SdkWrapper();

            // Set some properties
            wrapper.EventRaiseType           = SdkWrapper.EventRaiseTypes.CurrentThread;
            wrapper.TelemetryUpdateFrequency = 1;

            // Listen for various iRacing events
            wrapper.Connected        += wrapper_Connected;
            wrapper.Disconnected     += wrapper_Disconnected;
            wrapper.TelemetryUpdated += wrapper_TelemetryUpdated;

            // Save OnTrack state
            oldIsOnTrack = false;

            // Create a new instance of the OBSWebsocket object
            obs            = new OBSWebsocket();
            obsWsConnected = false;

            // Listen for various OBS events
            obs.OnSceneChange += onSceneChange;

            wrapper.Start();
            StatusChanged();
        }
예제 #4
0
        public iRacingSLI()
        {
            InitializeComponent();
            this.Text = "iRacing SLI v" + Version;
            cfg = new configHandler(console);
            connection = new connectionHelper(console);
            connection.setupConnection(startConnection, cboPorts, cfg);
            brk = new brakeVibe();

            int top = Convert.ToInt16(cfg.readSetting("Top", "100")) > -3000 ? Convert.ToInt16(cfg.readSetting("Top", "100")) : 100;
            int left = Convert.ToInt16(cfg.readSetting("Left", "100")) > -3000 ? Convert.ToInt16(cfg.readSetting("Left", "100")) : 100;
            this.SetDesktopLocation(top, left);
            this.cboSpdUnit.SelectedIndex = Convert.ToInt16(cfg.readSetting("spdUnit", "0"));
            this.trkIntensity.Value = Convert.ToInt16(cfg.readSetting("intensity", "0"));
            this.chkTelem.Checked = Convert.ToBoolean(cfg.readSetting("telemEnable", "True"));
            this.chkBrake.Checked = Convert.ToBoolean(cfg.readSetting("brakeEnable", "False"));
            this.groupBox1.Enabled = this.chkBrake.Checked;
            this.trkTol.Value = Convert.ToInt16(cfg.readSetting("brakeTol", "35"));
            this.trkSens.Value = Convert.ToInt16(cfg.readSetting("brakeSens", "3"));

            console("Start iRacingSDK Wrapper");
            wrapper = new SdkWrapper();
            wrapper.EventRaiseType = SdkWrapper.EventRaiseTypes.CurrentThread;
            wrapper.TelemetryUpdateFrequency = 20;

            wrapper.Connected += wrapper_Connected;
            wrapper.Disconnected += wrapper_Disconnected;
            wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
            wrapper.TelemetryUpdated += wrapper_TelemetryUpdated;

            wrapper.Start();
            ticker = 39;
            prevLapTime = 0;
        }
예제 #5
0
 public Session(int _nonRtFps, Form1 _form, SdkWrapper _sessionWrapper, Dash _sessionDash)
 {
     NonRTCalculationFPS = _nonRtFps;
     sessionWrapper      = _sessionWrapper;
     sessionForm         = _form;
     sessionDash         = _sessionDash;
 }
예제 #6
0
        public Form1()
        {
            InitializeComponent();

            m_logger.Debug("Initializing iR SDK Wrapper");

            m_wrapper = new SdkWrapper();
            m_wrapper.SessionInfoUpdated += OnSessionInfoUpdated;
            m_wrapper.TelemetryUpdated   += OnTelemetryUpdated;

            m_logger.Debug("Starting iR SDK Wrapper");
            m_wrapper.Start();
            m_logger.Debug("Wrapper Started");

            m_tooltip.SetToolTip(nudFuelMult, "Sets the multiplier to the fuel rate used during the calculation for fuel needed.");
            m_tooltip.SetToolTip(nudLapOffset, "Adds this number of laps to the race length during fuel calculation.");
            m_tooltip.SetToolTip(cbOnlyGreen, "When enabled, only laps done in a race under green flag conditions are logged. Useful if you expect a lot of cautions.");
            m_tooltip.SetToolTip(btnEnableAutoFuel, "If enabled, will automatically set the pitstop fuel amount when you cross the yellow cones.\nIf disabled, will only monitor.");
            m_tooltip.SetToolTip(cbUnits, "Selects which units to use when displaying and calculating fuel. Automatic will try to use what the game does.");

            OpenConfig();

            if (cbUnits.SelectedIndex == -1)
            {
                cbUnits.SelectedIndex = 0;
            }

            UpdateLabels();
        }
예제 #7
0
        private void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            DisplayMngr = new DisplayManager(this);
            String[] ports = ArduinoLink.CheckComPorts();
            foreach (var item in ports)
            {
                ComPortBox.Items.Add(item);
            }
            ComPortBox.SelectedIndex = 0;
            StartButtonLabel.Content = "Start";
            StartButtonImage.Source  = this.startImage;

            this.ArduinoConnection                         = new ArduinoLink();
            this.ArduinoMessagesReceivingMngr              = new ArduinoMessagesReceiving();
            this.ArduinoMessagesSendingMngr                = new ArduinoMessagesSending();
            this.ArduinoConnection.SerialMessageReceived  += ArduinoMessagesReceivingMngr.SerialMessageReceiver;
            this.ArduinoMessagesReceivingMngr.ButtonPress += this.ArduinoSLIButtonPress;
            this.ArduinoMessagesSendingMngr.TestFinished  += this.ArduinoSLITestFinished;

            // Create a new instance of the SdkWrapper object
            this.wrapper = new SdkWrapper
            {
                EventRaiseType           = SdkWrapper.EventRaiseTypes.CurrentThread,
                TelemetryUpdateFrequency = 30    //60  //NEWBUILD
            };
            // Tell it to raise events on the current thread (don't worry if you don't know what a thread is)
            // Only update telemetry 60 times per second
            // Attach some useful events so you can respond when they get raised
            this.wrapper.Connected          += this.WrapperConnected;
            this.wrapper.Disconnected       += this.WrapperDisconnected;
            this.wrapper.SessionInfoUpdated += this.WrapperSessionInfoUpdated;
            this.wrapper.TelemetryUpdated   += this.WrapperTelemetryUpdated;

            DisplayMngr.ArduinoConnection = this.ArduinoConnection;
            DisplayMngr.Wrapper           = this.wrapper;

            if (ComPortBox.SelectedIndex >= 0)
            {
                if (DisplayMngr.ConfSet)
                {
                    StartButton.IsEnabled = true;
                }
            }
            else
            {
                StartButton.IsEnabled = false;
            }
            LoadConfsinDirectory();
            DisplayMngr.ShiftLightData = ShiftLightData.LoadShiftData(AppDomain.CurrentDomain.BaseDirectory + "ShiftLightData.xml"); //Load ShiftLightData.xml

            if (StartButton.IsEnabled)
            {
                DisplayMngr.Test = true;
                this._conect();
                this.TMDisplayTest();
            }

            //this.MyNotifyIcon.ShowBalloonTip("iRduino", "Estamos Rodando", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info);
            this.Hide();
        }
        private void UpdateIncidents(SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            var type = Sim.Instance.SessionData.SessionType[0].ToString();
            var time = e.UpdateTime;

            var oldDict = _drivers.ToDictionary(driver => driver.Id);
            var newDict = Sim.Instance.Drivers.ToDictionary(driver => driver.Id);

            _drivers.Clear();

            foreach (var kvp in newDict)
            {
                var id = kvp.Key;
                var driver = kvp.Value;

                var prevInc = 0;
                if (oldDict.ContainsKey(id))
                {
                    prevInc = oldDict[id].CurrentResults.Incidents;
                }

                var delta = driver.CurrentResults.Incidents - prevInc;
                if (delta > 0)
                {
                    _incidents.Add(new Incident(driver, type, time, delta));
                }

                _drivers.Add(driver);
            }
        }
        private void SaveSessionInfo(SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            var dir = "output";
            if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);

            var path = Path.Combine(dir, $"sessioninfo_{e.UpdateTime.ToString("0")}.txt");
            File.WriteAllText(path, e.SessionInfo.Yaml);
        }
예제 #10
0
        public RaceDataReceiver(SdkWrapper cnx, IRaceServerProxy server)
        {
            Guard.Argument.IsNotNull(cnx, "cnx");
            Guard.Argument.IsNotNull(server, "server");

            _cnx = cnx;
            _serverProxy = server;
        }
예제 #11
0
        public Dash(Form1 form, SdkWrapper wrapper)
        {
            _dashForm = form;

            _wrapper     = wrapper;
            _idleImg     = new PictureBox();
            _manipulator = new FormManipulator(this._dashForm);
        }
예제 #12
0
        public Form1()
        {
            InitializeComponent();

            wrapper = new SdkWrapper();
            wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
            wrapper.Start();
        }
예제 #13
0
        public Form1()
        {
            InitializeComponent();

            wrapper = new SdkWrapper();
            wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
            wrapper.Start();
        }
예제 #14
0
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            // The session info has updated
            bool shouldUpdateGrid = false;

            // Let's check every driver for a new lap
            foreach (var driver in Sim.Instance.Drivers)
            {
                // Ignore if there are no results yet
                if (driver.CurrentResults == null) continue;

                // Get the number of laps this driver has completed
                var currentLap = driver.CurrentResults.LapsComplete;

                // Check what lap this driver was on the last update
                int? previousLap = null;
                if (previousLaps.ContainsKey(driver.Id))
                {
                    // We already stored their previous lap
                    previousLap = previousLaps[driver.Id];
                    
                    // Then update the lap number to the current lap
                    previousLaps[driver.Id] = currentLap;
                }
                else
                {
                    // We didn't store their lap yet, so add it
                    previousLaps.Add(driver.Id, currentLap);
                }

                // Check if their lap number has changed
                if (previousLap == null || previousLap.Value < currentLap)
                {
                    // Lap has changed, grab their laptime and add to the list of lap entries
                    var lastTime = driver.CurrentResults.LastTime;

                    var entry = new LapEntry();
                    entry.CustomerId = driver.CustId;
                    entry.Name = driver.Name;
                    entry.CarNumber = driver.CarNumber;

                    entry.Lap = lastTime.LapNumber;
                    entry.Laptime = lastTime.Value;
                    entry.LaptimeDisplay = lastTime.Display;

                    laps.Add(entry);

                    // After we checked every driver we need to update the grid to reflect the changes
                    shouldUpdateGrid = true;
                }
            }

            if (shouldUpdateGrid)
            {
                bindingSource.ResetBindings(false);
            }
        }
예제 #15
0
        private Connection()
        {
            _sdk = new SdkWrapper();
            _sdk.TelemetryUpdateFrequency = 5;
            _sdk.EventRaiseType           = SdkWrapper.EventRaiseTypes.BackgroundThread;

            _sdk.SessionInfoUpdated += SdkOnSessionInfoUpdated;
            _sdk.TelemetryUpdated   += SdkOnTelemetryUpdated;
        }
예제 #16
0
        public Form1()
        {
            InitializeComponent();

            _wrapper = new SdkWrapper();
            _wrapper.Start();

            LoadDropdowns();
        }
예제 #17
0
        private Connection()
        {
            _sdk = new SdkWrapper();
            _sdk.TelemetryUpdateFrequency = 5;
            _sdk.EventRaiseType = SdkWrapper.EventRaiseTypes.BackgroundThread;

            _sdk.SessionInfoUpdated += SdkOnSessionInfoUpdated;
            _sdk.TelemetryUpdated += SdkOnTelemetryUpdated;
        }
예제 #18
0
        public Form1()
        {
            InitializeComponent();

            _wrapper = new SdkWrapper();
            _wrapper.Start();

            LoadDropdowns();
        }
예제 #19
0
        public IRacing()
        {
            wrapper = new SdkWrapper();
               // wrapper.TelemetryUpdateFrequency = 4;
            wrapper.TelemetryUpdated += OnTelemetryUpdated;
            wrapper.SessionInfoUpdated += OnSessionInfoUpdated;

            _hardware = new AGHardware();
        }
예제 #20
0
        public Form1()
        {
            InitializeComponent();
            wrapper = new SdkWrapper();
            wrapper.Start();
            wrapper.TelemetryUpdateFrequency = 5;
            wrapper.TelemetryUpdated        += OnTelemetryUpdated;

            time = string.Format("{0:00}:{1:00}:{2:00}", hours, minutes, second);
        }
예제 #21
0
        public SdkWrapperProxy(SdkWrapper wrapper, bool record)
        {
            this.wrapper = wrapper;
            this.record  = record;

            wrapper.TelemetryUpdated   += OnTelemetryUpdate;
            wrapper.SessionInfoUpdated += OnSessionInfoUpdate;

            sessionInfoUpdateHandlers = new List <EventHandler <SdkWrapper.SessionInfoUpdatedEventArgs> >();
            telemetryUpdateHandlers   = new List <EventHandler <ITelemetryUpdatedEvent> >();
        }
예제 #22
0
        public Form1()
        {
            InitializeComponent();

            wrapper = new SdkWrapper();
            wrapper.TelemetryUpdateFrequency = 5;
            wrapper.SessionInfoUpdated      += OnSessionInfoUpdated;
            wrapper.TelemetryUpdated        += OnTelemetryUpdated;

            wrapper.Start();
        }
예제 #23
0
        public Form1()
        {
            InitializeComponent();

            wrapper = new SdkWrapper();
            wrapper.TelemetryUpdateFrequency = 5;
            wrapper.SessionInfoUpdated += OnSessionInfoUpdated;
            wrapper.TelemetryUpdated += OnTelemetryUpdated;

            wrapper.Start();
        }
예제 #24
0
 static void ExecuteFlightPlan(SdkWrapper wrapper)
 {
     try
     {
         var fp = TelloSdkCoreNet.flightplans.FlightPlan.Materialize(System.IO.File.ReadAllText(@"/Users/peterhallock/Documents/git/TelloSdkCoreNet/TestApp/TestApp\FP_4-10-18 102058 PM_b59c89eb.json.fp"));
         wrapper.ExecuteFlightPlan(fp);
     }
     catch (Exception ex)
     {
         WriteError(ex.Message);
         Console.ReadLine();
     }
 }
예제 #25
0
        private Sim()
        {
            _sdk     = new SdkWrapper();
            _drivers = new List <Driver>();

            _sessionData           = new SessionData();
            _mustUpdateSessionData = true;

            // Attach events
            _sdk.Connected          += SdkOnConnected;
            _sdk.Disconnected       += SdkOnDisconnected;
            _sdk.TelemetryUpdated   += SdkOnTelemetryUpdated;
            _sdk.SessionInfoUpdated += SdkOnSessionInfoUpdated;
        }
예제 #26
0
        public MainWindow()
        {
            InitializeComponent();

            // Create instance
            wrapper = new SdkWrapper();
            // Listen to events
            wrapper.TelemetryUpdated   += OnTelemetryUpdated;
            wrapper.SessionInfoUpdated += OnSessionInfoUpdated;

            // Start it!
            Sim.Instance.Start();
            wrapper.Start();
        }
예제 #27
0
        private Sim()
        {
            _sdk = new SdkWrapper();
            _drivers = new List<Driver>();

            _sessionData = new SessionData();
            _mustUpdateSessionData = true;

            // Attach events
            _sdk.Connected += SdkOnConnected;
            _sdk.Disconnected += SdkOnDisconnected;
            _sdk.TelemetryUpdated += SdkOnTelemetryUpdated;
            _sdk.SessionInfoUpdated += SdkOnSessionInfoUpdated;
        }
예제 #28
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            wrapper = new SdkWrapper();

            wrapper.Connected += wrapper_Connected;
            wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
            wrapper.TelemetryUpdated += wrapper_TelemetryUpdated;
            wrapper.Disconnected += wrapper_Disconnected;
            wrapper.Start();

            Application.Run(new AppContext());
        }
예제 #29
0
        public Form1()
        {
            InitializeComponent();
            shiftLbl.Text = "";

            if (ReadSettings())
            {
                // Create instance
                wrapper = new SdkWrapper();
                wrapper.TelemetryUpdateFrequency = 30;
                // Listen to events
                wrapper.TelemetryUpdated   += OnTelemetryUpdated;
                wrapper.SessionInfoUpdated += OnSessionInfoUpdated;
                // Start it!
                wrapper.Start();
            }
        }
예제 #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="iRacing"/> class.
        /// </summary>
        public iRacing() : base()
        {
            _name        = "iRacing";
            _displayName = "iRacing";
            _displayName = "iRacing";
            _author      = "Alex Greenland";
            _url         = "http://onehud.co.uk/";
            _processNames.Add("iRacingSim");
            _processNames.Add("iRacingSim64");
            _processNames.Add("iRacingSim64DX11");
            _processNames.Add("iRacingSimDX11");

            _wrapper = new SdkWrapper();
            _wrapper.TelemetryUpdated   += OnTelemetryUpdated;
            _wrapper.SessionInfoUpdated += OnSessionInfoUpdated;
            _wrapper.Disconnected       += OnSimDisconnected;
        }
예제 #31
0
        private void OnTelemetryUpdated(object sender, SdkWrapper.TelemetryUpdatedEventArgs e)
        {
            var replayFrame = e.TelemetryInfo.ReplayFrameNum.Value;
            var replayEndFrame = wrapper.GetTelemetryValue<int>("ReplayFrameNumEnd").Value;
            var sum = replayFrame + replayEndFrame;

            label1.Text = "ReplayFrameNum: " + replayFrame
                          + "\n\nReplayFrameNumEnd: " + replayEndFrame
                          + "\n\nSum: " + sum
                          + "\n\nSessionTime: " + e.TelemetryInfo.SessionTime.Value
                          + "\n\nReplaySessionTime: " + e.TelemetryInfo.ReplaySessionTime.Value;


            progressBar1.Minimum = 0;
            progressBar1.Maximum = sum;
            progressBar1.Value = replayFrame;
        }
예제 #32
0
        public Form1()
        {
            InitializeComponent();

            Init();

            if (turnFormEnabled)
            {
                turn         = new Turn();
                turn.Visible = turnFormEnabled;
            }

            wrapper = new SdkWrapper();
            wrapper.Start();
            wrapper.TelemetryUpdateFrequency = 60;
            wrapper.TelemetryUpdated        += OnTelemetryUpdated;
            wrapper.SessionInfoUpdated      += OnSessionInfoUpdated;
        }
예제 #33
0
        public Form1()
        {
            InitializeComponent();

            // Create a new instance of the SdkWrapper object
            wrapper = new SdkWrapper();

            // Tell it to raise events on the current thread (don't worry if you don't know what a thread is)
            wrapper.EventRaiseType = SdkWrapper.EventRaiseTypes.CurrentThread;

            // Only update telemetry 10 times per second
            wrapper.TelemetryUpdateFrequency = 10;

            // Attach some useful events so you can respond when they get raised
            wrapper.Connected          += wrapper_Connected;
            wrapper.Disconnected       += wrapper_Disconnected;
            wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
            wrapper.TelemetryUpdated   += wrapper_TelemetryUpdated;
        }
예제 #34
0
        public Form1()
        {
            InitializeComponent();

            _sdk     = new iRacingSDK();
            _wrapper = new SdkWrapper();
            //_wrapper = new iRacingMock.ClassLibrary.Mock("D:\\_20190810_115035.csv");

            //defaultSession = new DefaultSession();
            dash = new Dash(this, _wrapper);
            dash.InitDash();
            new Configurator().StartConfig(ref maxRpm, ref location, ref dash.minRpmPercent, ref dash.shiftLight1Percent, ref dash.shiftLight2Percent, ref dash.redLinePercent, ref fps);

            Location = location;
            _wrapper.TelemetryUpdateFrequency = fps;

            SubscribeToEvents();
            _wrapper.Start();
        }
예제 #35
0
        public Form1()
        {
            InitializeComponent();

            // Create a new instance of the SdkWrapper object
            wrapper = new SdkWrapper();

            // Tell it to raise events on the current thread (don't worry if you don't know what a thread is)
            wrapper.EventRaiseType = SdkWrapper.EventRaiseTypes.CurrentThread;

            // Only update telemetry 10 times per second
            wrapper.TelemetryUpdateFrequency = 10;

            // Attach some useful events so you can respond when they get raised
            wrapper.Connected += wrapper_Connected;
            wrapper.Disconnected += wrapper_Disconnected;
            wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
            wrapper.TelemetryUpdated += wrapper_TelemetryUpdated;
        }
예제 #36
0
        private void wrapper_SessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            // Create a Deserializer
            // Tell it to ignore unmatched properties unless you have mapped every single property
            var deserializer = new Deserializer(ignoreUnmatched: true);
            
            // Read the session info yaml
            using (var reader = new StringReader(e.SessionInfo.Yaml))
            {
                var customSessionInfo = deserializer.Deserialize<CustomSessionInfo>(reader);

                // Write it to a label for example
                label1.Text = "WeekendInfo:TrackName: " + customSessionInfo.WeekendInfo.TrackName
                              + "\n"
                              + "WeekendInfo:WeekendOptions:StartingGrid: " +
                              customSessionInfo.WeekendInfo.WeekendOptions.StartingGrid
                              + "\n"
                              + "DriverInfo:Drivers[0]:UserName: " + customSessionInfo.DriverInfo.Drivers[0].UserName;
            }
        }
예제 #37
0
        public Form1()
        {
            InitializeComponent();

            // Create a new instance of the SdkWrapper object
            wrapper = new SdkWrapper();

            wrapper.EventRaiseType = SdkWrapper.EventRaiseTypes.CurrentThread;
            wrapper.TelemetryUpdateFrequency = 10;

            wrapper.Connected += wrapper_Connected;
            wrapper.Disconnected += wrapper_Disconnected;
            wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
            wrapper.TelemetryUpdated += wrapper_TelemetryUpdated;

            // Bind a list of drivers to the grid
            binding = new BindingSource();
            drivers = new List<Driver>();
            binding.DataSource = drivers;
            driversGrid.DataSource = binding;
        }
예제 #38
0
        public Form1()
        {
            InitializeComponent();

            // Create a new instance of the SdkWrapper object
            wrapper = new SdkWrapper();

            wrapper.EventRaiseType           = SdkWrapper.EventRaiseTypes.CurrentThread;
            wrapper.TelemetryUpdateFrequency = 10;

            wrapper.Connected          += wrapper_Connected;
            wrapper.Disconnected       += wrapper_Disconnected;
            wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
            wrapper.TelemetryUpdated   += wrapper_TelemetryUpdated;


            // Bind a list of drivers to the grid
            binding                = new BindingSource();
            drivers                = new List <Driver>();
            binding.DataSource     = drivers;
            driversGrid.DataSource = binding;
        }
        public iRacingSLI()
        {
            try
            {
                InitializeComponent();
                this.Text = "iRacing SLI v" + Version;
                cfg = new configHandler(console);
                connection = new connectionHelper(console);
                connection.setupConnection(startConnection, cboPorts, cfg);

                int top = Convert.ToInt16(cfg.readSetting("Top", "100")) > -3000 ? Convert.ToInt16(cfg.readSetting("Top", "100")) : 100;
                int left = Convert.ToInt16(cfg.readSetting("Left", "100")) > -3000 ? Convert.ToInt16(cfg.readSetting("Left", "100")) : 100;
                this.SetDesktopLocation(top, left);
                this.cboSpdUnit.SelectedIndex = Convert.ToInt16(cfg.readSetting("spdUnit", "0"));
                this.trkIntensity.Value = Convert.ToInt16(cfg.readSetting("intensity", "0"));
                this.chkTelem.Checked = Convert.ToBoolean(cfg.readSetting("telemEnable", "True"));

                console("Start iRacingSDK Wrapper");
                wrapper = new SdkWrapper();
                wrapper.EventRaiseType = SdkWrapper.EventRaiseTypes.CurrentThread;
                wrapper.TelemetryUpdateFrequency = 20;
                //wrapper.ConnectSleepTime = 1;

                wrapper.Connected += wrapper_Connected;
                wrapper.Disconnected += wrapper_Disconnected;
                wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
                wrapper.TelemetryUpdated += wrapper_TelemetryUpdated;

                wrapper.Start();
                ticker = 39;
                prevLapTime = 0;
            }
            catch (Exception exe)
            {
                ExceptionHelper.writeToLogFile(exe.Message, exe.ToString(), "Constructor", exe.LineNumber(), this.FindForm().Name);
            }
        }
예제 #40
0
        public iRacingSLI()
        {
            try
            {
                InitializeComponent();
                this.Text  = "iRacing SLI v" + Version;
                cfg        = new configHandler(console);
                connection = new connectionHelper(console);
                connection.setupConnection(startConnection, cboPorts, cfg);

                int top  = Convert.ToInt16(cfg.readSetting("Top", "100")) > -3000 ? Convert.ToInt16(cfg.readSetting("Top", "100")) : 100;
                int left = Convert.ToInt16(cfg.readSetting("Left", "100")) > -3000 ? Convert.ToInt16(cfg.readSetting("Left", "100")) : 100;
                this.SetDesktopLocation(top, left);
                this.cboSpdUnit.SelectedIndex = Convert.ToInt16(cfg.readSetting("spdUnit", "0"));
                this.trkIntensity.Value       = Convert.ToInt16(cfg.readSetting("intensity", "0"));
                this.chkTelem.Checked         = Convert.ToBoolean(cfg.readSetting("telemEnable", "True"));

                console("Start iRacingSDK Wrapper");
                wrapper = new SdkWrapper();
                wrapper.EventRaiseType           = SdkWrapper.EventRaiseTypes.CurrentThread;
                wrapper.TelemetryUpdateFrequency = 20;
                //wrapper.ConnectSleepTime = 1;

                wrapper.Connected          += wrapper_Connected;
                wrapper.Disconnected       += wrapper_Disconnected;
                wrapper.SessionInfoUpdated += wrapper_SessionInfoUpdated;
                wrapper.TelemetryUpdated   += wrapper_TelemetryUpdated;

                wrapper.Start();
                ticker      = 39;
                prevLapTime = 0;
            }
            catch (Exception exe)
            {
                ExceptionHelper.writeToLogFile(exe.Message, exe.ToString(), "Constructor", exe.LineNumber(), this.FindForm().Name);
            }
        }
예제 #41
0
        // Example method that adds some data such as your lap distance and track surface to the string builder
        private void ArrayExample(StringBuilder sb, SdkWrapper.TelemetryUpdatedEventArgs e)
        {
            // Get your own CarIdx:
            int myId = wrapper.DriverId;

            // Get the arrays you want
            float[] lapDistances = e.TelemetryInfo.CarIdxLapDistPct.Value;
            TrackSurfaces[] surfaces = e.TelemetryInfo.CarIdxTrackSurface.Value;

            // Your car data is at your id index;
            float myLapDistance = lapDistances[myId];
            TrackSurfaces mySurface = surfaces[myId];

            sb.AppendLine("My lap distance: " + myLapDistance);
            sb.AppendLine("My track surface: " + mySurface.ToString());
        }
예제 #42
0
        public override void OnTelemetryUpdated(SdkWrapper.TelemetryUpdatedEventArgs e)
        {
#if !DEBUG
            this.SessionTime = e.TelemetryInfo.SessionTime.Value;
            this.ReplaySessionTime = e.TelemetryInfo.ReplaySessionTime.Value;
            this.UpdateEvents();
#endif
        }
예제 #43
0
 public override void OnSessionInfoUpdated(SdkWrapper.SessionInfoUpdatedEventArgs e)
 {
 }
예제 #44
0
 internal PitCommandControl(SdkWrapper wrapper) : base(wrapper)
 {
 }
예제 #45
0
        static void PrintMenu(SdkWrapper wrapper)
        {
            var done = false;

            //wrapper.BaseActions.CommandMode().Execute();
            while (!done)
            {
                TelloSdkCoreNet.actions.Action action = null;
                Console.Clear();
                Console.WriteLine("1.TakeOff");
                Console.WriteLine("2.Land");
                Console.WriteLine("3.Flip");
                Console.WriteLine("4.Fly forward");
                Console.WriteLine("5.Fly back");
                Console.WriteLine("6.Rotate");
                Console.WriteLine("7.Battery %");
                Console.WriteLine("8.Execute flight plan");
                Console.WriteLine("9.Exit");
                var choice = Console.ReadLine();
                try
                {
                    switch (choice)
                    {
                    case "1":
                    {
                        action = wrapper.BaseActions.TakeOff();
                        break;
                    }

                    case "2":
                    {
                        action = wrapper.BaseActions.Land();
                        break;
                    }

                    case "3":
                    {
                        action = wrapper.FlipActions.FlipBackLeft();
                        break;
                    }

                    case "4":
                    {
                        action = wrapper.FlyActions.FlyForward(50);
                        break;
                    }

                    case "5":
                    {
                        action = wrapper.FlyActions.FlyBack(50);
                        break;
                    }

                    case "6":
                    {
                        action = wrapper.RotationActions.RotateClockwise(360);
                        break;
                    }

                    case "7":
                    {
                        var resp = wrapper.BaseActions.QueryBattery().Execute();
                        if (resp == SdkWrapper.SdkReponses.OK)
                        {
                            Console.WriteLine($"Battery percentage is {wrapper.BaseActions.QueryBattery().ServerResponse}%");
                            Console.ReadLine();
                        }
                        break;
                    }

                    case "8":
                    {
                        ExecuteFlightPlan(wrapper);
                        break;
                    }

                    case "9":
                    {
                        done = true;
                        break;
                    }
                    }
                    if (action != null)
                    {
                        var resp1 = action.Execute();
                        if (resp1 == SdkWrapper.SdkReponses.FAIL)
                        {
                            if (action.LastException != null)
                            {
                                throw action.LastException;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteError(ex.Message);
                    Console.ReadLine();
                }
            }
        }
예제 #46
0
        private void OnSessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            sessionInfo = e.SessionInfo;

            // Stop if we don't have a session number yet
            if (telemetry.Sessions.CurrentSession.SessionNum == null) return;

            if (_mustUpdateSessionData)
            {
                UpdateSessionInformation();
            }

              //  if (_mustReloadDrivers)
              //  {
                UpdateDrivers(sessionInfo);
              //  }
        }
예제 #47
0
 public void Before()
 {
     wrapper = new SdkWrapper();
     proxy   = new SdkWrapperProxy(wrapper, false);
 }
예제 #48
0
        // Example method that adds speed and roll values to the string builder
        private void TelemetryExample(StringBuilder sb, SdkWrapper.TelemetryUpdatedEventArgs e)
        {
            // Important distinction: TelemetryInfo.Speed (for example) returns an object of type TelemetryValue. 
            // This object contains more than just the value; also the unit, name and a description.
            // To get just the value, you use the Value property.
            // This goes for every property of the TelemetryInfo class.

            sb.AppendLine("Speed: " + e.TelemetryInfo.Speed.Value); // Without unit
            sb.AppendLine("Speed: " + e.TelemetryInfo.Speed.ToString()); // with unit
            sb.AppendLine("Roll: " + e.TelemetryInfo.Roll.ToString());
        }
예제 #49
0
        // Event handler called when the telemetry is updated
        // This happens (max) 60 times per second
        private void wrapper_TelemetryUpdated(object sender, SdkWrapper.TelemetryUpdatedEventArgs e)
        {
            telemetryLabel.Text = string.Format("Telemetry (last updated {0})", DateTime.Now.TimeOfDay.ToString());

            // Let's just write some random values:
            StringBuilder sb = new StringBuilder();

            this.TelemetryExample(sb, e);
            this.ArrayExample(sb, e);
            this.BitfieldsExample(sb, e);

            // Get a (fictional) value that is not covered in the TelemetryInfo properties
            var fictionalObject = wrapper.GetTelemetryValue<int>("VariableName");
            var fictionalValue = fictionalObject.Value;

            telemetryTextBox.Text = sb.ToString();
        }
예제 #50
0
        private void wrapper_TelemetryUpdated(object sender, SdkWrapper.TelemetryUpdatedEventArgs e)
        {
            // Besides the driver details found in the session info, there's also things in the telemetry
            // that are properties of a driver, such as their lap, lap distance, track surface, distance relative
            // to yourself and more.
            // We update the existing list of drivers with the telemetry values here.

            // If we are currently renewing the drivers list it makes little sense to update the existing drivers
            // because they will change anyway
            if (isUpdatingDrivers) return;

            // Store the current session number so we know which session to read 
            // There can be multiple sessions in a server (practice, Q, race, or warmup, race, etc).
            currentSessionNum = e.TelemetryInfo.SessionNum.Value;
            
            this.UpdateDriversTelemetry(e.TelemetryInfo);
        }
예제 #51
0
        private void wrapper_SessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            // Indicate that we are updating the drivers list
            isUpdatingDrivers = true;

            // Parse the Drivers section of the session info into a list of drivers
            this.ParseDrivers(e.SessionInfo);

            // Parse the ResultsPositions section of the session info to get the positions and times of drivers
            this.ParseTimes(e.SessionInfo);

            // Indicate we are finished updating drivers
            isUpdatingDrivers = false;
        }
 public TelemetryInfoProxy(SdkWrapper wrapper, TelemetryInfo telemetryInfo)
 {
     this.wrapper       = wrapper;
     this.telemetryInfo = telemetryInfo;
 }
 public ReplayControl(SdkWrapper wrapper) : base(wrapper)
 {
 }
예제 #54
0
        // Example method that adds some caution flags to the string builder if they are displayed in the sim
        private void BitfieldsExample(StringBuilder sb, SdkWrapper.TelemetryUpdatedEventArgs e)
        {
            // The value of SessionFlags returns a SessionFlag object which contains information about all currently active flags
            // Use the Contains method to check if it contains a specific flag.

            // EngineWarnings and CameraStates behave similarly.

            SessionFlag flags = e.TelemetryInfo.SessionFlags.Value;

            if (flags.Contains(SessionFlags.Black))
            {
                sb.AppendLine("Black flag!");
            }
            if (flags.Contains(SessionFlags.Disqualify))
            {
                sb.AppendLine("DQ");
            }
            if (flags.Contains(SessionFlags.Repair))
            {
                sb.AppendLine("Repair");
            }
            if (flags.Contains(SessionFlags.Checkered))
            {
                sb.AppendLine("Checkered");
            }
        }
예제 #55
0
        private void OnTelemetryUpdated(object sender, SdkWrapper.TelemetryUpdatedEventArgs e)
        {
            // Grab a copy of the session info
            telemetryInfo = e.TelemetryInfo;

            ReadData();

            // Deal with the session changing
            if (telemetry.Sessions.CurrentSession == null || (telemetry.Sessions.CurrentSession.SessionNum != telemetryInfo.SessionNum.Value))
            {
                _mustUpdateSessionData = true;

                // Session changed, reset session info
                this.ResetSession();
            }
        }
예제 #56
0
        // Event handler called when the session info is updated
        // This typically happens when a car crosses the finish line for example
        private void wrapper_SessionInfoUpdated(object sender, SdkWrapper.SessionInfoUpdatedEventArgs e)
        {
            sessionInfoLabel.Text = string.Format("Session info (last update time: {0})", e.UpdateTime);

            // Let's just dump the session info:
            sessionInfoTextBox.Text = e.SessionInfo.Yaml;

            // Read some values using a YAML query
            string trackName = e.SessionInfo.GetValue("WeekendInfo:TrackName:");
            int sessionId = int.Parse(e.SessionInfo.GetValue("WeekendInfo:SessionId:"));
            string windSpeed = e.SessionInfo.GetValue("WeekendInfo:WeekendOptions:WindSpeed:");

            // Read some values with the easier notation (no need to write the YAML query)
            var trackLength = e.SessionInfo["WeekendInfo"]["TrackLength"].GetValue();
            var driver1Name = e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", 1]["UserName"].GetValue();

            // Attempt to read the username of a random driver safely
            var random = new Random();
            var id = random.Next(0, 60);

            string driverName;
            if (e.SessionInfo["DriverInfo"]["Drivers"]["CarIdx", id]["UserName"].TryGetValue(out driverName))
            {
                // Success
                MessageBox.Show(driverName);
            }
            else
            {
                // not found
                MessageBox.Show("Error retrieving name of driver " + id);
            }
        }
예제 #57
0
 public TelloSdkService()
 {
     _wrapper = SdkWrapper.Instance;
 }
예제 #58
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     _wrapper = new SdkWrapper();
     _wrapper.SessionInfoUpdated += OnSessionInfoUpdated;
     _wrapper.Start();
 }
 internal  TextureControl(SdkWrapper wrapper) : base(wrapper)
 {
 }
예제 #60
0
        private static void wrapper_TelemetryUpdated(object sender, SdkWrapper.TelemetryUpdatedEventArgs e)
        {
            Debug.Assert(currentRecording != null);

            if (onTrack)
            {
                currentRecording.Add(new TelemetryInfoEntry(e.TelemetryInfo) { timeStamp = e.UpdateTime });
                onTrack = e.TelemetryInfo.IsOnTrack.Value;
            }

            onTrack = e.TelemetryInfo.IsOnTrack.Value;
        }