Example #1
0
        public void UpdateRawWithNewDialogue()
        {
            if (SpokenText != string.Empty)
            {
                SpokenText = SpokenText.Replace('’', '\'').Replace('~', '~').Replace("  ", " ");

                //Find where the end of the old dialogue text should be
                int lineIndex;
                if (RawLine.Contains("$Nu"))
                {
                    lineIndex = RawLine.IndexOf("$",
                                                RawLine.IndexOf("$Nu", StringComparison.Ordinal) + 2,
                                                StringComparison.Ordinal);
                }
                else
                {
                    lineIndex = RawLine.IndexOf("$", SpeechIndex, StringComparison.Ordinal);
                }

                var oldDialogue = lineIndex > SpeechIndex
                    ? RawLine.Substring(SpeechIndex, lineIndex - SpeechIndex)
                    : RawLine.Substring(SpeechIndex);

                RawLine = RawLine.Substring(0, SpeechIndex) + SpokenText +
                          RawLine.Substring(SpeechIndex + oldDialogue.Length);
            }

            RawLine = RawLine.Replace(Environment.NewLine, "\\n");
        }
Example #2
0
        public void Parse(char separator)
        {
            string[]       cols          = RawLine.Split(separator);
            DateTimeOffset lineTimestamp = DateTimeOffset.Parse(cols.ElementAtOrDefault(0));

            Timestamp     = new DateTime(FileDate.Year, FileDate.Month, FileDate.Day, lineTimestamp.Hour, lineTimestamp.Minute, 0);
            TimestampUnix = (Timestamp - unixMin).TotalSeconds;
            Power1        = decimal.TryParse(cols.ElementAtOrDefault(1), out decimal tmp1) ? tmp1 : default(decimal);
            Power2        = decimal.TryParse(cols.ElementAtOrDefault(2), out decimal tmp2) ? tmp2 : default(decimal);
        }
Example #3
0
                public Node(RawLine line, char indent, List <Node> children = null)
                {
                    if (IndentSpan == null)
                    {
                        throw new Exception("Indentation span not set!");
                    }

                    Level    = GetIndent(line.Text, indent) / _indent;
                    Children = children ?? new List <Node>();

                    _line = line.Trim();
                }
Example #4
0
        public static List <SignitureItem> LoadFromRawText(string textFile)
        {
            List <SignitureItem> ret = new List <SignitureItem>();

            string[] rawLines = File.ReadAllLines(textFile);

            for (int i = 0; i < rawLines.Length - 1; i++)
            {
                string        currentLine      = rawLines[i];
                RawLine       currentConverted = new RawLine(currentLine);
                string        nextLine         = rawLines[i + 1];
                RawLine       nextConverted    = new RawLine(nextLine);
                int           rank             = rawLines.Length - i;
                SignitureItem item             = new SignitureItem(currentConverted.StartTime, nextConverted.StartTime, currentConverted.Phrase, rank);
                ret.Add(item);
            }
            return(ret);
        }
Example #5
0
 internal string GetTextValue()
 {
     return(RawLine.Substring(3 + Tag.Length).Trim());
 }
