コード例 #1
0
        internal static LogRowData CreateData(Stream stream, LogRowIndex index)
        {
            byte[] buffer = new byte[index.RowLength + 2];
            char[] chars  = new char[index.RowLength];

            if (stream.Position != index.RowStart)
            {
                stream.Seek(index.RowStart, SeekOrigin.Begin);
            }

            stream.Read(buffer, 0, index.RowLength);

            int length = buffer.IndexOf((byte)'\r', 0);

            if (length == -1)
            {
                length = buffer.IndexOf((byte)'\n', 0);
            }

            for (int i = 0; i < length; i++)
            {
                chars[i] = (char)buffer[i];
            }

            index.GetValues(out int timeStampIndex, out int nameIndex, out int userIndex, out int cycleIndex, out int valueIndex);

            var itemId          = new string(chars, nameIndex, index.NameLength);
            var timeStamp       = LogRowDataFactory.ParseDate(chars, 0, LogRowIndex.TimeStampLength);
            var user            = new string(chars, userIndex, index.UserLength);
            var cycleIndexValue = long.Parse(new string(chars, cycleIndex, index.CycleLength), NumberStyles.None);
            var value           = new string(chars, valueIndex, length - valueIndex);

            return(new LogRowData(timeStamp, itemId, user, cycleIndexValue, value));
        }
コード例 #2
0
        internal void Add(string item, LogRowIndex index)
        {
            List <LogRowIndex> indexByItem;

            if (!IndexesByItem.TryGetValue(item, out indexByItem))
            {
                indexByItem = new List <LogRowIndex>();
                IndexesByItem.Add(item, indexByItem);
            }

            indexByItem.Add(index);
            Indexes.Add(index);
            Count++;
        }
コード例 #3
0
ファイル: LogFileParser.cs プロジェクト: ArcamEBM/LogStudio
        internal static void ParseRow(char[] rowBuffer, int rowLength, long startPos, char separator, out LogRowIndex index, out string itemID)
        {
            ushort[] lengths = new ushort[3];

            int rowIndex = LogRowIndex.TimeStampLength;

            for (var i = 0; i < lengths.Length; i++)
            {
                int lastIndex = rowIndex;
                rowIndex   = rowBuffer.IndexOf(separator, rowIndex + 1);
                lengths[i] = (ushort)(rowIndex - 1 - lastIndex);
            }

            itemID = new string(rowBuffer, LogRowIndex.TimeStampLength + 1, lengths[0]);

            index = new LogRowIndex(startPos, (ushort)rowLength, lengths[0], lengths[1], (byte)lengths[2]);
        }
コード例 #4
0
        public LogRowIndex[] GetItemRows(string itemID, int fromIndex, int length)
        {
            m_Lock.EnterReadLock();
            try
            {
                LogRowIndex[] res = new LogRowIndex[length];

                List <LogRowIndex> items = m_RowIndexes[itemID];

                length = Math.Min(length, items.Count);

                for (int index = 0; index < length; index++)
                {
                    res[index] = items[fromIndex + index];
                }
                return(res);
            }
            finally
            {
                m_Lock.ExitReadLock();
            }
        }
コード例 #5
0
        internal static LogRowDataPoint CreateDataPoint(PagedStreamReader reader, LogRowIndex index)
        {
            byte[] buffer = new byte[index.RowLength];
            char[] chars  = new char[index.RowLength];

            reader.Read(buffer, index.RowStart, index.RowLength);

            int length = buffer.IndexOf((byte)'\r', 0);

            if (length == -1)
            {
                length = buffer.IndexOf((byte)'\n', 0);
            }

            for (int i = 0; i < length; i++)
            {
                chars[i] = (char)buffer[i];
            }

            index.GetValues(out int timeStampIndex, out int nameIndex, out int userIndex, out int cycleIndex, out int valueIndex);

            var timeStamp = ParseDate(chars, 0, LogRowIndex.TimeStampLength); //, "yyyy-MM-dd hh:mm:ss.fff", culture);

            string valueString = new string(chars, valueIndex, length - valueIndex);

            double value;

            if (!double.TryParse(valueString, NumberStyles.Any, m_Culture, out double val))
            {
                value = valueString == "True" ? 1d : 0d;
            }
            else
            {
                value = val;
            }

            return(new LogRowDataPoint(timeStamp, value));
        }
コード例 #6
0
ファイル: LogFileParser.cs プロジェクト: ArcamEBM/LogStudio
 private void AddLogRowIndex(string itemID, RowIndexCollection indexCollection, LogRowIndex index)
 {
     if (m_FilteredItems == null)
     {
         indexCollection.Add(itemID, index);
     }
     else if (m_FilteredItems.Contains(itemID))
     {
         indexCollection.Add(itemID, index);
     }
 }
コード例 #7
0
 public LogRowData GetData(LogRowIndex index)
 {
     return(GetData(new[] { index }).First());
 }
コード例 #8
0
 public LogRowDataPoint GetDataPoint(LogRowIndex index)
 {
     return(GetDataPoints(new[] { index }).First());
 }