示例#1
0
 void PushReceivedMessages(ReceivedMessageList list)
 {
     foreach (var message in list)
     {
         message.GenerateLogText();
     }
     _messageList.AddRange(list);
 }
示例#2
0
        public ReceivedMessageList GetReceivedMessageList()
        {
            ReceivedMessageList list;

            lock (_lock)
            {
                list         = _messageList;
                _messageList = new ReceivedMessageList();
            }
            return(list);
        }
示例#3
0
        // IReceivedMessageProcessor
        public void ProcessMessages(ReceivedMessageList list)
        {
            RaiseListChangedEvents = false;

            foreach (var message in list)
            {
                AddNewLine(message.LogText);
            }

            RaiseListChangedEvents = true;
            ResetBindings();
        }
示例#4
0
        public void ProcessTextMessage(string line)
        {
            lock (_lock)
            {
                var messageList     = new ReceivedMessageList();
                var receivedMessage = messageList.Add(++_rawId, line);

                CanMessage canMessage = ProcessMessageData(line, receivedMessage);
                if (canMessage != null)
                {
                    receivedMessage.CanMessage = canMessage;
                }

                PushReceivedMessages(messageList);
            }
        }
示例#5
0
        int ParseMessages(string data, ReceivedMessageList messageList)
        {
            int length = data.Length;
            int pos    = 0;

            while (true)
            {
                int remain = length - pos;
                if (remain <= 0)
                {
                    break;
                }

                int c = data[pos];
                switch (c)
                {
                case 13:
                    messageList.Add(++_rawId, "ok");
                    pos++;
                    continue;

                case 7:
                    messageList.Add(++_rawId, "error");
                    pos++;
                    continue;
                }

                int end = data.IndexOf('\r', pos);
                if (end < 0)
                {
                    return(pos);
                }

                string message = data.Substring(pos, end - pos);
                pos = end + 1;

                var receivedMessage = messageList.Add(++_rawId, message);


                CanMessage canMessage = ProcessMessageData(message, receivedMessage);
                if (canMessage != null)
                {
                    receivedMessage.CanMessage = canMessage;
                }
            }
            return(-1);
        }
示例#6
0
        // IReceivedMessageProcessor
        public void ProcessMessages(ReceivedMessageList messageList)
        {
            using (_statuses.CreateUpdateSuppressor())
                using (_selectedIdStatus != null ? _selectedIdStatus.GetDataStatuses().CreateUpdateSuppressor() : null)
                {
                    foreach (var message in messageList)
                    {
                        var canMessage = message.CanMessage;
                        if (canMessage == null)
                        {
                            continue;
                        }

                        canMessage.ApplyMask(_config.DataMask);

                        CanIdStatus status = _statuses.GetStatus(canMessage.Id);
                        status.ProcessMessage(canMessage);
                    }
                }
        }
示例#7
0
        public bool ProcessStream(string data)
        {
            lock (_lock)
            {
                _buffer += data;

                var messageList = new ReceivedMessageList();

                int pos = ParseMessages(_buffer, messageList);
                if (pos < 0)
                {
                    _buffer = "";
                }
                else
                {
                    _buffer = _buffer.Substring(pos);
                }

                PushReceivedMessages(messageList);
            }
            return(true);
        }
示例#8
0
        public void ProcessMessages(ReceivedMessageList messages)
        {
            if (!Enable)
            {
                return;
            }

            List <string> list = new List <string>();

            foreach (var message in messages)
            {
                if (message.CanMessage == null)
                {
                    continue;
                }
                list.Add(message.RawText);
            }

            if (list.Count > 0)
            {
                System.IO.File.AppendAllLines(FileName, list);
            }
        }