Jump to content
The simFlight Network Forums

Aidas

new Members
  • Posts

    1
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Lithuania

Aidas's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hello, I'm using c# and I can't get anything to work. For example, latitude and longitude: public partial class frmMain : Form { // ===================================== // DECLARE OFFSETS YOU WANT TO USE HERE // ===================================== private Offset<uint> airspeed = new Offset<uint>(0x02BC); private Offset<FsLongitude> playerLon = new Offset<FsLongitude>(0x0568, 8); private Offset<FsLatitude> playerLat = new Offset<FsLatitude>(0x0560, 8); // Create Lon/Lat classes that we'll create using different data formats private Offset<uint> avionicsMaster = new Offset<uint>(0x2E80); private FsLatitude latitude; private FsLongitude longitude; public frmMain() { this.latitude = this.playerLat.Value; this.longitude = this.playerLon.Value; InitializeComponent(); configureForm(); // Start the connection timer to look for a flight sim this.timerConnection.Start(); } // This method is called every 1 second by the connection timer. private void timerConnection_Tick(object sender, EventArgs e) { // Try to open the connection try { FSUIPCConnection.Open(); // If there was no problem, stop this timer and start the main timer this.timerConnection.Stop(); this.timerMain.Start(); showLatLon(); // Update the connection status configureForm(); } catch { // No connection found. Don't need to do anything, just keep trying } } private void showLatLon() { this.lat.Text = this.latitude.ToString(false, "d", 6); this.lon.Text = this.longitude.ToString(false, "d", 6); // Update the information on the form // (See the Examples Application for more information on using Offsets). // 1. Airspeed double airspeedKnots = (double)this.airspeed.Value / 128d; this.txtAirspeed.Text = airspeedKnots.ToString("F0"); // 2. Master Avionics this.chkAvionicsMaster.Checked = avionicsMaster.Value > 0; } // This method runs 20 times per second (every 50ms). This is set on the timerMain properties. private void timerMain_Tick(object sender, EventArgs e) { // Call process() to read/write data to/from FSUIPC // We do this in a Try/Catch block incase something goes wrong try { FSUIPCConnection.Process(); showLatLon(); } catch (Exception ex) { // An error occured. Tell the user and stop this timer. this.timerMain.Stop(); MessageBox.Show("Communication with FSUIPC Failed\n\n" + ex.Message, "FSUIPC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // Update the connection status configureForm(); // start the connection timer this.timerConnection.Start(); } } // This runs when the master avionics tick has been changed private void chkAvionicsMaster_CheckedChanged(object sender, EventArgs e) { // Update the FSUIPC offset with the new value (1 = Checked/On, 0 = Unchecked/Off) this.avionicsMaster.Value = (uint)(this.chkAvionicsMaster.Checked ? 1 : 0); } // Configures the status label depending on if we're connected or not private void configureForm() { if (FSUIPCConnection.IsOpen) { this.lblConnectionStatus.Text = "Connected to " + FSUIPCConnection.FlightSimVersionConnected.ToString(); this.lblConnectionStatus.ForeColor = Color.Green; } else { this.lblConnectionStatus.Text = "Disconnected. Looking for Flight Simulator..."; this.lblConnectionStatus.ForeColor = Color.Red; } } private void control_ValueChanged(object sender, EventArgs e) { // Called whenever one of the values on the form changes // Create the new showLatLon(); } // Form is closing so stop all the timers and close FSUIPC Connection private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { this.timerConnection.Stop(); this.timerMain.Stop(); FSUIPCConnection.Close(); } } That returns: Anyone knows why? ;( Appreciate for reading, Aidas
×
×
  • 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.