Example #1
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
            {
            }
        }
Example #2
0
            internal void Copy(NowPlaying src)
            {
                SeekPosition = src.SeekPosition;
                Length       = src.Length;
                if (OneLine == null || src.OneLine == null)
                {
                    OneLine = src.OneLine;
                }
                else
                {
                    OneLine.Copy(src.OneLine);
                }
                if (TwoLine == null || src.TwoLine == null)
                {
                    TwoLine = src.TwoLine;
                }
                else
                {
                    TwoLine.Copy(src.TwoLine);
                }
                if (ThreeLine == null || src.ThreeLine == null)
                {
                    ThreeLine = src.ThreeLine;
                }
                else
                {
                    ThreeLine.Copy(src.ThreeLine);
                }

                ImageKey = src.ImageKey;
            }
Example #3
0
        private void ScalarToYaml(YamlScalar node, string pres, Context c)
        {
            var s = node.Value;

            // If tag can be resolved from the content, or tag is !!str,
            // no need to explicitly specify it.
            var auto_tag = YamlNode.ShorthandTag(AutoTagResolver.Resolve(s));
            var tag      = TagToYaml(node, auto_tag);

            if (tag != "" && tag != "!!str")
            {
                Write(tag + " ");
            }

            if (IsValidPlainText(s, c) && !(node.ShorthandTag() == "!!str" && auto_tag != null && !node.Properties.ContainsKey("plainText")))
            {
                // one line plain style
                Write(s);
                if (c != Context.NoBreak)
                {
                    WriteLine();
                }
            }
            else
            {
                if (ForbiddenChars.IsMatch(s) || OneLine.IsMatch(s) ||
                    (config.ExplicitlyPreserveLineBreaks &&
                     GetPropertyOrNull(node, "Don'tCareLineBreaks") == null))
                {
                    // double quoted
                    Write(DoubleQuotedString.Quote(s, pres, c));
                    if (c != Context.NoBreak)
                    {
                        WriteLine();
                    }
                }
                else
                {
                    // Literal style
                    if (s[s.Length - 1] == '\n' || s[s.Length - 1] == '\r')
                    {
                        WriteLine("|+2");
                    }
                    else
                    {
                        WriteLine("|-2");
                        s += "\r\n"; // guard
                    }
                    var press = pres + "  ";
                    for (int p = 0; p < s.Length;)
                    {
                        var m = UntilBreak.Match(s, p); // does not fail because of the guard
                        Write(pres + s.Substring(p, m.Length));
                        p += m.Length;
                    }
                }
            }
        }
