protected ValueSegment _Clone(ValueSegment vseg) { vseg.TimeStart = TimeStart; vseg.TimeEnd = TimeEnd; return(vseg); }
public void Remove(ValueSegment vs) { values.Remove(vs); }
public void Update(SimulateDllModel dllmodel, int time) { SVUnit.Update(dllmodel); Move(time); ValueSegment nseg = null; if (CurrentSegment != null) { nseg = CurrentSegment; if (time > nseg.TimeEnd) { if (!SVUnit.Value.Equals(nseg.Value)) { nseg = nseg.Clone(); nseg.Value = SVUnit.Value; nseg.TimeStart = nseg.TimeEnd + 1; nseg.TimeEnd = time; values.Insert(CurrentIndex + 1, nseg); } else { nseg.TimeEnd = time; } } else if (time >= nseg.TimeStart && time <= nseg.TimeEnd) { if (!SVUnit.Value.Equals(nseg.Value)) { values.Remove(nseg); ValueSegment lseg = nseg.Clone(); ValueSegment rseg = nseg.Clone(); nseg = nseg.Clone(); lseg.TimeEnd = time - 1; rseg.TimeStart = time + 1; nseg.TimeStart = nseg.TimeEnd = time; nseg.Value = SVUnit.Value; if (rseg.TimeEnd >= rseg.TimeStart) { values.Insert(CurrentIndex, rseg); } values.Insert(CurrentIndex, nseg); if (lseg.TimeEnd >= lseg.TimeStart) { values.Insert(CurrentIndex, lseg); } } } else { throw new ArgumentException(String.Format("Cannot get value segment related to time {0:d}", time)); } } else if (values.Count() == 0) { Init(time); CurrentIndex = 0; CurrentSegment.Value = SVUnit.Value; } else if (CurrentIndex < 0) { nseg = values.First().Clone(); nseg.Value = SVUnit.Value; nseg.TimeStart = nseg.TimeEnd = time; values.Insert(0, nseg); } else { throw new ArgumentException(String.Format("Cannot get value segment related to time {0:d}", time)); } }
public void Add(ValueSegment vs) { values.Add(vs); }