public Radar(string R_Name, GeoCordSystemDegMinSecUtilities.LatLongClass R_Position, string R_SIC, string R_SAC)
 {
     RadarName = R_Name;
     RadarPosition = new GeoCordSystemDegMinSecUtilities.LatLongClass(R_Position.GetLatLongDecimal().LatitudeDecimal, R_Position.GetLatLongDecimal().LongitudeDecimal);
     SIC = R_SIC;
     SAC = R_SAC;
 }
Exemple #2
0
 public Radar(string R_Name, GeoCordSystemDegMinSecUtilities.LatLongClass R_Position, string R_SIC, string R_SAC)
 {
     RadarName     = R_Name;
     RadarPosition = new GeoCordSystemDegMinSecUtilities.LatLongClass(R_Position.GetLatLongDecimal().LatitudeDecimal, R_Position.GetLatLongDecimal().LongitudeDecimal);
     SIC           = R_SIC;
     SAC           = R_SAC;
 }
        public void Build_Prediction_Marker(PointLatLng Base_Position, string ACID, MySqlProvider.PredictionTableNumberType Table_Type, ref GMapOverlay Overlay)
        {
            MySqlProvider SqlProvider = new MySqlProvider();
            System.Collections.Generic.List<MySqlProvider.PredictionDataSetOneRow> Record = SqlProvider.GetOneRecordPerTimeAndACID(Table_Type, SharedData.LookAheadTime, ACID, false);

            // If prediction data for the given parameters exists
            // then lets add it to the display list.
            if (Record.Count > 0)
            {
                GeoCordSystemDegMinSecUtilities.LatLongClass P_Pont = new GeoCordSystemDegMinSecUtilities.LatLongClass(double.Parse(Record[0].Lat), double.Parse(Record[0].Lon));

                PointLatLng PredictedPoint = new PointLatLng(P_Pont.GetLatLongDecimal().LatitudeDecimal, P_Pont.GetLatLongDecimal().LongitudeDecimal);
                PredictionMarker PM;

                string label = Record[0].ACID + "\n" + Record[0].Time.ToShortTimeString();

                switch (Table_Type)
                {
                    case MySqlProvider.PredictionTableNumberType.One:
                        PM = new PredictionMarker(Base_Position, Color.Magenta, PredictedPoint, label);
                        Overlay.Markers.Add(PM);
                        break;
                    case MySqlProvider.PredictionTableNumberType.Two:
                        PM = new PredictionMarker(Base_Position, Color.Blue, PredictedPoint, label);
                        Overlay.Markers.Add(PM);
                        break;
                    case MySqlProvider.PredictionTableNumberType.Three:
                        PM = new PredictionMarker(Base_Position, Color.Orange, PredictedPoint, label);
                        Overlay.Markers.Add(PM);
                        break;
                }
            }
        }
Exemple #4
0
        private static void DecodeAzimuthAndDistance(ref GeoCordSystemDegMinSecUtilities.LatLongClass NewPosition, double Distance, double Azimuth)
        {
            GeoCordSystemDegMinSecUtilities.LatLongClass ResultPosition = new GeoCordSystemDegMinSecUtilities.LatLongClass();

            //////////////////////////////////////////////////////////////////////////////////
            //
            // Here loop through the defined radars and determine the source of the data.
            // Once the source is determined calculate the extact position of the target
            // by taking the position of the radar and applying the range and bearing.
            // Display time of reception
            // Extract the cu
            // rrent SIC/SAC so the correct radar can be applied
            //
            ASTERIX.SIC_SAC_Time SIC_SAC_TIME = (ASTERIX.SIC_SAC_Time)CAT01.I001DataItems[CAT01.ItemIDToIndex("010")].value;
            foreach (SystemAdaptationDataSet.Radar RDS in SystemAdaptationDataSet.RadarDataSet)
            {
                // If the current SIC/SAC code matched the code of one of the defined radars
                // then go ahead and calculate the Lat/Long position.
                if (RDS.SIC == SIC_SAC_TIME.SIC.ToString() && RDS.SAC == SIC_SAC_TIME.SAC.ToString())
                {
                    ResultPosition = GeoCordSystemDegMinSecUtilities.CalculateNewPosition(RDS.RadarPosition, Distance, Azimuth);
                }
            }

            NewPosition.SetPosition(ResultPosition.GetLatLongDecimal());
        }
Exemple #5
0
        public OutData GetResult()
        {
            // select a reference elllipsoid
            Ellipsoid reference = Ellipsoid.WGS84;
            // instantiate the calculator
            GeodeticCalculator geoCalc = new GeodeticCalculator();
            // Used to calculate the time to the min distance
            GlobalPosition Orig_Track_1_Pos = new GlobalPosition(new GlobalCoordinates(Track_1_Pos.Latitude, Track_1_Pos.Longitude));

            int UpdateStep = 60 / Properties.Settings.Default.SEepToolUpdateRate;

            for (int LookAheadIndex = 1; LookAheadIndex <= ((MaxLookAheadTimeInMinutes * 60) / UpdateStep); LookAheadIndex++)
            {
                // Calculate new position X seconds ahead for track 1
                double Range = (Track_1_SPD / 60) / UpdateStep;
                GeoCordSystemDegMinSecUtilities.LatLongClass ResultPosition_1 =
                    GeoCordSystemDegMinSecUtilities.CalculateNewPosition(new GeoCordSystemDegMinSecUtilities.LatLongClass(Track_1_Pos.Latitude.Degrees, Track_1_Pos.Longitude.Degrees), (double)Range, (double)Track_1_TRK);
                GPoint MarkerPositionLocal = FormMain.gMapControl.FromLatLngToLocal(new PointLatLng(ResultPosition_1.GetLatLongDecimal().LatitudeDecimal, ResultPosition_1.GetLatLongDecimal().LongitudeDecimal));
                ReturnData.Track_1_Pos_Min.X = MarkerPositionLocal.X;
                ReturnData.Track_1_Pos_Min.Y = MarkerPositionLocal.Y;

                // Calculate new position X seconds ahead for track 2
                Range = (Track_2_SPD / 60) / 15;
                GeoCordSystemDegMinSecUtilities.LatLongClass ResultPosition_2 =
                    GeoCordSystemDegMinSecUtilities.CalculateNewPosition(new GeoCordSystemDegMinSecUtilities.LatLongClass(Track_2_Pos.Latitude.Degrees, Track_2_Pos.Longitude.Degrees), (double)Range, (double)Track_2_TRK);
                MarkerPositionLocal          = FormMain.gMapControl.FromLatLngToLocal(new PointLatLng(ResultPosition_2.GetLatLongDecimal().LatitudeDecimal, ResultPosition_2.GetLatLongDecimal().LongitudeDecimal));
                ReturnData.Track_2_Pos_Min.X = MarkerPositionLocal.X;
                ReturnData.Track_2_Pos_Min.Y = MarkerPositionLocal.Y;

                double distance1 = geoCalc.CalculateGeodeticMeasurement(reference, Track_1_Pos, Track_2_Pos).PointToPointDistance;
                double distance2 = geoCalc.CalculateGeodeticMeasurement(reference, new GlobalPosition(new GlobalCoordinates(ResultPosition_1.GetLatLongDecimal().LatitudeDecimal, ResultPosition_1.GetLatLongDecimal().LongitudeDecimal)),
                                                                        new GlobalPosition(new GlobalCoordinates(ResultPosition_2.GetLatLongDecimal().LatitudeDecimal, ResultPosition_2.GetLatLongDecimal().LongitudeDecimal))).PointToPointDistance;

                // Calculate distance between present and new position
                if ((distance1 < distance2) && (LookAheadIndex != 1))
                {
                    ReturnData.Is_Converging = true;
                    ReturnData.MinDistance   = distance2 * 0.00053996; // Convert to nautical miles

                    double DistanceToTravel = geoCalc.CalculateGeodeticMeasurement(reference, Orig_Track_1_Pos, new GlobalPosition(new GlobalCoordinates(ResultPosition_1.GetLatLongDecimal().LatitudeDecimal, ResultPosition_1.GetLatLongDecimal().LongitudeDecimal))).PointToPointDistance;
                    DistanceToTravel            = DistanceToTravel * 0.00053996; // Convert to nautical miles
                    ReturnData.SecondsToMinimum = (int)((DistanceToTravel / Track_1_SPD) * 60.0 * 60.0);
                    // We have reached the minimum distance
                    break;
                }
                else if ((distance1 < distance2) && (LookAheadIndex == 1))
                {
                    ReturnData.Is_Converging = false;
                    break;
                }

                Track_1_Pos = new GlobalPosition(new GlobalCoordinates(ResultPosition_1.GetLatLongDecimal().LatitudeDecimal, ResultPosition_1.GetLatLongDecimal().LongitudeDecimal));
                Track_2_Pos = new GlobalPosition(new GlobalCoordinates(ResultPosition_2.GetLatLongDecimal().LatitudeDecimal, ResultPosition_2.GetLatLongDecimal().LongitudeDecimal));
            }

            return(ReturnData);
        }
Exemple #6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            DisplayAttributes.DisplayAttributesType NewDisplayAttribute = new DisplayAttributes.DisplayAttributesType();
            NewDisplayAttribute.ItemName  = this.comboBoxDataItem.Text;
            NewDisplayAttribute.TextSize  = int.Parse(this.comboBoxTextSizeChoice.Text);
            NewDisplayAttribute.TextFont  = new FontFamily(this.comboBoxTextFontChoice.Text);
            NewDisplayAttribute.TextColor = Color.FromName(this.comboBoxTextColorChoice.Text);
            NewDisplayAttribute.LineWidth = int.Parse(this.comboBoxLineWidth.Text);
            NewDisplayAttribute.LineColor = Color.FromName(this.comboBoxLineColorChoice.Text);
            NewDisplayAttribute.LineStyle = DisplayAttributes.GetLineStypefromString(this.comboBoxLineStyleChoice.Text);

            NewDisplayAttribute.AreaPolygonColor = Color.FromName(this.comboBoxAreaPolygonColorChoice.Text);
            NewDisplayAttribute.ImageSize        = new Size((int)this.numericUpDown_X.Value, (int)this.numericUpDown_Y.Value);
            DisplayAttributes.SetDisplayAttribute((DisplayAttributes.DisplayItemsType)Enum.Parse(typeof(DisplayAttributes.DisplayItemsType), NewDisplayAttribute.ItemName, true), NewDisplayAttribute);

            // Always update the background color as well
            NewDisplayAttribute           = new DisplayAttributes.DisplayAttributesType();
            NewDisplayAttribute.TextColor = Color.FromName(this.comboBoxBackgroundColor.Text);
            NewDisplayAttribute.ItemName  = "BackgroundColor";
            DisplayAttributes.SetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor, NewDisplayAttribute);

            // Populate the display origin
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LatPrefix;
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LoNPrefix;

            if (this.comboBoxLatDirection.SelectedIndex == 0)
            {
                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
            }
            else
            {
                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;
            }

            if (this.comboBoxLonDirection.SelectedIndex == 0)
            {
                LoNPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
            }
            else
            {
                LoNPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;
            }

            GeoCordSystemDegMinSecUtilities.LatLongClass LatLon =
                new GeoCordSystemDegMinSecUtilities.LatLongClass(int.Parse(this.txtLatDDD.Text), int.Parse(this.txtLatMM.Text), int.Parse(this.txtLatSS.Text), LatPrefix,
                                                                 int.Parse(this.txtLonDDD.Text), int.Parse(this.txtLonMM.Text), int.Parse(this.txtLonSS.Text), LoNPrefix);

            SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(LatLon.GetLatLongDecimal().LatitudeDecimal, LatLon.GetLatLongDecimal().LongitudeDecimal);
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            DisplayAttributes.DisplayAttributesType NewDisplayAttribute = new DisplayAttributes.DisplayAttributesType();
            NewDisplayAttribute.ItemName = this.comboBoxDataItem.Text;
            NewDisplayAttribute.TextSize = int.Parse(this.comboBoxTextSizeChoice.Text);
            NewDisplayAttribute.TextFont = new FontFamily(this.comboBoxTextFontChoice.Text);
            NewDisplayAttribute.TextColor = Color.FromName(this.comboBoxTextColorChoice.Text);
            NewDisplayAttribute.LineWidth = int.Parse(this.comboBoxLineWidth.Text);
            NewDisplayAttribute.LineColor = Color.FromName(this.comboBoxLineColorChoice.Text);
            NewDisplayAttribute.LineStyle = DisplayAttributes.GetLineStypefromString(this.comboBoxLineStyleChoice.Text);

            NewDisplayAttribute.AreaPolygonColor = Color.FromName(this.comboBoxAreaPolygonColorChoice.Text);

            DisplayAttributes.SetDisplayAttribute((DisplayAttributes.DisplayItemsType)Enum.Parse(typeof(DisplayAttributes.DisplayItemsType), NewDisplayAttribute.ItemName, true), NewDisplayAttribute);

               // Always update the background color as well
            NewDisplayAttribute = new DisplayAttributes.DisplayAttributesType();
            NewDisplayAttribute.TextColor = Color.FromName(this.comboBoxBackgroundColor.Text);
            NewDisplayAttribute.ItemName = "BackgroundColor";
            DisplayAttributes.SetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor, NewDisplayAttribute);

            // Populate the display origin
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LatPrefix;
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LoNPrefix;

            if (this.comboBoxLatDirection.SelectedIndex == 0)
                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
            else
                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;

            if (this.comboBoxLonDirection.SelectedIndex == 0)
                LoNPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
            else
                LoNPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;

            GeoCordSystemDegMinSecUtilities.LatLongClass LatLon =
                new GeoCordSystemDegMinSecUtilities.LatLongClass(int.Parse(this.txtLatDDD.Text), int.Parse(this.txtLatMM.Text), int.Parse(this.txtLatSS.Text), LatPrefix,
                    int.Parse(this.txtLonDDD.Text), int.Parse(this.txtLonMM.Text), int.Parse(this.txtLonSS.Text), LoNPrefix);

            SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(LatLon.GetLatLongDecimal().LatitudeDecimal, LatLon.GetLatLongDecimal().LongitudeDecimal);
        }
Exemple #8
0
        public void Build_Prediction_Marker(PointLatLng Base_Position, string ACID, MySqlProvider.PredictionTableNumberType Table_Type, ref GMapOverlay Overlay)
        {
            MySqlProvider SqlProvider = new MySqlProvider();

            System.Collections.Generic.List <MySqlProvider.PredictionDataSetOneRow> Record = SqlProvider.GetOneRecordPerTimeAndACID(Table_Type, SharedData.LookAheadTime, ACID, false);

            // If prediction data for the given parameters exists
            // then lets add it to the display list.
            if (Record.Count > 0)
            {
                GeoCordSystemDegMinSecUtilities.LatLongClass P_Pont = new GeoCordSystemDegMinSecUtilities.LatLongClass(double.Parse(Record[0].Lat), double.Parse(Record[0].Lon));

                PointLatLng      PredictedPoint = new PointLatLng(P_Pont.GetLatLongDecimal().LatitudeDecimal, P_Pont.GetLatLongDecimal().LongitudeDecimal);
                PredictionMarker PM;

                string label = Record[0].ACID + "\n" + Record[0].Time.ToShortTimeString();

                switch (Table_Type)
                {
                case MySqlProvider.PredictionTableNumberType.One:
                    PM = new PredictionMarker(Base_Position, Color.Magenta, PredictedPoint, label);
                    Overlay.Markers.Add(PM);
                    break;

                case MySqlProvider.PredictionTableNumberType.Two:
                    PM = new PredictionMarker(Base_Position, Color.Blue, PredictedPoint, label);
                    Overlay.Markers.Add(PM);
                    break;

                case MySqlProvider.PredictionTableNumberType.Three:
                    PM = new PredictionMarker(Base_Position, Color.Orange, PredictedPoint, label);
                    Overlay.Markers.Add(PM);
                    break;
                }
            }
        }
Exemple #9
0
 public Waypoint(string W_Name, GeoCordSystemDegMinSecUtilities.LatLongClass W_Position, bool Is_COP_In)
 {
     WaypointName     = W_Name;
     WaypointPosition = new GeoCordSystemDegMinSecUtilities.LatLongClass(W_Position.GetLatLongDecimal().LatitudeDecimal, W_Position.GetLatLongDecimal().LongitudeDecimal);
     Is_COP           = Is_COP_In;
 }
        private static void DecodeAzimuthAndDistance(ref GeoCordSystemDegMinSecUtilities.LatLongClass NewPosition, double Distance, double Azimuth)
        {
            GeoCordSystemDegMinSecUtilities.LatLongClass ResultPosition = new GeoCordSystemDegMinSecUtilities.LatLongClass();

            //////////////////////////////////////////////////////////////////////////////////
            //
            // Here loop through the defined radars and determine the source of the data.
            // Once the source is determined calculate the extact position of the target
            // by taking the position of the radar and applying the range and bearing.
            // Display time of reception
            // Extract the cu
            // rrent SIC/SAC so the correct radar can be applied
            //
            ASTERIX.SIC_SAC_Time SIC_SAC_TIME = (ASTERIX.SIC_SAC_Time)CAT01.I001DataItems[CAT01.ItemIDToIndex("010")].value;
            foreach (SystemAdaptationDataSet.Radar RDS in SystemAdaptationDataSet.RadarDataSet)
            {
                // If the current SIC/SAC code matched the code of one of the defined radars
                // then go ahead and calculate the Lat/Long position.
                if (RDS.SIC == SIC_SAC_TIME.SIC.ToString() && RDS.SAC == SIC_SAC_TIME.SAC.ToString())
                {
                    ResultPosition = GeoCordSystemDegMinSecUtilities.CalculateNewPosition(RDS.RadarPosition, Distance, Azimuth);
                }
            }

            NewPosition.SetPosition(ResultPosition.GetLatLongDecimal());
        }
