PDA

View Full Version : Anyone using FSUIPC 4 with SDK r27 c++ library?


davidt
17 Sep 2007, 14:33
Hi,

I've been playing around with trying to use FSUIPC 4.16 (just downloaded this morning), and using the C++ library of the SDK r27.

Has anyone been using this? If so, what version of VS are you using? I've been trying with VS2005 and VC++2008 beta and been running into all sorts of errors trying to get the simple UIPCHello.cpp working.

First I had errors after creating an empty project with it complaining about the use of chars vs. LPWSTRs. I fixed that.. but then started getting an error about LIBC.lib not being found.

I wasn't sure if it was something I was doing or not, so I started a new win 32 console project, and when I include the FSUIPC_User.h file and recompile (while not even trying to make any calls), I get errors:

1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(37) : error C2146: syntax error : missing ';' before identifier 'FSUIPC_Version'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(39) : error C2146: syntax error : missing ';' before identifier 'FSUIPC_FS_Version'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(41) : error C2146: syntax error : missing ';' before identifier 'FSUIPC_Lib_Version'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(41) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(41) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(45) : error C2146: syntax error : missing ';' before identifier 'FSUIPC_Open'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(45) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(45) : error C2146: syntax error : missing ')' before identifier 'dwFSReq'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(45) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(45) : error C2059: syntax error : ')'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(46) : error C2146: syntax error : missing ';' before identifier 'FSUIPC_Open2'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(46) : error C2146: syntax error : missing ')' before identifier 'dwFSReq'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(46) : error C2059: syntax error : ')'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(48) : error C2146: syntax error : missing ';' before identifier 'FSUIPC_Read'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(48) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(48) : error C2146: syntax error : missing ')' before identifier 'dwOffset'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(48) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(48) : error C2059: syntax error : ')'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(49) : error C2146: syntax error : missing ';' before identifier 'FSUIPC_ReadSpecial'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(49) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(49) : error C2146: syntax error : missing ')' before identifier 'dwOffset'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(49) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(49) : error C2059: syntax error : ')'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(50) : error C2146: syntax error : missing ';' before identifier 'FSUIPC_Write'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(50) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(50) : error C2146: syntax error : missing ')' before identifier 'dwOffset'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(50) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(50) : error C2059: syntax error : ')'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(51) : error C2146: syntax error : missing ';' before identifier 'FSUIPC_Process'
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(51) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(51) : error C2065: 'pdwResult' : undeclared identifier
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(51) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\john\my documents\visual studio 2008\projects\fsuipctest4\fsuipctest4\fsuipc_user. h(51) : fatal error C1903: unable to recover from previous error(s); stopping compilation


Has anyone been able to use the C++ library?? If so, what version of visual studio? Was there anything you needed to do to get it to work? What am I missing/doing wrong here?

Thanks,
David

Golf-HotelDelta
17 Sep 2007, 15:32
I have no problem with VC++ .NET Version 7, but I don't have the file FSUIPC_User.h, only FSUIPC.h.

If I use VC++ 2005 Express Edition I get other errors.

George

davidt
17 Sep 2007, 16:24
Hi Golf,

.net v7 - that's also known as .net 2003, correct?

I think my error earlier was that I was using the wrong C version of the SDK. I had another look and am now looking at the MFC version of the SDK.

Still some weird problems, though. It builds fine in VC6, however when I try to run it I get an error and it crashed, giving me the "Do you want to send this error to Microsoft" dialog box.

I noticed that the other c sdk has a lib file. Do you include anything like that into your project? I'm guessing there might be an error because it can't find something. If not.. I'm unsure what could be giving me that message, because I'm simply compiling and running the included example.

Thanks,
David

Golf-HotelDelta
17 Sep 2007, 17:14
.net v7 - that's also known as .net 2003, correct?
Yes, that's correct.

I noticed that the other c sdk has a lib file. Do you include anything like that into your project?
No, just the standard $(VCInstallDir) plus $(FrameworkSDKDir)

Try creating an MFC Dialog application and use the debugger.

George

Golf-HotelDelta
17 Sep 2007, 17:40
The UIPCHello example won't work in FS9 or FSX. It uses:

