public GraphData(GraphData Original) { void Clone(object CloneFrom, CloneType cloneType) { switch (cloneType) { case CloneType.Status: { if (CloneFrom is ObservableCollection <int> cf) { foreach (int status in cf) { StatusValues.Add(status); } } break; } case CloneType.Latency: { if (CloneFrom is ObservableCollection <int> cf) { foreach (int latency in cf) { LatencyValues.Add(latency); } } break; } case CloneType.TimeStamps: { if (CloneFrom is ObservableCollection <DateTime> cf) { foreach (DateTime dt in cf) { TimeStamps.Add(new DateTime(dt.Ticks)); } } break; } } } GroupName = Original.GroupName; Label = Original.Label; FromHost = Original.FromHost; ToHost = Original.ToHost; Clone(Original.TimeStamps, CloneType.TimeStamps); Clone(Original.StatusValues, CloneType.Status); Clone(Original.LatencyValues, CloneType.Latency); }
public void newTimeStamp(DateTime time) { if (TimeStamps.Count > 10000) //20 minuten een maximale heap van ruwweg 90mb met het maximale aantal bodies { //remove all elements except for the first that exceed 10000 var list = TimeStamps.ToList(); list.RemoveRange(1, list.Count - 10000); //we want to keep the first element so you can still go back TimeStamps = list.ToDictionary(k => k.Key, v => v.Value); Console.WriteLine("Edited map to contain {0} items...", TimeStamps.Count); } Console.WriteLine("saved {0} items", CurMap.celestialBodies.Count); TimeStamps.Add(time, (Map)CurMap.Clone()); }
public virtual float AppendLog(float time, float[] values, float dt, bool ClearIfTimeSuspicious) { if (tMax < time) { tMax = time; } if (resetControllerOffset) { controllerOffset = time; resetControllerOffset = false; tMax = 0; } time -= controllerOffset; if (time < 0 || time < lastTime) // controller has reset { if (ClearIfTimeSuspicious) { ClearAll(); return(0); } else { time = lastTime + dt - controllerOffset; tMax = time; } } if (seriesList.Count != values.Length) { throw new Exception("Data size mismatch"); } for (int i = 0; i < values.Length; i++) { seriesList[i].Values.Add(values[i]); } if (TimeStamps.Count == 0) { TimeStamps.Add(time); } else { TimeStamps.Add(time); } var bkp = lastTime; lastTime = time; return(time - bkp); }