Exemple #11
0
        // Update Mouse possition on the control
        private void gMapControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                RngBrngMarker RB_Marker = new RngBrngMarker(gMapControl.FromLocalToLatLng(StartMousePoint.X, StartMousePoint.Y), "Test", new Font(FontFamily.GenericSansSerif, 3), Brushes.Yellow, new Point(StartMousePoint.X, StartMousePoint.Y), new Point(e.X, e.Y));
                ToolsOverlay.Markers.Clear();
                ToolsOverlay.Markers.Add(RB_Marker);
                gMapControl.Refresh();
            }

            PointLatLng MouseLatLong = gMapControl.FromLocalToLatLng(e.X, e.Y);
            this.labelLat_Long.Location = new Point(this.labelLat_Long.Location.X, (gMapControl.Size.Height - 4));

            if (Properties.Settings.Default.DisplayPosInDecimals)
            {
                this.labelLat_Long.Text = MouseLatLong.Lat + " " + MouseLatLong.Lng;
            }
            else
            {
                GeoCordSystemDegMinSecUtilities.LatLongClass ToConvert = new GeoCordSystemDegMinSecUtilities.LatLongClass(MouseLatLong.Lat, MouseLatLong.Lng);
                string Latitude_S, Longitude_S;
                ToConvert.GetDegMinSecStringFormat(out Latitude_S, out Longitude_S);
                this.labelLat_Long.Text = Latitude_S + " " + Longitude_S;
            }

            if (e.Button == MouseButtons.Left && isDraggingMarker && currentMarker != null)
            {
                PointLatLng MousePosition = gMapControl.FromLocalToLatLng(e.X, e.Y);
                GPoint MarkerPositionLocal = gMapControl.FromLatLngToLocal(currentMarker.Position);
                GPoint NewLabelPosition = new GPoint(MarkerPositionLocal.X - e.X, MarkerPositionLocal.Y - e.Y);
                GMapTargetandLabel MyMarker = (GMapTargetandLabel)currentMarker;
                MyMarker.LabelOffset = new Point(NewLabelPosition.X, NewLabelPosition.Y);
                gMapControl.Refresh();
            }
            else if (SharedData.bool_Listen_for_Data == true)
            {
                bool Mouse_Not_Over_Label = true;
                GMapOverlay[] overlays = new GMapOverlay[] { DinamicOverlay };
                for (int i = overlays.Length - 1; i >= 0; i--)
                {
                    GMapOverlay o = overlays[i];
                    if (o != null && o.IsVisibile)
                        foreach (GMapMarker m in o.Markers)
                            if (m.IsVisible && m.IsHitTestVisible)
                            {
                                PointLatLng MousePosition = gMapControl.FromLocalToLatLng(e.X, e.Y);
                                GPoint MarkerPositionLocal = gMapControl.FromLatLngToLocal(m.Position);
                                GPoint NewLabelPosition = new GPoint(MarkerPositionLocal.X - e.X, MarkerPositionLocal.Y - e.Y);
                                if (MouseIsOnTheLabel(e, m))
                                {
                                    GMapTargetandLabel MyMarker = (GMapTargetandLabel)m;
                                    MyMarker.ShowLabelBox = true;
                                    gMapControl.Refresh();

                                    if (ExtendedLabel.Visible)
                                    {
                                        Mouse_Not_Over_Label = false;
                                        HandleExtendedLabel(MyMarker);
                                    }
                                }
                                else
                                {

                                    GMapTargetandLabel MyMarker = (GMapTargetandLabel)m;
                                    MyMarker.ShowLabelBox = false;

                                }

                            }

                    if (Mouse_Not_Over_Label)
                        ExtendedLabel.DefaultAll();
                }
            }
        }
Exemple #12
0
        private string BuildExportedData()
        {
            string Data         = "";
            int    TargetNumber = 1;

            if (TypeOfExporter == ExporterType.GePath)
            {
                // On load determine what SSR codes are present end populate the combo box
                if (MainASTERIXDataStorage.CAT01Message.Count > 0)
                {
                    foreach (MainASTERIXDataStorage.CAT01Data Msg in MainASTERIXDataStorage.CAT01Message)
                    {
                        CAT01I070Types.CAT01070Mode3UserData Mode3AData = (CAT01I070Types.CAT01070Mode3UserData)Msg.CAT01DataItems[CAT01.ItemIDToIndex("070")].value;
                        if (Mode3AData != null)
                        {
                            if (Mode3AData.Code_Validated == CAT01I070Types.Code_Validation_Type.Code_Validated)
                            {
                                if (Mode3AData.Mode3A_Code == (string)this.comboBox1.Items[this.comboBox1.SelectedIndex])
                                {
                                    // Get Lat/Long
                                    CAT01I040Types.CAT01I040MeasuredPosInPolarCoordinates LatLongData = (CAT01I040Types.CAT01I040MeasuredPosInPolarCoordinates)Msg.CAT01DataItems[CAT01.ItemIDToIndex("040")].value;
                                    // Get Flight Level
                                    CAT01I090Types.CAT01I090FlightLevelUserData FlightLevelData = (CAT01I090Types.CAT01I090FlightLevelUserData)Msg.CAT01DataItems[CAT01.ItemIDToIndex("090")].value;

                                    double LevelInMeeters = 0.0;
                                    if (FlightLevelData != null)
                                    {
                                        try
                                        {
                                            LevelInMeeters = (FlightLevelData.FlightLevel * 100.00) * SharedData.FeetToMeeters;
                                        }
                                        catch
                                        {
                                        }
                                    }

                                    Data = Data + "P" + TargetNumber.ToString() + "," + "SSR" + Mode3AData.Mode3A_Code + "_" + TargetNumber.ToString() + "," + LatLongData.LatLong.GetLatLongDecimal().LongitudeDecimal.ToString() +
                                           "," + LatLongData.LatLong.GetLatLongDecimal().LatitudeDecimal.ToString() + "," + LevelInMeeters.ToString() + Environment.NewLine;

                                    TargetNumber++;
                                }
                            }
                        }
                    }
                }
                else if (MainASTERIXDataStorage.CAT48Message.Count > 0)
                {
                    foreach (MainASTERIXDataStorage.CAT48Data Msg in MainASTERIXDataStorage.CAT48Message)
                    {
                        CAT48I070Types.CAT48I070Mode3UserData Mode3AData = (CAT48I070Types.CAT48I070Mode3UserData)Msg.CAT48DataItems[CAT48.ItemIDToIndex("070")].value;
                        if (Mode3AData != null)
                        {
                            if (Mode3AData.Code_Validated == CAT48I070Types.Code_Validation_Type.Code_Validated)
                            {
                                if (Mode3AData.Mode3A_Code == (string)this.comboBox1.Items[this.comboBox1.SelectedIndex])
                                {
                                    // Get Lat/Long in decimal
                                    CAT48I040Types.CAT48I040MeasuredPosInPolarCoordinates LatLongData = (CAT48I040Types.CAT48I040MeasuredPosInPolarCoordinates)Msg.CAT48DataItems[CAT48.ItemIDToIndex("040")].value;
                                    // Get Flight Level
                                    CAT48I090Types.CAT48I090FlightLevelUserData FlightLevelData = (CAT48I090Types.CAT48I090FlightLevelUserData)Msg.CAT48DataItems[CAT48.ItemIDToIndex("090")].value;

                                    double LevelInMeeters = 0.0;
                                    if (FlightLevelData != null)
                                    {
                                        try
                                        {
                                            LevelInMeeters = (FlightLevelData.FlightLevel * 100.00) * SharedData.FeetToMeeters;
                                        }
                                        catch
                                        {
                                        }
                                    }

                                    Data = Data + "P" + TargetNumber.ToString() + "," + "SSR" + Mode3AData.Mode3A_Code + "_" + TargetNumber.ToString() + "," + LatLongData.LatLong.GetLatLongDecimal().LongitudeDecimal.ToString() +
                                           "," + LatLongData.LatLong.GetLatLongDecimal().LatitudeDecimal.ToString() + "," + LevelInMeeters.ToString() + Environment.NewLine;

                                    TargetNumber++;
                                }
                            }
                        }
                    }
                }
                else if (MainASTERIXDataStorage.CAT62Message.Count > 0)
                {
                    foreach (MainASTERIXDataStorage.CAT62Data Msg in MainASTERIXDataStorage.CAT62Message)
                    {
                        CAT62I060Types.CAT62060Mode3UserData Mode3AData = (CAT62I060Types.CAT62060Mode3UserData)Msg.CAT62DataItems[CAT62.ItemIDToIndex("060")].value;

                        if (Mode3AData != null)
                        {
                            if (Mode3AData.Mode3A_Code == (string)this.comboBox1.Items[this.comboBox1.SelectedIndex])
                            {
                                // Get Lat/Long in decimal
                                GeoCordSystemDegMinSecUtilities.LatLongClass LatLongData = (GeoCordSystemDegMinSecUtilities.LatLongClass)Msg.CAT62DataItems[CAT62.ItemIDToIndex("105")].value;

                                double FlightLevelData = 0.0;
                                if (Msg.CAT62DataItems[CAT62.ItemIDToIndex("136")].value != null)
                                {
                                    try
                                    {
                                        // Get Flight Level
                                        FlightLevelData = (double)Msg.CAT62DataItems[CAT62.ItemIDToIndex("136")].value;
                                    }
                                    catch
                                    {
                                    }
                                }

                                double LevelInMeeters = (FlightLevelData * 100.00) * SharedData.FeetToMeeters;
                                Data = Data + "P" + TargetNumber.ToString() + "," + "SSR" + Mode3AData.Mode3A_Code + "_" + TargetNumber.ToString() + "," + LatLongData.GetLatLongDecimal().LongitudeDecimal.ToString() +
                                       "," + LatLongData.GetLatLongDecimal().LatitudeDecimal.ToString() + "," + LevelInMeeters.ToString() + Environment.NewLine;

                                TargetNumber++;
                            }
                        }
                    }
                }
            }
            else
            {
                // On load determine what SSR codes are present end populate the combo box
                if (MainASTERIXDataStorage.CAT01Message.Count > 0)
                {
                    foreach (MainASTERIXDataStorage.CAT01Data Msg in MainASTERIXDataStorage.CAT01Message)
                    {
                        CAT01I070Types.CAT01070Mode3UserData Mode3AData = (CAT01I070Types.CAT01070Mode3UserData)Msg.CAT01DataItems[CAT01.ItemIDToIndex("070")].value;

                        if (Mode3AData != null)
                        {
                            if (Mode3AData.Code_Validated == CAT01I070Types.Code_Validation_Type.Code_Validated)
                            {
                                if (Mode3AData.Mode3A_Code == (string)this.comboBox1.Items[this.comboBox1.SelectedIndex])
                                {
                                    // Get Lat/Long
                                    CAT01I040Types.CAT01I040MeasuredPosInPolarCoordinates LatLongData = (CAT01I040Types.CAT01I040MeasuredPosInPolarCoordinates)Msg.CAT01DataItems[CAT01.ItemIDToIndex("040")].value;
                                    // Get Flight Level
                                    CAT01I090Types.CAT01I090FlightLevelUserData FlightLevelData = (CAT01I090Types.CAT01I090FlightLevelUserData)Msg.CAT01DataItems[CAT01.ItemIDToIndex("090")].value;

                                    double LevelInMeeters = 0.0;
                                    if (FlightLevelData != null)
                                    {
                                        try
                                        {
                                            LevelInMeeters = (FlightLevelData.FlightLevel * 100.00) * SharedData.FeetToMeeters;
                                        }
                                        catch
                                        {
                                        }
                                    }

                                    Data = Data + LatLongData.LatLong.GetLatLongDecimal().LongitudeDecimal.ToString() +
                                           "," + LatLongData.LatLong.GetLatLongDecimal().LatitudeDecimal.ToString() + "," + LevelInMeeters.ToString() + Environment.NewLine;
                                }
                            }
                        }
                    }
                }
                else if (MainASTERIXDataStorage.CAT48Message.Count > 0)
                {
                    foreach (MainASTERIXDataStorage.CAT48Data Msg in MainASTERIXDataStorage.CAT48Message)
                    {
                        CAT48I070Types.CAT48I070Mode3UserData Mode3AData = (CAT48I070Types.CAT48I070Mode3UserData)Msg.CAT48DataItems[CAT48.ItemIDToIndex("070")].value;
                        if (Mode3AData != null)
                        {
                            if (Mode3AData.Code_Validated == CAT48I070Types.Code_Validation_Type.Code_Validated)
                            {
                                if (Mode3AData.Mode3A_Code == (string)this.comboBox1.Items[this.comboBox1.SelectedIndex])
                                {
                                    // Get Lat/Long in decimal
                                    CAT48I040Types.CAT48I040MeasuredPosInPolarCoordinates LatLongData = (CAT48I040Types.CAT48I040MeasuredPosInPolarCoordinates)Msg.CAT48DataItems[CAT48.ItemIDToIndex("040")].value;
                                    // Get Flight Level
                                    CAT48I090Types.CAT48I090FlightLevelUserData FlightLevelData = (CAT48I090Types.CAT48I090FlightLevelUserData)Msg.CAT48DataItems[CAT48.ItemIDToIndex("090")].value;

                                    double LevelInMeeters = 0.0;
                                    if (FlightLevelData != null)
                                    {
                                        try
                                        {
                                            LevelInMeeters = (FlightLevelData.FlightLevel * 100.00) * SharedData.FeetToMeeters;
                                        }
                                        catch
                                        {
                                        }
                                    }
                                    Data = Data + LatLongData.LatLong.GetLatLongDecimal().LongitudeDecimal.ToString() +
                                           "," + LatLongData.LatLong.GetLatLongDecimal().LatitudeDecimal.ToString() + "," + LevelInMeeters.ToString() + Environment.NewLine;
                                }
                            }
                        }
                    }
                }
                else if (MainASTERIXDataStorage.CAT62Message.Count > 0)
                {
                    foreach (MainASTERIXDataStorage.CAT62Data Msg in MainASTERIXDataStorage.CAT62Message)
                    {
                        CAT62I060Types.CAT62060Mode3UserData Mode3AData = (CAT62I060Types.CAT62060Mode3UserData)Msg.CAT62DataItems[CAT62.ItemIDToIndex("060")].value;

                        if (Mode3AData != null)
                        {
                            if (Mode3AData.Mode3A_Code == (string)this.comboBox1.Items[this.comboBox1.SelectedIndex])
                            {
                                // Get Lat/Long in decimal
                                GeoCordSystemDegMinSecUtilities.LatLongClass LatLongData = (GeoCordSystemDegMinSecUtilities.LatLongClass)Msg.CAT62DataItems[CAT62.ItemIDToIndex("105")].value;

                                double FlightLevelData = 0.0;
                                if (Msg.CAT62DataItems[CAT62.ItemIDToIndex("136")].value != null)
                                {
                                    try
                                    {
                                        // Get Flight Level
                                        FlightLevelData = (double)Msg.CAT62DataItems[CAT62.ItemIDToIndex("136")].value;
                                    }
                                    catch
                                    {
                                    }
                                }

                                double LevelInMeeters = (FlightLevelData * 100.00) * SharedData.FeetToMeeters;

                                Data = Data + LatLongData.GetLatLongDecimal().LongitudeDecimal.ToString() +
                                       "," + LatLongData.GetLatLongDecimal().LatitudeDecimal.ToString() + "," + LevelInMeeters.ToString() + Environment.NewLine;

                                TargetNumber++;
                            }
                        }
                    }
                }
            }

            return(Data);
        }
        public static void Save()
        {
            string BackgroundColor = "Black";
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // HANLDE Display Attributes First
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            string FileName;
            FileName = @"C:\ASTERIX\ADAPTATION\DisplayAttributes.txt";
            DisplayAttributes.DisplayAttributesType DisplayAttribute = new DisplayAttributes.DisplayAttributesType();
            string DisplayAttributesStream = "#ITEM_NAME,TEXT_SIZE,TEXT_FONT,TEXT_COLOR,LINE_WIDTH,LINE_COLOR,LINE_STYLE,AREA_COLOR,IMAGE_SIZE" + Environment.NewLine;

            System.Collections.Generic.List<DisplayAttributes.DisplayAttributesType> AllDisplayAtributes = DisplayAttributes.GetAllDisplayAttributes();

            foreach (DisplayAttributes.DisplayAttributesType DataItem in DisplayAttributes.GetAllDisplayAttributes())
            {
                if (DataItem.ItemName != "BackgroundColor")
                {
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.ItemName + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.TextSize.ToString() + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.TextFont.Name + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.TextColor.Name + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.LineWidth.ToString() + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.LineColor.Name + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.LineStyle.ToString() + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.AreaPolygonColor.Name + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.ImageSize.Width.ToString() + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.ImageSize.Height.ToString() + Environment.NewLine;
                }
                else
                {
                    BackgroundColor = DataItem.TextColor.Name;
                }
            }

            // Remove the last character, which is the new line.
            DisplayAttributesStream.Remove(DisplayAttributesStream.Length - 1);

            // create a writer and open the file
            TextWriter tw = new StreamWriter(FileName);

            try
            {
                // write a line of text to the file
                tw.Write(DisplayAttributesStream);
                MessageBox.Show("DisplayAttributes succefully saved");
            }
            catch (System.IO.IOException e)
            {
                MessageBox.Show(e.Message);
            }

            // close the stream
            tw.Close();

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // HANLDE MainSettings First
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            FileName = @"C:\ASTERIX\ADAPTATION\Main_Settings.txt";
            DisplayAttributesStream = "# System center is : Deg (int), Min (int), Sec (int), Prefix (E/W/N/S)" + Environment.NewLine;

            GeoCordSystemDegMinSecUtilities.LatLongClass LatLon = new GeoCordSystemDegMinSecUtilities.LatLongClass(SystemAdaptationDataSet.SystemOriginPoint.Lat, SystemAdaptationDataSet.SystemOriginPoint.Lng);
            int Int_Lat_Sec = (int)LatLon.GetDegMinSec().Latitude.Sec;
            string LatPrefix = "N";
            if (LatLon.GetDegMinSec().Latitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.S)
                LatPrefix = "S";
            int Int_Lon_Sec = (int)LatLon.GetDegMinSec().Longitude.Sec;
            string LonPrefix = "E";
            if (LatLon.GetDegMinSec().Longitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.W)
                LonPrefix = "W";

            // 44,6,0,N,20,0,0,E
            DisplayAttributesStream = DisplayAttributesStream + "SYS_ORIGIN," +
                LatLon.GetDegMinSec().Latitude.Deg.ToString() + ',' + LatLon.GetDegMinSec().Latitude.Min.ToString() + ',' + Int_Lat_Sec.ToString() + ',' + LatPrefix + ',' +
                LatLon.GetDegMinSec().Longitude.Deg.ToString() + ',' + LatLon.GetDegMinSec().Longitude.Min.ToString() + ',' + Int_Lon_Sec.ToString() + ',' + LonPrefix +
                Environment.NewLine; ;

            DisplayAttributesStream = DisplayAttributesStream + "BACKGROUND," + BackgroundColor;

            // create a writer and open the file
            tw = new StreamWriter(FileName);

            try
            {
                // write a line of text to the file
                tw.Write(DisplayAttributesStream);
                MessageBox.Show("Main_Settings succefully saved");
            }
            catch (System.IO.IOException e)
            {
                MessageBox.Show(e.Message);
            }

            // close the stream
            tw.Close();
        }
