Ejemplo n.º 1
0
        public void OnRadarTrackUpdate(RDP.RadarTrack updated)
        {
            // Prevents some errors while the coupling ocours.
            if (updated.CoupledFDR == null)
            {
                return;
            }

            // Validate if the callsign still exist. Otherwise remove from the Dict.
            if (FDP2.GetFDRIndex(updated.CoupledFDR.Callsign) == -1)
            {
                ssrCodeValues.TryRemove(updated.CoupledFDR.Callsign, out _);
            }
            else
            {
                bool codeValidity = this.isSSRCodeValid(updated.CoupledFDR, updated.ActualAircraft);
                ssrCodeValues.AddOrUpdate(updated.CoupledFDR.Callsign, codeValidity, (k, v) => codeValidity);
            }
        }
Ejemplo n.º 2
0
        /// First we check if the itemType is our custom Label Item, and a flight data record exists (since we need a callsign)
        /// Then we get the previously calculated character from our dictionary and display it by returning a custom label item.
        /// Note we change the items colour from the default colour if it is a 'Z' char.
        public CustomLabelItem GetCustomLabelItem(string itemType, Track track, FDP2.FDR flightDataRecord, RDP.RadarTrack radarTrack)
        {
            if (flightDataRecord == null)
            {
                return(null);
            }

            if (itemType != LABEL_ITEM)
            {
                return(null);
            }

            char val = 'P';

            pbnValues.TryGetValue(flightDataRecord.Callsign, out val);

            return(new CustomLabelItem()
            {
                Type = itemType,
                ForeColourIdentity = Colours.Identities.Default,
                Text = val.ToString()
            });
        }
Ejemplo n.º 3
0
 // Not needed for this plugin.
 public void OnRadarTrackUpdate(RDP.RadarTrack updated)
 {
 }
Ejemplo n.º 4
0
        /**
         *  Construct Aircraft data
         *
         *      string[] strArray = msg.Split(':');
         *      this.callsign = strArray[0];
         *      this.upDown = this.callsign[0];
         *      this.callsign = this.callsign.Substring(1);
         *      this.origin = strArray[1];
         *      this.dest = strArray[2];
         *      this.squawk = string.IsNullOrEmpty(strArray[3]) ? (string)null : strArray[3];
         *      this.sentSquawk = string.IsNullOrEmpty(strArray[4]) ? (string)null : strArray[4];
         *      this.groundState = strArray[5][0];
         *      this.altitude = int.Parse(strArray[6]);
         *      this.heading = int.Parse(strArray[7]);
         *      this.gone = int.Parse(strArray[8]);
         *      this.toGo = int.Parse(strArray[9]);
         *      this.aircraftType = strArray[10];
         *      this.sidName = string.IsNullOrEmpty(strArray[11]) ? (string)null : strArray[11];
         *      this.runway = string.IsNullOrEmpty(strArray[12]) ? (string)null : strArray[12];
         *      this.fpRules = strArray[13][0] == 'V' ? FltRules.VFR : FltRules.IFR;
         *      this.rfl = int.Parse(strArray[14]);
         *      this.estDepTime = strArray[15];
         *      this.spd = strArray[16];
         *      this.groundspeed = int.Parse(strArray[17]);
         *      this.route = strArray[18];
         *      this.distanceFromMe = int.Parse(strArray[19]);
         *      this.commsType = strArray[20][0];
         *      try
         *      {
         *              this.lat = double.Parse(strArray[21]);
         *              this.lon = double.Parse(strArray[22]);
         *      }
         *      catch
         *      {
         *      }
         *      if (!(Presenter.CurrentAirfield == "EGLL") && !(Presenter.CurrentAirfield == "EGCC"))
         *              return;
         *      this.scratchpad = strArray[23];
         *
         */

        private void SendAircraftMetadata(FDP2.FDR fdr)
        {
            if (fdr == null)
            {
                return;
            }

            if (fdr.PredictedPosition.Location == null)
            {
                return;
            }

            RDP.RadarTrack radTrack = fdr.CoupledTrack;
            if (radTrack == null)
            {
                radTrack = RDP.RadarTracks.FirstOrDefault(r => r.ASMGCSCoupledFDR == fdr);
            }

            string gone = "0";
            string togo = "0";
            string tome = "0";

            if (fdr.ParsedRoute?.Count > 0)
            {
                gone = Conversions.CalculateDistance(fdr.ParsedRoute.First().Intersection.LatLong, fdr.PredictedPosition.Location).ToString("0");
                togo = Conversions.CalculateDistance(fdr.ParsedRoute.Last().Intersection.LatLong, fdr.PredictedPosition.Location).ToString("0");
                tome = Conversions.CalculateDistance(Airport == null ? Network.Me.Position : Airport.LatLong, fdr.PredictedPosition.Location).ToString("0");
            }

            string upDown = "U";

            if (radTrack?.OnGround == true || fdr.ATD == DateTime.MaxValue)
            {
                upDown = "D";
            }

            string gndState = " ";

            if (fdr.DepAirport == Airport?.ICAOName && fdr.State == FDP2.FDR.FDRStates.STATE_COORDINATED)
            {
                gndState = "T";
            }

            int ahdg = 0;

            vStripsAssignedHeadings.TryGetValue(fdr.Callsign, out ahdg);

            string meta = string.Join(":",
                                      upDown + fdr.Callsign,
                                      fdr.DepAirport,
                                      fdr.DesAirport,
                                      fdr.AssignedSSRCode == -1 ? "" : Convert.ToString(fdr.AssignedSSRCode, 8),
                                      radTrack != null ? Convert.ToString(radTrack.ActualAircraft.TransponderCode, 8): "",
                                      gndState,
                                      fdr.CFLUpper <= FDP2.FDR.LEVEL_VSA ? 0 : fdr.CFLUpper,
                                      ahdg,
                                      gone,
                                      togo,
                                      fdr.AircraftType + "/" + fdr.AircraftWake,
                                      (fdr.DepAirport == Airport?.ICAOName ? fdr.SIDSTARString:""), //  modified JMG - Inhibit STAR population for airborne
                                      fdr.RunwayString,
                                      fdr.FlightRules,
                                      fdr.RFL,
                                      fdr.ETD.ToString("HHmm"),
                                      0,
                                      fdr.PredictedPosition.Groundspeed.ToString("0"),
                                      fdr.Route,
                                      tome,
                                      fdr.TextOnly ? "T" : fdr.ReceiveOnly ? "R" : "V",
                                      fdr.PredictedPosition.Location.Latitude,
                                      fdr.PredictedPosition.Location.Longitude,
                                      fdr.LabelOpData);

            Instance?.SendData("M" + meta);
            SendRemarks(fdr);
        }
