Jump to content
The simFlight Network Forums

Writing in one Payload Station


Recommended Posts

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();
        }
    }
}

 

Edited by alancordez
Link to comment
Share on other sites

Hi Patrick,

You can search for a PayloadStation by name using the Find() method:

        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
            // Find PayloadStation by name (NOTE: The matching is case-sensitive)
            FsPayloadStation CabOA = this.payloadStations.Find(ps => ps.Name == "CAB OA");
            if (CabOA != null)
            {
                // Payload station found
                double newWeightKGs = 0;
                if (double.TryParse(txtboxCabOa.Text, out newWeightKGs))
                {
                    CabOA.WeightKgs = newWeightKGs;
                }
            }
            FSUIPCConnection.PayloadServices.WriteChanges();
        }

 Paul

 

Link to comment
Share on other sites

  • 7 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.