Exemple #14
0
        public static void Load()
        {
            string ConfigurationData;
            string FileName;

            char[]       delimiterChars = { ',', '\t' };
            StreamReader MyStreamReader;

            string ItemName;
            int    LatDeg;
            int    LatMin;
            int    LatSec;

            GeoCordSystemDegMinSecUtilities.LatLongPrefix LatPrefix;
            int LonDeg;
            int LonMin;
            int LonSec;

            GeoCordSystemDegMinSecUtilities.LatLongPrefix LonPrefix;

            /////////////////////////////////////////////////////////////////////////
            // First set the system origin
            /////////////////////////////////////////////////////////////////////////
            FileName = @"C:\ASTERIX\ADAPTATION\Main_Settings.txt";
            Exception Bad_Main_Settings = new Exception("Bad Main_Settings.txt file");

            if (System.IO.File.Exists(FileName))
            {
                MyStreamReader = System.IO.File.OpenText(FileName);
                while (MyStreamReader.Peek() >= 0)
                {
                    ConfigurationData = MyStreamReader.ReadLine();
                    string[] words = ConfigurationData.Split(delimiterChars);
                    if (words[0][0] != '#')
                    {
                        switch (words[0])
                        {
                        case "SYS_ORIGIN":
                            ItemName = words[0];

                            // Get Latitude
                            if (int.TryParse(words[1], out LatDeg) == false)
                            {
                                throw Bad_Main_Settings;
                            }
                            if (int.TryParse(words[2], out LatMin) == false)
                            {
                                throw Bad_Main_Settings;
                            }
                            if (int.TryParse(words[3], out LatSec) == false)
                            {
                                throw Bad_Main_Settings;
                            }

                            switch (words[4])
                            {
                            case "E":
                                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
                                break;

                            case "W":
                                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;
                                break;

                            case "N":
                                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
                                break;

                            case "S":
                                LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;
                                break;

                            default:
                                throw Bad_Main_Settings;
                            }

                            // Get Longitude
                            if (int.TryParse(words[5], out LonDeg) == false)
                            {
                                throw Bad_Main_Settings;
                            }
                            if (int.TryParse(words[6], out LonMin) == false)
                            {
                                throw Bad_Main_Settings;
                            }
                            if (int.TryParse(words[7], out LonSec) == false)
                            {
                                throw Bad_Main_Settings;
                            }

                            switch (words[8])
                            {
                            case "E":
                                LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
                                break;

                            case "W":
                                LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;
                                break;

                            case "N":
                                LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
                                break;

                            case "S":
                                LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;
                                break;

                            default:
                                throw Bad_Main_Settings;
                            }

                            GeoCordSystemDegMinSecUtilities.LatLongClass T = new GeoCordSystemDegMinSecUtilities.LatLongClass(LatDeg, LatMin, LatSec,
                                                                                                                              LatPrefix, LonDeg, LonMin, LonSec, LonPrefix);
                            SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(T.GetLatLongDecimal().LatitudeDecimal, T.GetLatLongDecimal().LongitudeDecimal);

                            break;

                        case "BACKGROUND":

                            DisplayAttributes.DisplayAttributesType DisplayAttributeBackground = DisplayAttributes.GetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor);
                            DisplayAttributeBackground.TextColor = System.Drawing.Color.FromName(words[1]);
                            DisplayAttributes.SetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor, DisplayAttributeBackground);
                            break;
                        }
                    }
                }
            }
            else
            {
                // Here is it initialized to the center of Bosnia and Herzegovina.
                SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(44.05267, 17.6769);
            }
        }
        private void PopulateForm()
        {
            // Populate the display origin
            GeoCordSystemDegMinSecUtilities.LatLongClass LatLon = new GeoCordSystemDegMinSecUtilities.LatLongClass(SystemAdaptationDataSet.SystemOriginPoint.Lat, SystemAdaptationDataSet.SystemOriginPoint.Lng);
            this.txtLatDDD.Text = LatLon.GetDegMinSec().Latitude.Deg.ToString();
            this.txtLatMM.Text = LatLon.GetDegMinSec().Latitude.Min.ToString();
            int Int_Sec = (int)LatLon.GetDegMinSec().Latitude.Sec;
            this.txtLatSS.Text = Int_Sec.ToString();
            if (LatLon.GetDegMinSec().Latitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.N)
                this.comboBoxLatDirection.SelectedIndex = 0;
            else
                this.comboBoxLatDirection.SelectedIndex = 1;

            this.txtLonDDD.Text = LatLon.GetDegMinSec().Longitude.Deg.ToString();
            this.txtLonMM.Text = LatLon.GetDegMinSec().Longitude.Min.ToString();
            Int_Sec = (int)LatLon.GetDegMinSec().Longitude.Sec;
            this.txtLonSS.Text = Int_Sec.ToString();
            if (LatLon.GetDegMinSec().Longitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.E)
                this.comboBoxLonDirection.SelectedIndex = 0;
            else
                this.comboBoxLonDirection.SelectedIndex = 1;

            // Load all display items and set it to the first one in the list
            // and it will cause the selected index to change that will then trigger
            // a call to sync data function
            foreach (DisplayAttributes.DisplayAttributesType DataItem in DisplayAttributes.GetAllDisplayAttributes())
                if (DataItem.ItemName != "BackgroundColor")
                    comboBoxDataItem.Items.Add(DataItem.ItemName);

            // Background Color
            Type colorType = typeof(System.Drawing.Color);
            PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static |
                                          BindingFlags.DeclaredOnly | BindingFlags.Public);
            foreach (PropertyInfo c in propInfoList)
                this.comboBoxBackgroundColor.Items.Add(c.Name);

            // Now set the index of the background color to the currently set background color.
            this.comboBoxBackgroundColor.SelectedIndex =
                this.comboBoxBackgroundColor.FindStringExact(DisplayAttributes.GetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor).TextColor.Name);

            /////////////////////////////////////////////////////////////
            // TEXT ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Text Attributes Color
            foreach (PropertyInfo c in propInfoList)
                this.comboBoxTextColorChoice.Items.Add(c.Name);

            // Text Attributes Font
            FontFamily[] ffArray = FontFamily.Families;
            foreach (FontFamily ff in ffArray)
                this.comboBoxTextFontChoice.Items.Add(ff.Name);

            for (int Index = 0; Index < this.comboBoxTextFontChoice.Items.Count; Index++)
            {
                try { Font TestFOnt = new Font(this.comboBoxTextFontChoice.Items[Index].ToString(), 7); }
                catch { this.comboBoxTextFontChoice.Items.RemoveAt(Index); }
            }

            /////////////////////////////////////////////////////////////
            // LINE ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Line Attributes Color
            foreach (PropertyInfo c in propInfoList)
                this.comboBoxLineColorChoice.Items.Add(c.Name);

            // Line Attributes Type
            // Hard coded

            /////////////////////////////////////////////////////////////
            // AREA/POLYGON ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Area/Polygon Attributes
            foreach (PropertyInfo c in propInfoList)
                this.comboBoxAreaPolygonColorChoice.Items.Add(c.Name);

            /////////////////////////////////////////////////////////////
            // IMAGE ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Now set index to the first display item
            this.comboBoxDataItem.SelectedIndex = 0;
        }
Exemple #16
0
        private void comboBoxSSRCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.listBoxDataBySSRCode.Items.Clear();

            if (SSR_Code_Lookup.Length > 0)
            {
                // On load determine what SSR codes are present end populate the combo box
                if (MainASTERIXDataStorage.CAT01Message.Count > 0)
                {
                    foreach (MainASTERIXDataStorage.CAT01Data Msg in MainASTERIXDataStorage.CAT01Message)
                    {
                        CAT01I070Types.CAT01070Mode3UserData MyData = (CAT01I070Types.CAT01070Mode3UserData)Msg.CAT01DataItems[CAT01.ItemIDToIndex("070")].value;

                        if (MyData.Mode3A_Code == this.comboBoxSSRCode.Items[this.comboBoxSSRCode.SelectedIndex].ToString())
                        {
                            ASTERIX.SIC_SAC_Time SIC_SAC_TIME = (ASTERIX.SIC_SAC_Time)Msg.CAT01DataItems[CAT01.ItemIDToIndex("010")].value;

                            // Display time
                            string Time = SIC_SAC_TIME.TimeofReception.Hour.ToString().PadLeft(2, '0') + ":" + SIC_SAC_TIME.TimeofReception.Minute.ToString().PadLeft(2, '0') + ":" +
                                          SIC_SAC_TIME.TimeofReception.Second.ToString().PadLeft(2, '0') + ":" + SIC_SAC_TIME.TimeofReception.Millisecond.ToString().PadLeft(3, '0');
                            this.listBoxDataBySSRCode.Items.Add("Rcvd Time: " + Time);

                            CAT01I040Types.CAT01I040MeasuredPosInPolarCoordinates PositionData = (CAT01I040Types.CAT01I040MeasuredPosInPolarCoordinates)Msg.CAT01DataItems[CAT01.ItemIDToIndex("040")].value;
                            this.listBoxDataBySSRCode.Items.Add("\tDistance:\t" + PositionData.Measured_Distance);
                            this.listBoxDataBySSRCode.Items.Add("\tAzimuth:\t" + PositionData.Measured_Azimuth.ToString());
                            string Lat, Lon;
                            PositionData.LatLong.GetDegMinSecStringFormat(out Lat, out Lon);
                            this.listBoxDataBySSRCode.Items.Add("\tLat/Long:\t" + Lat + "/" + Lon);

                            // Display Data
                            CAT01I090Types.CAT01I090FlightLevelUserData FL_Data = (CAT01I090Types.CAT01I090FlightLevelUserData)Msg.CAT01DataItems[CAT01.ItemIDToIndex("090")].value;
                            this.listBoxDataBySSRCode.Items.Add("\tMode Validated:\t" + FL_Data.Code_Validated.ToString());
                            this.listBoxDataBySSRCode.Items.Add("\tMode Garbled:\t" + FL_Data.Code_Garbled.ToString());
                            this.listBoxDataBySSRCode.Items.Add("\tFL:\t" + FL_Data.FlightLevel.ToString());

                            this.listBoxDataBySSRCode.Items.Add("    ");
                        }
                    }
                }
                else if (MainASTERIXDataStorage.CAT48Message.Count > 0)
                {
                    foreach (MainASTERIXDataStorage.CAT48Data Msg in MainASTERIXDataStorage.CAT48Message)
                    {
                        CAT48I070Types.CAT48I070Mode3UserData MyData = (CAT48I070Types.CAT48I070Mode3UserData)Msg.CAT48DataItems[CAT48.ItemIDToIndex("070")].value;

                        if (MyData.Mode3A_Code == this.comboBoxSSRCode.Items[this.comboBoxSSRCode.SelectedIndex].ToString())
                        {
                            ASTERIX.SIC_SAC_Time SIC_SAC_TIME = (ASTERIX.SIC_SAC_Time)Msg.CAT48DataItems[CAT48.ItemIDToIndex("010")].value;

                            // Display time
                            string Time = SIC_SAC_TIME.TimeofReception.Hour.ToString().PadLeft(2, '0') + ":" + SIC_SAC_TIME.TimeofReception.Minute.ToString().PadLeft(2, '0') + ":" +
                                          SIC_SAC_TIME.TimeofReception.Second.ToString().PadLeft(2, '0') + ":" + SIC_SAC_TIME.TimeofReception.Millisecond.ToString().PadLeft(3, '0');
                            this.listBoxDataBySSRCode.Items.Add("Rcvd Time: " + Time);

                            // Display Data
                            CAT48I240Types.CAT48I240ACID_Data ACID_String = (CAT48I240Types.CAT48I240ACID_Data)Msg.CAT48DataItems[CAT48.ItemIDToIndex("240")].value;
                            if (ACID_String != null)
                            {
                                this.listBoxDataBySSRCode.Items.Add("\t" + "Callsign:" + ACID_String.ACID);
                            }
                            else
                            {
                                this.listBoxDataBySSRCode.Items.Add("\t" + "Callsign: N/A");
                            }

                            CAT48I040Types.CAT48I040MeasuredPosInPolarCoordinates PositionData = (CAT48I040Types.CAT48I040MeasuredPosInPolarCoordinates)Msg.CAT48DataItems[CAT48.ItemIDToIndex("040")].value;
                            this.listBoxDataBySSRCode.Items.Add("\tDistance:\t" + PositionData.Measured_Distance);
                            this.listBoxDataBySSRCode.Items.Add("\tAzimuth:\t" + PositionData.Measured_Azimuth.ToString());
                            string Lat, Lon;
                            PositionData.LatLong.GetDegMinSecStringFormat(out Lat, out Lon);
                            this.listBoxDataBySSRCode.Items.Add("\tLat/Long:\t" + Lat + "/" + Lon);

                            CAT48I090Types.CAT48I090FlightLevelUserData FL_Data = (CAT48I090Types.CAT48I090FlightLevelUserData)Msg.CAT48DataItems[CAT48.ItemIDToIndex("090")].value;
                            this.listBoxDataBySSRCode.Items.Add("\tMode Validated:\t" + FL_Data.Code_Validated.ToString());
                            this.listBoxDataBySSRCode.Items.Add("\tMode Garbled:\t" + FL_Data.Code_Garbled.ToString());
                            this.listBoxDataBySSRCode.Items.Add("\tFL:\t" + FL_Data.FlightLevel.ToString());
                            this.listBoxDataBySSRCode.Items.Add("    ");
                        }
                    }
                }
                else if (MainASTERIXDataStorage.CAT62Message.Count > 0)
                {
                    foreach (MainASTERIXDataStorage.CAT62Data Msg in MainASTERIXDataStorage.CAT62Message)
                    {
                        CAT62I060Types.CAT62060Mode3UserData MyData = (CAT62I060Types.CAT62060Mode3UserData)Msg.CAT62DataItems[CAT62.ItemIDToIndex("060")].value;

                        if (MyData.Mode3A_Code == this.comboBoxSSRCode.Items[this.comboBoxSSRCode.SelectedIndex].ToString())
                        {
                            ASTERIX.SIC_SAC_Time SIC_SAC_TIME = (ASTERIX.SIC_SAC_Time)Msg.CAT62DataItems[CAT62.ItemIDToIndex("010")].value;

                            // TIME
                            string Time = SIC_SAC_TIME.TimeofReception.Hour.ToString().PadLeft(2, '0') + ":" + SIC_SAC_TIME.TimeofReception.Minute.ToString().PadLeft(2, '0') + ":" +
                                          SIC_SAC_TIME.TimeofReception.Second.ToString().PadLeft(2, '0') + ":" + SIC_SAC_TIME.TimeofReception.Millisecond.ToString().PadLeft(3, '0');
                            this.listBoxDataBySSRCode.Items.Add("Rcvd Time: " + Time);
                            // TRACK NUMBER
                            int TrackNumber = (int)Msg.CAT62DataItems[CAT62.ItemIDToIndex("040")].value;
                            this.listBoxDataBySSRCode.Items.Add("\t" + "TRACK#:" + TrackNumber.ToString());
                            // CALLSIGN
                            CAT62I380Types.CAT62I380Data CAT62I380Data = (CAT62I380Types.CAT62I380Data)Msg.CAT62DataItems[CAT62.ItemIDToIndex("380")].value;
                            if (CAT62I380Data != null)
                            {
                                this.listBoxDataBySSRCode.Items.Add("\t" + "Callsign:" + CAT62I380Data.ACID.ACID_String);
                            }
                            // POSITION
                            GeoCordSystemDegMinSecUtilities.LatLongClass LatLongData = (GeoCordSystemDegMinSecUtilities.LatLongClass)Msg.CAT62DataItems[CAT62.ItemIDToIndex("105")].value;
                            string Lat, Lon;
                            LatLongData.GetDegMinSecStringFormat(out Lat, out Lon);
                            this.listBoxDataBySSRCode.Items.Add("\tLat/Long:\t" + Lat + "/" + Lon);
                            // FLIGHT LEVEL
                            double FlightLevel = (double)Msg.CAT62DataItems[CAT62.ItemIDToIndex("136")].value;
                            if (Msg.CAT62DataItems[CAT62.ItemIDToIndex("136")].value != null)
                            {
                                this.listBoxDataBySSRCode.Items.Add("\tFL:\t" + FlightLevel.ToString());
                            }
                            else
                            {
                                this.listBoxDataBySSRCode.Items.Add("\tFL:\t" + "N/A");
                            }
                            this.listBoxDataBySSRCode.Items.Add("    ");
                        }
                    }
                }
            }
            else
            {
                this.listBoxDataBySSRCode.Items.Add("No data was acquired !!!");
            }
        }
