The online racing simulator
InSim/OutSim/OutGauge lib in .NET
2
(34 posts, started )
Quote from wabz :Heh, sorry if I came across too angry - I thought the "Omg Plagiarism@!*&" thread title should have been sufficient to show I wasn't that serious Just would've been nice I think, because it is so different (and so much less) to the code you gave in that thread.

No comments in sdether's code required....

This kind of thing is why I never patch my code directly with provided source, but use that source to understand the solution and roll my own. I'll gladly give credit to all sources that helped me, but I don't want to have my codebase infringe on anyone else's copyright, whether permission is granted or not.

Anyway, i'm playing with the codepage stuff now, but I have a ton of things on my plate, so it may still be another week until I release a new version of LFSLib.
Do you have a new version ready soon ??
I love what you have done so far...

btw, is it possible to connect through the isrelay.liveforspeed.net with this library?
I'm sorry it's taking so long, but the last two months have not given me any time to finish up the bug fixes and code page additions i've been working on. I don't have a date right now, except that it is on my list of things to do.

I have not looked at what is required to change transparent support for the relay server, but it's on the list after above changes go out.

Quote from bluejudas :Do you have a new version ready soon ??
I love what you have done so far...

btw, is it possible to connect through the isrelay.liveforspeed.net with this library?

Quote from sdether :I'm sorry it's taking so long, but the last two months have not given me any time to finish up the bug fixes and code page additions i've been working on. I don't have a date right now, except that it is on my list of things to do.

I have not looked at what is required to change transparent support for the relay server, but it's on the list after above changes go out.

Tanx, nice to see its alive
Can somebody give me a pointer as I am a bit stuck.

I am trying to hook into LFS using this lib with visual Basic Express 2005.

I have declared

Dim handler As New InSim.InSimHandler(True, False)

and then inside a button event I have

With handler
With .Configuration
.LFSHost = "127.0.0.1"
.LFSHostPort = 29999
.UseSplitMessages = True
End With

Try
.Initialize(10)
Catch ex As FullMotion.LiveForSpeed.InSim.Exceptions.InSimHandlerException.ConnectionFailed
MsgBox("failed to make connection")

End Try


End With


Unfortunately it fails to find LFS and pretty much hangs the game, even when I have shut my routine down. I have probaby missed something very basic as I am only just starting with VB so any helpful pointers would be appreciated.

I am only really wanting to connect with outsim if it makes a difference.

thanks

Maxim
MaximUK:

A couple of things.

1. You do have LFS starting with \insim=29999 ?
2. you never set .ReplyPort, which just happens to default to 29999. Now, it should be possible to listen and send on the same port (never tested it myself), but not if who you are communicating with is on the same machine. I.e. LFS binds to port 29999 so when you try to bind the replyPort to 29999, you'll just block. Try setting .ReplyPort = 30000 . I assume this blocking prevents the exception to be thrown and that's why you are hanging.
3. If you really just want outsim, use OutSimHandler instead and make sure that outsim is properly configured in LFS's cfg.txt

Hope that helps
Thanks for the help sdether. I think I am close now but I still can't get OutSim data.

I start LFS with \inSim 29999
then my code is (ignore any _ characters as they are added to aid reading the code)
Dim InSimHandler As New InSim.InSimHandler(True, False)
Dim WithEvents outSimHandler As New OutSim.OutSimHandler(30001)
Dim OutSimPacket As OutSim.Events.PhysicsState


then inside the Connect button event:

With InSimHandler
_____With .Configuration
________.LFSHost = "127.0.0.1"
________.LFSHostPort = 29999
________ .UseSplitMessages = True
________ .ReplyPort = "30000"
_____End With
___ Try
______.Initialize(10)
______ tb_feedback.Text = "connected to InSim"
___ Catch ex As ___FullMotion.LiveForSpeed.InSim.Exceptions.InSimHandlerException.ConnectionFailed
______ MsgBox("failed to make connection")
___ End Try
End With

With outSimHandler
___ .Initialize()
End With

InSimHandler.SendMessage("are we talking?")
InSimHandler.StartOutSim(25)
tb_feedback.Text = "started OutSim at 25ms updates"

I then have an outSimHandler_Updated(....) event but it doesn't seem to trigger. InSim seems ok as it displays messages in-game ok

I wanted to enable InSim as well as OutSim so I can push messages into LFS while developing the software.

Maxim
Sorry but I can't still make Outgauge work I tried changing the cfg.txt file but it didn't work.

What exactly has to be changed and where?
Ok, I don't to VB.NET, so this is going to be in C#, but it should at least be close enough to get you going.

There are two ways to use OutGauge, by itself or via InSim.

To use it by itself, you need to configure it in the cfg file, such as:


OutGauge Mode 2
OutGauge Delay 100
OutGauge IP 127.0.0.1
OutGauge Port 30001
OutGauge ID 0

And then the setup code in C# would be

OutGaugeHandler handler = new OutGaugeHandler(30001);
handler.Updated += new OutGaugeHandler.GaugeEvent(outGauge_Updated);
Console.WriteLine("created handler");
while (true)
{
//clearly you'll want to handle this loop some other way,
//or in the case of Windows.Forms, don't even need to
//worry about a loop like this.
//The point is, after you start the handler, your OutGauge events
//are received by another thread, so do whatever you need with
//thread that started the handler
}


If you are getting OutGauge via InSim, start lfs with /insim=30000 and the consuming code in C# would be

handler = new InSimHandler(false, false);
Configuration config = handler.Configuration;
config.LFSHost = "127.0.0.1";
config.LFSHostPort = 30000;
config.ReplyPort = 30001;
config.UseKeepAlives = true;
config.UseSplitMessages = true;
config.GuaranteedDelivery = true;
handler.Initialize();
Console.WriteLine("LFS info:");
Console.WriteLine(" Product: {0}", handler.Version.Product);
Console.WriteLine(" Version: {0}", handler.Version.Version);
Console.WriteLine(" Serial: {0}", handler.Version.Serial);
handler.GaugeUpdated += new OutGaugeHandler.GaugeEvent(outGauge_Updated);
handler.StartOutGauge(100);
while (true)
{
// same story with this loop as in the above case
}

How you just need to create the event handler that receives the OutGauge events, which is the same in both scenarios:

void outGauge_Updated(object sender,
FullMotion.LiveForSpeed.OutGauge.Events.Gauge gauge)
{
Console.WriteLine("OutGauge -----------------------");
Console.WriteLine("Time: {0}", gauge.Time);
Console.WriteLine("ID: {0}", gauge.Id);
Console.WriteLine("Car: {0}", gauge.Car);
Console.WriteLine("RPM: {0}", gauge.RPM);
Console.WriteLine("Speed: {0}", gauge.Speed);
Console.WriteLine("Message1: {0}", gauge.DisplayMessage1);
Console.WriteLine("Message2: {0}", gauge.DisplayMessage2);
}

Hope that helps,
sdether
2

FGED GREDG RDFGDR GSFDG