static char *pFS[] = { "FS98", "FS2000", "CFS2", "CFS1", "Fly!", "FS2002" };

and

(FSConnection.GetVersion() & 0xffff) ? 'a' + (FSConnection.GetVersion() & 0xff) - 1 : 0x0);

will fail on FS9 and above.

George

Pete Dowson
17 Sep 2007, 19:05
Has anyone been able to use the C++ library??

There's no C++ examples or library provided in the FSUIPC SDK. All my code is C only, not C++.

The examples in the SDK are just that -- examples. They are for READING. Any C programmer should be able to read them and understand them easily. Even the source of the library is provided, so you don't need to use that either, you can do your own thing entirely. The interface is completely open and usable in any language, you just need to read it and understand it, and this is why I kept to basic C with no complications.

The errors you list in FSUIPC_User.h appear to be due to the omission of the BOOL typedef. Did you forget to include the Windows.h before including the FSUIPC header?

I've also replied to the same post in my Support Forum.

Regards

Pete

Pete Dowson
17 Sep 2007, 19:29
The UIPCHello example won't work in FS9 or FSX. It uses:

static char *pFS[] = { "FS98", "FS2000", "CFS2", "CFS1", "Fly!", "FS2002" };

It's provided as an example, not the solution for everyone to copy verbatim. The little exercise to update it for other versions is left to the reader. ;-)

Pete

Golf-HotelDelta
18 Sep 2007, 04:09
It's provided as an example, not the solution for everyone to copy verbatim.

Yes Pete, when I opened the example yesterday, it produced a dialog for a helipad :confused:

I had forgotten that I had modified it many moons ago as my first attempt at using FSUIPC. Since then I have created many other applications for both FS9 and FSX.

George

davidt
18 Sep 2007, 08:23
Hi Golf,

I had gotten around the problem with the chars by changing them to wchar_t types, and putting an L in front of the quotes. Seemed to work with that.

so:
static wchar_t *pFS[] = { L"FS98", L"FS2000", L"CFS2", L"CFS1", L"Fly!", L"FS2002" };


Pete: if these are only example interfaces, is there any documentation regarding how to program using FSUIPC directly?

Thanks,
David

Pete Dowson
18 Sep 2007, 08:51
Pete: if these are only example interfaces, is there any documentation regarding how to program using FSUIPC directly?

The SDK contains the source of the Library, which provides the C code for the interface itself. You can built it all into your program in any way you wish. there is nothing hidden. Once the common memory area is established via memory mapped file facilities, there's actually just the one call (via a SendMessageTimeout), and the rest is merely a matter of data formats, which you can see from the struct definitions in the header.

I haven't provided any tutorials on how to program in C, if that's what you mean. I thought the C source would be sufficient. The interface is actually 100% identical to that established by Adam Szofran in the FS5 and FS6 versions of his module. All he ever did was provide the headers and the same type of source as I have -- no library as such. I tried to make it a little easier with the wrappers, it was never meant to confuse. I've had no complaints of such confusion in the 7 or 8 years it's been available.

If you are not all that familiar with C, then possibly the Visual Basic examples and sources would be more readable for you?

Regards

Pete

davidt
18 Sep 2007, 10:24
Thanks Pete,

I'm pretty sure I can figure out the programming part of it - it's the how to use FSUIPC part I'm a little lost on.

For example, how then do I do something like subscribing to a system event using the functions provided in the C header? All I see is open, close, read, write and process.

What functions do I use to get callback results such as system events?

Thanks,
David

Pete Dowson
18 Sep 2007, 10:39
For example, how then do I do something like subscribing to a system event using the functions provided in the C header? All I see is open, close, read, write and process.

What functions do I use to get callback results such as system events?

There are no such things as "system events" or "callbacks" in the FSUIPC interface. You are thinking of something else entirely, like SimConnect. The FSUIPC interface is a memory read/write emulating interface, like "peek/poke, not "client/sever"". The Library facilities provided reflect that. Don't you see "read", "write", "process"? Where do you get the idea of system events and callbacks?

