Jump to content
The simFlight Network Forums

scottme

Members
  • Posts

    6
  • Joined

  • Last visited

About scottme

  • Birthday 01/01/1970

Contact Methods

  • Website URL
    http://

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

scottme's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Thanks once again Pete, that worked a treat! I am having issues read the Altitude from 0x0570 (also TAS from 0x02B8) My relevant code is DWORD dwSize = 2048; BYTE pMem [2048]; if (FSUIPC_Open2(SIM_ANY, &dwResult, pMem, dwSize)) { etc... In a different module: int ReadInitFS(double *FS_LatLong, float *FS_MainStates) { DWORD dwResult; __int64 FS_LatLongTemp[3] = {0}; __int32 FS_MainStatesTemp[4] = {0}; // Get location & State //FSUIPC_Read(0x0560, 8, &FS_LatLongTemp[1], &dwResult);//Lat //FSUIPC_Read(0x0568, 8, &FS_LatLongTemp[2], &dwResult);//Long FSUIPC_Read(0x0570, 8, &FS_LatLongTemp[3], &dwResult);//Alt //FSUIPC_Read(0x057C, 4, &FS_MainStatesTemp[1], &dwResult);//Phi //FSUIPC_Read(0x0578, 4, &FS_MainStatesTemp[2], &dwResult);//Theta //FSUIPC_Read(0x0580, 4, &FS_MainStatesTemp[3], &dwResult);//Psi //FSUIPC_Read(0x02B8, 4, &FS_MainStatesTemp[4], &dwResult);//TAS FSUIPC_Process(&dwResult); // Process the request(s) // Change FS to Real Units: Lat Long Alt FS_LatLong[1] = (double)FS_LatLongTemp[1] * (90.0 / (10017500.0 * 65536.0 * 65536.0 )); FS_LatLong[2] = (double)FS_LatLongTemp[2] * (360.0 / (65536.0 * 65536.0 * 65536.0 * 65536.0)); FS_LatLong[3] = (double)FS_LatLongTemp[3] / (65536.0 * 65536.0); // Phi, Theta, Psi FS_MainStates[1] = (float)FS_MainStatesTemp[1] * 360.0 / (65536.0 * 65536.0); FS_MainStates[2] = (float)FS_MainStatesTemp[2] * 360.0 / (65536.0 * 65536.0); FS_MainStates[3] = (float)FS_MainStatesTemp[3] * 360.0 / (65536.0 * 65536.0); FS_MainStates[4] = (float)FS_MainStatesTemp[4] / 128.0 / (float) MPS2KTS; return dwResult; } I can read Latitude, Longitude and the Euler angles perfectly. As soon as I try reading Altitude or TAS, I get run-time stack errors about dwResult and FS_LatLongTemp / FS_MainStatesTemp. I checked out FSInterogate, but it didn't tell me how Altitude differs from Lat/Long. I also tried pulling Altitude and TAS out of the integer matrices and the run-time error dissappeared, but I am getting a value which changes with bank angle! I wold very much appreciate any help!
  2. Hi all (especially Pete!) I am having a little problem with coding my module Dialog app. I think I have it set up OK, but I am having some hassle setting up the timer with the SetTimer function. Basically, my code is: ..... // Handles WNDPROC oldWndProc; // The standard window procedure used by the flight simulator HWND hFSimWindow; // Flight simulator main window handle HWND hwndDlg = NULL;// Handle for My dialog window HINSTANCE g_hInst; // Handle for the mainDLL call #define MENU_ENTRY "VSM Modules" #define ID_MY_MENUITEM1 40001 // My Dialog Routine BOOL CALLBACK FSBDlgProc(HWND hwndDlg, UINT Message, WPARAM wParam, LPARAM lParam) { // Set the timer SetTimer( hwndDlg, // handle to FSBridge IDT_TIMER1, // timer identifier 20, // 1/1000th seconds: 10000 = 10 second interval (TIMERPROC) NULL); // no timer callback switch(Message) { case WM_INITDIALOG: { //Initialise FSUIPC etc return 0; } case WM_TIMER: { // Main Code - Get Sim Values using FSUIPC // Display data to Static Text in the Dialog box return 0; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_CANCEL: PostMessage(hwndDlg, WM_CLOSE, 0, 0); break; case ID_FILE_EXIT: PostMessage(hwndDlg, WM_CLOSE, 0, 0); break; } break; case WM_CLOSE: { DestroyWindow(hwndDlg); } break; case WM_DESTROY: { FSUIPC_Close(); hwndDlg = NULL; KillTimer(hwndDlg, IDT_TIMER1); } break; default: return FALSE; } return TRUE; } /** * Main window procedure that is called by the flight simulator to process * incoming window messages. */ LRESULT CALLBACK FSimWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_NCPAINT: { HMENU hMenu, hMyMenu; hMenu = GetMenu(hwnd); //Copy the handle of the Menu item if (hMenu != NULL) { int i; // Look for our menu entry in the main menu. for (i = 0; i < GetMenuItemCount(hMenu); i++) { char buf[128]; GetMenuString(hMenu, i, buf, 128, MF_BYPOSITION); if (strcmp(buf, MENU_ENTRY) == 0) { // It is already here, we do not need to add it again break; } } // end of loop if (i < GetMenuItemCount(hMenu)) { // It is already here, we do not need to add it again break; } /* Create new menu. NOTE: It seems that this will be * reached more times, so we cannot save the handle, because * in such case it could be destroyed and we will not have * any access to it in the simulator. */ hMyMenu = CreateMenu(); AppendMenu(hMyMenu, MF_STRING | MF_ENABLED, ID_MY_MENUITEM1, "&FSBridge"); // add the created menu to the main menu AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hMyMenu, MENU_ENTRY); } } break; case WM_PAINT: { } break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_MY_MENUITEM1: { // Only create Dialog if not existing if (!IsWindow(hwndDlg)) { hwndDlg = CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_FSBRIDGE), hwnd, FSBDlgProc); ShowWindow(hwndDlg, SW_SHOW); } } break; } //break; return TRUE; } // Call the original window procedure to handle all other messages return CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam); } /** * Entry point of the DLL. */ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) { g_hInst = hInstDLL; //copies the hInstDLL into "instance" for use it into all the APIs switch (fdwReason) { case DLL_PROCESS_ATTACH: // Finds the window of title "FS98MAIN" (FS) and returns the handle hFSimWindow = FindWindow("FS98MAIN", NULL); // Gets the handle of the standard FS proceedure oldWndProc = (WNDPROC)SetWindowLong(hFSimWindow, GWL_WNDPROC, (LONG)FSimWindowProc); break; } return TRUE; } Where do I place the SetTimer call? If I place it at the start of FSimWindowProc, FS stops painting the window. If I place where shown at the start of the Dialog procedure, it gets reset when any message gets sent to the Dialog procedure. A better place seems to be in the WM_PAINT section of the main FSimWindowProc - any better suggestions? Overall, is this the most efficient way of displaying dynamic FSUIPC generated text in an internal FS Dialog module at about the same frequency as the FS Framerate (about 20-40fps)? Also, if I close the Dialog box, it will not reopen/re-initialise. Any ideas why? I presume it is OK to de-initialise using the Dialog procedure (WM_CLOSE) and not FSAPI module_deinit? I am also having some runtime / stack issues around the transfering of data from the FSUIPC_PROCESS calls, but I will get to that next... Apologies about the hefty post, but any helpful hints would be hugely appreciated. Cheers, Scott.
  3. Hi, I'm trying to do the same, but I am having a little trouble finding the DLLMain instance. I thought all I would have to do is declare HINSTANCE hInstDLL = NULL and use hInstDLL in the CreateDialog call, but it appears not. hInstDLL contains the DLLmain handle right, or have I got it wrong? My CreateDialog call is as follows: g_hFSBRidge = CreateDialog(hInstDLL, MAKEINTRESOURCE(IDD_FSBRIDGE), hwnd, FSBDlgProc); I'm sure it's easy, it's just my first serious shot into the world of dialog boxes. Thanks for you help so far anyway... Scott.
  4. Hi all, Some good stuff here. I am doing similar, but I am running a real time MATLAB/SIMULINK code to generate fm data and using the xPC API to communicate with the FS module. I have successfully written a plugin for X-Plane, but now I am trying FS2004 using an internal FS module and talk to FSUIPC (with FS set to 0 frame rate - thanks again Pete!). Oh yeh, the real time code also generates motion / jack data :) Sorry, I don't know enough about direct-x gauges - I am struggling enough with this internal module. Question - Can someone tell me a good starting point / source code for an internal module for FS2004? I have Jose's source (big thanks), just trying to figure out which one is best - the ones based on Joel's code (clock / rain) won't register in FS2004 (Ah ha! I found it! fsmenu.zip)
  5. Thanks Pete and Jeroen, Some useful stuff here. I had tried this last week and sort of gave up and jumped onto X-Plane, hoping I could get something running quickly while I solved the FS problems - turned out not to be the case! Interesting one about the serial interface over the net interface. A little tricky in c++, but I might check it out. Never really considered Variable time-step mode in "real time" mode, might be interesting to consider (hehe, you've played with this stuff before...). I am going to hit this with a big hammer and start from the minimum running FS9 spec and 30fps, and kill any non-vital XP processes and see where I stand. We are doing all this work in a referbished Link 707 3dof simuulator base, so should be fantastic when it gets up and running. Thanks once again, Scott
  6. Hi Pete and all, Rather than starting a new topic, I though I'd recycle this one. I am also trying to run an external flight model. My system runs like so: 1. Flight data (Lat, Long, Altitude plus 3 attitude angles) is sent from an external PC in real time at 50hz (MATLAB / xPC target). Data is sent via network UDP 2. A C++ program receives UDP packets on FS2004 machine and fires these 6 data values to FSUIPC/FS2004 The visual system must be smooth and as close to 50Hz as possible. My first trials have shown that every few second or so, 10 or more frames are dropped, so the motion is fairly smooth then stops and resumes so the overall effect is stuttering. I was wondering if anyone had any experience (successful or otherwise) of running FS2004 like this. I know FS2004 can be sped up by turning everything off in the setting and using low res, but are there any non obvious ways of significantly speeding FS2004 up, such as removing all a/c but 1, changing thread priorities etc. Also, I presume running XP as "light" as possible would also be a requirment. Any other hints? Pete, is it possible to safely change the thread priority of FSUIPC alone, or must I change it for FS2004 as well?. Is matching the FS2004 framerate with the incoming data rate vital for this process? I will be quite happy to share my c++ program if any is interested. Thanks for the fantastic support forum and hope all is now well with your eye. I almost imagine that your eye problem occurred from all your typing in this forum! :) My FS2004 system spec is : Windows XP Pentium IV 2.8 Prescott on Asus P4C800-E delux MB Asus FX5700 video 1024Mb RAM Best Regards, Scott (registered FSUIPC user).
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.