Esempio n. 1
0
        public void DataIsWrittenIn16MBChunks()
        {
            int dataWrites = 0;
            int timeWrites = 0;
            GlobalEvents.Hook<LogFileWriteAction>((x) =>
                                                      {
                                                          Assert.AreEqual(null, x.File);
                                                          Assert.AreEqual("test", x.Group);
                                                          // Count the write actions););
                                                          if (x.FileType == LogFileType.Data)
                                                              dataWrites++;
                                                          if (x.FileType == LogFileType.Time)
                                                              timeWrites++;
                                                      }, false);

            int counter = 0;
            var source = new MemoryPool("test", MemoryAddress.StaticAbsolute, 0x123456, 0, 0x1234);

            source.Add(new MemoryFieldFunc<int>("testInt", (pool) => counter++));
            source.Add(new MemoryFieldFunc<string>("test", (pool) => "test"));

            var group = new LogGroup(null, "test", source);

            // Fill up  a data file
            for (int i = 0; i < 1441792; i++) // 28 * 1441792 = 38.5MiB
                group.Update(i); // +28 bytes

            Assert.AreEqual(38, dataWrites); // 38*1MiB
            Assert.AreEqual(10, timeWrites);

            group.Close();

            Assert.AreEqual(39, dataWrites); // last 0.5MiB
            Assert.AreEqual(11, timeWrites);
        }
Esempio n. 2
0
        public LogSampleGroup(LogGroup group)
        {
            Buffer = group.ExtractDataBuffer();
            Name   = group.Name;

            /**** Create custom timeline containing offset for current and next time samples *****/
            TimeLine_Current = group.Timeline;
            var lastTime = -123;

            foreach (var kvp in TimeLine_Current)
            {
                if (lastTime != -123)
                {
                    TimeLine_Next.Add(lastTime, kvp.Value);
                }
                lastTime = kvp.Key;
            }
            TimeLine_Next.Add(lastTime, Buffer.Length);

            foreach (var field in group.Fields)
            {
                var logFieldType     = typeof(LogSampleField <>).MakeGenericType(new[] { field.ValueType });
                var logFieldInstance =
                    (IDataField)
                    Activator.CreateInstance(logFieldType, new object[3] {
                    field.Name, field.ValueType, this
                });
                _fields.Add(field.Name, logFieldInstance);
                _fieldById.Add(field.ID, logFieldInstance);
            }
        }
Esempio n. 3
0
 public LogField(LogGroup group, string name, string id, string type)
 {
     ID = Int32.Parse(id);
     Name = name;
     Group = group;
     DataSource = new LogFieldDataField(name, type);
     this.ValueType = Type.GetType(type);
 }
Esempio n. 4
0
 public LogField(LogGroup group, IDataField field, int id)
 {
     ID = id;
     Name = field.Name;
     Group = group;
     DataSource = field;
     this.ValueType = field.ValueType;
 }
Esempio n. 5
0
 public LogField(LogGroup group, string name, string id, string type)
 {
     ID             = Int32.Parse(id);
     Name           = name;
     Group          = group;
     DataSource     = new LogFieldDataField(name, type);
     this.ValueType = Type.GetType(type);
 }
Esempio n. 6
0
 public LogField(LogGroup group, IDataField field, int id)
 {
     ID             = id;
     Name           = field.Name;
     Group          = group;
     DataSource     = field;
     this.ValueType = field.ValueType;
 }
Esempio n. 7
0
        public LogGroupStream(LogGroup group, LogFileType type, int size)
        {
            Group = group;
            Type  = type;
            Size  = size;

            AllocateBuffer();
        }
Esempio n. 8
0
        public bool Subscribe(IDataNode dataSource, string[] fieldLimit)
        {
            LogGroup logGroup;

            if (_groups.Any(x => x.Name == dataSource.Name))
            {
                logGroup = _groups.Where(x => x.Name == dataSource.Name).FirstOrDefault();
                return(logGroup.Resubscribe(dataSource));
            }

            logGroup = new LogGroup(this, dataSource.Name, dataSource, fieldLimit);
            _groups.Add(logGroup);

            return(true);
        }
Esempio n. 9
0
        public void Create()
        {
            int counter = 0;
            var source = new MemoryPool("test", MemoryAddress.StaticAbsolute, 0x123456, 0, 0x1234);

            source.Add(new MemoryFieldFunc<int>("testInt", (pool) => counter++));
            source.Add(new MemoryFieldFunc<string>("test", (pool) => "test"));

            var group = new LogGroup(null, "test", source);

            Assert.AreEqual("test", group.Name);
            Assert.AreEqual(2, group.Fields.Count());
            Assert.AreEqual("testInt", group.Fields.FirstOrDefault().Name);
            Assert.AreEqual("test", group.Fields.Skip(1).FirstOrDefault().Name);

            Assert.True(group.Subscribed);
        }