Please look at the code in the examples. That is what they are for. It isn't surprising you can't get anywhere if you aren't looking at what is available. :-(

Regards

Pete

davidt
18 Sep 2007, 10:48
Hi Pete,

I have looked at the examples, which is why I'm asking these questions.

I know SimConnect can offer me access to system events. I'm wondering if/how I can get at that data through FSUIPC, that's all.

So apparently the answer is no. Thank you.

David.

Pete Dowson
18 Sep 2007, 10:55
I know SimConnect can offer me access to system events. I'm wondering if/how I can get at that data through FSUIPC, that's all.

So apparently the answer is no. Thank you.

What "system event" is not detectable through one or other of the Offsets supported by FSUIPC4, please? If it is needed and not there, I can add it. If it is new to FSX then it probably isn't really appropriate, but everything which was supported for previous versions of FS should be there, as they were then. I can add new things if needed, but on the whole folks developing only for FSX would be using SimConnect.

Either way, it wouldn't be labelled "system event", however, as "eventing" is simply not something which occurs in such an interface.

Please just clarify what it is you want to do rather than make such blanket incorrect assumptions.

Regards

Pete

davidt
18 Sep 2007, 12:34
I was looking to see if I would be able to do something similar to "SimConnect_SubscribeToSystemEvent(4sec)" with FSUIPC, where my application would be getting a callback with some data every 4 seconds from SimConnect.

I don't think it's a "blanket incorrect statement" based on looking at the functions available, and you telling me: "There are no such things as "system events" or "callbacks" in the FSUIPC interface".

Like I said, if there's a way, please let me know. I'd rather not create a timed polling loop if I can get some kind of callback instead. I'm just trying to (quickly) evaluate whether or not I can use FSUIPC in the way that I think I need to.

Thanks
David

scruffyduck
18 Sep 2007, 12:48
If you are working with FSX and need callbacks and events then you might consider using simconnect direct rather than going through FSUIPC4. Pete will correct me if I am wrong but FSUIPC4 uses SimConnect to get it's information.

Pete Dowson
18 Sep 2007, 13:19
I was looking to see if I would be able to do something similar to "SimConnect_SubscribeToSystemEvent(4sec)" with FSUIPC, where my application would be getting a callback with some data every 4 seconds from SimConnect.

Such things in a polling interface are done by using Windows WM_TIMER calls or TimerProcs.

I don't think it's a "blanket incorrect statement" based on looking at the functions available, and you telling me: "There are no such things as "system events" or "callbacks" in the FSUIPC interface".

Sorry, it is, simply because most of the "system events" that tell you anything (other than simple wake-ups which are easy in many other ways) are covered by updating the relevant Offset in FSUIPC's memory mapped way of doing things.

You are simply completely misconstruing the entire way the interface works. I think, if you feel you need a Client/Server interface with callbacks and events you should go to Simconnect direct and forget versions of FS before FSX. Is that not suitable for you?

Like I said, if there's a way, please let me know. I'd rather not create a timed polling loop if I can get some kind of callback instead.

Check out the standard Windows API "SetTimer". You can use that not only to receive WM_TIMER messages but, alternatively, to set a callback to a "TimerProc".

I'm just trying to (quickly) evaluate whether or not I can use FSUIPC in the way that I think I need to.

Check the list of offsets and see if the data and/or control you require is present. Otherwise, and especially if you are only interested in FSX and future versions of FS, forget FSUIPC and look at SimConnect.

Regards

Pete

Pete Dowson
18 Sep 2007, 13:22
If you are working with FSX and need callbacks and events then you might consider using simconnect direct rather than going through FSUIPC4. Pete will correct me if I am wrong but FSUIPC4 uses SimConnect to get it's information.

Yes, it does, for 95% of its current needs. Hopefully 100% in the future, but possibly dropping to 80% if MS doesn't sort out the weather interface sufficiently in due course. That's the main area in which the provisions are significantly less than FSUIPC managed (by hacking) in previous versions of FS. I'd rather not have to hack into the weather implementation a fourth time -- the previous times took hundreds, even thousands of hours each. :-(

Regards

Pete

