beauxis
-
Posts
7 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Gallery
Downloads
Posts posted by beauxis
-
-
Here is the full code
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using FSUIPC; using System.Windows.Threading; using MySql.Data.MySqlClient; namespace WpfApp5 { /// <summary> /// Logique d'interaction pour Page2.xaml /// </summary> public partial class Page2 : Page { // Set up a timer private DispatcherTimer timerMain = new DispatcherTimer(); // ===================================== // DECLARE OFFSETS YOU WANT TO USE HERE // ===================================== private Offset<uint> parkingbrakes = new Offset<uint>(0x0BC8); private Offset<uint> verticalspeed = new Offset<uint>(0x02C8); private Offset<uint> avionicsMaster = new Offset<uint>(0x2E80); public Page2() { InitializeComponent(); configureForm(); timerMain.Interval = TimeSpan.FromMilliseconds(50); timerMain.Tick += timerMain_Tick; } // The connect/disconnect buton private void btnToggleConnection_Click(object sender, RoutedEventArgs e) { if (FSUIPCConnection.IsOpen) { // Connection is currently open // Stop the main timer this.timerMain.Stop(); // Close the connection FSUIPCConnection.Close(); } else { // Try to open the connection try { this.lblConnectionStatus.Text = "Looking for a flight simulator..."; this.lblConnectionStatus.Foreground = Brushes.Goldenrod; FSUIPCConnection.Open(); // If there was no problem, start the main timer this.timerMain.Start(); } catch (Exception ex) { // An error occured. Tell the user. MessageBox.Show("Connection Failed\n\n" + ex.Message, "FSUIPC", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } configureForm(); } // 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 parking_brakes = (double)this.parkingbrakes.Value; if (parking_brakes > 0) { this.txtAirspeed.Text = "Set"; //MySqlCommand command = conn.CreateCommand(); conn.Open(); //command.CommandText = "UPDATE va_system SET value=1 WHERE id=1;"; //MySqlDataReader reader = command.ExecuteReader(); } else { this.txtAirspeed.Text = "Off"; } //Touch double verticalSpeedMPS = (double)this.verticalspeed.Value / 256d; double vertical_speedFPM = verticalSpeedMPS * 60d * 3.28084d; this.txttouch.Text = vertical_speedFPM.ToString("F0"); // 2. Master Avionics this.chkAvionicsMaster.IsChecked = avionicsMaster.Value > 0; } 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", MessageBoxButton.OK, MessageBoxImage.Exclamation); // Update the connection status configureForm(); } } // This runs when the master avionics tick has been changed private void chkAvionicsMaster_Click(object sender, RoutedEventArgs e) { // Update the FSUIPC offset with the new value (1 = Checked/On, 0 = Unchecked/Off) this.avionicsMaster.Value = (uint)(this.chkAvionicsMaster.IsChecked.Value ? 1 : 0); } // Configures the button and status label depending on if we're connected or not private void configureForm() { if (FSUIPCConnection.IsOpen) { this.btnToggleConnection.Content = "Disconnect"; this.lblConnectionStatus.Text = "Connected to " + FSUIPCConnection.FlightSimVersionConnected.ToString(); this.lblConnectionStatus.Foreground = Brushes.Green; } else { this.btnToggleConnection.Content = "Connect"; this.lblConnectionStatus.Text = "Disconnected"; this.lblConnectionStatus.Foreground = Brushes.Red; } } // Window closing so stop the timer and close the connection private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { this.timerMain.Stop(); FSUIPCConnection.Close(); } } }
-
Yes my code is very simple so it's weird...
How can I contact him ?
Thanks
-
I still have the problem, the value displays for a negative vertical speed is around 3 300 000 000...
Any solution ?
-
Okay I will try thank you very much !
-
I started to program a C# app but I have a problem with the vertical speed of the aircraft with offset 030C : when the vertical speed is positive there is no problem but when the aircraft starts descending the vertical speed displayed is around 4294967300... I tried to convert it to int value because I think this is a uint value but it does not work.
Anyone have a solution for that ?
Thanks, Thomas
Negative Vertical Speed 030C offset
in FSUIPC Client DLL for .NET
Posted
Ho thank you it works ! I will open more my eyes in the future 😉