示例#1
0
 public void NewLogEntry(object aSender, LogEntry aEntry)
 {
     if ((aEntry != null) && (OnNewEntry != null))
     {
         OnNewEntry(this, aEntry);
     }
 }
示例#2
0
        public override void ExecuteLoop()
        {
            this.m_Port.Open();

            while (true)
            {
                int BytesToRead = this.m_Port.BytesToRead;

                if (BytesToRead > 0)
                {
                    //byte[] Buffer = new byte[BytesToRead];
                    char[] Buffer = new char[BytesToRead];

                    this.m_Port.Read(Buffer, 0, BytesToRead);
                    {
                        // pass the Buffer[i] to the syntax analyser

                        // Just for test
                        if (this.OnNewEntry != null)
                        {
                            LogEntry newLogEntry = new LogEntry();
                            string Data = "";

                            for (int i = 0; i < Buffer.Length; i++)
                            {
                                Data = Data + Buffer[i].ToString();
                            }

                            this.m_Port.Write(Data);

                            newLogEntry.StationId = this.StationId;
                            newLogEntry.Start = DateTime.Now;
                            newLogEntry.Duration = m_Random.Next(600);
                            newLogEntry.Stop = DateTime.Now;
                            newLogEntry.FirstParty = Data;
                            newLogEntry.SecondParty = Data;

                            this.OnNewEntry(this, newLogEntry);
                        }

                    }

                }

                // Just for test

                /*
                        if (this.OnNewEntry != null)
                        {
                            if (this.m_NextEvenetTime <= Environment.TickCount)
                            {
                                int NextEvenetTime = Environment.TickCount + (m_Random.Next(5000));
                                LogEntry newLogEntry = new LogEntry();

                                newLogEntry.StationId = this.StationId;
                                newLogEntry.Start = DateTime.Now;
                                newLogEntry.Duration = m_Random.Next(600);
                                newLogEntry.Stop = DateTime.Now;
                                newLogEntry.FirstParty = this.m_NextEvenetTime.ToString();
                                newLogEntry.SecondParty = NextEvenetTime.ToString();

                                this.m_NextEvenetTime = NextEvenetTime;

                                this.OnNewEntry(this, newLogEntry);
                            }

                        }
                */

                Thread.Sleep(100);
                if (this.StopRequest)
                    break;
            }

            this.m_Port.Close();
        }
示例#3
0
        private void OnNewLogEntry(object aSender, LogEntry aEntry)
        {
            if (aEntry != null)
            {
                lock (m_Log)
                {
                    m_Log.Add(aEntry);
                }

                if (this.OnNewEntry != null) this.OnNewEntry(this, aEntry);
            }
        }