Example #4
0
        public EFD_Msg(StreamReader Reader)
        {
            string OneLine;

            char[] delimiterChars = { ' ' };

            // Parse the file and extract all data needed by EFD
            while (Reader.Peek() >= 0)
            {
                OneLine = Reader.ReadLine();
                string[] Words = OneLine.Split(delimiterChars);
                Waypoint WPT   = new Waypoint();

                try
                {
                    switch (Words[0])
                    {
                    case "-IFPLID":
                        IFPLID = Words[1];
                        break;

                    case "-ARCID":
                        ACID = Words[1];
                        break;

                    case "-FLTSTATE":
                        FLTSTATE = Words[1];
                        break;

                    case "-ARCTYP":
                        ARCTYP = Words[1];
                        break;

                    case "-ADEP":
                        ADEP = Words[1];
                        break;

                    case "-ADES":
                        ADES = Words[1];
                        break;

                    case "-EOBT":
                        EOBT = Words[1];
                        break;

                    case "-EOBD":
                        EOBD = Words[1];
                        break;

                    case "-GEO":
                        try
                        {
                            string LAT = Words[4];
                            string LON = Words[6];
                            // -LATTD 550302N -LONGTD 1070037W
                            int LAT_DEG = int.Parse(LAT.Substring(0, 2));
                            int LAT_MIN = int.Parse(LAT.Substring(2, 2));
                            int LAT_SEC = int.Parse(LAT.Substring(4, 2));
                            GeoCordSystemDegMinSecUtilities.LatLongPrefix LAT_Prefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.Not_Valid;
                            if (LAT[6] == 'N')
                            {
                                LAT_Prefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.N;
                            }
                            else
                            {
                                LAT_Prefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.S;
                            }

                            int LON_DEG = int.Parse(LON.Substring(0, 3));
                            int LON_MIN = int.Parse(LON.Substring(3, 2));
                            int LON_SEC = int.Parse(LON.Substring(5, 2));
                            GeoCordSystemDegMinSecUtilities.LatLongPrefix LON_Prefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.Not_Valid;
                            if (LON[7] == 'W')
                            {
                                LON_Prefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.W;
                            }
                            else
                            {
                                LON_Prefix = GeoCordSystemDegMinSecUtilities.LatLongPrefix.E;
                            }

                            WPT.Name                = Words[2];
                            WPT.Position            = new GeoCordSystemDegMinSecUtilities.LatLongClass(LAT_DEG, LAT_MIN, LAT_SEC, LAT_Prefix, LON_DEG, LON_MIN, LON_SEC, LON_Prefix);
                            WPT.Position_Determined = true;
                            GEO_Artifical_List.Add(WPT);
                        }
                        catch (Exception e)
                        {
                            CBS_Main.WriteToLogFile("Exception in EFD_Msg.cs, -GEP Parsing: " + e.Message);
                        }
                        break;

                    case "-BEGIN":
                        if (Words[1] == "RTEPTS")
                        {
                        }
                        else if (Words[1] == "ASPLIST")
                        {
                        }
                        else
                        {
                        }
                        break;

                    // Maastricht UAC Entry and Exit Times
                    // -ASP -AIRSPDES EDYYAOI -ETI 130404091206 -XTI 130404095840
                    case "":
                        if ((Words.Length == 8) && (Words[1] == "-ASP"))
                        {
                            // Always extract UAC Entry and Exit Times
                            if ((Words[2] == "-AIRSPDES") && (Words[3] == "EDYYAOI"))
                            {
                                AOI_ENTRY_TIME = CBS_Main.GetDate_Time_From_YYYYMMDDHHMMSS("20" + Words[5]);
                                AOI_ENTRY_TIME_YYMMDDHHMMSS = "20" + Words[5];
                                AOI_EXIT_TIME = CBS_Main.GetDate_Time_From_YYYYMMDDHHMMSS("20" + Words[7]);
                                AOI_EXIT_TIME_YYMMDDHHMMSS = "20" + Words[7];
                            }

                            //// Now extract all MUAC sectors and sector entry/exit times
                            //// Always extract UAC Entry and Exit Times
                            //if ((Words[2] == "-AIRSPDES") && (Words[3].Substring(0, 4) == "EDYY"))
                            //{
                            //    string Sector_ID = Words[3].Substring(4, (Words[3].Length - 4));
                            //    // FOX,FOX1,FOX2,UAC,UACX,AOI
                            //    if (Sector_ID != "FOX" && Sector_ID != "FOX1" && Sector_ID != "FOX2" &&
                            //        Sector_ID != "UAC" && Sector_ID != "UACX" && Sector_ID != "AOI")
                            //    {
                            //        Sector Sector = new Sector();
                            //        Sector.ID = Sector_ID;
                            //        Sector.SECTOR_ENTRY_TIME = CBS_Main.GetDate_Time_From_YYYYMMDDHHMMSS("20" + Words[5]);
                            //        Sector.SECTOR_EXIT_TIME = CBS_Main.GetDate_Time_From_YYYYMMDDHHMMSS("20" + Words[7]);
                            //        Sector_List.Add(Sector);
                            //    }
                            //}
                        }
                        else if (Words.Length > 1)
                        {
                            if (Words[1] == "-AD" || Words[1] == "-VEC" || Words[1] == "-PT")
                            {
                                FIX_TO_LATLNG.FIXPOINT_TYPE FIX = new FIX_TO_LATLNG.FIXPOINT_TYPE();

                                switch (Words[1])
                                {
                                // -AD  -ADID OMDB -ETO 130404033500 -PTRTE DCT
                                case "-AD":

                                    break;

                                // -VEC -RELDIST 01 -FL F010 -ETO 130404034715
                                case "-VEC":

                                    // Extract data from -PT line
                                    WPT.Name         = "-VEC" + Words[3];
                                    WPT.Flight_Level = Words[5].Substring(1);         // Remove F at the beggining.
                                    WPT.ETO          = Words[7];

                                    if (TrajectoryPoints.Count > 0)
                                    {
                                        // Add a new point to the list
                                        // Only add position that are known
                                        // as defined in the fixpoint table.
                                        TrajectoryPoints.Add(WPT);
                                    }

                                    break;

                                // -PT  -PTID GEO01 -FL F300 -ETO 130404041754
                                case "-PT":

                                    // Extract data from -PT line
                                    WPT.Name         = Words[4];
                                    WPT.Flight_Level = Words[6].Substring(1);         // Remove F at the beggining.
                                    WPT.ETO          = Words[8];

                                    FIX = FIX_TO_LATLNG.Get_LATLNG(WPT.Name);
                                    if (FIX.Is_Found == true)
                                    {
                                        WPT.Position            = FIX.Position;
                                        WPT.Position_Determined = true;

                                        // Add a new point to the list
                                        // Only add position that are known
                                        // as defined in the fixpoint table.
                                        TrajectoryPoints.Add(WPT);
                                    }
                                    else
                                    {
                                        // Lets check if the point is in the artifical EFD message
                                        // provided list. If so extract the position and assign it to
                                        // the main trajectory WPT list
                                        foreach (Waypoint GEO_WPT in GEO_Artifical_List)
                                        {
                                            if (WPT.Name == GEO_WPT.Name)
                                            {
                                                WPT.Position            = new GeoCordSystemDegMinSecUtilities.LatLongClass(GEO_WPT.Position.GetLatLongDecimal().LatitudeDecimal, GEO_WPT.Position.GetLatLongDecimal().LongitudeDecimal);
                                                WPT.Position_Determined = true;
                                                TrajectoryPoints.Add(WPT);
                                                break;
                                            }
                                        }
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception e)
                {
                    CBS_Main.WriteToLogFile("Exception in EFD_Msg.cs, Instantiation: " + e.Message);
                }
            }

            /////////////////////////////////////////////////////////////////////////
            // DO NOT CHANGE THE ORDER OF THE FOLLOWING CALLS
            /////////////////////////////////////////////////////////////////////////

            // Here parse the list and
            // 1. Remove all "-VEC points from the end of the list
            // 2. Determine Lon/Lat of each -VEC point
            ParseTrajectoryList(ref TrajectoryPoints);

            // Iterate through the sector lists and
            // calculate sector entry/exit levels based on the
            // extrapolation data calculated from the main trajectory
            // WPT list
            // CalculateSectorEntry_Exit_Times(ref Sector_List);

            /////////////////////////////////
            // Now set AOI Entry/Exit Points
            CalculateAOI_Entry_Exit_Times();

            Reader.Close();
            Reader.Dispose();
            ///////////////////////////////////////////////////////////////////////
            ///////////////////////////////////////////////////////////////////////
        }
Example #5
0
        private void ReadHDRFile(sFLTData FLTData, string HeaderFile)
        {
            int    FileNum;
            string OneLine;
            bool   isCorner = false;

            FileNum = FileSystem.FreeFile();
            FileSystem.FileOpen(FileNum, HeaderFile, OpenMode.Input, OpenAccess.Read);
            while (!(FileSystem.EOF(FileNum)))
            {
                OneLine = Strings.LCase((string)(FileSystem.LineInput(FileNum)));
                if (OneLine.IndexOf("ncols") + 1 > 0)
                {
                    int.TryParse((string)(OneLine.Replace("ncols", "").Replace("\t", "").Replace(" ", "")), out FLTData.ncols);
                }
                if (OneLine.IndexOf("nrows") + 1 > 0)
                {
                    int.TryParse((string)(OneLine.Replace("nrows", "").Replace("\t", "").Replace(" ", "")), out FLTData.nrows);
                }
                if (OneLine.IndexOf("xllcorner") + 1 > 0)
                {
                    isCorner = true;
                    double.TryParse(OneLine.Replace("xllcorner", "").Replace("\t", "").Replace(" ", ""), out FLTData.xllcenter);
                }
                if (OneLine.IndexOf("yllcorner") + 1 > 0)
                {
                    isCorner = true;
                    double.TryParse(OneLine.Replace("yllcorner", "").Replace("\t", "").Replace(" ", ""), out FLTData.yllcenter);
                }
                if (OneLine.IndexOf("xllcenter") + 1 > 0)
                {
                    double.TryParse(OneLine.Replace("xllcenter", "").Replace("\t", "").Replace(" ", ""), out FLTData.xllcenter);
                }
                if (OneLine.IndexOf("yllcenter") + 1 > 0)
                {
                    double.TryParse(OneLine.Replace("yllcenter", "").Replace("\t", "").Replace(" ", ""), out FLTData.yllcenter);
                }
                if (OneLine.IndexOf("cellsize") + 1 > 0)
                {
                    string tStr;
                    double tDbl;
                    tStr = OneLine.Substring(OneLine.IndexOfAny(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }));
                    double.TryParse(tStr, out tDbl);
                    tDbl             = Math.Round(tDbl, 13);
                    FLTData.cellsize = tDbl;
                }
                if (OneLine.IndexOf("nodata_value") + 1 > 0)
                {
                    double t = (double)FLTData.NODATA_value;
                    double.TryParse(OneLine.Replace("nodata_value", "").Replace(" ", "").Replace("\t", ""), out t);
                    FLTData.NODATA_value = (int)t;
                }
                if (OneLine.IndexOf("byteorder") + 1 > 0)
                {
                    FLTData.byteorder = (string)(OneLine.Replace("byteorder", "").Replace(" ", "").Replace("\t", ""));
                }
            }

            if (isCorner)
            {
                FLTData.xllcenter += FLTData.cellsize / 2;
                FLTData.yllcenter += FLTData.cellsize / 2;
            }

            FileSystem.FileClose(FileNum);
        }
Example #6
0
        //Decript the Licence File

        #region         private bool LeerFile(TextReader myTextReader, ref DatosFile myFileData)

        private bool LeerFile(TextReader myTextReader, ref DatosFile myFileData)
        {
            /* File Schema:
             * File Format: spsproparts_[ProductID]_productVersion].lic
             *
             * spsProParts                          --> Always
             * http://www.spsproparts.net           --> Always
             * ProductName: productAAA              --> Product Name, doesn't have any meaning
             * ProductVersion: 1.0.0.0              --> Needs to be the same as in the name of the lic file (used internally without dots)
             * ProductID: 123456789ABCDEF           --> Needs to be the same as in the name of the lic file
             * LicenseID: 987654321QWERTY           --> IMPORTANT: needed als public key to decrypt the raw data
             * RXpTjTdBl7RP1oQqfqScDlYXQxgAYPg+m    --> Raw data
             *
             * Raw data format:
             * EngineVersion|LicenseDate|TypeLicense|EvaluationDate|EvaluationDays|MAC|IP|Domain|Client|Other
             * 1.0|20071125|mac|||112233445566|||ClientAAA||
             * EngineVersion                        --> The version of this Class. In the future, the class can change
             * LicenseDate                          --> Date of issuance of the License - yyyymmdd
             * TypeLicense                          --> can be: mac - ip - days - date - domain
             * EvaluationDate                       --> If the expiration evaluation periode is absolute - yyyymmdd
             * EvaluationDays                       --> If the expiration evaluation periode is relative - number of days
             * MAC                                  --> MAC Address to check, if TypeLicense is "mac"
             * IP                                   --> IP Address to check, if TypeLicense is "ip"
             * Domain                               --> Domain name to check, if TypeLicense is "domain"
             *  Host
             * Client                               --> Client name and other information
             * Other                                --> Reserved for other information
             * Host
             */

            bool   blnReturn = false;
            string OneLine;
            int    LineCounter = 1;

            string[] TempString;

            try
            {
                //Read each line of the File, inclusive the raw data (last line), and set it in the object
                while ((OneLine = myTextReader.ReadLine()) != null)
                {
                    //Console.WriteLine(OneLine);

                    switch (LineCounter)
                    {
                    case (1):
                        //Nothing to do --> "spsProParts"
                        break;

                    case (2):
                        //Nothing to do --> "http://www.spsrproparts.net"
                        break;

                    case (3):
                        TempString             = OneLine.Split(':');
                        myFileData.ProductName = TempString[1].Trim();
                        break;

                    case (4):
                        TempString = OneLine.Split(':');
                        myFileData.ProductVersion = TempString[1].Trim().Replace(".", string.Empty);
                        break;

                    case (5):
                        TempString           = OneLine.Split(':');
                        myFileData.ProductID = TempString[1].Trim();
                        break;

                    case (6):
                        TempString           = OneLine.Split(':');
                        myFileData.LicenseID = TempString[1].Trim();
                        break;

                    case (7):
                        myFileData.RawData = OneLine;
                        break;

                    default:
                        break;
                    }
                    LineCounter++;
                }
                myTextReader.Close();

                string RawLine;
                //Read the values of the encrypted last line, and set it in the object
                using (CryptoString myCryptoString = new CryptoString())
                {
                    RawLine = myCryptoString.Decrypt(myFileData.RawData, myFileData.LicenseID);
                    //string RawLine = myCryptoString.Encrypt("1.0|20071125|days||1|11223344556677|||clientAA||", myFileData.LicenseID);
                    //Console.WriteLine(RawLine);
                }
                TempString = RawLine.Split('|');
                myFileData.LicenseEngineVersion = TempString[0].Trim();
                myFileData.LicenseDate          = TempString[1].Trim();
                //Type Licenses can be: mac - ip - days - date - domain
                switch (TempString[2].Trim().ToLower())
                {
                case ("mac"):
                    myFileData.LicenseSort = DatosFile.TypeLicense.MAC;
                    break;

                case ("ip"):
                    myFileData.LicenseSort = DatosFile.TypeLicense.IP;
                    break;

                case ("days"):
                    myFileData.LicenseSort = DatosFile.TypeLicense.EvaluationDays;
                    break;

                case ("date"):
                    myFileData.LicenseSort = DatosFile.TypeLicense.EvaluationDate;
                    break;

                case ("domain"):
                    myFileData.LicenseSort = DatosFile.TypeLicense.Domain;
                    break;

                case ("host"):
                    myFileData.LicenseSort = DatosFile.TypeLicense.Host;
                    break;

                default:
                    break;
                }
                myFileData.DateExpiration   = TempString[3].Trim();
                myFileData.DaysToExpiration = TempString[4].Trim();
                myFileData.MacAddress       = TempString[5].Trim();
                myFileData.IpAddress        = TempString[6].Trim();
                myFileData.DomainName       = TempString[7].Trim();
                myFileData.HostName         = TempString[8].Trim();
                myFileData.ClientName       = TempString[9].Trim();
                myFileData.OtherInformation = TempString[10].Trim();

                blnReturn = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("BuscarControlar:Controlar.LeerFile - " + ex);
            }

            return(blnReturn);
        }