Ejemplo n.º 5
0
        /// vatSys calls this function when it encounters a custom label item (defined in Labels.xml) during the label rendering.
        /// itemType is the value of the Type attribute in Labels.xml
        /// If it's not our item being called (another plugins, for example), return null.
        /// As a general rule, don't do processing in here as you'll slow down the ASD refresh. In the case of parsing a level to a string though, that's fine.
        public CustomLabelItem GetCustomLabelItem(string itemType, Track track, FDP2.FDR flightDataRecord, RDP.RadarTrack radarTrack)
        {
            if (flightDataRecord == null)
            {
                return(null);
            }

            switch (itemType)
            {
            case LABEL_ITEM_LEVEL:
                int    level  = radarTrack == null ? flightDataRecord.PRL / 100 : radarTrack.CorrectedAltitude / 100;
                string sLevel = level.ToString("D3");
                if (level > RDP.TRANSITION_ALTITUDE)    //then flight level
                {
                    sLevel = "F" + sLevel;
                }
                else
                {
                    sLevel = "A" + sLevel;
                }

                return(new CustomLabelItem()
                {
                    Text = sLevel
                });

            default:
                return(null);
            }
        }
Ejemplo n.º 6
0
 public CustomLabelItem GetCustomLabelItem(string itemType, Track track, FDP2.FDR flightDataRecord, RDP.RadarTrack radarTrack)
 {
     return(null);
 }
Ejemplo n.º 7
0
        /// First we check if the itemType is our custom Label Item, and a flight data record exists (since we need a callsign)
        /// Then we get the previously calculated character from our dictionary and display it by returning a custom label item.
        /// Note we change the items colour from the default colour if it is a 'Z' char.
        public CustomLabelItem GetCustomLabelItem(string itemType, Track track, FDP2.FDR flightDataRecord, RDP.RadarTrack radarTrack)
        {
            if (flightDataRecord == null)
            {
                return(null);
            }

            if (itemType != LABEL_ITEM)
            {
                return(null);
            }

            // Check if the SSR is valid. Otherwise return the "Dupe" tag.
            ssrCodeValues.TryGetValue(flightDataRecord.Callsign, out bool isCodeValid);
            if (isCodeValid)
            {
                return(null);
            }

            return(new CustomLabelItem()
            {
                Type = itemType,
                ForeColourIdentity = Colours.Identities.Default,
                Text = "Dupe"
            });
        }