Ejemplo n.º 1
0
        public static void Load()
        {
            string DisplayAdaptationDataLine;
            string FileName;

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

            FileName = @"C:\ASTERIX\ADAPTATION\DisplayAttributes.txt";

            if (System.IO.File.Exists(FileName))
            {
                MyStreamReader = System.IO.File.OpenText(FileName);
                while (MyStreamReader.Peek() >= 0)
                {
                    DisplayAdaptationDataLine = MyStreamReader.ReadLine();
                    string[] words = DisplayAdaptationDataLine.Split(delimiterChars);
                    if (words[0][0] != '#')
                    {
                        DisplayAttributes.DisplayAttributesType DisplayAttribute = new DisplayAttributes.DisplayAttributesType();

                        DisplayAttribute.ItemName         = words[0];
                        DisplayAttribute.TextSize         = int.Parse(words[1]);
                        DisplayAttribute.TextFont         = new FontFamily(words[2]);
                        DisplayAttribute.TextColor        = Color.FromName(words[3]);
                        DisplayAttribute.LineWidth        = int.Parse(words[4]);
                        DisplayAttribute.LineColor        = Color.FromName(words[5]);
                        DisplayAttribute.LineStyle        = DisplayAttributes.GetLineStypefromString(words[6]);
                        DisplayAttribute.AreaPolygonColor = Color.FromName(words[7]);
                        DisplayAttribute.ImageSize        = new Size(int.Parse(words[8]), int.Parse((words[9])));
                        DisplayAttributes.SetDisplayAttribute((DisplayAttributes.DisplayItemsType)Enum.Parse(typeof(DisplayAttributes.DisplayItemsType), DisplayAttribute.ItemName, true), DisplayAttribute);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Initialise()
        {
            StreamReader MyStreamReader;
            string       OneLine;

            char[] delimiterChars = { ',' };

            try
            {
                using (MyStreamReader = System.IO.File.OpenText(Properties.Settings.Default.Border))
                {
                    if (MyStreamReader != null)
                    {
                        // Parse the file and extract all data needed by EFD
                        while (MyStreamReader.Peek() >= 0)
                        {
                            OneLine = MyStreamReader.ReadLine();
                            string[] Words = OneLine.Split(delimiterChars);
                            GeoCordSystemDegMinSecUtilities.LatLongClass SectorPoint = new GeoCordSystemDegMinSecUtilities.LatLongClass(double.Parse(Words[0]), double.Parse(Words[1]));
                            Sector_List.Add(SectorPoint);
                        }
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 3
0
 public void StartParsing()
 {
     using (MyStreamReader sr = new MyStreamReader("Data1.txt"))
     {
         try
         {
             Logger.LogInfo("Start parsing...");
             Shipment shipment = new Shipment(sr, Logger);
             Logger.LogInfo("Ended parsing...");
         }
         catch (Exception ex)
         {
             Logger.LogError(ex.Message);
         }
     }
 }
Ejemplo n.º 4
0
        private void ReadInput()
        {
            //Start reading our file.
            LoggerSAP.Log("Reading in: {0}...", _csvEdbFileName);
            MyStreamReader sr = new MyStreamReader(_csvEdbFileName);
            string         csvLine;
            int            lineCount = 0;

            while (!sr.EndOfStream)
            {
                csvLine = sr.ReadLine(); lineCount++;
                AddNode(new CSVMeshNode.CSVMeshNodeTemplate(csvLine)); //No need to explicitly wait for semaphore, because AddNode() already does this.
                Thread.SpinWait(1);                                    //Give away a little of processor time.
            }
            sr.Close();
            LoggerSAP.Log("Finished reading {0} ({1} entries).", _csvEdbFileName, lineCount);
        }
Ejemplo n.º 5
0
        public static FIXPOINT_TYPE Get_LATLNG(string FIX)
        {
            FIXPOINT_TYPE Return_FIX = new FIXPOINT_TYPE();
            string        FIXPOINT_Data;
            string        FileName = Path.Combine(CBS_Main.Get_AIRAC_Dir(), "fixpoints");

            char[]       delimiterChars = { ';' };
            StreamReader MyStreamReader;

            if (File.Exists(FileName))
            {
                // Lets read in settings from the file
                MyStreamReader = System.IO.File.OpenText(FileName);

                while (MyStreamReader.Peek() >= 0)
                {
                    FIXPOINT_Data = MyStreamReader.ReadLine();
                    string[] words = FIXPOINT_Data.Split(delimiterChars);

                    if (words[0] == FIX)
                    {
                        Return_FIX.Is_Found = true;
                        Return_FIX.Name     = FIX;

                        string sLAT = words[4];
                        if (words[4][0] == '.')
                        {
                            sLAT = '0' + words[4];
                        }

                        string sLON = words[5];
                        if (words[5][0] == '.')
                        {
                            sLON = '0' + words[5];
                        }

                        double LAT = double.Parse(sLAT);
                        double LNG = double.Parse(sLON);
                        Return_FIX.SetPosition(LAT, LNG);
                        break;
                    }
                }
            }
            return(Return_FIX);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            ILogger logger = new StaticLogger();

            using (MyStreamReader sr = new MyStreamReader("Data1.txt"))
            {
                try
                {
                    logger.LogInfo("Start parsing...");
                    Shipment shipment = new Shipment(sr, logger);
                    logger.LogInfo("Ended parsing...");
                }
                catch (Exception ex)
                {
                    logger.LogError(ex.Message);
                }
                Console.Out.WriteLine("Done...");
                Console.ReadKey();
            }
        }
Ejemplo n.º 7
0
        public static void Load()
        {
            string ConfigurationData;
            string FileName;

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

            string CurrentItem;
            string SectorName = "NONE";

            int    LatDeg;
            int    LatMin;
            double LatSec;

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

            GeoCordSystemDegMinSecUtilities.LatLongPrefix LonPrefix;

            System.Collections.Generic.List <GeoCordSystemDegMinSecUtilities.LatLongClass> Sector_Points = new List <GeoCordSystemDegMinSecUtilities.LatLongClass>();

            FileName = @"C:\ASTERIX\ADAPTATION\Sectors.txt";
            Exception Bad_Sectors = new Exception("Bad Sectors.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] != '#')
                    {
                        // Get Item
                        CurrentItem = words[0];

                        // If the is a name, then it is a new sector
                        if (words[0] == "SECTOR_NAME")
                        {
                            // If we have reached a new name it means that we have parsed
                            // the data for previous sector
                            if (SectorName != "NONE")
                            {
                                // Now add the new sector to the data set
                                SystemAdaptationDataSet.SectorBorderDataSet.Add(new SystemAdaptationDataSet.SectorBorder(SectorName, Sector_Points));

                                // Save off the new name
                                SectorName = words[1];

                                // Empty the list so it is ready for the next sector
                                Sector_Points = new List <GeoCordSystemDegMinSecUtilities.LatLongClass>();
                            }
                            // This is first sector so just save off the name
                            else
                            {
                                SectorName = words[1];
                            }
                        }
                        // This a new point, so extract it an save it into a local list
                        else
                        {
                            // Get Latitude
                            if (int.TryParse(words[0], out LatDeg) == false)
                            {
                                throw Bad_Sectors;
                            }
                            if (int.TryParse(words[1], out LatMin) == false)
                            {
                                throw Bad_Sectors;
                            }
                            if (Double.TryParse(words[2], out LatSec) == false)
                            {
                                throw Bad_Sectors;
                            }
                            switch (words[3])
                            {
                            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_Sectors;
                            }

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

                            switch (words[7])
                            {
                            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_Sectors;
                            }

                            Sector_Points.Add((new GeoCordSystemDegMinSecUtilities.LatLongClass(LatDeg, LatMin, LatSec,
                                                                                                LatPrefix, LonDeg, LonMin, LonSec, LonPrefix)));
                        }
                    }
                }

                // Now add the last processed sector
                SystemAdaptationDataSet.SectorBorderDataSet.Add(new SystemAdaptationDataSet.SectorBorder(SectorName, Sector_Points));
            }
        }
Ejemplo n.º 8
0
        public static void Initialize()
        {
            /////////////////////////////////////////////////////////////////
            // First check where we are running and prepare app
            //
            if (Get_Host_OS() == Host_OS.LINUX)
            {
                // Linux
                Source_Path        = "/var/EFD/";
                flights_Path       = "/var/cbs/prediction/flights/";
                System_Status_Path = "/var/cbs/prediction/systemStatus/";
                Main_Status_Path   = "/var/cbs/prediction/status/";
                App_Settings_Path  = "/var/cbs/settings/EFD/";
                AIRAC_Data_Path    = "/var/cbs/settings/AIRAC/";
                Tmp_Directory      = "/tmp/";
            }

            // Now make sure that proper directory structure
            // is set up on the host machine
            if (Directory.Exists(App_Settings_Path) == false)
            {
                Directory.CreateDirectory(App_Settings_Path);
                WriteToLogFile("Creating " + App_Settings_Path);
            }
            if (Directory.Exists(Source_Path) == false)
            {
                Directory.CreateDirectory(Source_Path);
                WriteToLogFile("Creating " + Source_Path);
            }
            if (Directory.Exists(flights_Path) == false)
            {
                Directory.CreateDirectory(flights_Path);
                WriteToLogFile("Creating " + flights_Path);
            }
            if (Directory.Exists(System_Status_Path) == false)
            {
                Directory.CreateDirectory(System_Status_Path);
                WriteToLogFile("Creating " + System_Status_Path);
            }
            if (Directory.Exists(Main_Status_Path) == false)
            {
                Directory.CreateDirectory(Main_Status_Path);
                WriteToLogFile("Creating " + Main_Status_Path);
            }
            if (Directory.Exists(AIRAC_Data_Path) == false)
            {
                Directory.CreateDirectory(AIRAC_Data_Path);
                WriteToLogFile("Creating " + AIRAC_Data_Path);
            }
            if (Directory.Exists(Tmp_Directory) == false)
            {
                Directory.CreateDirectory(Tmp_Directory);
                WriteToLogFile("Creating " + Tmp_Directory);
            }

            // Check if cbs_config.txt exists, if so load settings
            // data saved from the previous session
            string Settings_Data;
            string FileName = Path.Combine(App_Settings_Path, "cbs_config.txt");

            char[]       delimiterChars = { ' ' };
            StreamReader MyStreamReader;

            if (File.Exists(FileName))
            {
                WriteToLogFile("Processing " + FileName);

                // Lets read in settings from the file
                MyStreamReader = System.IO.File.OpenText(FileName);
                while (MyStreamReader.Peek() >= 0)
                {
                    Settings_Data = MyStreamReader.ReadLine();
                    if (Settings_Data[0] != '#')
                    {
                        string[] words = Settings_Data.Split(delimiterChars);

                        switch (words[0])
                        {
                        case "SOURCE_DIR":
                            Source_Path = words[1];
                            break;

                        case "FLIGHTS_DIR":
                            flights_Path = words[1];
                            break;

                        case "SYSTEM_STATUS_DIR":
                            System_Status_Path = words[1];
                            break;

                        case "MAIN_STATUS_DIR":
                            Main_Status_Path = words[1];
                            break;

                        case "HEART_BEAT":
                            HEART_BEAT = words[1];
                            break;

                        case "COLD_POWER_UP":
                            Cold_Start_Timeout_Min = int.Parse(words[1]);
                            break;

                        case "SYS_STATUS_UPDATE_RATE":
                            System_Status_Update_Rate_Sec = int.Parse(words[1]);
                            break;

                        case "NO_EFD_DATA_TIMEOUT":
                            No_EFD_Data_Timout = int.Parse(words[1]);
                            break;

                        case "AIRAC_DATA_SOURCE":
                            AIRAC_Data_Path = words[1];
                            break;

                        case "MYSQL_SERVER":
                            MySqlWriter.MySQLConnetionString.server_name = words[1];
                            break;

                        case "MYSQL_USER":
                            MySqlWriter.MySQLConnetionString.login_name = words[1];
                            break;

                        case "MYSQL_DATABASE":
                            MySqlWriter.MySQLConnetionString.database = words[1];
                            break;

                        case "MYSQL_TABLE":
                            MySqlWriter.MySQLConnetionString.table_name = words[1];
                            break;

                        case "DEBUG":
                            debug_on = words[1];
                            break;

                        default:
                            break;
                        }
                    }
                }

                MyStreamReader.Close();
                MyStreamReader.Dispose();

                // Here check if there has been more than parameter since
                // application has been down
                TimeSpan TenMin  = new TimeSpan(0, Cold_Start_Timeout_Min, 0);
                TimeSpan AppDown = DateTime.UtcNow - Get_Power_OFF_Time();

                // Now check if the application has been down for more than
                // 10 minutes. If so then clear the directory
                if (AppDown > TenMin)
                {
                    ClearSourceDirectory();
                    WriteToLogFile("APP down for more then 10min, clearing " + Source_Path);
                }
                else
                {
                    // Call routine to process all files that might have
                    // arrived in the last 10 minutes or less.
                }

                // Lets save once so HART BEAT gets saved right away
                SaveSettings();
            }
            else
            {
                // Lets then create one with default setting
                SaveSettings();

                // Since we had no idea when the application was last powered off
                // we assume it has been more than timuout parameter, sop lets delete all files
                ClearSourceDirectory();
                WriteToLogFile("APP down time unknown, clearing " + Source_Path);
            }

            // Now start heart beat timer.
            Cold_Start_Timer          = new System.Timers.Timer(10000); // Set up the timer for 1minute
            Cold_Start_Timer.Elapsed += new ElapsedEventHandler(_HEART_BEAT_timer_Elapsed);
            Cold_Start_Timer.Enabled  = true;

            // Start input data monitor
            EFD_File_Handler.Initialise();

            // Open up connection to the MySQL database
            MySqlWriter.Initialise();

            //////////////////////////////////////////////////////
            // Start periodic timer that will drive system status
            // update logic
            // Now start heart beat timer.
            System_Status_Timer          = new System.Timers.Timer((System_Status_Update_Rate_Sec * 100)); // Set up the timer for 1minute
            System_Status_Timer.Elapsed += new ElapsedEventHandler(System_Status_Periodic_Update);
            System_Status_Timer.Enabled  = true;
            CBS_Main.WriteToLogFile("Started system status heart beat timer");
        }
Ejemplo n.º 9
0
        public static void Load()
        {
            string DisplayAdaptationDataLine;
            string FileName;

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

            FileName = @"C:\ASTERIX\ADAPTATION\LabelAttributes.txt";

            if (System.IO.File.Exists(FileName))
            {
                MyStreamReader = System.IO.File.OpenText(FileName);
                while (MyStreamReader.Peek() >= 0)
                {
                    DisplayAdaptationDataLine = MyStreamReader.ReadLine();
                    string[] words = DisplayAdaptationDataLine.Split(delimiterChars);
                    if (words[0][0] != '#')
                    {
                        switch (words[0])
                        {
                        case "TEXT_COLOR":
                            TextColor = Color.FromName(words[1]);
                            break;

                        case "TEXT_FONT":
                            TextFont = new FontFamily(words[1]);
                            break;

                        case "TEXT_SIZE":
                            TextSize = int.Parse(words[1]);
                            break;

                        case "LINE_COLOR":
                            LineColor = Color.FromName(words[1]);
                            break;

                        case "LINE_STYLE":
                            LineStyle = DisplayAttributes.GetLineStypefromString(words[1]);
                            break;

                        case "LINE_WIDTH":
                            LineWidth = int.Parse(words[1]);
                            break;

                        case "TARGET_COLOR":
                            TargetColor = Color.FromName(words[1]);
                            break;

                        case "TARGET_STYLE":
                            TargetStyle = DisplayAttributes.GetLineStypefromString(words[1]);
                            break;

                        case "TARGET_SIZE":
                            TargetSize = int.Parse(words[1]);
                            break;

                        default:
                            MessageBox.Show("Bad format of LabelAttributes.txt");
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public static void Load()
        {
            string ConfigurationData;
            string FileName;

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

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

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

            GeoCordSystemDegMinSecUtilities.LatLongPrefix LonPrefix;

            FileName = @"C:\ASTERIX\ADAPTATION\Waypoints.txt";
            Exception Bad_Waypoints = new Exception("Bad Waypoints.txt file");
            bool      Is_COP;

            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] != '#')
                    {
                        ItemName = words[0];
                        // Get Radar Name

                        // Get Latitude
                        if (int.TryParse(words[1], out LatDeg) == false)
                        {
                            throw Bad_Waypoints;
                        }
                        if (int.TryParse(words[2], out LatMin) == false)
                        {
                            throw Bad_Waypoints;
                        }
                        if (Double.TryParse(words[3], out LatSec) == false)
                        {
                            throw Bad_Waypoints;
                        }
                        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_Waypoints;
                        }

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

                        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_Waypoints;
                        }

                        if (words[9] == "TRUE")
                        {
                            Is_COP = true;
                        }
                        else
                        {
                            Is_COP = false;
                        }

                        // Now add the radar
                        SystemAdaptationDataSet.WaypointDataSet.Add(new SystemAdaptationDataSet.Waypoint(ItemName, new GeoCordSystemDegMinSecUtilities.LatLongClass(LatDeg, LatMin, LatSec,
                                                                                                                                                                    LatPrefix, LonDeg, LonMin, LonSec, LonPrefix), Is_COP));
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public static void Load()
        {
            string ConfigurationData;
            string FileName;

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

            string CurrentItem;
            string StateName = "NONE";
            double Lat;
            double Lon;


            System.Collections.Generic.List <GeoCordSystemDegMinSecUtilities.LatLongClass> Sector_Points = new List <GeoCordSystemDegMinSecUtilities.LatLongClass>();

            FileName = @"C:\ASTERIX\ADAPTATION\States.txt";
            Exception Bad_States = new Exception("Bad States.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] != '#')
                    {
                        // Get Item
                        CurrentItem = words[0];

                        // If the is a name, then it is a new sector
                        if (words[0] == "STATE_NAME")
                        {
                            // If we have reached a new name it means that we have parsed
                            // the data for previous sector
                            if (StateName != "NONE")
                            {
                                // Now add the new sector to the data set
                                SystemAdaptationDataSet.StateBorderDataSet.Add(new SystemAdaptationDataSet.StateBorder(StateName, Sector_Points));

                                // Save off the new name
                                StateName = words[1];

                                // Empty the list so it is ready for the next sector
                                Sector_Points = new List <GeoCordSystemDegMinSecUtilities.LatLongClass>();
                            }
                            // This is first sector so just save off the name
                            else
                            {
                                StateName = words[1];
                            }
                        }
                        // This a new point, so extract it an save it into a local list
                        else
                        {
                            // Get Longitude
                            if (double.TryParse(words[0], out Lon) == false)
                            {
                                throw Bad_States;
                            }
                            // Get Latitude
                            if (double.TryParse(words[1], out Lat) == false)
                            {
                                throw Bad_States;
                            }

                            Sector_Points.Add((new GeoCordSystemDegMinSecUtilities.LatLongClass(Lat, Lon)));
                        }
                    }
                }

                // Now add the last processed sector
                SystemAdaptationDataSet.StateBorderDataSet.Add(new SystemAdaptationDataSet.StateBorder(StateName, Sector_Points));
            }
        }
Ejemplo n.º 12
0
        public static void Load()
        {
            string ConfigurationData;
            string FileName;

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

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

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

            GeoCordSystemDegMinSecUtilities.LatLongPrefix LonPrefix;

            FileName = @"C:\ASTERIX\ADAPTATION\Radars.txt";
            Exception Bad_Radars = new Exception("Bad Radars.txt file");
            string    SIC, SAC;

            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] != '#')
                    {
                        // Sarajevo_TWR,	43, 49, 11.76, E, 18, 20, 23.4, N, 8, 34
                        ItemName = words[0];
                        // Get Radar Name

                        // Get Latitude
                        if (int.TryParse(words[1], out LatDeg) == false)
                        {
                            throw Bad_Radars;
                        }
                        if (int.TryParse(words[2], out LatMin) == false)
                        {
                            throw Bad_Radars;
                        }
                        if (Double.TryParse(words[3], out LatSec) == false)
                        {
                            throw Bad_Radars;
                        }
                        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_Radars;
                        }

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

                        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_Radars;
                        }

                        // Get SIC/SAC
                        SIC = words[9];
                        SAC = words[10];

                        // Now add the radar
                        SystemAdaptationDataSet.RadarDataSet.Add(new SystemAdaptationDataSet.Radar(ItemName, new GeoCordSystemDegMinSecUtilities.LatLongClass(LatDeg, LatMin, LatSec,
                                                                                                                                                              LatPrefix, LonDeg, LonMin, LonSec, LonPrefix), SIC, SAC));
                    }
                }
            }
            else
            {
                // As a default two radars (Jahorina and Sarajevo TWR are loaded, however it will be modified during the
                // system power on via configuration files if they exist.
                // Add SJJ TWR
                SystemAdaptationDataSet.RadarDataSet.Add(new SystemAdaptationDataSet.Radar("SJJ TWR", new GeoCordSystemDegMinSecUtilities.LatLongClass(43, 49, 11.76, GeoCordSystemDegMinSecUtilities.LatLongPrefix.E, 18, 20, 23.4, GeoCordSystemDegMinSecUtilities.LatLongPrefix.N), "8", "34"));
                // Add Jahorina
                SystemAdaptationDataSet.RadarDataSet.Add(new SystemAdaptationDataSet.Radar("Jahorina", new GeoCordSystemDegMinSecUtilities.LatLongClass(43, 43, 33.69, GeoCordSystemDegMinSecUtilities.LatLongPrefix.E, 18, 33, 5.69, GeoCordSystemDegMinSecUtilities.LatLongPrefix.N), "23", "2"));
            }
        }
Ejemplo n.º 13
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);
            }
        }