Jump to content
The simFlight Network Forums

alancordez

new Members
  • Posts

    4
  • Joined

  • Last visited

  • Days Won

    1

alancordez last won the day on April 30 2023

alancordez had the most liked content!

Profile Information

  • Gender
    Male
  • Location
    Germany

alancordez's Achievements

Newbie

Newbie (1/14)

  • One Month Later Rare
  • First Post Rare
  • Conversation Starter Rare
  • Week One Done Rare

Recent Badges

2

Reputation

  1. For the last part of my project (then I am finally set with everything 🙂 ) I need to write a kg Value from a textbox (name: txtboxCabOa) into a specific Compartment for example into "CAB OA" with one single Button click. My code looks like this but I am really confused with this one, because there is only a possibility with a hard coded list. Hopefully there is a workaround for one CAB like OA or OB or OC. Greetings Patrick namespace EFBWPF { public partial class MainWindow : Window { List<FsPayloadStation> payloadStations = null; private void btnSendData_Click(object sender, RoutedEventArgs e) { FSUIPCConnection.PayloadServices.RefreshData(); // Assign the payload stations to our class level variable for easier access this.payloadStations = FSUIPCConnection.PayloadServices.PayloadStations; //Assigning only one Cabin FsPayloadStation CabOA = this.nudWeight.Value = (decimal)station.WeightKgs; double WeightKGs = 0; if (double.TryParse(txtboxCabOa.Text, out newWeightKGs)) FSUIPCConnection.PayloadServices.WriteChanges(); } } }
  2. Many thanks for your help - it works just great - I am really happy 🙂
  3. Hi guys, I am so happy with the WPF C# from Paul Templates and the DLL. Right now I am trying to write one value (Fuel in kgs) from my textbox (txtboxCenterTank.Text) to the Simulator. But I am struggling a bit. Do you guys have any hints ? Thanks Patrick public partial class MainWindow : Window { FsFuelTanksCollection fuelTanks = null; // Set up a main timer private DispatcherTimer timerMain = new DispatcherTimer(); // And another to look for a connection private DispatcherTimer timerConnection = new DispatcherTimer(); // ===================================== // DECLARE OFFSETS YOU WANT TO USE HERE // ===================================== private Offset<uint> airspeed = new Offset<uint>(0x02BC); public MainWindow() { InitializeComponent(); configureForm(); timerMain.Interval = TimeSpan.FromMilliseconds(50); timerMain.Tick += timerMain_Tick; timerConnection.Interval = TimeSpan.FromMilliseconds(1000); timerConnection.Tick += timerConnection_Tick; timerConnection.Start(); } 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(); // Update the connection status configureForm(); } catch { // No connection found. Don't need to do anything, just keep trying } } // This method runs 20 times per second (every 50ms). This is set in the form constructor above. 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(); // 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"); } catch (Exception ex) { // An error occured. Tell the user and stop this timer. this.timerMain.Stop(); MessageBox.Show("Communication with Aircraft Failed\n\n" + ex.Message, "FSUIPC", MessageBoxButton.OK, MessageBoxImage.Exclamation); // Update the connection status configureForm(); } } // Configures the button and status label depending on if we're connected or not private void configureForm() { if (FSUIPCConnection.IsOpen) { this.lblConnectionStatus.Text = "Connection to Aircraft established"; this.lblConnectionStatus.Foreground = Brushes.Green; } else { this.lblConnectionStatus.Text = "Disconnected. Looking for Aircraft Connection..."; this.lblConnectionStatus.Foreground = Brushes.Red; } } // Window closing so stop all the timers and close the connection private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { this.timerConnection.Stop(); this.timerMain.Stop(); FSUIPCConnection.Close(); } // With this Button I am trying to write values to the Center Main Tank private void btnWrite_Click(object sender, RoutedEventArgs e) { FsFuelTank tank = this.fuelTanks[tankControl.FuelTank]; FSFuelTanks.Centre_Main = txtboxCenterTank.Text; //here the error occures FSUIPCConnection.PayloadServices.WriteChanges(); } } }
×
×
  • 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.