Example #6
0
		public static void compile(string filein, string fileout, string fileoutBin, string filetemp, string type)
		{
			List<Config> cfgs = Config.loadConfig(@"assembler\config.txt");
			List<RawLine> linesraw = new List<RawLine>();
			foreach (string f in filein.Split(','))
			{
				FileStream fs = new FileStream(f, FileMode.Open, FileAccess.Read);
				StreamReader sr = new StreamReader(fs);
				var temp = sr.ReadToEnd();
				foreach (var item in temp.Split('\n'))
				{
					RawLine rl = new RawLine();
					rl.filename = f;
					rl.line = item;
					linesraw.Add(rl);
				}
				fs.Close();
			}

			int basePos;

			List<Line> lines = new List<Line>();

			lines.Add(Line.match(".section .text", null));
			if (type == "bios")
			{
				Console.WriteLine("type=bios");
				int sp = 0x02000000;//0x0200C000
				basePos = 0x02000000;
				lines.Add(Line.match("movhi sp, %hiadj(" + sp + ")", null));
				lines.Add(Line.match("addi sp, sp, %lo(" + sp + ")", null));
				lines.Add(Line.match("jmpi main", null));
			}
			else if (type == "dos")
			{
				Console.WriteLine("type=dos");
				int sp = 0x02000000;//0x0200C000
				basePos = 0x00000000;
				lines.Add(Line.match("movhi sp, %hiadj(" + sp + ")", null));
				lines.Add(Line.match("addi sp, sp, %lo(" + sp + ")", null));
				lines.Add(Line.match("jmpi main", null));
			}
			else if (type == "app")
			{
				Console.WriteLine("type=app");
				uint h = 0x80000000;
				basePos = (int)(h);
				lines.Add(Line.match("call main", null));
				lines.Add(Line.match("ret", null));
			}
			else if (type == "debug")
			{
				Console.WriteLine("type=debug");
				basePos = 0x00000000;
			}
			else
			{
				throw new Exception();
			}

			foreach (var lineraw in linesraw)
			{
				string raw = lineraw.line;
				if (raw.Trim().Length > 0)
				{
					string temp = raw.Trim();
					if (temp.StartsWith(".string"))
					{
						temp = temp.Substring(".string ".Length);
						temp = ".string " + temp;
					}
					else
					{
						temp = temp.Replace('\t', ' ');
						while (true)
						{
							if (temp.Contains("  "))
							{
								temp = temp.Replace("  ", " ");
							}
							else
							{
								break;
							}
						}
					}

					Line line = Line.match(temp, lineraw.filename);
					if (line == null)
					{
						throw new Exception("unknow line:" + raw);
					}
					lines.Add(line);
				}
			}
			lines.Add(Line.match(".section .text", null));
			lines.Add(Line.match("_Z7__eof__v:", null));
			lines.Add(Line.match("movhi r2, %hiadj(eof)", null));
			lines.Add(Line.match("addi r2, r2, %lo(eof)", null));
			lines.Add(Line.match("ret", null));
			lines.Add(Line.match(".section .data", null));
			lines.Add(Line.match("eof:", null));
			lines.Add(Line.match(".zero 4", null));

			List<Line> linespass2 = new List<Line>();
			foreach (var line in lines)
			{

				//bgtu rA, rB, label bltu rB, rA, label

				//bleu rA, rB, label bgeu rB, rA, label
				//cmpgt rC, rA, rB cmplt rC, rB, rA
				//cmpgti rB, rA, IMMED cmpgei rB, rA, (IMMED+1)
				//cmpgtu rC, rA, rB cmpltu rC, rB, rA
				//cmpgtui rB, rA, IMMED cmpgeui rB, rA, (IMMED+1)
				//cmple rC, rA, rB cmpge rC, rB, rA
				//cmplei rB, rA, IMMED cmplti rB, rA, (IMMED+1)
				//cmpleu rC, rA, rB cmpgeu rC, rB, rA
				//cmpleui rB, rA, IMMED cmpltui rB, rA, (IMMED+1)

				//movia rB, label orhi rB, r0, %hiadj(label)
				//addi, rB, r0, %lo(label)

				//subi rB, rA, IMMED addi rB, rA, (-IMMED)

				if ((new Config("nop")).match(line))//nop add r0, r0, r0
				{
					linespass2.Add(Line.match("add r0, r0, r0", line.filename));
				}
				//br sym                       @          20 @                      0 @   6 @          000110      0x06
				else if ((new Config("br sym")).match(line))//ble rA, rB, label bge rB, rA, label
				{
					linespass2.Add(Line.match("beq r0, r0, " + line.op1.text, line.filename));
				}
				else if ((new Config("ble reg, reg, sym")).match(line))//ble rA, rB, label bge rB, rA, label
				{
					linespass2.Add(Line.match("bge " + line.op2.text + ", " + line.op1.text + ", " + line.op3.text, line.filename));
				}
				else if ((new Config("bgt reg, reg, sym")).match(line))//bgt rA, rB, label blt rB, rA, label
				{
					linespass2.Add(Line.match("blt " + line.op2.text + ", " + line.op1.text + ", " + line.op3.text, line.filename));
				}
				else if ((new Config("movi reg, ins")).match(line))//movi rB, IMMED addi, rB, r0, IMMED
				{
					linespass2.Add(Line.match("addi " + line.op1.text + ", r0, " + line.op2.text, line.filename));
				}
				else if ((new Config("movui reg, ins")).match(line))//movui rB, IMMED ori rB, r0, IMMED
				{
					linespass2.Add(Line.match("ori " + line.op1.text + ", r0, " + line.op2.text, line.filename));
				}
				else if ((new Config("mov reg, reg")).match(line))//mov rC, rA add rC, rA, r0
				{
					linespass2.Add(Line.match("add " + line.op1.text + ", " + line.op2.text + ", r0", line.filename));
				}
				else if ((new Config("movhi reg, ins")).match(line))//movhi rB, IMMED orhi rB, r0, IMMED
				{
					linespass2.Add(Line.match("orhi " + line.op1.text + ", r0, " + line.op2.text, line.filename));
				}
				else if ((new Config("stw reg, gprel")).match(line))//stw r2, %gprel(Sd2Card_status_)(gp)
				{
					//%gprel(immed32) Replace the immed32 address with an offset from the global pointer immed32 –_gp
					//movhi	r1, %hiadj(c)
					linespass2.Add(Line.match("orhi r1, r0, %hiadj(" + line.op2.sym + line.op2.getSymAdj() + ")", line.filename));
					//addi	r1, r1, %lo(c)
					linespass2.Add(Line.match("addi r1, r1, %lo(" + line.op2.sym + line.op2.getSymAdj() + ")", line.filename));
					//ldw	r4, 0(r1)
					linespass2.Add(Line.match("stw " + line.op1.text + ", 0(r1)", line.filename));
				}
				else if ((new Config("ldw reg, gprel")).match(line))//ldw r4, %gprel(c)(gp)
				{
					//%gprel(immed32) Replace the immed32 address with an offset from the global pointer immed32 –_gp
					//movhi	r1, %hiadj(c)
					linespass2.Add(Line.match("orhi r1, r0, %hiadj(" + line.op2.sym + line.op2.getSymAdj() + ")", line.filename));
					//addi	r1, r1, %lo(c)
					linespass2.Add(Line.match("addi r1, r1, %lo(" + line.op2.sym + line.op2.getSymAdj() + ")", line.filename));
					//ldw	r4, 0(r1)
					linespass2.Add(Line.match("ldw " + line.op1.text + ", 0(r1)", line.filename));
				}
				else if ((new Config("ldwio reg, regins")).match(line))//ldw r4, %gprel(c)(gp)
				{
					//ldw	r4, 0(r1)
					linespass2.Add(Line.match("ldw " + line.op1.text + ", " + line.op2.text, line.filename));
				}
				else if ((new Config("stwio reg, regins")).match(line))//ldw r4, %gprel(c)(gp)
				{
					//ldw	r4, 0(r1)
					linespass2.Add(Line.match("stw " + line.op1.text + ", " + line.op2.text, line.filename));
				}
				else if ((new Config("jmpi sym")).match(line))//jmpi
				{
					//movhi	r1, %hiadj(c)
					linespass2.Add(Line.match("orhi r1, r0, %hiadj(" + line.op1.sym + ")", line.filename));
					//addi	r1, r1, %lo(c)
					linespass2.Add(Line.match("addi r1, r1, %lo(" + line.op1.sym + ")", line.filename));
					//ldw	r4, 0(r1)
					linespass2.Add(Line.match("jmp r1", line.filename));
				}
				else if ((new Config("jmpi ins")).match(line))//jmpi
				{
					//movhi	r1, %hiadj(c)
					linespass2.Add(Line.match("orhi r1, r0, %hiadj(" + line.op1.ins + ")", line.filename));
					//addi	r1, r1, %lo(c)
					linespass2.Add(Line.match("addi r1, r1, %lo(" + line.op1.ins + ")", line.filename));
					//ldw	r4, 0(r1)
					linespass2.Add(Line.match("jmp r1", line.filename));
				}

				else
				{
					linespass2.Add(line);
				}
			}
			lines = linespass2;


			int pos;

			List<Sym> syms = new List<Sym>();

			List<DataIns> dataInsList = new List<DataIns>();

			pos = basePos;
			{
				foreach (var item in lines)
				{
					var line = item;
					if (line.type == Line.LineType.sym)
					{
						Sym sym = new Sym();
						sym.name = line.sym;
						sym.filename = line.filename;
						sym.pos = pos;
						syms.Add(sym);
					}
					else if (line.type == Line.LineType.cmd)
					{
						addCmd(cfgs, line, ref pos, dataInsList);
					}
					else
					{
						addData(line, ref pos, syms, dataInsList);
					}
				}
			}

			foreach (var item in dataInsList)
			{
				if (item is Ins)
				{
					var ins = item as Ins;
					if (ins.op != null)
					{
						if (ins.op.sym != null)
						{
							Sym found = null;
							foreach (var sym in syms)
							{
								if (ins.op.sym == sym.name && ins.op.filename == sym.filename)
								{
									found = sym; break;
								}
							}
							if (found == null)
							{
								foreach (var sym in syms)
								{
									if (ins.op.sym == sym.name)
									{
										found = sym; break;
									}
								}
							}
							if (found == null)
							{
								throw new Exception("not found:" + ins.op.sym);
							}
							if (ins.format == 0)
							{
								if (ins.textformat == 15 || ins.textformat == 20)
								{
									ins.IMM16 = found.pos - ins.pos - 4;
									if (ins.IMM16 > 32768 || ins.IMM16 < -30000)
									{
										throw new Exception();
									}
								}
								else if (ins.textformat == 10)
								{
									int temppos = found.pos;
									if (ins.op.symAdj != null)
									{
										temppos += ins.op.symAdj.Value;
									}
									ins.IMM16 = procAdj(ins.op, temppos);
									if (ins.IMM16 > 32768 || ins.IMM16 < -30000)
									{
										throw new Exception();
									}
								}
								else
								{
									throw new Exception();
								}
							}
							else if (ins.format == 2)
							{
								if (found.pos > 35000000)
								{
									throw new Exception();
								}
								ins.IMM26 = found.pos >> 2;
							}
						}
						else
						{
							ins.IMM16 = procAdj(ins.op, ins.op.ins.Value);
							if (ins.IMM16 > 70000 || ins.IMM16 < -70000)
							{
								throw new Exception();
							}
						}
					}
				}

				if (item is Data)
				{
					var data = item as Data;
					if (data.sym != null)
					{
						Sym found = null;
						int val = 0;
						foreach (var sym in syms)
						{
							if (data.sym == sym.name && data.filename == sym.filename)
							{
								found = sym;
								val = found.pos;
								break;
							}
						}
						if (found == null)
						{
							foreach (var sym in syms)
							{
								if (data.sym == sym.name)
								{
									found = sym;
									val = found.pos;
									break;
								}
							}
						}
						if (found == null)
						{
							throw new Exception("not found:" + data.sym);
						}
						byte[] src = new byte[4];
						src[3] = (byte)((val >> 24) & 0xFF);
						src[2] = (byte)((val >> 16) & 0xFF);
						src[1] = (byte)((val >> 8) & 0xFF);//高8位
						src[0] = (byte)(val & 0xFF);//低位
						data.data = src;
					}
				}
			}

			{
				FileStream fs2 = new FileStream("temp.sym", FileMode.Create, FileAccess.Write);
				StreamWriter sw = new StreamWriter(fs2);
				foreach (var sym in syms)
				{
					sw.WriteLine(sym.pos + "," + sym.name);
				}
				sw.Flush();
				fs2.Close();
			}

			{
				int len = pos;
				FileStream fs = new FileStream(fileoutBin, FileMode.Create, FileAccess.Write);
				FileStream fs2 = new FileStream(fileout, FileMode.Create, FileAccess.Write);
				FileStream fs3 = new FileStream(filetemp, FileMode.Create, FileAccess.Write);

				BinaryWriter bw = new BinaryWriter(fs);
				StreamWriter sw = new StreamWriter(fs2);
				StreamWriter sw3 = new StreamWriter(fs3);
				//bw.Write(len);
				//bw.Write(entry);

				int posx = 0;
				foreach (var item in dataInsList)
				{
					string ssym = "";
					foreach (var sym in syms)
					{
						if (((posx) * 4) == sym.pos)
						{
							ssym += sym.name + ",";
						}
					}

					if (item is Ins)
					{
						var ins = item as Ins;
						//[31]1bit:4 byte/8 byte
						//[30:24]7bit:cmd
						//[23:20]4bit:reg1
						//[19:16]4bit:reg2
						//[15:0]16bit:ins1
						//[31:0]32bit:ins2
						int insbin = 0;
						if (ins.format == 0)//andi reg, reg, ins
						{
							insbin = (ins.bitregA << (31 - 5)) | (ins.bitregB << (31 - 10)) | ((ins.IMM16 & 0x0000FFFF) << (5)) | (ins.bitcmd);
						}
						else if (ins.format == 1)
						{
							insbin = (ins.bitregA << (31 - 5)) | (ins.bitregB << (31 - 10)) | (ins.bitregC << (31 - 15)) | (ins.IMM6 << (5 + 5)) | (ins.bitcmd << (5)) | 0;
						}
						else if (ins.format == 2)
						{
							insbin = (ins.IMM26 << 5) | (ins.bitcmd);
						}
						else if (ins.format == 3)
						{
							insbin = (ins.bitregA << (31 - 5)) | (ins.bitregB << (31 - 10)) | (ins.bitregC << (31 - 15)) | (ins.IMM6 << (5 + 5)) | (ins.bitcmd << (5)) | 31;
						}

						int paritycheck = 0;
						for (int i = 0; i < 31; i++)
						{
							paritycheck ^= (insbin >> i) & 1;
						}

						insbin |= (~paritycheck) << 31;

						bw.Write(insbin);
						writehex(insbin, posx++, sw);

						sw3.WriteLine(getHex8((posx - 1) * 4) + " [" + getHex8(insbin) + "] (" + ssym + ") " + ins.line.text);

					}

					if (item is Data)
					{
						var data = item as Data;
						for (int i = 0; i < data.len; i += 4)
						{
							int val = 0;
							if (i + 0 < data.data.Length)
							{
								val |= (data.data[i + 0]);
							}
							if (i + 1 < data.data.Length)
							{
								val |= (data.data[i + 1] << 8);
							}
							if (i + 2 < data.data.Length)
							{
								val |= (data.data[i + 2] << 16);
							}
							if (i + 3 < data.data.Length)
							{
								val |= (data.data[i + 3] << 24);
							}
							bw.Write(val);
							writehex(val, posx++, sw);
							sw3.WriteLine(getHex8((posx - 1) * 4) + " [" + getHex8(val) + "] (" + ssym + ")");
						}
					}
				}

				Console.WriteLine("size:" + posx * 4);
				sw.WriteLine(":00000001FF");

				sw.Flush();
				fs2.Close();

				sw3.Flush();
				fs3.Close();

				bw.Flush();
				fs.Close();

			}
			//Console.ReadLine();
		}