Exemple #17
0
        private void PopulateForm()
        {
            // Populate the display origin
            GeoCordSystemDegMinSecUtilities.LatLongClass LatLon = new GeoCordSystemDegMinSecUtilities.LatLongClass(SystemAdaptationDataSet.SystemOriginPoint.Lat, SystemAdaptationDataSet.SystemOriginPoint.Lng);
            this.txtLatDDD.Text = LatLon.GetDegMinSec().Latitude.Deg.ToString();
            this.txtLatMM.Text  = LatLon.GetDegMinSec().Latitude.Min.ToString();
            int Int_Sec = (int)LatLon.GetDegMinSec().Latitude.Sec;

            this.txtLatSS.Text = Int_Sec.ToString();
            if (LatLon.GetDegMinSec().Latitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.N)
            {
                this.comboBoxLatDirection.SelectedIndex = 0;
            }
            else
            {
                this.comboBoxLatDirection.SelectedIndex = 1;
            }

            this.txtLonDDD.Text = LatLon.GetDegMinSec().Longitude.Deg.ToString();
            this.txtLonMM.Text  = LatLon.GetDegMinSec().Longitude.Min.ToString();
            Int_Sec             = (int)LatLon.GetDegMinSec().Longitude.Sec;
            this.txtLonSS.Text  = Int_Sec.ToString();
            if (LatLon.GetDegMinSec().Longitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.E)
            {
                this.comboBoxLonDirection.SelectedIndex = 0;
            }
            else
            {
                this.comboBoxLonDirection.SelectedIndex = 1;
            }

            // Load all display items and set it to the first one in the list
            // and it will cause the selected index to change that will then trigger
            // a call to sync data function
            foreach (DisplayAttributes.DisplayAttributesType DataItem in DisplayAttributes.GetAllDisplayAttributes())
            {
                if (DataItem.ItemName != "BackgroundColor")
                {
                    comboBoxDataItem.Items.Add(DataItem.ItemName);
                }
            }

            // Background Color
            Type colorType = typeof(System.Drawing.Color);

            PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static |
                                                                  BindingFlags.DeclaredOnly | BindingFlags.Public);
            foreach (PropertyInfo c in propInfoList)
            {
                this.comboBoxBackgroundColor.Items.Add(c.Name);
            }

            // Now set the index of the background color to the currently set background color.
            this.comboBoxBackgroundColor.SelectedIndex =
                this.comboBoxBackgroundColor.FindStringExact(DisplayAttributes.GetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor).TextColor.Name);

            /////////////////////////////////////////////////////////////
            // TEXT ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Text Attributes Color
            foreach (PropertyInfo c in propInfoList)
            {
                this.comboBoxTextColorChoice.Items.Add(c.Name);
            }

            // Text Attributes Font
            FontFamily[] ffArray = FontFamily.Families;
            foreach (FontFamily ff in ffArray)
            {
                this.comboBoxTextFontChoice.Items.Add(ff.Name);
            }

            for (int Index = 0; Index < this.comboBoxTextFontChoice.Items.Count; Index++)
            {
                try { Font TestFOnt = new Font(this.comboBoxTextFontChoice.Items[Index].ToString(), 7); }
                catch { this.comboBoxTextFontChoice.Items.RemoveAt(Index); }
            }

            /////////////////////////////////////////////////////////////
            // LINE ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Line Attributes Color
            foreach (PropertyInfo c in propInfoList)
            {
                this.comboBoxLineColorChoice.Items.Add(c.Name);
            }

            // Line Attributes Type
            // Hard coded


            /////////////////////////////////////////////////////////////
            // AREA/POLYGON ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Area/Polygon Attributes
            foreach (PropertyInfo c in propInfoList)
            {
                this.comboBoxAreaPolygonColorChoice.Items.Add(c.Name);
            }

            /////////////////////////////////////////////////////////////
            // IMAGE ATTRIBUTES
            /////////////////////////////////////////////////////////////

            // Now set index to the first display item
            this.comboBoxDataItem.SelectedIndex = 0;
        }
Exemple #18
0
        public static void Save()
        {
            string BackgroundColor = "Black";
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // HANLDE Display Attributes First
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            string FileName;

            FileName = @"C:\ASTERIX\ADAPTATION\DisplayAttributes.txt";
            DisplayAttributes.DisplayAttributesType DisplayAttribute = new DisplayAttributes.DisplayAttributesType();
            string DisplayAttributesStream = "#ITEM_NAME,TEXT_SIZE,TEXT_FONT,TEXT_COLOR,LINE_WIDTH,LINE_COLOR,LINE_STYLE,AREA_COLOR,IMAGE_SIZE" + Environment.NewLine;

            System.Collections.Generic.List <DisplayAttributes.DisplayAttributesType> AllDisplayAtributes = DisplayAttributes.GetAllDisplayAttributes();

            foreach (DisplayAttributes.DisplayAttributesType DataItem in DisplayAttributes.GetAllDisplayAttributes())
            {
                if (DataItem.ItemName != "BackgroundColor")
                {
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.ItemName + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.TextSize.ToString() + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.TextFont.Name + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.TextColor.Name + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.LineWidth.ToString() + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.LineColor.Name + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.LineStyle.ToString() + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.AreaPolygonColor.Name + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.ImageSize.Width.ToString() + ',';
                    DisplayAttributesStream = DisplayAttributesStream + DataItem.ImageSize.Height.ToString() + Environment.NewLine;
                }
                else
                {
                    BackgroundColor = DataItem.TextColor.Name;
                }
            }

            // Remove the last character, which is the new line.
            DisplayAttributesStream.Remove(DisplayAttributesStream.Length - 1);

            // create a writer and open the file
            TextWriter tw = new StreamWriter(FileName);

            try
            {
                // write a line of text to the file
                tw.Write(DisplayAttributesStream);
                MessageBox.Show("DisplayAttributes succefully saved");
            }
            catch (System.IO.IOException e)
            {
                MessageBox.Show(e.Message);
            }

            // close the stream
            tw.Close();


            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // HANLDE MainSettings First
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            FileName = @"C:\ASTERIX\ADAPTATION\Main_Settings.txt";
            DisplayAttributesStream = "# System center is : Deg (int), Min (int), Sec (int), Prefix (E/W/N/S)" + Environment.NewLine;

            GeoCordSystemDegMinSecUtilities.LatLongClass LatLon = new GeoCordSystemDegMinSecUtilities.LatLongClass(SystemAdaptationDataSet.SystemOriginPoint.Lat, SystemAdaptationDataSet.SystemOriginPoint.Lng);
            int    Int_Lat_Sec = (int)LatLon.GetDegMinSec().Latitude.Sec;
            string LatPrefix   = "N";

            if (LatLon.GetDegMinSec().Latitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.S)
            {
                LatPrefix = "S";
            }
            int    Int_Lon_Sec = (int)LatLon.GetDegMinSec().Longitude.Sec;
            string LonPrefix   = "E";

            if (LatLon.GetDegMinSec().Longitude.Prefix == GeoCordSystemDegMinSecUtilities.LatLongPrefix.W)
            {
                LonPrefix = "W";
            }

            // 44,6,0,N,20,0,0,E
            DisplayAttributesStream = DisplayAttributesStream + "SYS_ORIGIN," +
                                      LatLon.GetDegMinSec().Latitude.Deg.ToString() + ',' + LatLon.GetDegMinSec().Latitude.Min.ToString() + ',' + Int_Lat_Sec.ToString() + ',' + LatPrefix + ',' +
                                      LatLon.GetDegMinSec().Longitude.Deg.ToString() + ',' + LatLon.GetDegMinSec().Longitude.Min.ToString() + ',' + Int_Lon_Sec.ToString() + ',' + LonPrefix +
                                      Environment.NewLine;;

            DisplayAttributesStream = DisplayAttributesStream + "BACKGROUND," + BackgroundColor;

            // create a writer and open the file
            tw = new StreamWriter(FileName);

            try
            {
                // write a line of text to the file
                tw.Write(DisplayAttributesStream);
                MessageBox.Show("Main_Settings succefully saved");
            }
            catch (System.IO.IOException e)
            {
                MessageBox.Show(e.Message);
            }

            // close the stream
            tw.Close();
        }
Exemple #19
0
 private void UpdatelblCenter()
 {
     GeoCordSystemDegMinSecUtilities.LatLongClass ToConvert = new GeoCordSystemDegMinSecUtilities.LatLongClass(gMapControl.Position.Lat, gMapControl.Position.Lng);
     string Latitude_S, Longitude_S;
     ToConvert.GetDegMinSecStringFormat(out Latitude_S, out Longitude_S);
     this.lblCenterLat.Text = Latitude_S;
     this.lblCenterLon.Text = Longitude_S;
 }
Exemple #20
0
        private static void DecodeAzimuthAndDistance(ref GeoCordSystemDegMinSecUtilities.LatLongClass NewPosition, out double Distance, out double Azimuth, Bit_Ops BO)
        {
            double Distance_Loc = 0.0;
            double Azimuth_Loc  = 0.0;

            GeoCordSystemDegMinSecUtilities.LatLongClass ResultPosition = new GeoCordSystemDegMinSecUtilities.LatLongClass();
            ///////////////////////////////////////////////////////////////////////////////////////
            // Decode Distance
            ///////////////////////////////////////////////////////////////////////////////////////
            if (BO.DWord[Bit_Ops.Bit16] == true)
            {
                Distance_Loc = RHO_1;
            }
            if (BO.DWord[Bit_Ops.Bit17] == true)
            {
                Distance_Loc = Distance_Loc + RHO_2;
            }
            if (BO.DWord[Bit_Ops.Bit18] == true)
            {
                Distance_Loc = Distance_Loc + RHO_3;
            }
            if (BO.DWord[Bit_Ops.Bit19] == true)
            {
                Distance_Loc = Distance_Loc + RHO_4;
            }
            if (BO.DWord[Bit_Ops.Bit20] == true)
            {
                Distance_Loc = Distance_Loc + RHO_5;
            }
            if (BO.DWord[Bit_Ops.Bit21] == true)
            {
                Distance_Loc = Distance_Loc + RHO_6;
            }
            if (BO.DWord[Bit_Ops.Bit22] == true)
            {
                Distance_Loc = Distance_Loc + RHO_7;
            }
            if (BO.DWord[Bit_Ops.Bit23] == true)
            {
                Distance_Loc = Distance_Loc + RHO_8;
            }
            if (BO.DWord[Bit_Ops.Bit24] == true)
            {
                Distance_Loc = Distance_Loc + RHO_9;
            }
            if (BO.DWord[Bit_Ops.Bit25] == true)
            {
                Distance_Loc = Distance_Loc + RHO_10;
            }
            if (BO.DWord[Bit_Ops.Bit26] == true)
            {
                Distance_Loc = Distance_Loc + RHO_11;
            }
            if (BO.DWord[Bit_Ops.Bit27] == true)
            {
                Distance_Loc = Distance_Loc + RHO_12;
            }
            if (BO.DWord[Bit_Ops.Bit28] == true)
            {
                Distance_Loc = Distance_Loc + RHO_13;
            }
            if (BO.DWord[Bit_Ops.Bit29] == true)
            {
                Distance_Loc = Distance_Loc + RHO_14;
            }
            if (BO.DWord[Bit_Ops.Bit30] == true)
            {
                Distance_Loc = Distance_Loc + RHO_15;
            }
            if (BO.DWord[Bit_Ops.Bit31] == true)
            {
                Distance_Loc = Distance_Loc + RHO_16;
            }

            ///////////////////////////////////////////////////////////////////////////////////////
            // Decode Azimuth
            ///////////////////////////////////////////////////////////////////////////////////////
            if (BO.DWord[Bit_Ops.Bit0] == true)
            {
                Azimuth_Loc = THETA_1;
            }
            if (BO.DWord[Bit_Ops.Bit1] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_2;
            }
            if (BO.DWord[Bit_Ops.Bit2] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_3;
            }
            if (BO.DWord[Bit_Ops.Bit3] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_4;
            }
            if (BO.DWord[Bit_Ops.Bit4] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_5;
            }
            if (BO.DWord[Bit_Ops.Bit5] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_6;
            }
            if (BO.DWord[Bit_Ops.Bit6] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_7;
            }
            if (BO.DWord[Bit_Ops.Bit7] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_8;
            }
            if (BO.DWord[Bit_Ops.Bit8] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_9;
            }
            if (BO.DWord[Bit_Ops.Bit9] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_10;
            }
            if (BO.DWord[Bit_Ops.Bit10] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_11;
            }
            if (BO.DWord[Bit_Ops.Bit11] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_12;
            }
            if (BO.DWord[Bit_Ops.Bit12] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_13;
            }
            if (BO.DWord[Bit_Ops.Bit13] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_14;
            }
            if (BO.DWord[Bit_Ops.Bit14] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_15;
            }
            if (BO.DWord[Bit_Ops.Bit15] == true)
            {
                Azimuth_Loc = Azimuth_Loc + THETA_16;
            }

            Azimuth  = Azimuth_Loc;
            Distance = Distance_Loc;

            //////////////////////////////////////////////////////////////////////////////////
            //
            // Here loop through the defined radars and determine the source of the data.
            // Once the source is determined calculate the extact position of the target
            // by taking the position of the radar and applying the range and bearing.
            // Display time of reception
            //
            // Extract the current SIC/SAC so the correct radar can be applied
            //
            ASTERIX.SIC_SAC_Time SIC_SAC_TIME = (ASTERIX.SIC_SAC_Time)CAT01.I001DataItems[CAT01.ItemIDToIndex("010")].value;
            foreach (SystemAdaptationDataSet.Radar RDS in SystemAdaptationDataSet.RadarDataSet)
            {
                // If the current SIC/SAC code matched the code of one of the defined radars
                // then go ahead and calculate the Lat/Long position.
                if (RDS.SIC == SIC_SAC_TIME.SIC.ToString() && RDS.SAC == SIC_SAC_TIME.SAC.ToString())
                {
                    ResultPosition = GeoCordSystemDegMinSecUtilities.CalculateNewPosition(RDS.RadarPosition, Distance_Loc, Azimuth_Loc);
                }
            }

            NewPosition.SetPosition(ResultPosition.GetLatLongDecimal());
        }
        public static void Load()
        {
            string ConfigurationData;
            string FileName;
            char[] delimiterChars = { ',', '\t' };
            StreamReader MyStreamReader;

            string ItemName;
            int LatDeg;
            int LatMin;
            int LatSec;
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LatPrefix;
            int LonDeg;
            int LonMin;
            int LonSec;
            GeoCordSystemDegMinSecUtilities.LatLongPrefix LonPrefix;

            /////////////////////////////////////////////////////////////////////////
            // First set the system origin
            /////////////////////////////////////////////////////////////////////////
            FileName = @"C:\ASTERIX\ADAPTATION\Main_Settings.txt";
            Exception Bad_Main_Settings = new Exception("Bad Main_Settings.txt file");
            if (System.IO.File.Exists(FileName))
            {
                MyStreamReader = System.IO.File.OpenText(FileName);
                while (MyStreamReader.Peek() >= 0)
                {
                    ConfigurationData = MyStreamReader.ReadLine();
                    string[] words = ConfigurationData.Split(delimiterChars);
                    if (words[0][0] != '#')
                    {
                        switch (words[0])
                        {
                            case "SYS_ORIGIN":
                                ItemName = words[0];

                                // Get Latitude
                                if (int.TryParse(words[1], out LatDeg) == false)
                                    throw Bad_Main_Settings;
                                if (int.TryParse(words[2], out LatMin) == false)
                                    throw Bad_Main_Settings;
                                if (int.TryParse(words[3], out LatSec) == false)
                                    throw Bad_Main_Settings;

                                switch (words[4])
                                {
                                    case "E":
                                        LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
                                        break;
                                    case "W":
                                        LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;
                                        break;
                                    case "N":
                                        LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
                                        break;
                                    case "S":
                                        LatPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;
                                        break;
                                    default:
                                        throw Bad_Main_Settings;
                                }

                                // Get Longitude
                                if (int.TryParse(words[5], out LonDeg) == false)
                                    throw Bad_Main_Settings;
                                if (int.TryParse(words[6], out LonMin) == false)
                                    throw Bad_Main_Settings;
                                if (int.TryParse(words[7], out LonSec) == false)
                                    throw Bad_Main_Settings;

                                switch (words[8])
                                {
                                    case "E":
                                        LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
                                        break;
                                    case "W":
                                        LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;
                                        break;
                                    case "N":
                                        LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
                                        break;
                                    case "S":
                                        LonPrefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;
                                        break;
                                    default:
                                        throw Bad_Main_Settings;
                                }

                                GeoCordSystemDegMinSecUtilities.LatLongClass T = new GeoCordSystemDegMinSecUtilities.LatLongClass(LatDeg, LatMin, LatSec,
                            LatPrefix, LonDeg, LonMin, LonSec, LonPrefix);
                                SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(T.GetLatLongDecimal().LatitudeDecimal, T.GetLatLongDecimal().LongitudeDecimal);

                                break;

                            case "BACKGROUND":

                                DisplayAttributes.DisplayAttributesType DisplayAttributeBackground = DisplayAttributes.GetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor);
                                DisplayAttributeBackground.TextColor = System.Drawing.Color.FromName(words[1]);
                                DisplayAttributes.SetDisplayAttribute(DisplayAttributes.DisplayItemsType.BackgroundColor, DisplayAttributeBackground);
                                break;
                        }
                    }
                }
            }
            else
            {
                // Here is it initialized to the center of Bosnia and Herzegovina.
                SystemAdaptationDataSet.SystemOrigin = new GMap.NET.PointLatLng(44.05267, 17.6769);
            }
        }
