Gwénaël Tan Posted June 17, 2014 Report Share Posted June 17, 2014 Hello, To start, I'm using v4.934 of FSUIPC. I try to change altitude of the plane. I test that with an example of FSUIPC of use. It's FSUIPCClientExample_CSharp project. slewMode.Value = 1; FSUIPCConnection.Process(); // Make a new point representing the centre of the threshold for 27L FsLatitude lat = new FsLatitude(51.464943d); FsLongitude lon = new FsLongitude(-0.434046d); FsLatLonPoint newPos = new FsLatLonPoint(lat, lon); // Now move this point 150 metres up the runway // Use one of the OffsetBy methods of the FsLatLonPoint class double rwyTrueHeading = 269.7d; newPos = newPos.OffsetByMetres(rwyTrueHeading, 150); // Set the new position playerLatitude.Value = newPos.Latitude.ToFSUnits8(); playerLongitude.Value = newPos.Longitude.ToFSUnits8(); // set the heading and altitude playerAltitude.Value = 1000; // Here I try to put the plane over the runway FSUIPCConnection.Process(); playerHeadingTrue.Value = (uint)(rwyTrueHeading * (65536d * 65536d) / 360d); FSUIPCConnection.Process(); // Turn off the slew mode slewMode.Value = 0; FSUIPCConnection.Process(); // Refresh the scenery sendControl.Value = REFRESH_SCENERY; FSUIPCConnection.Process(); // Reenable the timers this.timer1.Enabled = true; this.AIRadarTimer.Enabled = this.chkEnableAIRadar.Checked; FSUIPCConnection.Process(); So I try to put the plane at 1000feet with this line : playerAltitude.Value = 1000; But the plane is still on the runway. I don't understand why. I use this offset : private Offset<long> playerAltitude = new Offset<long>(0x0570); // Offset for moving the plane Thank you in advance for your help. Regards, Gwenael Link to comment Share on other sites More sharing options...
Paul Henty Posted June 17, 2014 Report Share Posted June 17, 2014 Hi Gwenael, Whenever you read or write and offset you must always consult the FSUIPC documentation. In this case (FSUIPC4) you need "FSUIPC4 Offset Status.pdf" from your modules folder. If you look at offset 0570 you'll see that this offset is in metres, not feet. Also the 'units' of the value are 4 bytes starting at offset 0574, so writing 1000 into 0570 is a very tiny fraction of a metre. Either you need to write your units only (no fractional metres) into 0574 by changing the offset definition to: private Offset<int> playerAltitude = new Offset<int>(0x0574); // Offset for moving the plane Then write the whole number of metres (converting from feet) playerAltitude.Value = (long)(1000.0 * 0.3048); Or, you need to scale your value by (65536*65536) and write to 0570 (Keep the offset definition the same) - e.g: playerAltitude.Value = (long)(1000.0 * 0.3048 * 65536.0 * 65536.0); Paul Link to comment Share on other sites More sharing options...
Gwénaël Tan Posted June 17, 2014 Author Report Share Posted June 17, 2014 Hi Paul, Thank you for your answer. It's a mistake from me, i would like to write 1000meter :) And a double mistake, so sorry, I use this offset. private Offset<long> playerAltitude = new Offset<long>(0x0570); // Offset for moving the plane So I've tried the solution two but the plane is still on the runway. Yes, I have the "FSUIPC4 Offset Status.pdf", but I'm little confuse with this. sorry. I work on this every day to progress :) Thank you again.Gwenael Link to comment Share on other sites More sharing options...
Paul Henty Posted June 17, 2014 Report Share Posted June 17, 2014 Hi Gwenael, I've tried this out and there seems to be a timing issue when refreshing the scenery. If you don't give FSX enough time to move the plane then the 'refresh scenery' process seems to stop the moving. If your application will not need to reload the scenery after moving, you can get around this problem by not sending the REFRESH_SCENERY control (i.e. delete the following two lines) sendControl.Value = REFRESH_SCENERY; FSUIPCConnection.Process(); If you DO need to refresh the scenery, then you need to wait a bit before sending the control. I found that half a second was enough. Use the Sleep() method on the current thread to wait before sending the REFRESH_SCENERY, comme ça: // Refresh the scenery System.Threading.Thread.Sleep(500); // Wait for the sim to move the plane. sendControl.Value = REFRESH_SCENERY; FSUIPCConnection.Process(); I'm sorry my example code was wrong. I didn't ever try to move the plane into the air. I've tried both methods for setting the altitude from my previous post and both work with the fixes in this post. Paul Link to comment Share on other sites More sharing options...
Gwénaël Tan Posted June 18, 2014 Author Report Share Posted June 18, 2014 Hi Paul, Thank you a lot for your answer. It's work. Now I just need to stop the plane, because with the altitude the plane fly or I just need to place the plane over the runway without move :)Thank you again. :) Have a nice day. Gwenael Link to comment Share on other sites More sharing options...
Paul Henty Posted June 18, 2014 Report Share Posted June 18, 2014 HI, Now I just need to stop the plane, because with the altitude the plane fly You just need to leave the sim in 'slew mode' then. Comment or remove these lines: // Turn off the slew mode slewMode.Value = 0; FSUIPCConnection.Process(); Paul Link to comment Share on other sites More sharing options...
Gwénaël Tan Posted June 18, 2014 Author Report Share Posted June 18, 2014 Hi, I find a good solution, I use private Offset<short> pause = new Offset<short>(0x0262, true); // Example of a write only offset. pause.Value = 1; after the slewMode.value=0; And it's good for me. Because with my other program I need a pause button, like this I can turn off the pause mode.Thank you again for your help. :) Gwenael Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now