示例#1
0
 protected ValueSegment _Clone(ValueSegment vseg)
 {
     vseg.TimeStart = TimeStart;
     vseg.TimeEnd   = TimeEnd;
     return(vseg);
 }
示例#2
0
 public void Remove(ValueSegment vs)
 {
     values.Remove(vs);
 }
示例#3
0
        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));
            }
        }
示例#4
0
 public void Add(ValueSegment vs)
 {
     values.Add(vs);
 }