Exemple #22
0
        public static void DecodeCAT62I105(byte[] Data)
        {
            // Get an instance of bit ops
            Bit_Ops BO = new Bit_Ops();

            BO.DWord[Bit_Ops.Bits0_7_Of_DWord]   = Data[CAT62.CurrentDataBufferOctalIndex + 3];
            BO.DWord[Bit_Ops.Bits8_15_Of_DWord]  = Data[CAT62.CurrentDataBufferOctalIndex + 2];
            BO.DWord[Bit_Ops.Bits16_23_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 1];
            BO.DWord[Bit_Ops.Bits24_31_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex];

            double Result    = 0.0;
            double Latitude  = 0.0;
            double Longitude = 0.0;

            // Check for negative values
            if (BO.DWord[Bit_Ops.Bit31] == true)
            {
                BO.DWord[Bit_Ops.Bit0]  = !BO.DWord[Bit_Ops.Bit0];
                BO.DWord[Bit_Ops.Bit1]  = !BO.DWord[Bit_Ops.Bit1];
                BO.DWord[Bit_Ops.Bit2]  = !BO.DWord[Bit_Ops.Bit2];
                BO.DWord[Bit_Ops.Bit3]  = !BO.DWord[Bit_Ops.Bit3];
                BO.DWord[Bit_Ops.Bit4]  = !BO.DWord[Bit_Ops.Bit4];
                BO.DWord[Bit_Ops.Bit5]  = !BO.DWord[Bit_Ops.Bit5];
                BO.DWord[Bit_Ops.Bit6]  = !BO.DWord[Bit_Ops.Bit6];
                BO.DWord[Bit_Ops.Bit7]  = !BO.DWord[Bit_Ops.Bit7];
                BO.DWord[Bit_Ops.Bit8]  = !BO.DWord[Bit_Ops.Bit8];
                BO.DWord[Bit_Ops.Bit9]  = !BO.DWord[Bit_Ops.Bit9];
                BO.DWord[Bit_Ops.Bit10] = !BO.DWord[Bit_Ops.Bit10];
                BO.DWord[Bit_Ops.Bit11] = !BO.DWord[Bit_Ops.Bit11];
                BO.DWord[Bit_Ops.Bit12] = !BO.DWord[Bit_Ops.Bit12];
                BO.DWord[Bit_Ops.Bit13] = !BO.DWord[Bit_Ops.Bit13];
                BO.DWord[Bit_Ops.Bit14] = !BO.DWord[Bit_Ops.Bit14];
                BO.DWord[Bit_Ops.Bit15] = !BO.DWord[Bit_Ops.Bit15];
                BO.DWord[Bit_Ops.Bit16] = !BO.DWord[Bit_Ops.Bit16];
                BO.DWord[Bit_Ops.Bit17] = !BO.DWord[Bit_Ops.Bit17];
                BO.DWord[Bit_Ops.Bit18] = !BO.DWord[Bit_Ops.Bit18];
                BO.DWord[Bit_Ops.Bit19] = !BO.DWord[Bit_Ops.Bit19];
                BO.DWord[Bit_Ops.Bit20] = !BO.DWord[Bit_Ops.Bit20];
                BO.DWord[Bit_Ops.Bit21] = !BO.DWord[Bit_Ops.Bit21];
                BO.DWord[Bit_Ops.Bit22] = !BO.DWord[Bit_Ops.Bit22];
                BO.DWord[Bit_Ops.Bit23] = !BO.DWord[Bit_Ops.Bit23];
                BO.DWord[Bit_Ops.Bit24] = !BO.DWord[Bit_Ops.Bit24];
                BO.DWord[Bit_Ops.Bit25] = !BO.DWord[Bit_Ops.Bit25];
                BO.DWord[Bit_Ops.Bit26] = !BO.DWord[Bit_Ops.Bit26];
                BO.DWord[Bit_Ops.Bit27] = !BO.DWord[Bit_Ops.Bit27];
                BO.DWord[Bit_Ops.Bit28] = !BO.DWord[Bit_Ops.Bit28];
                BO.DWord[Bit_Ops.Bit29] = !BO.DWord[Bit_Ops.Bit29];
                BO.DWord[Bit_Ops.Bit30] = !BO.DWord[Bit_Ops.Bit30];
                BO.DWord[Bit_Ops.Bit31] = !BO.DWord[Bit_Ops.Bit31];
                BO.DWord[Bit_Ops.Bits16_31_Of_DWord] = BO.DWord[Bit_Ops.Bits16_31_Of_DWord] + 1;

                if (BO.DWord[Bit_Ops.Bit0] == true)
                {
                    Result = POS_FIX_1;
                }
                if (BO.DWord[Bit_Ops.Bit1] == true)
                {
                    Result = Result + POS_FIX_2;
                }
                if (BO.DWord[Bit_Ops.Bit2] == true)
                {
                    Result = Result + POS_FIX_3;
                }
                if (BO.DWord[Bit_Ops.Bit3] == true)
                {
                    Result = Result + POS_FIX_4;
                }
                if (BO.DWord[Bit_Ops.Bit4] == true)
                {
                    Result = Result + POS_FIX_5;
                }
                if (BO.DWord[Bit_Ops.Bit5] == true)
                {
                    Result = Result + POS_FIX_6;
                }
                if (BO.DWord[Bit_Ops.Bit6] == true)
                {
                    Result = Result + POS_FIX_7;
                }
                if (BO.DWord[Bit_Ops.Bit7] == true)
                {
                    Result = Result + POS_FIX_8;
                }
                if (BO.DWord[Bit_Ops.Bit8] == true)
                {
                    Result = Result + POS_FIX_9;
                }
                if (BO.DWord[Bit_Ops.Bit9] == true)
                {
                    Result = Result + POS_FIX_10;
                }
                if (BO.DWord[Bit_Ops.Bit10] == true)
                {
                    Result = Result + POS_FIX_11;
                }
                if (BO.DWord[Bit_Ops.Bit11] == true)
                {
                    Result = Result + POS_FIX_12;
                }
                if (BO.DWord[Bit_Ops.Bit12] == true)
                {
                    Result = Result + POS_FIX_13;
                }
                if (BO.DWord[Bit_Ops.Bit13] == true)
                {
                    Result = Result + POS_FIX_14;
                }
                if (BO.DWord[Bit_Ops.Bit14] == true)
                {
                    Result = Result + POS_FIX_15;
                }
                if (BO.DWord[Bit_Ops.Bit15] == true)
                {
                    Result = Result + POS_FIX_16;
                }
                if (BO.DWord[Bit_Ops.Bit16] == true)
                {
                    Result = Result + POS_FIX_17;
                }
                if (BO.DWord[Bit_Ops.Bit17] == true)
                {
                    Result = Result + POS_FIX_18;
                }
                if (BO.DWord[Bit_Ops.Bit18] == true)
                {
                    Result = Result + POS_FIX_19;
                }
                if (BO.DWord[Bit_Ops.Bit19] == true)
                {
                    Result = Result + POS_FIX_20;
                }
                if (BO.DWord[Bit_Ops.Bit20] == true)
                {
                    Result = Result + POS_FIX_21;
                }
                if (BO.DWord[Bit_Ops.Bit21] == true)
                {
                    Result = Result + POS_FIX_22;
                }
                if (BO.DWord[Bit_Ops.Bit22] == true)
                {
                    Result = Result + POS_FIX_23;
                }
                if (BO.DWord[Bit_Ops.Bit23] == true)
                {
                    Result = Result + POS_FIX_24;
                }
                if (BO.DWord[Bit_Ops.Bit24] == true)
                {
                    Result = Result + POS_FIX_25;
                }
                if (BO.DWord[Bit_Ops.Bit25] == true)
                {
                    Result = Result + POS_FIX_26;
                }
                if (BO.DWord[Bit_Ops.Bit26] == true)
                {
                    Result = Result + POS_FIX_27;
                }
                if (BO.DWord[Bit_Ops.Bit27] == true)
                {
                    Result = Result + POS_FIX_28;
                }

                Latitude = -Result;
            }
            else
            {
                ///////////////////////////////////////////////////////////////////////////////////////
                if (BO.DWord[Bit_Ops.Bit0] == true)
                {
                    Result = POS_FIX_1;
                }
                if (BO.DWord[Bit_Ops.Bit1] == true)
                {
                    Result = Result + POS_FIX_2;
                }
                if (BO.DWord[Bit_Ops.Bit2] == true)
                {
                    Result = Result + POS_FIX_3;
                }
                if (BO.DWord[Bit_Ops.Bit3] == true)
                {
                    Result = Result + POS_FIX_4;
                }
                if (BO.DWord[Bit_Ops.Bit4] == true)
                {
                    Result = Result + POS_FIX_5;
                }
                if (BO.DWord[Bit_Ops.Bit5] == true)
                {
                    Result = Result + POS_FIX_6;
                }
                if (BO.DWord[Bit_Ops.Bit6] == true)
                {
                    Result = Result + POS_FIX_7;
                }
                if (BO.DWord[Bit_Ops.Bit7] == true)
                {
                    Result = Result + POS_FIX_8;
                }
                if (BO.DWord[Bit_Ops.Bit8] == true)
                {
                    Result = Result + POS_FIX_9;
                }
                if (BO.DWord[Bit_Ops.Bit9] == true)
                {
                    Result = Result + POS_FIX_10;
                }
                if (BO.DWord[Bit_Ops.Bit10] == true)
                {
                    Result = Result + POS_FIX_11;
                }
                if (BO.DWord[Bit_Ops.Bit11] == true)
                {
                    Result = Result + POS_FIX_12;
                }
                if (BO.DWord[Bit_Ops.Bit12] == true)
                {
                    Result = Result + POS_FIX_13;
                }
                if (BO.DWord[Bit_Ops.Bit13] == true)
                {
                    Result = Result + POS_FIX_14;
                }
                if (BO.DWord[Bit_Ops.Bit14] == true)
                {
                    Result = Result + POS_FIX_15;
                }
                if (BO.DWord[Bit_Ops.Bit15] == true)
                {
                    Result = Result + POS_FIX_16;
                }
                if (BO.DWord[Bit_Ops.Bit16] == true)
                {
                    Result = Result + POS_FIX_17;
                }
                if (BO.DWord[Bit_Ops.Bit17] == true)
                {
                    Result = Result + POS_FIX_18;
                }
                if (BO.DWord[Bit_Ops.Bit18] == true)
                {
                    Result = Result + POS_FIX_19;
                }
                if (BO.DWord[Bit_Ops.Bit19] == true)
                {
                    Result = Result + POS_FIX_20;
                }
                if (BO.DWord[Bit_Ops.Bit20] == true)
                {
                    Result = Result + POS_FIX_21;
                }
                if (BO.DWord[Bit_Ops.Bit21] == true)
                {
                    Result = Result + POS_FIX_22;
                }
                if (BO.DWord[Bit_Ops.Bit22] == true)
                {
                    Result = Result + POS_FIX_23;
                }
                if (BO.DWord[Bit_Ops.Bit23] == true)
                {
                    Result = Result + POS_FIX_24;
                }
                if (BO.DWord[Bit_Ops.Bit24] == true)
                {
                    Result = Result + POS_FIX_25;
                }
                if (BO.DWord[Bit_Ops.Bit25] == true)
                {
                    Result = Result + POS_FIX_26;
                }
                if (BO.DWord[Bit_Ops.Bit26] == true)
                {
                    Result = Result + POS_FIX_27;
                }
                if (BO.DWord[Bit_Ops.Bit27] == true)
                {
                    Result = Result + POS_FIX_28;
                }

                Latitude = Result;
            }

            Result = 0.0;

            BO.DWord[Bit_Ops.Bits0_7_Of_DWord]   = Data[CAT62.CurrentDataBufferOctalIndex + 7];
            BO.DWord[Bit_Ops.Bits8_15_Of_DWord]  = Data[CAT62.CurrentDataBufferOctalIndex + 6];
            BO.DWord[Bit_Ops.Bits16_23_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 5];
            BO.DWord[Bit_Ops.Bits24_31_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 4];

            // Check for negative values
            if (BO.DWord[Bit_Ops.Bit31] == true)
            {
                BO.DWord[Bit_Ops.Bit0]  = !BO.DWord[Bit_Ops.Bit0];
                BO.DWord[Bit_Ops.Bit1]  = !BO.DWord[Bit_Ops.Bit1];
                BO.DWord[Bit_Ops.Bit2]  = !BO.DWord[Bit_Ops.Bit2];
                BO.DWord[Bit_Ops.Bit3]  = !BO.DWord[Bit_Ops.Bit3];
                BO.DWord[Bit_Ops.Bit4]  = !BO.DWord[Bit_Ops.Bit4];
                BO.DWord[Bit_Ops.Bit5]  = !BO.DWord[Bit_Ops.Bit5];
                BO.DWord[Bit_Ops.Bit6]  = !BO.DWord[Bit_Ops.Bit6];
                BO.DWord[Bit_Ops.Bit7]  = !BO.DWord[Bit_Ops.Bit7];
                BO.DWord[Bit_Ops.Bit8]  = !BO.DWord[Bit_Ops.Bit8];
                BO.DWord[Bit_Ops.Bit9]  = !BO.DWord[Bit_Ops.Bit9];
                BO.DWord[Bit_Ops.Bit10] = !BO.DWord[Bit_Ops.Bit10];
                BO.DWord[Bit_Ops.Bit11] = !BO.DWord[Bit_Ops.Bit11];
                BO.DWord[Bit_Ops.Bit12] = !BO.DWord[Bit_Ops.Bit12];
                BO.DWord[Bit_Ops.Bit13] = !BO.DWord[Bit_Ops.Bit13];
                BO.DWord[Bit_Ops.Bit14] = !BO.DWord[Bit_Ops.Bit14];
                BO.DWord[Bit_Ops.Bit15] = !BO.DWord[Bit_Ops.Bit15];
                BO.DWord[Bit_Ops.Bit16] = !BO.DWord[Bit_Ops.Bit16];
                BO.DWord[Bit_Ops.Bit17] = !BO.DWord[Bit_Ops.Bit17];
                BO.DWord[Bit_Ops.Bit18] = !BO.DWord[Bit_Ops.Bit18];
                BO.DWord[Bit_Ops.Bit19] = !BO.DWord[Bit_Ops.Bit19];
                BO.DWord[Bit_Ops.Bit20] = !BO.DWord[Bit_Ops.Bit20];
                BO.DWord[Bit_Ops.Bit21] = !BO.DWord[Bit_Ops.Bit21];
                BO.DWord[Bit_Ops.Bit22] = !BO.DWord[Bit_Ops.Bit22];
                BO.DWord[Bit_Ops.Bit23] = !BO.DWord[Bit_Ops.Bit23];
                BO.DWord[Bit_Ops.Bit24] = !BO.DWord[Bit_Ops.Bit24];
                BO.DWord[Bit_Ops.Bit25] = !BO.DWord[Bit_Ops.Bit25];
                BO.DWord[Bit_Ops.Bit26] = !BO.DWord[Bit_Ops.Bit26];
                BO.DWord[Bit_Ops.Bit27] = !BO.DWord[Bit_Ops.Bit27];
                BO.DWord[Bit_Ops.Bit28] = !BO.DWord[Bit_Ops.Bit28];
                BO.DWord[Bit_Ops.Bit29] = !BO.DWord[Bit_Ops.Bit29];
                BO.DWord[Bit_Ops.Bit30] = !BO.DWord[Bit_Ops.Bit30];
                BO.DWord[Bit_Ops.Bit31] = !BO.DWord[Bit_Ops.Bit31];
                BO.DWord[Bit_Ops.Bits16_31_Of_DWord] = BO.DWord[Bit_Ops.Bits16_31_Of_DWord] + 1;

                if (BO.DWord[Bit_Ops.Bit0] == true)
                {
                    Result = POS_FIX_1;
                }
                if (BO.DWord[Bit_Ops.Bit1] == true)
                {
                    Result = Result + POS_FIX_2;
                }
                if (BO.DWord[Bit_Ops.Bit2] == true)
                {
                    Result = Result + POS_FIX_3;
                }
                if (BO.DWord[Bit_Ops.Bit3] == true)
                {
                    Result = Result + POS_FIX_4;
                }
                if (BO.DWord[Bit_Ops.Bit4] == true)
                {
                    Result = Result + POS_FIX_5;
                }
                if (BO.DWord[Bit_Ops.Bit5] == true)
                {
                    Result = Result + POS_FIX_6;
                }
                if (BO.DWord[Bit_Ops.Bit6] == true)
                {
                    Result = Result + POS_FIX_7;
                }
                if (BO.DWord[Bit_Ops.Bit7] == true)
                {
                    Result = Result + POS_FIX_8;
                }
                if (BO.DWord[Bit_Ops.Bit8] == true)
                {
                    Result = Result + POS_FIX_9;
                }
                if (BO.DWord[Bit_Ops.Bit9] == true)
                {
                    Result = Result + POS_FIX_10;
                }
                if (BO.DWord[Bit_Ops.Bit10] == true)
                {
                    Result = Result + POS_FIX_11;
                }
                if (BO.DWord[Bit_Ops.Bit11] == true)
                {
                    Result = Result + POS_FIX_12;
                }
                if (BO.DWord[Bit_Ops.Bit12] == true)
                {
                    Result = Result + POS_FIX_13;
                }
                if (BO.DWord[Bit_Ops.Bit13] == true)
                {
                    Result = Result + POS_FIX_14;
                }
                if (BO.DWord[Bit_Ops.Bit14] == true)
                {
                    Result = Result + POS_FIX_15;
                }
                if (BO.DWord[Bit_Ops.Bit15] == true)
                {
                    Result = Result + POS_FIX_16;
                }
                if (BO.DWord[Bit_Ops.Bit16] == true)
                {
                    Result = Result + POS_FIX_17;
                }
                if (BO.DWord[Bit_Ops.Bit17] == true)
                {
                    Result = Result + POS_FIX_18;
                }
                if (BO.DWord[Bit_Ops.Bit18] == true)
                {
                    Result = Result + POS_FIX_19;
                }
                if (BO.DWord[Bit_Ops.Bit19] == true)
                {
                    Result = Result + POS_FIX_20;
                }
                if (BO.DWord[Bit_Ops.Bit20] == true)
                {
                    Result = Result + POS_FIX_21;
                }
                if (BO.DWord[Bit_Ops.Bit21] == true)
                {
                    Result = Result + POS_FIX_22;
                }
                if (BO.DWord[Bit_Ops.Bit22] == true)
                {
                    Result = Result + POS_FIX_23;
                }
                if (BO.DWord[Bit_Ops.Bit23] == true)
                {
                    Result = Result + POS_FIX_24;
                }
                if (BO.DWord[Bit_Ops.Bit24] == true)
                {
                    Result = Result + POS_FIX_25;
                }
                if (BO.DWord[Bit_Ops.Bit25] == true)
                {
                    Result = Result + POS_FIX_26;
                }
                if (BO.DWord[Bit_Ops.Bit26] == true)
                {
                    Result = Result + POS_FIX_27;
                }
                if (BO.DWord[Bit_Ops.Bit27] == true)
                {
                    Result = Result + POS_FIX_28;
                }

                Longitude = -Result;
            }
            else
            {
                if (BO.DWord[Bit_Ops.Bit0] == true)
                {
                    Result = POS_FIX_1;
                }
                if (BO.DWord[Bit_Ops.Bit1] == true)
                {
                    Result = Result + POS_FIX_2;
                }
                if (BO.DWord[Bit_Ops.Bit2] == true)
                {
                    Result = Result + POS_FIX_3;
                }
                if (BO.DWord[Bit_Ops.Bit3] == true)
                {
                    Result = Result + POS_FIX_4;
                }
                if (BO.DWord[Bit_Ops.Bit4] == true)
                {
                    Result = Result + POS_FIX_5;
                }
                if (BO.DWord[Bit_Ops.Bit5] == true)
                {
                    Result = Result + POS_FIX_6;
                }
                if (BO.DWord[Bit_Ops.Bit6] == true)
                {
                    Result = Result + POS_FIX_7;
                }
                if (BO.DWord[Bit_Ops.Bit7] == true)
                {
                    Result = Result + POS_FIX_8;
                }
                if (BO.DWord[Bit_Ops.Bit8] == true)
                {
                    Result = Result + POS_FIX_9;
                }
                if (BO.DWord[Bit_Ops.Bit9] == true)
                {
                    Result = Result + POS_FIX_10;
                }
                if (BO.DWord[Bit_Ops.Bit10] == true)
                {
                    Result = Result + POS_FIX_11;
                }
                if (BO.DWord[Bit_Ops.Bit11] == true)
                {
                    Result = Result + POS_FIX_12;
                }
                if (BO.DWord[Bit_Ops.Bit12] == true)
                {
                    Result = Result + POS_FIX_13;
                }
                if (BO.DWord[Bit_Ops.Bit13] == true)
                {
                    Result = Result + POS_FIX_14;
                }
                if (BO.DWord[Bit_Ops.Bit14] == true)
                {
                    Result = Result + POS_FIX_15;
                }
                if (BO.DWord[Bit_Ops.Bit15] == true)
                {
                    Result = Result + POS_FIX_16;
                }
                if (BO.DWord[Bit_Ops.Bit16] == true)
                {
                    Result = Result + POS_FIX_17;
                }
                if (BO.DWord[Bit_Ops.Bit17] == true)
                {
                    Result = Result + POS_FIX_18;
                }
                if (BO.DWord[Bit_Ops.Bit18] == true)
                {
                    Result = Result + POS_FIX_19;
                }
                if (BO.DWord[Bit_Ops.Bit19] == true)
                {
                    Result = Result + POS_FIX_20;
                }
                if (BO.DWord[Bit_Ops.Bit20] == true)
                {
                    Result = Result + POS_FIX_21;
                }
                if (BO.DWord[Bit_Ops.Bit21] == true)
                {
                    Result = Result + POS_FIX_22;
                }
                if (BO.DWord[Bit_Ops.Bit22] == true)
                {
                    Result = Result + POS_FIX_23;
                }
                if (BO.DWord[Bit_Ops.Bit23] == true)
                {
                    Result = Result + POS_FIX_24;
                }
                if (BO.DWord[Bit_Ops.Bit24] == true)
                {
                    Result = Result + POS_FIX_25;
                }
                if (BO.DWord[Bit_Ops.Bit25] == true)
                {
                    Result = Result + POS_FIX_26;
                }
                if (BO.DWord[Bit_Ops.Bit26] == true)
                {
                    Result = Result + POS_FIX_27;
                }

                Longitude = Result;
            }

            GeoCordSystemDegMinSecUtilities.LatLongClass LatLong = new GeoCordSystemDegMinSecUtilities.LatLongClass(Latitude, Longitude);

            //////////////////////////////////////////////////////////////////////////////////
            // Now assign it to the generic list
            CAT62.I062DataItems[CAT62.ItemIDToIndex("105")].value = LatLong;
            //////////////////////////////////////////////////////////////////////////////////

            // Increase data buffer index so it ready for the next data item.
            CAT62.CurrentDataBufferOctalIndex = CAT62.CurrentDataBufferOctalIndex + 8;
        }
        private static void DecodeAzimuthAndDistance(ref GeoCordSystemDegMinSecUtilities.LatLongClass NewPosition, out double Distance, out double Azimuth, Bit_Ops BO)
        {
            double Distance_Loc = 0.0;
            double Azimuth_Loc = 0.0;
            GeoCordSystemDegMinSecUtilities.LatLongClass ResultPosition = new GeoCordSystemDegMinSecUtilities.LatLongClass();
            ///////////////////////////////////////////////////////////////////////////////////////
            // Decode Distance
            ///////////////////////////////////////////////////////////////////////////////////////
            if (BO.DWord[Bit_Ops.Bit16] == true)
                Distance_Loc = RHO_1;
            if (BO.DWord[Bit_Ops.Bit17] == true)
                Distance_Loc = Distance_Loc + RHO_2;
            if (BO.DWord[Bit_Ops.Bit18] == true)
                Distance_Loc = Distance_Loc + RHO_3;
            if (BO.DWord[Bit_Ops.Bit19] == true)
                Distance_Loc = Distance_Loc + RHO_4;
            if (BO.DWord[Bit_Ops.Bit20] == true)
                Distance_Loc = Distance_Loc + RHO_5;
            if (BO.DWord[Bit_Ops.Bit21] == true)
                Distance_Loc = Distance_Loc + RHO_6;
            if (BO.DWord[Bit_Ops.Bit22] == true)
                Distance_Loc = Distance_Loc + RHO_7;
            if (BO.DWord[Bit_Ops.Bit23] == true)
                Distance_Loc = Distance_Loc + RHO_8;
            if (BO.DWord[Bit_Ops.Bit24] == true)
                Distance_Loc = Distance_Loc + RHO_9;
            if (BO.DWord[Bit_Ops.Bit25] == true)
                Distance_Loc = Distance_Loc + RHO_10;
            if (BO.DWord[Bit_Ops.Bit26] == true)
                Distance_Loc = Distance_Loc + RHO_11;
            if (BO.DWord[Bit_Ops.Bit27] == true)
                Distance_Loc = Distance_Loc + RHO_12;
            if (BO.DWord[Bit_Ops.Bit28] == true)
                Distance_Loc = Distance_Loc + RHO_13;
            if (BO.DWord[Bit_Ops.Bit29] == true)
                Distance_Loc = Distance_Loc + RHO_14;
            if (BO.DWord[Bit_Ops.Bit30] == true)
                Distance_Loc = Distance_Loc + RHO_15;
            if (BO.DWord[Bit_Ops.Bit31] == true)
                Distance_Loc = Distance_Loc + RHO_16;

            ///////////////////////////////////////////////////////////////////////////////////////
            // Decode Azimuth
            ///////////////////////////////////////////////////////////////////////////////////////
            if (BO.DWord[Bit_Ops.Bit0] == true)
                Azimuth_Loc = THETA_1;
            if (BO.DWord[Bit_Ops.Bit1] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_2;
            if (BO.DWord[Bit_Ops.Bit2] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_3;
            if (BO.DWord[Bit_Ops.Bit3] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_4;
            if (BO.DWord[Bit_Ops.Bit4] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_5;
            if (BO.DWord[Bit_Ops.Bit5] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_6;
            if (BO.DWord[Bit_Ops.Bit6] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_7;
            if (BO.DWord[Bit_Ops.Bit7] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_8;
            if (BO.DWord[Bit_Ops.Bit8] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_9;
            if (BO.DWord[Bit_Ops.Bit9] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_10;
            if (BO.DWord[Bit_Ops.Bit10] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_11;
            if (BO.DWord[Bit_Ops.Bit11] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_12;
            if (BO.DWord[Bit_Ops.Bit12] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_13;
            if (BO.DWord[Bit_Ops.Bit13] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_14;
            if (BO.DWord[Bit_Ops.Bit14] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_15;
            if (BO.DWord[Bit_Ops.Bit15] == true)
                Azimuth_Loc = Azimuth_Loc + THETA_16;

            Azimuth = Azimuth_Loc;
            Distance = Distance_Loc;

            //////////////////////////////////////////////////////////////////////////////////
            //
            // Here loop through the defined radars and determine the source of the data.
            // Once the source is determined calculate the extact position of the target
            // by taking the position of the radar and applying the range and bearing.
            // Display time of reception
            //
            // Extract the current SIC/SAC so the correct radar can be applied
            //
            ASTERIX.SIC_SAC_Time SIC_SAC_TIME = (ASTERIX.SIC_SAC_Time)CAT48.I048DataItems[CAT48.ItemIDToIndex("010")].value;
            foreach (SystemAdaptationDataSet.Radar RDS in SystemAdaptationDataSet.RadarDataSet)
            {
                // If the current SIC/SAC code matched the code of one of the defined radars
                // then go ahead and calculate the Lat/Long position.
                if (RDS.SIC == SIC_SAC_TIME.SIC.ToString() && RDS.SAC == SIC_SAC_TIME.SAC.ToString())
                {
                    ResultPosition = GeoCordSystemDegMinSecUtilities.CalculateNewPosition(RDS.RadarPosition, Distance_Loc, Azimuth_Loc);
                }
            }

            NewPosition.SetPosition(ResultPosition.GetLatLongDecimal());
        }
        public static void DecodeCAT62I105(byte[] Data)
        {
            // Get an instance of bit ops
            Bit_Ops BO = new Bit_Ops();

            BO.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 3];
            BO.DWord[Bit_Ops.Bits8_15_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 2];
            BO.DWord[Bit_Ops.Bits16_23_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 1];
            BO.DWord[Bit_Ops.Bits24_31_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex];

            double Result = 0.0;
            double Latitude = 0.0;
            double Longitude = 0.0;

            // Check for negative values
            if (BO.DWord[Bit_Ops.Bit31] == true)
            {
                BO.DWord[Bit_Ops.Bit0] = !BO.DWord[Bit_Ops.Bit0];
                BO.DWord[Bit_Ops.Bit1] = !BO.DWord[Bit_Ops.Bit1];
                BO.DWord[Bit_Ops.Bit2] = !BO.DWord[Bit_Ops.Bit2];
                BO.DWord[Bit_Ops.Bit3] = !BO.DWord[Bit_Ops.Bit3];
                BO.DWord[Bit_Ops.Bit4] = !BO.DWord[Bit_Ops.Bit4];
                BO.DWord[Bit_Ops.Bit5] = !BO.DWord[Bit_Ops.Bit5];
                BO.DWord[Bit_Ops.Bit6] = !BO.DWord[Bit_Ops.Bit6];
                BO.DWord[Bit_Ops.Bit7] = !BO.DWord[Bit_Ops.Bit7];
                BO.DWord[Bit_Ops.Bit8] = !BO.DWord[Bit_Ops.Bit8];
                BO.DWord[Bit_Ops.Bit9] = !BO.DWord[Bit_Ops.Bit9];
                BO.DWord[Bit_Ops.Bit10] = !BO.DWord[Bit_Ops.Bit10];
                BO.DWord[Bit_Ops.Bit11] = !BO.DWord[Bit_Ops.Bit11];
                BO.DWord[Bit_Ops.Bit12] = !BO.DWord[Bit_Ops.Bit12];
                BO.DWord[Bit_Ops.Bit13] = !BO.DWord[Bit_Ops.Bit13];
                BO.DWord[Bit_Ops.Bit14] = !BO.DWord[Bit_Ops.Bit14];
                BO.DWord[Bit_Ops.Bit15] = !BO.DWord[Bit_Ops.Bit15];
                BO.DWord[Bit_Ops.Bit16] = !BO.DWord[Bit_Ops.Bit16];
                BO.DWord[Bit_Ops.Bit17] = !BO.DWord[Bit_Ops.Bit17];
                BO.DWord[Bit_Ops.Bit18] = !BO.DWord[Bit_Ops.Bit18];
                BO.DWord[Bit_Ops.Bit19] = !BO.DWord[Bit_Ops.Bit19];
                BO.DWord[Bit_Ops.Bit20] = !BO.DWord[Bit_Ops.Bit20];
                BO.DWord[Bit_Ops.Bit21] = !BO.DWord[Bit_Ops.Bit21];
                BO.DWord[Bit_Ops.Bit22] = !BO.DWord[Bit_Ops.Bit22];
                BO.DWord[Bit_Ops.Bit23] = !BO.DWord[Bit_Ops.Bit23];
                BO.DWord[Bit_Ops.Bit24] = !BO.DWord[Bit_Ops.Bit24];
                BO.DWord[Bit_Ops.Bit25] = !BO.DWord[Bit_Ops.Bit25];
                BO.DWord[Bit_Ops.Bit26] = !BO.DWord[Bit_Ops.Bit26];
                BO.DWord[Bit_Ops.Bit27] = !BO.DWord[Bit_Ops.Bit27];
                BO.DWord[Bit_Ops.Bit28] = !BO.DWord[Bit_Ops.Bit28];
                BO.DWord[Bit_Ops.Bit29] = !BO.DWord[Bit_Ops.Bit29];
                BO.DWord[Bit_Ops.Bit30] = !BO.DWord[Bit_Ops.Bit30];
                BO.DWord[Bit_Ops.Bit31] = !BO.DWord[Bit_Ops.Bit31];
                BO.DWord[Bit_Ops.Bits16_31_Of_DWord] = BO.DWord[Bit_Ops.Bits16_31_Of_DWord] + 1;

                if (BO.DWord[Bit_Ops.Bit0] == true)
                    Result = POS_FIX_1;
                if (BO.DWord[Bit_Ops.Bit1] == true)
                    Result = Result + POS_FIX_2;
                if (BO.DWord[Bit_Ops.Bit2] == true)
                    Result = Result + POS_FIX_3;
                if (BO.DWord[Bit_Ops.Bit3] == true)
                    Result = Result + POS_FIX_4;
                if (BO.DWord[Bit_Ops.Bit4] == true)
                    Result = Result + POS_FIX_5;
                if (BO.DWord[Bit_Ops.Bit5] == true)
                    Result = Result + POS_FIX_6;
                if (BO.DWord[Bit_Ops.Bit6] == true)
                    Result = Result + POS_FIX_7;
                if (BO.DWord[Bit_Ops.Bit7] == true)
                    Result = Result + POS_FIX_8;
                if (BO.DWord[Bit_Ops.Bit8] == true)
                    Result = Result + POS_FIX_9;
                if (BO.DWord[Bit_Ops.Bit9] == true)
                    Result = Result + POS_FIX_10;
                if (BO.DWord[Bit_Ops.Bit10] == true)
                    Result = Result + POS_FIX_11;
                if (BO.DWord[Bit_Ops.Bit11] == true)
                    Result = Result + POS_FIX_12;
                if (BO.DWord[Bit_Ops.Bit12] == true)
                    Result = Result + POS_FIX_13;
                if (BO.DWord[Bit_Ops.Bit13] == true)
                    Result = Result + POS_FIX_14;
                if (BO.DWord[Bit_Ops.Bit14] == true)
                    Result = Result + POS_FIX_15;
                if (BO.DWord[Bit_Ops.Bit15] == true)
                    Result = Result + POS_FIX_16;
                if (BO.DWord[Bit_Ops.Bit16] == true)
                    Result = Result + POS_FIX_17;
                if (BO.DWord[Bit_Ops.Bit17] == true)
                    Result = Result + POS_FIX_18;
                if (BO.DWord[Bit_Ops.Bit18] == true)
                    Result = Result + POS_FIX_19;
                if (BO.DWord[Bit_Ops.Bit19] == true)
                    Result = Result + POS_FIX_20;
                if (BO.DWord[Bit_Ops.Bit20] == true)
                    Result = Result + POS_FIX_21;
                if (BO.DWord[Bit_Ops.Bit21] == true)
                    Result = Result + POS_FIX_22;
                if (BO.DWord[Bit_Ops.Bit22] == true)
                    Result = Result + POS_FIX_23;
                if (BO.DWord[Bit_Ops.Bit23] == true)
                    Result = Result + POS_FIX_24;
                if (BO.DWord[Bit_Ops.Bit24] == true)
                    Result = Result + POS_FIX_25;
                if (BO.DWord[Bit_Ops.Bit25] == true)
                    Result = Result + POS_FIX_26;
                if (BO.DWord[Bit_Ops.Bit26] == true)
                    Result = Result + POS_FIX_27;
                if (BO.DWord[Bit_Ops.Bit27] == true)
                    Result = Result + POS_FIX_28;

                Latitude = -Result;

            }
            else
            {
                ///////////////////////////////////////////////////////////////////////////////////////
                if (BO.DWord[Bit_Ops.Bit0] == true)
                    Result = POS_FIX_1;
                if (BO.DWord[Bit_Ops.Bit1] == true)
                    Result = Result + POS_FIX_2;
                if (BO.DWord[Bit_Ops.Bit2] == true)
                    Result = Result + POS_FIX_3;
                if (BO.DWord[Bit_Ops.Bit3] == true)
                    Result = Result + POS_FIX_4;
                if (BO.DWord[Bit_Ops.Bit4] == true)
                    Result = Result + POS_FIX_5;
                if (BO.DWord[Bit_Ops.Bit5] == true)
                    Result = Result + POS_FIX_6;
                if (BO.DWord[Bit_Ops.Bit6] == true)
                    Result = Result + POS_FIX_7;
                if (BO.DWord[Bit_Ops.Bit7] == true)
                    Result = Result + POS_FIX_8;
                if (BO.DWord[Bit_Ops.Bit8] == true)
                    Result = Result + POS_FIX_9;
                if (BO.DWord[Bit_Ops.Bit9] == true)
                    Result = Result + POS_FIX_10;
                if (BO.DWord[Bit_Ops.Bit10] == true)
                    Result = Result + POS_FIX_11;
                if (BO.DWord[Bit_Ops.Bit11] == true)
                    Result = Result + POS_FIX_12;
                if (BO.DWord[Bit_Ops.Bit12] == true)
                    Result = Result + POS_FIX_13;
                if (BO.DWord[Bit_Ops.Bit13] == true)
                    Result = Result + POS_FIX_14;
                if (BO.DWord[Bit_Ops.Bit14] == true)
                    Result = Result + POS_FIX_15;
                if (BO.DWord[Bit_Ops.Bit15] == true)
                    Result = Result + POS_FIX_16;
                if (BO.DWord[Bit_Ops.Bit16] == true)
                    Result = Result + POS_FIX_17;
                if (BO.DWord[Bit_Ops.Bit17] == true)
                    Result = Result + POS_FIX_18;
                if (BO.DWord[Bit_Ops.Bit18] == true)
                    Result = Result + POS_FIX_19;
                if (BO.DWord[Bit_Ops.Bit19] == true)
                    Result = Result + POS_FIX_20;
                if (BO.DWord[Bit_Ops.Bit20] == true)
                    Result = Result + POS_FIX_21;
                if (BO.DWord[Bit_Ops.Bit21] == true)
                    Result = Result + POS_FIX_22;
                if (BO.DWord[Bit_Ops.Bit22] == true)
                    Result = Result + POS_FIX_23;
                if (BO.DWord[Bit_Ops.Bit23] == true)
                    Result = Result + POS_FIX_24;
                if (BO.DWord[Bit_Ops.Bit24] == true)
                    Result = Result + POS_FIX_25;
                if (BO.DWord[Bit_Ops.Bit25] == true)
                    Result = Result + POS_FIX_26;
                if (BO.DWord[Bit_Ops.Bit26] == true)
                    Result = Result + POS_FIX_27;
                if (BO.DWord[Bit_Ops.Bit27] == true)
                    Result = Result + POS_FIX_28;

                Latitude = Result;
            }

            Result = 0.0;

            BO.DWord[Bit_Ops.Bits0_7_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 7];
            BO.DWord[Bit_Ops.Bits8_15_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 6];
            BO.DWord[Bit_Ops.Bits16_23_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 5];
            BO.DWord[Bit_Ops.Bits24_31_Of_DWord] = Data[CAT62.CurrentDataBufferOctalIndex + 4];

            // Check for negative values
            if (BO.DWord[Bit_Ops.Bit31] == true)
            {
                BO.DWord[Bit_Ops.Bit0] = !BO.DWord[Bit_Ops.Bit0];
                BO.DWord[Bit_Ops.Bit1] = !BO.DWord[Bit_Ops.Bit1];
                BO.DWord[Bit_Ops.Bit2] = !BO.DWord[Bit_Ops.Bit2];
                BO.DWord[Bit_Ops.Bit3] = !BO.DWord[Bit_Ops.Bit3];
                BO.DWord[Bit_Ops.Bit4] = !BO.DWord[Bit_Ops.Bit4];
                BO.DWord[Bit_Ops.Bit5] = !BO.DWord[Bit_Ops.Bit5];
                BO.DWord[Bit_Ops.Bit6] = !BO.DWord[Bit_Ops.Bit6];
                BO.DWord[Bit_Ops.Bit7] = !BO.DWord[Bit_Ops.Bit7];
                BO.DWord[Bit_Ops.Bit8] = !BO.DWord[Bit_Ops.Bit8];
                BO.DWord[Bit_Ops.Bit9] = !BO.DWord[Bit_Ops.Bit9];
                BO.DWord[Bit_Ops.Bit10] = !BO.DWord[Bit_Ops.Bit10];
                BO.DWord[Bit_Ops.Bit11] = !BO.DWord[Bit_Ops.Bit11];
                BO.DWord[Bit_Ops.Bit12] = !BO.DWord[Bit_Ops.Bit12];
                BO.DWord[Bit_Ops.Bit13] = !BO.DWord[Bit_Ops.Bit13];
                BO.DWord[Bit_Ops.Bit14] = !BO.DWord[Bit_Ops.Bit14];
                BO.DWord[Bit_Ops.Bit15] = !BO.DWord[Bit_Ops.Bit15];
                BO.DWord[Bit_Ops.Bit16] = !BO.DWord[Bit_Ops.Bit16];
                BO.DWord[Bit_Ops.Bit17] = !BO.DWord[Bit_Ops.Bit17];
                BO.DWord[Bit_Ops.Bit18] = !BO.DWord[Bit_Ops.Bit18];
                BO.DWord[Bit_Ops.Bit19] = !BO.DWord[Bit_Ops.Bit19];
                BO.DWord[Bit_Ops.Bit20] = !BO.DWord[Bit_Ops.Bit20];
                BO.DWord[Bit_Ops.Bit21] = !BO.DWord[Bit_Ops.Bit21];
                BO.DWord[Bit_Ops.Bit22] = !BO.DWord[Bit_Ops.Bit22];
                BO.DWord[Bit_Ops.Bit23] = !BO.DWord[Bit_Ops.Bit23];
                BO.DWord[Bit_Ops.Bit24] = !BO.DWord[Bit_Ops.Bit24];
                BO.DWord[Bit_Ops.Bit25] = !BO.DWord[Bit_Ops.Bit25];
                BO.DWord[Bit_Ops.Bit26] = !BO.DWord[Bit_Ops.Bit26];
                BO.DWord[Bit_Ops.Bit27] = !BO.DWord[Bit_Ops.Bit27];
                BO.DWord[Bit_Ops.Bit28] = !BO.DWord[Bit_Ops.Bit28];
                BO.DWord[Bit_Ops.Bit29] = !BO.DWord[Bit_Ops.Bit29];
                BO.DWord[Bit_Ops.Bit30] = !BO.DWord[Bit_Ops.Bit30];
                BO.DWord[Bit_Ops.Bit31] = !BO.DWord[Bit_Ops.Bit31];
                BO.DWord[Bit_Ops.Bits16_31_Of_DWord] = BO.DWord[Bit_Ops.Bits16_31_Of_DWord] + 1;

                if (BO.DWord[Bit_Ops.Bit0] == true)
                    Result = POS_FIX_1;
                if (BO.DWord[Bit_Ops.Bit1] == true)
                    Result = Result + POS_FIX_2;
                if (BO.DWord[Bit_Ops.Bit2] == true)
                    Result = Result + POS_FIX_3;
                if (BO.DWord[Bit_Ops.Bit3] == true)
                    Result = Result + POS_FIX_4;
                if (BO.DWord[Bit_Ops.Bit4] == true)
                    Result = Result + POS_FIX_5;
                if (BO.DWord[Bit_Ops.Bit5] == true)
                    Result = Result + POS_FIX_6;
                if (BO.DWord[Bit_Ops.Bit6] == true)
                    Result = Result + POS_FIX_7;
                if (BO.DWord[Bit_Ops.Bit7] == true)
                    Result = Result + POS_FIX_8;
                if (BO.DWord[Bit_Ops.Bit8] == true)
                    Result = Result + POS_FIX_9;
                if (BO.DWord[Bit_Ops.Bit9] == true)
                    Result = Result + POS_FIX_10;
                if (BO.DWord[Bit_Ops.Bit10] == true)
                    Result = Result + POS_FIX_11;
                if (BO.DWord[Bit_Ops.Bit11] == true)
                    Result = Result + POS_FIX_12;
                if (BO.DWord[Bit_Ops.Bit12] == true)
                    Result = Result + POS_FIX_13;
                if (BO.DWord[Bit_Ops.Bit13] == true)
                    Result = Result + POS_FIX_14;
                if (BO.DWord[Bit_Ops.Bit14] == true)
                    Result = Result + POS_FIX_15;
                if (BO.DWord[Bit_Ops.Bit15] == true)
                    Result = Result + POS_FIX_16;
                if (BO.DWord[Bit_Ops.Bit16] == true)
                    Result = Result + POS_FIX_17;
                if (BO.DWord[Bit_Ops.Bit17] == true)
                    Result = Result + POS_FIX_18;
                if (BO.DWord[Bit_Ops.Bit18] == true)
                    Result = Result + POS_FIX_19;
                if (BO.DWord[Bit_Ops.Bit19] == true)
                    Result = Result + POS_FIX_20;
                if (BO.DWord[Bit_Ops.Bit20] == true)
                    Result = Result + POS_FIX_21;
                if (BO.DWord[Bit_Ops.Bit21] == true)
                    Result = Result + POS_FIX_22;
                if (BO.DWord[Bit_Ops.Bit22] == true)
                    Result = Result + POS_FIX_23;
                if (BO.DWord[Bit_Ops.Bit23] == true)
                    Result = Result + POS_FIX_24;
                if (BO.DWord[Bit_Ops.Bit24] == true)
                    Result = Result + POS_FIX_25;
                if (BO.DWord[Bit_Ops.Bit25] == true)
                    Result = Result + POS_FIX_26;
                if (BO.DWord[Bit_Ops.Bit26] == true)
                    Result = Result + POS_FIX_27;
                if (BO.DWord[Bit_Ops.Bit27] == true)
                    Result = Result + POS_FIX_28;

                Longitude = -Result;
            }
            else
            {
                if (BO.DWord[Bit_Ops.Bit0] == true)
                    Result = POS_FIX_1;
                if (BO.DWord[Bit_Ops.Bit1] == true)
                    Result = Result + POS_FIX_2;
                if (BO.DWord[Bit_Ops.Bit2] == true)
                    Result = Result + POS_FIX_3;
                if (BO.DWord[Bit_Ops.Bit3] == true)
                    Result = Result + POS_FIX_4;
                if (BO.DWord[Bit_Ops.Bit4] == true)
                    Result = Result + POS_FIX_5;
                if (BO.DWord[Bit_Ops.Bit5] == true)
                    Result = Result + POS_FIX_6;
                if (BO.DWord[Bit_Ops.Bit6] == true)
                    Result = Result + POS_FIX_7;
                if (BO.DWord[Bit_Ops.Bit7] == true)
                    Result = Result + POS_FIX_8;
                if (BO.DWord[Bit_Ops.Bit8] == true)
                    Result = Result + POS_FIX_9;
                if (BO.DWord[Bit_Ops.Bit9] == true)
                    Result = Result + POS_FIX_10;
                if (BO.DWord[Bit_Ops.Bit10] == true)
                    Result = Result + POS_FIX_11;
                if (BO.DWord[Bit_Ops.Bit11] == true)
                    Result = Result + POS_FIX_12;
                if (BO.DWord[Bit_Ops.Bit12] == true)
                    Result = Result + POS_FIX_13;
                if (BO.DWord[Bit_Ops.Bit13] == true)
                    Result = Result + POS_FIX_14;
                if (BO.DWord[Bit_Ops.Bit14] == true)
                    Result = Result + POS_FIX_15;
                if (BO.DWord[Bit_Ops.Bit15] == true)
                    Result = Result + POS_FIX_16;
                if (BO.DWord[Bit_Ops.Bit16] == true)
                    Result = Result + POS_FIX_17;
                if (BO.DWord[Bit_Ops.Bit17] == true)
                    Result = Result + POS_FIX_18;
                if (BO.DWord[Bit_Ops.Bit18] == true)
                    Result = Result + POS_FIX_19;
                if (BO.DWord[Bit_Ops.Bit19] == true)
                    Result = Result + POS_FIX_20;
                if (BO.DWord[Bit_Ops.Bit20] == true)
                    Result = Result + POS_FIX_21;
                if (BO.DWord[Bit_Ops.Bit21] == true)
                    Result = Result + POS_FIX_22;
                if (BO.DWord[Bit_Ops.Bit22] == true)
                    Result = Result + POS_FIX_23;
                if (BO.DWord[Bit_Ops.Bit23] == true)
                    Result = Result + POS_FIX_24;
                if (BO.DWord[Bit_Ops.Bit24] == true)
                    Result = Result + POS_FIX_25;
                if (BO.DWord[Bit_Ops.Bit25] == true)
                    Result = Result + POS_FIX_26;
                if (BO.DWord[Bit_Ops.Bit26] == true)
                    Result = Result + POS_FIX_27;

                Longitude = Result;
            }

            GeoCordSystemDegMinSecUtilities.LatLongClass LatLong = new GeoCordSystemDegMinSecUtilities.LatLongClass(Latitude, Longitude);

            //////////////////////////////////////////////////////////////////////////////////
            // Now assign it to the generic list
            CAT62.I062DataItems[CAT62.ItemIDToIndex("105")].value = LatLong;
            //////////////////////////////////////////////////////////////////////////////////

            // Increase data buffer index so it ready for the next data item.
            CAT62.CurrentDataBufferOctalIndex = CAT62.CurrentDataBufferOctalIndex + 8;
        }
Exemple #25
0
        public override void OnRender(Graphics g)
        {
            Pen MyPen = new Pen(new SolidBrush(LabelAttributes.TargetColor), LabelAttributes.TargetSize);

            MyPen.DashStyle = LabelAttributes.TargetStyle;

            // Draw AC Symbol
            g.DrawRectangle(MyPen, LocalPosition.X - 5, LocalPosition.Y - 5, 10, 10);
            AC_SYMB_START_X = LocalPosition.X - 5;
            AC_SYMB_START_Y = LocalPosition.Y - 5;

            /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Here handle drawing of Range/Bearing & SEP tool
            if (TargetToMonitor != -1)
            {
                Point StartPosition = new Point(LocalPosition.X, LocalPosition.Y);
                Point EndPosition   = DynamicDisplayBuilder.GetTargetPositionByIndex(TargetToMonitor);
                g.DrawLine(new Pen(Brushes.Yellow, 1), StartPosition, EndPosition);

                // select a reference elllipsoid
                Ellipsoid reference = Ellipsoid.WGS84;
                // instantiate the calculator
                GeodeticCalculator  geoCalc    = new GeodeticCalculator();
                GlobalPosition      Start      = new GlobalPosition(new GlobalCoordinates(this.Position.Lat, this.Position.Lng));
                PointLatLng         End_LatLng = FormMain.FromLocalToLatLng(EndPosition.X, EndPosition.Y);
                GlobalPosition      End        = new GlobalPosition(new GlobalCoordinates(End_LatLng.Lat, End_LatLng.Lng));
                GeodeticMeasurement GM         = geoCalc.CalculateGeodeticMeasurement(reference, End, Start);

                ////////////////////////////////////////////////////////////////////////////////////////////
                // Handle SEP Tool
                double TRK1_SPD = 0.0, TRK2_SPD = 0.0;
                double TRK1_AZ = 0.0, TRK2_AZ = 0.0;
                bool   Sep_Data_Is_Valid = true;

                if (!double.TryParse(CALC_GSPD_STRING, out TRK1_SPD))
                {
                    if (!double.TryParse(DAP_GSPD, out TRK1_SPD))
                    {
                        Sep_Data_Is_Valid = false;
                    }
                }

                if (!double.TryParse(DynamicDisplayBuilder.GetTarget_CALC_GSPD_ByIndex(TargetToMonitor), out TRK2_SPD))
                {
                    if (!double.TryParse(DynamicDisplayBuilder.GetTarget_DAP_GSPD_ByIndex(TargetToMonitor), out TRK2_SPD))
                    {
                        Sep_Data_Is_Valid = false;
                    }
                }

                if (!double.TryParse(CALC_HDG_STRING, out TRK1_AZ))
                {
                    if (!double.TryParse(TRK, out TRK1_AZ))
                    {
                        if (!double.TryParse(DAP_HDG, out TRK1_AZ))
                        {
                            Sep_Data_Is_Valid = false;
                        }
                    }
                }

                if (!double.TryParse(DynamicDisplayBuilder.GetTarget_CALC_HDG_ByIndex(TargetToMonitor), out TRK2_AZ))
                {
                    if (!double.TryParse(DynamicDisplayBuilder.GetTargetTRKByIndex(TargetToMonitor), out TRK2_AZ))
                    {
                        if (!double.TryParse(DynamicDisplayBuilder.GetTargetM_HDGByIndex(TargetToMonitor), out TRK2_AZ))
                        {
                            Sep_Data_Is_Valid = false;
                        }
                    }
                }

                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // If all the necessary data is avilable
                // then pass it on to the SEP tool calculator
                // and then draw the result
                string SepToolActive = "N/A";
                if (Sep_Data_Is_Valid)
                {
                    SEP_Tool_Calculator         SepTool       = new SEP_Tool_Calculator(Start, End, TRK1_SPD, TRK2_SPD, TRK1_AZ, TRK2_AZ, 20);
                    SEP_Tool_Calculator.OutData Sep_Tool_Data = SepTool.GetResult();

                    if (Sep_Tool_Data.Is_Converging)
                    {
                        g.DrawRectangle(new Pen(Brushes.Yellow, LabelAttributes.TargetSize), Sep_Tool_Data.Track_1_Pos_Min.X - 5, Sep_Tool_Data.Track_1_Pos_Min.Y - 5, 10, 10);
                        g.DrawRectangle(new Pen(Brushes.Yellow, LabelAttributes.TargetSize), Sep_Tool_Data.Track_2_Pos_Min.X - 5, Sep_Tool_Data.Track_2_Pos_Min.Y - 5, 10, 10);
                        g.DrawLine(new Pen(Brushes.Yellow, LabelAttributes.TargetSize), new Point(Sep_Tool_Data.Track_1_Pos_Min.X, Sep_Tool_Data.Track_1_Pos_Min.Y), new Point(StartPosition.X, StartPosition.Y));
                        g.DrawLine(new Pen(Brushes.Yellow, LabelAttributes.TargetSize), new Point(Sep_Tool_Data.Track_2_Pos_Min.X, Sep_Tool_Data.Track_2_Pos_Min.Y), new Point(EndPosition.X, EndPosition.Y));
                        TimeSpan T = TimeSpan.FromSeconds(Sep_Tool_Data.SecondsToMinimum);
                        SepToolActive = "min d:" + Math.Round(Sep_Tool_Data.MinDistance, 1).ToString() + "/" + T.Minutes.ToString() + ":" + T.Seconds.ToString();
                    }
                }

                // Now compute position half way between two points.
                double distance = GM.PointToPointDistance / 2.0;
                if (distance > 0.0)
                {
                    GlobalCoordinates GC         = geoCalc.CalculateEndingGlobalCoordinates(reference, new GlobalCoordinates(End_LatLng.Lat, End_LatLng.Lng), GM.Azimuth, distance);
                    GPoint            GP         = FormMain.FromLatLngToLocal(new PointLatLng(GC.Latitude.Degrees, GC.Longitude.Degrees));
                    double            Distane_NM = 0.00053996 * GM.PointToPointDistance;
                    g.DrawString(Math.Round(GM.Azimuth.Degrees).ToString() + "°/" + Math.Round(Distane_NM, 1).ToString() + "nm", new Font(FontFamily.GenericSansSerif, 9), Brushes.Yellow, new PointF(GP.X, GP.Y));

                    if (Sep_Data_Is_Valid && SepToolActive != "N/A")
                    {
                        g.DrawString(SepToolActive, new Font(FontFamily.GenericSansSerif, 9), Brushes.Yellow, new PointF(GP.X, GP.Y + 15));
                    }
                }
            }

            // Here handle history points
            // First draw all previous history points
            int Number_of_Points_Drawn = 0;

            for (int Index = HistoryPoints.Count - 2; Index >= 0; Index--)
            {
                if (Number_of_Points_Drawn < Properties.Settings.Default.HistoryPoints)
                {
                    HistoryPointsType I = HistoryPoints.ElementAt(Index);
                    GPoint            MarkerPositionLocal = FormMain.gMapControl.FromLatLngToLocal(new PointLatLng(I.LatLong.Lat, I.LatLong.Lng));
                    g.DrawEllipse(MyPen, MarkerPositionLocal.X, MarkerPositionLocal.Y, 3, 3);
                    Number_of_Points_Drawn++;
                }
            }



            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Here draw speed vector
            // // Find out what data should be used for speed vector? IAS, TAS, GSPD, MACH?
            if ((DataItemValidator(CALC_HDG_STRING) || DataItemValidator(DAP_HDG) || DataItemValidator(TRK)) && (DataItemValidator(DAP_GSPD) || DataItemValidator(CALC_GSPD_STRING)))
            {
                double Azimuth = 0.0;
                double Range   = 0.0;

                if (DataItemValidator(CALC_GSPD_STRING))
                {
                    Range = double.Parse(CALC_GSPD_STRING);
                }
                else
                {
                    Range = double.Parse(DAP_GSPD);
                }

                if (DataItemValidator(CALC_HDG_STRING))
                {
                    Azimuth = double.Parse(CALC_HDG_STRING);
                }
                else if (DataItemValidator(TRK))
                {
                    Azimuth = double.Parse(TRK);
                }
                else
                {
                    Azimuth = double.Parse(DAP_HDG);
                }

                Range = (Range / 60) * (double)Properties.Settings.Default.SpeedVector;

                GeoCordSystemDegMinSecUtilities.LatLongClass ResultPosition =
                    GeoCordSystemDegMinSecUtilities.CalculateNewPosition(new GeoCordSystemDegMinSecUtilities.LatLongClass(Position.Lat, Position.Lng), (double)Range, (double)Azimuth);

                GPoint MarkerPositionLocal = FormMain.gMapControl.FromLatLngToLocal(new PointLatLng(ResultPosition.GetLatLongDecimal().LatitudeDecimal, ResultPosition.GetLatLongDecimal().LongitudeDecimal));
                g.DrawLine(MyPen, new Point(LocalPosition.X, LocalPosition.Y), new Point(MarkerPositionLocal.X, MarkerPositionLocal.Y));
            }
            else
            {
                int T = 9;
                int r = T;
            }
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            MyPen           = new Pen(new SolidBrush(LabelAttributes.LineColor), LabelAttributes.LineWidth);
            MyPen.DashStyle = LabelAttributes.LineStyle;

            // Draw leader line
            g.DrawLine(MyPen, new Point(LocalPosition.X, LocalPosition.Y), new Point(LocalPosition.X - LabelOffset.X, LocalPosition.Y - LabelOffset.Y));

            // Draw label box
            Point LabelStartPosition = GetLabelStartingPoint();

            // Recalculate Label Width each cycle to adjust for the possible changes in the number of lines
            // and changes in the text size
            LabelHeight = 0;

            // Draw ModeA and coast indicator
            g.DrawString(ModeA_CI_STRING, ModeA_CI_FONT, ModeA_CI_BRUSH, LabelStartPosition.X + ModeA_CI_OFFSET.X, LabelStartPosition.Y + SpacingIndex);
            LabelHeight = LabelHeight + (int)ModeA_CI_FONT.Size + SpacingIndex * 2;


            if (CALLSIGN_STRING != "--------")
            {
                // Draw CALLSIGN
                g.DrawString(CALLSIGN_STRING, CALLSIGN_FONT, CALLSIGN_BRUSH, LabelStartPosition.X + CALLSIGN_OFFSET.X, LabelStartPosition.Y + LabelHeight);
                LabelHeight = LabelHeight + (int)CALLSIGN_FONT.Size + SpacingIndex * 2;
            }

            // Draw ModeC
            g.DrawString(ModeC_STRING, ModeC_FONT, ModeC_BRUSH, LabelStartPosition.X + ModeC_OFFSET.X, LabelStartPosition.Y + LabelHeight);

            // Draw CFL on the same line
            if (ModeC_STRING == null)
            {
                ModeC_STRING = "---";
            }
            CFL_OFFSET.X = ModeC_STRING.Length * (int)ModeC_FONT.Size;
            CFL_OFFSET.Y = LabelStartPosition.Y + LabelHeight;
            g.DrawString(CFL_STRING, CFL_FONT, CFL_BRUSH, LabelStartPosition.X + CFL_OFFSET.X, CFL_OFFSET.Y);
            CFL_START_X = LabelStartPosition.X + CFL_OFFSET.X;
            CFL_START_Y = CFL_OFFSET.Y;

            // Draw GSPD on the same line
            GSPD_OFFSET.X = (ModeC_STRING.Length * (int)ModeC_FONT.Size) + (CFL_STRING.Length * (int)CFL_FONT.Size);
            GSPD_OFFSET.Y = LabelStartPosition.Y + LabelHeight;

            if (CALC_GSPD_STRING != " ---")
            {
                g.DrawString(CALC_GSPD_STRING, GSPD_FONT, GSPD_BRUSH, LabelStartPosition.X + GSPD_OFFSET.X, GSPD_OFFSET.Y);
            }
            else if (DAP_GSPD != "N/A")
            {
                g.DrawString(DAP_GSPD, GSPD_FONT, GSPD_BRUSH, LabelStartPosition.X + GSPD_OFFSET.X, GSPD_OFFSET.Y);
            }
            else
            {
                g.DrawString(" ---", GSPD_FONT, GSPD_BRUSH, LabelStartPosition.X + GSPD_OFFSET.X, GSPD_OFFSET.Y);
            }

            GSPD_START_X = LabelStartPosition.X + GSPD_OFFSET.X;
            GSPD_START_Y = GSPD_OFFSET.Y;

            LabelHeight = LabelHeight + (int)GSPD_FONT.Size + SpacingIndex * 2;

            if (ShowLabelBox == true)
            {
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //  DRAW Assigned HDG, SPD and ROC
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                // HDG
                g.DrawString(A_HDG_STRING, A_HDG_FONT, A_HDG_BRUSH, LabelStartPosition.X + A_HDG_OFFSET.X, LabelStartPosition.Y + LabelHeight);
                HDG_START_X = LabelStartPosition.X + A_HDG_OFFSET.X;
                HDG_START_Y = LabelStartPosition.Y + LabelHeight;

                // SPD
                A_SPD_OFFSET.X = A_HDG_STRING.Length * (int)A_HDG_FONT.Size;
                A_SPD_OFFSET.Y = LabelStartPosition.Y + LabelHeight;
                g.DrawString(A_SPD_STRING, A_SPD_FONT, A_SPD_BRUSH, LabelStartPosition.X + A_SPD_OFFSET.X, A_SPD_OFFSET.Y);
                SPD_START_X = LabelStartPosition.X + A_SPD_OFFSET.X;
                SPD_START_Y = A_SPD_OFFSET.Y;

                // ROC
                //A_ROC_OFFSET.X = A_SPD_OFFSET.X + A_SPD_OFFSET.X + A_SPD_STRING.Length * (int)A_SPD_FONT.Size;
                //A_ROC_OFFSET.Y = LabelStartPosition.Y + LabelHeight;
                // g.DrawString(A_ROC_STRING, A_ROC_FONT, A_ROC_BRUSH, LabelStartPosition.X + A_ROC_OFFSET.X, A_ROC_OFFSET.Y);

                LabelHeight = LabelHeight + (int)A_SPD_FONT.Size + SpacingIndex * 2;

                // Add the final spacing index and draw the box
                LabelHeight = LabelHeight + SpacingIndex * 2;
                g.DrawRectangle(MyPen, LabelStartPosition.X, LabelStartPosition.Y, LabelWidth, LabelHeight);
            }
        }
 public Waypoint(string W_Name, GeoCordSystemDegMinSecUtilities.LatLongClass W_Position, bool Is_COP_In)
 {
     WaypointName = W_Name;
     WaypointPosition = new GeoCordSystemDegMinSecUtilities.LatLongClass(W_Position.GetLatLongDecimal().LatitudeDecimal, W_Position.GetLatLongDecimal().LongitudeDecimal);
     Is_COP = Is_COP_In;
 }