Jump to content
The simFlight Network Forums

Write programm on C#


A320_Pilot

Recommended Posts

 

1. What offset use for lights (landing, taxi, navigation, strobes for Read)?

 

 

 

0D0C.  The sample application that I supply with the DLL shows reading (and writing) of lights.

 

 

 

 

2.What is the difference in the offset value "int", "Long", "short", "double", "string"?

 

 

 

These are c# types and hold different types of data.  For example 'int' holds an Integer 32 bits wide.  'String' holds text. If you don't know what different types are you really need to learn some basic c#.  Here is a web page that explains the types:

 

http://msdn.microsoft.com/en-us/library/ya5y69ds.aspx

 

If you want to know which c# type to use with each offset you need to read the UserGuide.pdf.  Page 7 has a table showing which types to use depending on the size of the offset and what kind of data is stored in the offset.  You need to also need to read the information about each offset in "FSUIPC4 Offset Status.pdf"

 

 

 

3.Whether correctly I convert ground speed?

 

 

 

Knots is correct.

To convert metres/second to Km/h you need to multiply by 3.6:

double gsKMH = ((double)airspeed_gs.Value / 65536d * 3.6d);

 

4.And how convert Zero fuel weight, empty weight and payload?

 

 

 

The easiest way to get this data is to use the PayloadServices in the DLL.

 

At the top of your form (where you declare the offsets), declare a payload services object called 'ps'.

private PayloadServices ps;

After you Open() the connection to FSUIPC, assign this object:

                FSUIPCConnection.Open();

                ps = FSUIPCConnection.PayloadServices;

Then when you want to get the payload data you can use the code like this:

                ps.RefreshData();

                //Empty weight in lbs & kgs

                double fw_ew_lbs = ps.AircraftWeightLbs - ps.FuelWeightLbs - ps.PayloadWeightLbs;

                double fw_ew_kgs = ps.AircraftWeightKgs - ps.FuelWeightKgs - ps.PayloadWeightKgs;

                this.emw1.Text = fw_ew_lbs.ToString("F0") + " (Lbs)" + " / " + fw_ew_kgs.ToString("F0") + " (Kgs)";

                //---------------------------------------------------------------------------------//

                //Zero fuel weight in lbs & kgs

                double fw_zfw_lbs = ps.AircraftZeroFuelWeightLbs;

                double fw_zfw_kgs = ps.AircraftZeroFuelWeightKgs;

                this.zfw1.Text = fw_zfw_lbs.ToString("F0") + " (Lbs)" + " / " + fw_zfw_kgs.ToString("F0") + " (Kgs)";

                //---------------------------------------------------------------------------------//

                //Weight payload in lbs & kgs

                double fw_pl_lbs = ps.PayloadWeightLbs;

                double fw_pl_kgs = ps.PayloadWeightKgs;

                this.payload1.Text = fw_pl_lbs.ToString("F0") + " (Lbs)" + " / " + fw_pl_kgs.ToString("F0") + " (Kgs)";

Paul

Link to comment
Share on other sites

//TAS in knots & km/h
                double tasKMH = ((double)airspeed_tas.Value / 128d * 1.852d);
                double tasKnots = ((double)airspeed_tas.Value / 128d);
                this.tasAir1.Text = tasKnots.ToString("F0") + CLIENT_MSG4_RU
                    + " / " + tasKMH.ToString("F0") + CLIENT_MSG5_RU;
//IAS in knots & km/h
                double airpeedKmh = ((double)airspeed.Value / 128d * 1.852d);
                double airpeedKnots = ((double)airspeed.Value / 128d);
                this.iasAir1.Text = airpeedKnots.ToString("F0") + CLIENT_MSG4_RU
                    + " / " + airpeedKmh.ToString("F0") + CLIENT_MSG5_RU; 

I convert correctly?

As for the headlights, I did not understand, it is impossible to deduce (On, Off)!

Link to comment
Share on other sites

 

I convert correctly?

 

 

 

Yes, that looks good to me.

 

 

 

