The online racing simulator
Working InSim VB examples?
(15 posts, started )
#1 - Tube
Working InSim VB examples?
Hi all,

does anybody happen to have a source code of a working InSim program which uses the InSim "race tracking" mode?
Basically I want to show the gaps between cars in a manner which does not damage my eyes when there are 20 cars on track... but any example will surely help.

Help greatly appreciated
Cheers
Björn
#2 - Stuff
If its VB6 example you need, I posted one here. I have updated the okSocket control since that post so if you use it, there is an updated okSocket in the outgauge example I posted not too long ago, here. Hope it helps
#3 - Tube
thanks for dealing with me
Unfortunately, the VB 2005 Express Edition "update process" updates the source to a point where it won't run anymore It's really hard to see whats going on when like half of the functions simply don't exist anymore. there are some entries in the "knowledge base" which basically say:
the function has been replaced by another one. we don't know which one it is but it must be down there in the .NET framework for sure.

Actually I still have VB6 somewhere I guess, might try that first.
#4 - Stuff
Ahh .Net.. Check out Messiah's project, LFS Live. Its on sourceforge but didn't come up. There is also sdether's a few posts down <-click
-
(Tube) DELETED by Tube
#5 - Tube
I decided to use your VB6 example as a start, seems like a good decision so far
One thing that made me wonder was the "verifyid" of each packet. I turned on race tracking and guaranteed delivery, thus I had to send an ACK packet for each received packet with the verifyID of the received packet.

I basically created a CASE for each packet in the ParseMessage function so I have eg:

Case "PLL"
Dim udtPLL As IS_PLL
CopyMemory udtPLL, bytRecvData(0), LenB(udtPLL)
Call removeid(udtPLL)

and another function which deals with the packet, in this case removeid() :

Private Sub removeid(udtPLL As IS_PLL)
MsgBox (udtPLL.bytVerifyId)
End Sub

It outputs "?".
I'm not even sure what "bytVerifyId" contains in this example... something like an array of bytes maybe?
my VB days are so long gone
#6 - Stuff
Ahh the verify ID. You have two choices.

You could just not mess with it. Just dont send ISF_GUARANTEE in the ISI packet and then just ignore the verify ID. Not recommended imo because its best to check the data was sent and received.

Other way is to just send back the verify ID bytes in an ISP packet. Don't bother trying to print them out. The data is a 2-byte unsigned integer, which means you would have to convert it and so on. You'll notice in my ISP packet there are optional places for those verify bytes. Send it back like so:


Case "PLL"
Dim udtPLL As IS_PLL
CopyMemory udtPLL, bytRecvData(0), LenB(udtPLL)
Call SendISP("ACK", udtPLL.bytVerifyId(0), udtPLL.bytVerifyId(1))
Call removeid(udtPLL)

You could even make removeid() return a boolean and only send back the verify bytes if removeid() succeeded/udtPLL was processed.


Case "PLL"
Dim udtPLL As IS_PLL
CopyMemory udtPLL, bytRecvData(0), LenB(udtPLL)
If removeid(udtPLL) Then Call SendISP("ACK", udtPLL.bytVerifyId(0), udtPLL.bytVerifyId(1))

Lemme know
#7 - t1ger
Quote from Stuff :If its VB6 example you need, I posted one here. I have updated the okSocket control since that post so if you use it, there is an updated okSocket in the outgauge example I posted not too long ago, here. Hope it helps

Hi,

I am trying to use your InSim vba example, but I am struggling with something.

I have turned on Race Tracking by doing the following:


udtInSimInit.bytFlags = ISF_KEEP_ALIVE + ISF_SPLIT_MESSAGE + ISF_RACE_TRACKING

Then in the ParseMessage sub I have added the following case


Case "LAP"
Dim udtLAP As IS_LAP
CopyMemory udtLAP, bytRecvData(0), LenB(udtLAP)
frmMain.txtChat.Text = frmMain.txtChat.Text & vbNewLine & byt2str(udtLAP.bytPName) & " : " & byt2str(udtLAP.mshtTime.bytMin) & ":" & byt2str(udtLAP.mshtTime.bytSec) & "." & byt2str(udtLAP.mshtTime.bytHnd)

