public OrientationSensor(OrientationData data) : base((byte)0x01, (byte)6, data) { attitudeIndicator = new AttitudeIndicator(); headingIndicator = new HeadingIndicator(); headingIndicator.Location = new Point(400, 0); Controls.Add(attitudeIndicator); Controls.Add(headingIndicator); }
private void InitializeUiElements() { _airplaneStateGrid = this.FindControl <Grid>("airplaneStateGrid"); _overlayGrid = this.FindControl <Grid>("overlayGrid"); _atcMessagesDataGrid = this.FindControl <DataGrid>("atcMessagesDataGrid"); _ipLabel = this.FindControl <TextBlock>("ipLabel"); _txtLandingRoll = this.FindControl <TextBlock>("txtLandingRoll"); _txtLandingRollLabel = this.FindControl <TextBlock>("txtLandingRollLabel"); _mainTabControl = this.FindControl <TabControl>("mainTabControl"); _expander = this.FindControl <Expander>("expander"); _TabItem_ATC = this.FindControl <TabItem>("TabItem_ATC"); _landingDetails = this.FindControl <LandingStats>("landingDetails"); _FMSControl = this.FindControl <FMS>("FMSControl"); _AttitudeIndicator = this.FindControl <AttitudeIndicator>("AttitudeIndicator"); _AircraftStateControl = this.FindControl <AircraftStatus>("AircraftStateControl"); _FpdControl = this.FindControl <FlightPlanDb>("FpdControl"); }
void client_CommandReceived(object sender, CommandReceivedEventArgs e) { Dispatcher.BeginInvoke((Action)(() => { try { var type = typeof(IFAPIStatus).Assembly.GetType(e.Response.Type); if (type == typeof(APIAircraftState)) { var state = Serializer.DeserializeJson <APIAircraftState>(e.CommandString); Console.WriteLine(state.VerticalSpeed); // convert to fpm state.VerticalSpeed = float.Parse(Convert.ToString(state.VerticalSpeed * 200, CultureInfo.InvariantCulture.NumberFormat), CultureInfo.InvariantCulture.NumberFormat); // multiply by 200, this somehow gets it accurate.. airplaneStateGrid.DataContext = null; airplaneStateGrid.DataContext = state; pAircraftState = state; if (FMSControl.autoFplDirectActive) { FMSControl.updateAutoNav(state); } AircraftStateControl.AircraftState = state; AttitudeIndicator.updateAttitude(state.Pitch, state.Bank); updateLandingRoll(state); } else if (type == typeof(GetValueResponse)) { var state = Serializer.DeserializeJson <GetValueResponse>(e.CommandString); Console.WriteLine("{0} -> {1}", state.Parameters[0].Name, state.Parameters[0].Value); } else if (type == typeof(LiveAirplaneList)) { LiveAirplaneList airplaneList = Serializer.DeserializeJson <LiveAirplaneList>(e.CommandString); //airplaneDataGrid.ItemsSource = airplaneList.Airplanes; } else if (type == typeof(FacilityList)) { var facilityList = Serializer.DeserializeJson <FacilityList>(e.CommandString); //facilitiesDataGrid.ItemsSource = facilityList.Facilities; } else if (type == typeof(IFAPIStatus)) { var status = Serializer.DeserializeJson <IFAPIStatus>(e.CommandString); } else if (type == typeof(APIATCMessage)) { var msg = Serializer.DeserializeJson <APIATCMessage>(e.CommandString); // TODO client.ExecuteCommand("Live.GetCurrentCOMFrequencies"); } else if (type == typeof(APIFrequencyInfoList)) { var msg = Serializer.DeserializeJson <APIFrequencyInfoList>(e.CommandString); } else if (type == typeof(ATCMessageList)) { var msg = Serializer.DeserializeJson <ATCMessageList>(e.CommandString); atcMessagesDataGrid.ItemsSource = msg.ATCMessages; } else if (type == typeof(APIFlightPlan)) { var msg = Serializer.DeserializeJson <APIFlightPlan>(e.CommandString); Console.WriteLine("Flight Plan: {0} items", msg.Waypoints.Length); FMSControl.fplReceived(msg); //Update FMS with FPL from IF. foreach (var item in msg.Waypoints) { Console.WriteLine(" -> {0} {1} - {2}, {3}", item.Name, item.Code, item.Latitude, item.Longitude); } } } catch (System.NullReferenceException) { Console.WriteLine("Disconnected from server!"); //Let the client handle the lost connection. //connectionStatus = false; } })); }
private void pictureBox_attIndicator_Paint(object sender, PaintEventArgs e) { AttitudeIndicator.Paint_Olayi(e); }
private void timer_SeriPort_Tick(object sender, EventArgs e) { textBox1.Text = Convert.ToString(imu_data.accX); textBox2.Text = Convert.ToString(imu_data.accY); textBox3.Text = Convert.ToString(imu_data.accZ); textBox4.Text = Convert.ToString(imu_data.gyroX); textBox5.Text = Convert.ToString(imu_data.gyroY); textBox6.Text = Convert.ToString(imu_data.gyroZ); textBox7.Text = Convert.ToString(imu_data.magX); textBox8.Text = Convert.ToString(imu_data.magY); textBox9.Text = Convert.ToString(imu_data.magZ); textBox38.Text = Convert.ToString(imu_data.Temperature); //temp textBox11.Text = Convert.ToString(imu_data.PressureAltitude); //alt textBox10.Text = Convert.ToString(imu_data.TAS); //ias textBox16.Text = Convert.ToString(imu_data.pitch); textBox17.Text = Convert.ToString(imu_data.roll); textBox18.Text = Convert.ToString(imu_data.yaw); textBox41.Text = Convert.ToString(imu_data.gps_speed) + "." + Convert.ToString(imu_data.gps_speed_fraction); textBox30.Text = Convert.ToString(imu_data.ins_lat); textBox26.Text = Convert.ToString(imu_data.ins_lon); textBox33.Text = Convert.ToString(imu_data.INS_Vn); textBox20.Text = Convert.ToString(imu_data.INS_Ve); textBox21.Text = Convert.ToString(imu_data.INS_Vd); textBox29.Text = Convert.ToString(imu_data.counter); if (imu_data.IMU_data_valid == 1) { label16.ForeColor = Color.LawnGreen; } else { label16.ForeColor = Color.Red; } if (imu_data.GPS_valid == 1) { label30.ForeColor = Color.LawnGreen; } else { label16.ForeColor = Color.Red; } AttitudeIndicator.pitch = Convert.ToSingle(imu_data.pitch); AttitudeIndicator.roll = Convert.ToSingle(imu_data.roll); AttitudeIndicator.Refresh(); AirSpeedIndicator.airspeed = imu_data.TAS; AirSpeedIndicator.Refresh(); }
void client_CommandReceived(object sender, CommandReceivedEventArgs e) { Dispatcher.BeginInvoke((Action)(() => { var type = typeof(IFAPIStatus).Assembly.GetType(e.Response.Type); //System.IO.File.AppendAllText("C:\\IfApi\\IfApiCommandResp.txt", e.Response.Type + ": " + e.CommandString + "\n"); //if (pCustomCmdSent) //{ // txtResp.AppendText(e.Response.Type + " " + e.CommandString + "\n\n"); // txtResp.ScrollToEnd(); // pCustomCmdSent = false; //} if (type == typeof(APIAircraftState)) { var state = Serializer.DeserializeJson <APIAircraftState>(e.CommandString); //Console.WriteLine(e.CommandString); //airplaneStateGrid.DataContext = null; //airplaneStateGrid.DataContext = state; pAircraftState = state; if (FMSControl.autoFplDirectActive) { FMSControl.updateAutoNav(state); } AircraftStateControl.AircraftState = state; AttitudeIndicator.updateAttitude(pAircraftState.Pitch, pAircraftState.Bank); } else if (type == typeof(GetValueResponse)) { var state = Serializer.DeserializeJson <GetValueResponse>(e.CommandString); Console.WriteLine("{0} -> {1}", state.Parameters[0].Name, state.Parameters[0].Value); } else if (type == typeof(LiveAirplaneList)) { var airplaneList = Serializer.DeserializeJson <LiveAirplaneList>(e.CommandString); //airplaneDataGrid.ItemsSource = airplaneList.Airplanes; } else if (type == typeof(FacilityList)) { var facilityList = Serializer.DeserializeJson <FacilityList>(e.CommandString); //facilitiesDataGrid.ItemsSource = facilityList.Facilities; } else if (type == typeof(IFAPIStatus)) { var status = Serializer.DeserializeJson <IFAPIStatus>(e.CommandString); updateConnectionStatus(status); //versionTextBlock.Text = status.AppVersion; //userNameTextBlock.Text = status.LoggedInUser; //deviceNameTextBlock.Text = status.DeviceName; //displayResolutionTextBlock.Text = string.Format("{0}x{1}", status.DisplayWidth, status.DisplayHeight); } else if (type == typeof(APIATCMessage)) { var msg = Serializer.DeserializeJson <APIATCMessage>(e.CommandString); //atcMessagesListBox.Items.Add(msg.Message); client.ExecuteCommand("Live.GetCurrentCOMFrequencies"); } else if (type == typeof(APIFrequencyInfoList)) { var msg = Serializer.DeserializeJson <APIFrequencyInfoList>(e.CommandString); //frequenciesDataGrid.ItemsSource = msg.Frequencies; } else if (type == typeof(ATCMessageList)) { var msg = Serializer.DeserializeJson <ATCMessageList>(e.CommandString); //atcMessagesDataGrid.ItemsSource = msg.ATCMessages; } else if (type == typeof(APIFlightPlan)) { var msg = Serializer.DeserializeJson <APIFlightPlan>(e.CommandString); Console.WriteLine("Flight Plan: {0} items", msg.Waypoints.Length); FMSControl.fplReceived(msg); foreach (var item in msg.Waypoints) { Console.WriteLine(" -> {0} {1} - {2}, {3}", item.Name, item.Code, item.Latitude, item.Longitude); } } })); }