Example #7
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     = string.Empty;
            int    LineCounter = 1;

            string[] TempString = new string[2];

            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);
        }
Example #8
0
        private void ProcessBytes(string gpsData)
        {
            while (gpsData.IndexOf('\n') != -1)
            {
                var parts = gpsData.Split('\n');
                _data += parts[0];
                _data  = _data.Trim();
                if (_data != string.Empty)
                {
                    if (_data.IndexOf("$GPRMS") != 0)
                    {
                        int g = 9;
                    }

                    if (_data.IndexOf("$GPRMC") == 0)
                    {
                        //  Debug.Print("GOT $GPRMC LINE");
                        if (GpsData != null)
                        {
                            var gpsPoint = GprmcParser.Parse(_data);

                            if (gpsPoint == null)
                            {
                                continue;
                            }

                            var isOk = true;

                            if (_lastPoint != null)
                            {
                                var distance = GeoDistanceCalculator.GetDistanceInMiles(gpsPoint.Latitude, gpsPoint.Longitude,
                                                                                        _lastPoint.Latitude, _lastPoint.Longitude);
                                double distInFeet = distance * 5280;
                                //  Debug.Print("distance = " + distance + " mi (" + distInFeet + " feet)");
                                if (distance < _minDistanceBetweenPoints)
                                {
                                    // Too close to the last point....don't raise the event
                                    isOk = false;
                                }

                                var timeDelta = (DateTime.Now - _lastDateTime);

                                if (timeDelta.Seconds > 60)
                                {
                                    // A minute has gone by, so update
                                    isOk          = true;
                                    _lastDateTime = DateTime.Now;
                                }
                            }
                            _lastPoint = gpsPoint;

                            // Raise the event
                            if (isOk)
                            {
                                GpsData(gpsPoint);
                            }
                        }
                    }

                    RawLine?.Invoke(_data);
                }
                gpsData = parts[1];
                _data   = string.Empty;
            }
            _data += gpsData;
        }
Example #9
0
 Node()
 {
     _line    = new RawLine();
     Children = new List <Node>();
     Level    = -1;
 }