DanKH
18 Sep 2007, 16:14
Hi

Sorry to interfere, but David, you might want to have a look at this to understand the ins and outs of IPC (Inter-Process Communication)

http://msdn2.microsoft.com/en-us/library/aa365574.aspx

Especially the Pipes part

or here:
http://www.cs.cf.ac.uk/Dave/C/node23.html#SECTION002300000000000000000
and messaging:
http://www.cs.cf.ac.uk/Dave/C/node25.html#SECTION002500000000000000000

FSUIPC is "just" a specialized IPC for Flight Simulator (hence the FS) the U-part I'm not sure about, but my guess is 'User' or something. A module that provide the developer an easi(er) access to the memory-areas that the FS-process uses. There no 'hacking' involved other than a laborious work of finding what the vast amount of address spaces hides within the process.

To Inter Communicate with a running process you need to understand the IPC part of FSUIPC, and reading the msdn article mentioned should give you some better idea of what is going on. Unlike Simconnect which acts like a Client/Server as mentioned correctly. SimConnect can use the "Client-part" of the FS-process to communicate, whereas IPC's have to use the messaging system (not to compare with the Messenger service found in Services! which is a whole other ballgame)

What Pete and his predecessors has done for us, is the FSUIPC and a very good SDK so everyone with the will to RTFM shouldn't have it too complicated in making an add-on that rely on data exchanges with FS. On top of that Pete has several other areas of the FS-process covered, eg. areas for controlling joysticks, weather etc. etc. and that is the part you pay for. For merely access to all the wonders, "offsets" or memory areas, the only price you have to pay is time to read the manual.

Sorry if I'm learning granny to blow eggs here, but somebody might get a bit better understanding of what a IPC really is. FSUIPC is "just" that: A FS-specialized IPC, where most of the hard work is already done.

davidt
18 Sep 2007, 16:27
Pete:
As for me misunderstanding - entirely possible. After reading your post again it sort of cleared it up.