Which I think is right, but for some reason I get an error when I click the connect button. See the attached screenshot for the error message. I dont understand it because it seems to be saying that something else is expected but the .bytMin IS correct.

Please tell me I am doing something wrong!!

Thanks in advance
Tim
Attached images
vb error.JPG
#8 - t1ger
Its OK I found my error!

For those of you who care, the code that works is as follows:


Case "SP1"
Dim udtSPX As IS_SPX
CopyMemory udtSPX, bytRecvData(0), LenB(udtSPX)
frmMain.txtChat.Text = frmMain.txtChat.Text & vbNewLine & " : " & udtSPX.mshtTime.bytMin & ":" & udtSPX.mshtTime.bytSec & "." & udtSPX.mshtTime.bytHnd

Basically the bytSec etc parts are single bytes, the byt2str() function needs an array of bytes to work.

Tim
#9 - Stuff
I've been working on a new project and have redone the way my InSim code works. This example uses a class to handle everything then will just raise events to the other forms/classes/etc that want them. Should be much easier.. you see?
Attached files
NewVBInSim.zip - 20.7 KB - 208 views
Quote from Stuff :I've been working on a new project and have redone the way my InSim code works. This example uses a class to handle everything then will just raise events to the other forms/classes/etc that want them. Should be much easier.. you see?

Thanks RayOK, that looks really neat! I have just got used to the other way you did it, but I think I will stop that and start using this method. Thanks again!! I just wish I understood it all!
I have had chance to use this now and ... WOW ... so much easier - well done RayOK! I love it.

At the same time you have taught me something about VB and there isn't *too* many things that make me wonder what the hell is going on!

I really can not thank you enough, I can now start doing what I wanted to do.



Tim
Yeah, after I made what I have there I wondered the same thing. Why didn't I use classes and an event system before with the primitive types instead of all those user-defined types? That method makes things so much easier, compact, etc..

Well, thanks for the thanks and as said, I will be happy to help with anything else
Thanks,

I will no doubt need your help!

The project I am starting is specifically a Hotlap tracking system, whereby it will watch you do hotlaps and keep a database of your split times and lap times and save them in a database. Then I will be able to see my session (in a seperate application btw not in LFS itself!) times and the differences between splits etc.

I also would like it to show on screen in LFS the difference of your current split with your best split time, but the only way I can think of doing this at the moment is through a message (top left of the screen) which could be difficult to see. Another way is using the /rcm command to show a race control message, but I have not tested this yet.

Is there any other (easy) way to show it on screen? I am not interested in using a DirectX proxy to do it btw - its too complicated (I think) and I like to understand all the code I write! For this reason I am glad your NewInSim stuff is quite simple, although I have seen some scary stuff at the bottom of the okSocket code!!!

Anyway, thanks in advance.

Tim
Yeah, that subclassing code used in the okSocket is interesting. Assembly stuff I guess. I don't really understand how it works either. The hardcores like Paul Canton (the guy who wrote the subclassing code) do and that works for me.

For some other nice (hardcore type) stuff you should check out some controls from planet source code, esp the stuff from Charles PV. All API and very easy to use. Cool things like toolbars, status bars, list view, even an .ico editor and a couple games! Linkage!

For the split times/on-screen stuff, the easiest way would be the rcm messages like you said. Just do a couple InSim.SendMessage lines and thats all it takes. And a timer control could clear it after 5 seconds or so.

I have thought about trying to figure out the DirectX API to make stuff appear on the LFS screen but have been kinda busy lately. Gotta update the Layout Thingy too.
Thanks for that link, I will check it out when I get chance.

I tested the message thing last night using rcm messages. At the moment I have a do..loop waiting for five seconds before it clears the message but I did think about using a timer to clear it instead, I just haven't worked out the details of this yet. So far so good though.

Thanks
Tim

Working InSim VB examples?
(15 posts, started )
FGED GREDG RDFGDR GSFDG