get rpm from beamng drive c# code example

Example: get rpm from beamng drive c#

using System;
using InSimDotNet.Out;
//In beamng go to settings -> other turn on OutGauge support
//Ip: 127.0.0.1 Port:4444
class Program {
    static void Main() {
        // Create timeout interval.
        TimeSpan timeout = TimeSpan.FromSeconds(10);

        // Create OutGauge object with the specified timeout.
        using (OutGauge outgauge = new OutGauge(timeout)) {
            // Attach event handler to packet-received event.
            outgauge.PacketReceived += outgauge_PacketReceived;
            outgauge.TimedOut += outgauge_TimedOut;

            // Start listening for packets from LFS.
            outgauge.Connect("127.0.0.1", 4444);

            // Stop program from exiting while listening.
            Console.ReadLine();
        }
    }

    static void outgauge_TimedOut(object sender, EventArgs e) {
        Console.WriteLine("OutGauge timed out!");
    }

    static void outgauge_PacketReceived(object sender, OutGaugeEventArgs e) {
        // Handle packet.
        Console.WriteLine(e.RPM);
    }
}

Tags:

Misc Example