예제 #1
0
파일: HelloWorld.cs 프로젝트: Jeffg24/irtvo
 public String init()
 {
     // returns script name and does other initialization
     this.sdk = new iRacingSDK();
     this.sdk.Startup();
     return "helloworld";
 }
예제 #2
0
파일: slowmo.cs 프로젝트: Jeffg24/irtvo
    public void ApiTick(iRacingSDK api)
    {
        if (this.position < length)
        {
            switch (this.state)
            {
                case 1:
                    api.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, this.max_value - ease(this.position) + 1, 1);
                    break;
                case -1:
                    api.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, ease(this.position), 1);
                    break;
                default:
                    break;
            }
        }
        else if (this.position >= length+10 && this.state != 0)
        {
            Console.WriteLine("Finished..." + this.state);
            if(this.state == 1)
                api.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, 1, 0);
            else if(this.state == -1)
                api.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, this.max_value, 1);
            this.state = 0;
        }

        if(this.state != 0)
            position++;
    }
        public void fetch(TelemetryInfo telem, iRacingSDK sdk, double fuelVal, Boolean sendTimeReset, Boolean sendTime, double prevFuel)
        {
            Gear = telem.Gear.Value;
            Speed = telem.Speed.Value;
            RPM = Convert.ToInt16(telem.RPM.Value);
            Shift = telem.ShiftIndicatorPct.Value;
            Lap = telem.Lap.Value > 199 ? 199 : telem.Lap.Value;
            Engine = (byte)(Convert.ToString(telem.EngineWarnings.Value).Contains("PitSpeedLimiter") ? 1 : 0);
            DeltaNeg = 0;
            Mins = 0;

            if (fuelVal != 0)
            {
                double tmp = Math.Round(telem.FuelLevel.Value/fuelVal, 2);
                if (tmp > 99.9)
                    Fuel = Convert.ToInt16(Math.Round(tmp));
                else if(tmp > 9.99){
                    Fuel = Convert.ToInt16(Math.Round(tmp * 10));
                    Engine |= 1 << 1;
                }
                else
                {
                    Fuel = Convert.ToInt16(Math.Round(tmp * 100));
                    Engine |= 2 << 1;
                }

            }
            else
            {
                Fuel = Convert.ToInt16(Math.Round(telem.FuelLevelPct.Value * 100));
                Engine |= 3 << 1;
            }

            if (prevFuel != 0)
                Engine |= (1 << 4);
            if (sendTimeReset)
                Engine |= (1 << 5);
            if (sendTime)
            {
                Engine |= (1 << 6);
                float l = Convert.ToSingle(sdk.GetData("LapLastLapTime"));
                if (l > 0)
                {
                    Mins = Convert.ToInt16(Math.Floor(l / 60));
                    int Secs = Convert.ToInt16(Math.Floor(l - (Mins * 60)));
                    int mSecs = Convert.ToInt16(Math.Floor((l - (Secs + (Mins * 60))) * 1000));
                    Delta = (Secs << 9) | mSecs;
                }
            }
            else
            {
                Delta = (int)(Math.Round(Convert.ToSingle(sdk.GetData("LapDeltaToBestLap")) * 1000));
                if (Delta <= 0)
                {
                    DeltaNeg = 1;
                    Delta = Delta * -1;
                }
                Delta = Delta > 9999 ? 9999 : Delta;
            }
        }
예제 #4
0
파일: slowmo.cs 프로젝트: Jeffg24/irtvo
 public String init()
 {
     // returns script name and does other initialization
     this.sdk = new iRacingSDK();
     this.sdk.Startup();
     this.state = 0;
     this.position = this.length;
     return "slowmo";
 }
예제 #5
0
        protected TelemetryValue(iRSDKSharp.iRacingSDK sdk, string name)
        {
            if (sdk == null)
            {
                throw new ArgumentNullException("sdk");
            }

            _exists = sdk.VarHeaders.ContainsKey(name);
            if (_exists)
            {
                var header = sdk.VarHeaders[name];
                _name        = name;
                _description = header.Desc;
                _unit        = header.Unit;
                _type        = header.Type;
            }
        }
예제 #6
0
        protected TelemetryValue(iRSDKSharp.iRacingSDK sdk, string name)
        {
            if (sdk == null)
            {
                throw new ArgumentNullException("sdk");
            }
            if (!sdk.VarHeaders.ContainsKey(name))
            {
                throw new ArgumentException("No telemetry value with the specified name exists.");
            }


            var header = sdk.VarHeaders[name];

            _Name        = name;
            _Description = header.Desc;
            _Unit        = header.Unit;
        }
예제 #7
0
파일: scripting.cs 프로젝트: Jeffg24/irtvo
 public void ApiTick(iRacingSDK api)
 {
     foreach (var pair in this.scripts)
         pair.Value.ApiTick(api);
 }
예제 #8
0
파일: sof.cs 프로젝트: Jeffg24/irtvo
 public void ApiTick(iRacingSDK api)
 {
 }
예제 #9
0
 public TelemetryInfo(iRacingSDK sdk)
 {
     this.sdk = sdk;
 }
예제 #10
0
 public iRacingAPI()
 {
     sdk = new iRacingSDK();
     lastUpdate = -1;
 }
예제 #11
0
파일: Program.cs 프로젝트: CloseUpDK/iRTVO
        static void Main(string[] args)
        {
            if (args.Length < 1)
                return;

            Bookmarks myBookmarks = new Bookmarks(); ;
            Bookmark thisEvent = null;
            int currentIndex = 0;
            int CurrentFrame = 0;
            bool run = true;
            using (StreamReader sw = new StreamReader(args[0], Encoding.UTF8))
            {
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(myBookmarks.GetType());
                myBookmarks = x.Deserialize(sw) as Bookmarks;
            }

            Console.WriteLine("Waiting for iRacing to come up ....");
            sdk = new iRacingSDK();
            while (!Console.KeyAvailable && run)
            {
                //Check if the SDK is connected
                if (sdk.IsConnected())
                {
                    while (sdk.GetData("SessionNum") == null)
                    {
                        Console.WriteLine("Waiting for Session...");
                        Thread.Sleep(200); // Allow other windows to initialize more faster
                        
                    }
                    
                    thisEvent = myBookmarks.List[currentIndex];

                    switch (thisEvent.BookmarkType)
                    {
                        case BookmarkType.Start:
                            ReplaySeek( thisEvent );
                            currentIndex++;
                            break;
                        case BookmarkType.Play:                            
                            CurrentFrame = (Int32)sdk.GetData("ReplayFrameNum");
                            if (CurrentFrame < thisEvent.ReplayPos)
                                continue;
                            sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.CamSwitchNum, thisEvent.DriverIdx, thisEvent.CamIdx);
                            SetPlaySpeed(thisEvent.PlaySpeed);
                            currentIndex++;
                            break;
                        case BookmarkType.Stop:
                            CurrentFrame = (Int32)sdk.GetData("ReplayFrameNum");
                            if (CurrentFrame < thisEvent.ReplayPos)
                                continue;
                            sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, 0, 0);
                            Console.WriteLine("End");
                            run = false;
                            break;
                        default:
                            run = false;
                            break;
                    }
                            
                    
                }
                else
                {                    
                    if ( sdk.Startup() )
                    {
                        Console.WriteLine("iRacing up and running.");
                    }
                    else
                        Thread.Sleep(2000);
                }
            }
            sdk.Shutdown();
        }
예제 #12
0
 public void initialize()
 {
     sdk = new iRacingSDK();
 }