As for the headlights, I did not understand, it is impossible to deduce (On, Off)!

 

 

 

This is as easy as I can make it:

 

1. At the top of your form with the other 'using' statements, add this:

using System.Collections;

2. Declare the offset as follows:

private Offset<BitArray> lights = new Offset<BitArray>(0x0D0C, 2);

3. Access each light as follows.  This example is for strobe lights (bit 4).  For other light numbers look up offset 0D0C in the "FSUIPC4 Offset Status.pdf".

                // Strobe lights (Bit 4)

                if (lights.Value[4])

                {

                    this.lblStrobeLights.Text = "Strobes ON";

                }

                else

                {

                    this.lblStrobeLights.Text = "Strobes OFF";

                }

Paul

Link to comment
Share on other sites

How to check whether the simulator is running or not?

 

You can only check this by trying the Open() or a Process().  If the simulator is not running these methods will throw an exception which you must catch.

 

The sample application shows this.  Look for the Open() and Process() calls and you will see the Try, Catch blocks that detect if the simulator is running.

 

Paul

Link to comment
Share on other sites

if (FSUIPCConnection.Open == true)
{ this.checksim.Text = CLIENT_MSG6_RU; }
else
{ this.checksim.Text = CLIENT_MSG7_RU; }

That's it right?

 

 

No.  That is not what is written in the example application.  You need to open the example application and look at the code in there.  Search for Open() and Process() and look at the try/catch blocks.  The catch blocks catch the errors when FS is not loaded.

 

Paul

Link to comment
Share on other sites

In the DB I can write, I do not know how to read parameters when touching!

 

When the "on ground" flag (0366) goes from 0 to 1, save the vertical speed and all the other data you need.

I suggest you create a set of variables (speed, v/s, altitude, lights etc) and an infinite loop that reads from FSUIPC and updates these variables.

Link to comment
Share on other sites

When the "on ground" flag (0366) goes from 0 to 1, save the vertical speed and all the other data you need.

I suggest you create a set of variables (speed, v/s, altitude, lights etc) and an infinite loop that reads from FSUIPC and updates these variables.

And this Grund flag will not work on taxi?

Link to comment
Share on other sites

And this Grund flag will not work on taxi?

 

It works all of the time.  So when you're taxiing it will be 1.  That's why you need to test it going from 0 to 1, not just being 1.  So if it's 1 you only save your data if the previous value was 0.

 

Paul

Link to comment
Share on other sites

It works all of the time.  So when you're taxiing it will be 1.  That's why you need to test it going from 0 to 1, not just being 1.  So if it's 1 you only save your data if the previous value was 0.

 

Paul

And still do not understand!

Link to comment
Share on other sites

You need one variable to hold current flag and one to hold the previous flag.
 

if (previous_onGndFlag != current_onGndFlag)
{
  if (current_onGndFlag == 1)
  {
    // - save the data you need -
  }
  previous_onGndFlag = current_onGndFlag;       // update previous_onGndFlag
}

For example...

Link to comment
Share on other sites


Well, and how then to define airport of departure that removed the ICAO code?

 

FSUIPC cannot tell you what airport you are at or departed from. 

 

The easiest way to get this information is to provide a text box for the user to enter the ICAO code manually.

 

The much more difficult way is to have a database of all the airports with their longitude and latitude.  You then take the player's Lon and Lat from FSUIPC and use it to work out which airport they are at.

 

Paul

Link to comment
Share on other sites

FSUIPC cannot tell you what airport you are at or departed from. 

 

The easiest way to get this information is to provide a text box for the user to enter the ICAO code manually.

 

The much more difficult way is to have a database of all the airports with their longitude and latitude.  You then take the player's Lon and Lat from FSUIPC and use it to work out which airport they are at.

 

Paul

MySQL Database for this good?

Link to comment
Share on other sites

MySQL Database for this good?

 

Yes that would be the easiest and fastest way if you know SQL.

 

Most people use text files, for example those produced by MakeRunways.exe by Pete Dowson. Text files are slower but people use them because they do not know how to use SQL databases.

 

Paul

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.