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); }
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); } }
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); }
public LogField(LogGroup group, IDataField field, int id) { ID = id; Name = field.Name; Group = group; DataSource = field; this.ValueType = field.ValueType; }
public LogGroupStream(LogGroup group, LogFileType type, int size) { Group = group; Type = type; Size = size; AllocateBuffer(); }
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); }
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); }