As for why I want to get at the timed events from FSX. I'm going to need to create a few other planes, and then updated their positions. Ideally in sync with when FSX prepares its visual frames, because I don't want AI controlled planes using flight plans or anything like that. (The 4sec thing was just an example - I know i'd need to do it a lot faster).

If I used a timer in my application, then how will I know if I'm trying to send updated info to FSX in sync with when it's drawing it?

As for FS requiements. This will only be for FSX and above. I'm looking at FSUIPC because I had tried creating a class to keep all my SimConnect methods together, but then found that the dispatch proc needed to be static in order to be passed to FS. Maybe that's not as big an issue as I had originally thought?

I'm trying to get data from another simulation which will be providing the locations of other planes I want to see flying around. This applicaiton is completely OO, and in C++. I wanted to have another class to handle my communication with SimConnect, so I wouldn't have global functions or variables sitting around in the application.


DanK: Thanks for that link. It's slowly making more and more sense. lol.

Pete Dowson
18 Sep 2007, 17:21
I'm going to need to create a few other planes, and then updated their positions. Ideally in sync with when FSX prepares its visual frames, because I don't want AI controlled planes using flight plans or anything like that.

FSUIPC offers no facilities to create aircraft in any case. You'll need to use SimConnect for AI planes, or (for previous versions of FS at any rate) the Multiplayer Interface. The FSX MP interface is an unknown at present.

If I used a timer in my application, then how will I know if I'm trying to send updated info to FSX in sync with when it's drawing it?

There's no way of knowing that, however you do it. All you can do it try to match FS's frame rate as best you can and accept the odd glitch now and then. You'd need to get FS into a stable frame rate -- say 20 fps - which means using the frame rate limiter and not overloading it.

SimConnect's interface is entirely asynchronous. Currently it uses TCP/IP packets even if (like FSUIPC) you are within the same process. In the future it will use Named Pipes locally, but this is still an asynchronous queued process. Because FSUIPC now uses SimConnect, it too is strictly asynchronous, but at least, being within the process it is slightly more likely to get the synchronicity right a lot of the time.

In previous versions of FS, FSUIPC was able to get synchronous action in FS for its own purposes, and offered facilities to client applications exploiting this. A direct peek/poke interface is more likely to achieve this than an queing client/server system, and especially one using the network TCP/IP stacks which are hardly efficient for local communication.

That said, for FSX FSUIPC4 is another layer on top of the SimConnect queuing indirection, so you need to look at going direct to SimConnect in any case.

As for FS requiements. This will only be for FSX and above. I'm looking at FSUIPC because I had tried creating a class to keep all my SimConnect methods together, but then found that the dispatch proc needed to be static in order to be passed to FS. Maybe that's not as big an issue as I had originally thought?

Sorry, I've no idea what you mean. I don't use C++. What's a "static dispatch proc"?

Regards

Pete

Pete Dowson
18 Sep 2007, 17:34
FSUIPC is "just" a specialized IPC for Flight Simulator (hence the FS) the U-part I'm not sure about, but my guess is 'User' or something.

Actually the "U" is for "Universal". The Adam Szofran originals were FS5IPC for FS95 and FS6IPC for FS98. He changed the offsets to match each new FS version. Folks writing applications to the interface had to change their programs for each version. When I stepped in for FS2000 (FS7) I decided to make my offset list look EXACTLY like FS6's except for the new ones, so instead of "FS7IPC" it was "FSUIPC" to indicate its impending universality (FS version-wise that is).

And so it's been. The FS6 offsets are still there, just the same, but this is an illusion created by mapping inside FSUIPC. Each successive version of FS adds more but retains the previous set. All in the name of compatibility -- allowing loads of good applications to be carried forward to each new release.

And it really isn't a true "IPC" in the relationship between FSUIPC and FS -- long gone are the days when FS conveniently kept all of its goodies in nice global data areas. Each offset tells a different story now. Some are composed artificially by FSUIPC from other values. Some are actually mapped directly into some FS data, but it isn't global data but heap-allocated and traced through the horridly complex VTables and other pointers used by today's C++ compilers. (I don't know much about C++ but I've used ASMs since 1964, which is how I find my way about inside programs).

And some offset values have to be obtained by calling procedures in FS, sometimes several, sometimes using handles ("This" pointers) obtained elsewhere. All this is done dynamically, as needed. And it is done as efficiently as possible so that it is almost impossible to measure the overhead in FS performance -- until FSX and SimConnect, where the overhead is down to TCP/IP only as far as I can tell.

Hope this make sense for you both!

Regards

Pete

davidt
19 Sep 2007, 08:35
You'll need to use SimConnect for AI planes, or (for previous versions of FS at any rate) the Multiplayer Interface. The FSX MP interface is an unknown at present.

Ah ok. That's (adding planes in FSU) was something I was looking for as well. If I could get at the multiplayer stuff I think I'd be all set. Too bad they tucked that stuff away.


All you can do it try to match FS's frame rate as best you can and accept the odd glitch now and then. You'd need to get FS into a stable frame rate -- say 20 fps - which means using the frame rate limiter and not overloading it.

Hmm. That's true. Well there is a way to have SimConnect notify the client on the visual frame. So I had been looking at doing all of my updates whenever I get a message from SimConnect about that. I hadn't thought of the queuing and TCP/IP delays (which you mentioned in the other reply you posted), so that's good to know. I suppose I can only do so much to minimze glitching as much as possible.


Sorry, I've no idea what you mean. I don't use C++. What's a "static dispatch proc"?

In SimConnect, using a function with "SimConnect_CallDispatch". The function that I make and pass to the CallDispatch method (which they call DispatchProc in most of the examples) cannot be a member function within a class. Classes add a hidden "this" parameter to every function definition, so if you try to create a class and use one of its functions with CallDispatch, it'll tell you that the function you're giving it doesn't match what it's expecting... unless you make the function static. However if it's static, then you can't really access the instance of the class you're using in your application.

I think what I can do is use a timed polling loop, and then keep calling SimConnect_GetNextDispatch. That will let me poll SimConnect and hopefully get frame notifications (if I poll fast enough) so that I can be closely synced with FSX.

At least that's what I'm hoping I'll be able to do... fingers are crossed.

Cheers,
David

Pete Dowson
19 Sep 2007, 09:09
Hmm. That's true. Well there is a way to have SimConnect notify the client on the visual frame.

Yes, there are both Visual and Sim frame notification intervals, though I've not yet had anything fast enough to distinguish between these (? -- an outstanding question with MS). The problem is the unpredictable time between that notification leaving FS's core, via TCP/IP stacks to the SimConnect.DLL and thence, via Windows messaging or callback, to your code -- along with another unknown, the process switch (here is where multiple cores come in handy of course).

Then of course there's the reverse path from you back to the FS core to do whatever it is you want to do on that frame. by that time you might be a frame or two later, of course.

However, it is possible to achieve some synchronisation, not 100%, by matching frame rates, as I said.

In SimConnect, using a function with "SimConnect_CallDispatch". The function that I make and pass to the CallDispatch method (which they call DispatchProc in most of the examples) cannot be a member function within a class.

Right ... but isn't that true of all Callback procedures? Callbacks can't pass the object handle.

However if it's static, then you can't really access the instance of the class you're using in your application.

But surely you'd only have one SimConnect handle (one open instance) at a time, so the processing of its dispatches is not an object of which there can be more than one. Your objects would be the individual aircraft, and you'd need to use the ID for each to index the object pointer or handle.

I think what I can do is use a timed polling loop, and then keep calling SimConnect_GetNextDispatch. That will let me poll SimConnect ...

That's turning a neat Client/Server setup into a polling setup akin to using FSUIPC. Why not simply supply a Message Window handle and user message number in the SimConnect_Open call, and get the notifications that way. Polling is not needed and less efficient with SimConnect. FSUIPC uses a Message Window.

Regards

Pete

davidt
19 Sep 2007, 10:20
Then of course there's the reverse path from you back to the FS core to do whatever it is you want to do on that frame. by that time you might be a frame or two later, of course.

However, it is possible to achieve some synchronisation, not 100%, by matching frame rates, as I said.

Yeah, that's true. Even if I'm off by a couple of frames.. as long as I'm consistently off, it should still look fine. :P

And trying to match the frame rate on my own is an option as well. I think the request for sim_frame will give me the simulation frame rate, so I can use that value to try to syncrhonize.

I saw in a paper that the simulation frame rate is 32Hz.


But surely you'd only have one SimConnect handle (one open instance) at a time, so the processing of its dispatches is not an object of which there can be more than one. Your objects would be the individual aircraft, and you'd need to use the ID for each to index the object pointer or handle.

Yes, but by keeping all the SimConnect stuff contained within a class, I can use it easily from other classes in the application.

I'm still thinking too much in the Java mindset, I think. Having something outside of a class just 'being there' somehow scares me.


Why not simply supply a Message Window handle and user message number in the SimConnect_Open call, and get the notifications that way. Polling is not needed and less efficient with SimConnect. FSUIPC uses a Message Window.

Hmm. That's a good point as well. I just had a look at the documenation though and it said using the Windows Events would be more efficient if you're not calling SimConnect frequently. I'll look into that, though. Thanks!

But this makes me think there are other windows related facilites that I might be able to take advantage of..

David

davidt
19 Sep 2007, 15:36
Why not simply supply a Message Window handle and user message number in the SimConnect_Open call, and get the notifications that way. Polling is not needed and less efficient with SimConnect. FSUIPC uses a Message Window.

Pete,

When you say Message Window, do you mean something like this (http://www.codeproject.com/dialog/messageonly.asp)?

Thanks,
David

Pete Dowson
19 Sep 2007, 15:56
Pete,

When you say Message Window, do you mean something like this (http://www.codeproject.com/dialog/messageonly.asp)?

Yes. It's an efficient Window for receiving messages with no claptrap slowing it down.

Pete

Marky2245
20 Mar 2008, 08:55
I use this code to get the timing from FS
FSUIPC_Read(0x238, sizeof(chTime), chTime, &dwReadResult)
It works great in fs2004.
And sort of works with FSX. slow might be hardware limits
I'm trying to learn SimConnect. Any links or info would
be helpful
Thanx