Пример #1
0
        public void UpdateView(double timestart, double timeend)
        {
            StreamReader fin = new StreamReader("simulog.log");

            while (!fin.EndOfStream)
            {
                string            text = fin.ReadLine();
                string[]          args = text.Split(' ');
                string            name = args[0];
                int               time = int.Parse(args[1]);
                ValueSegment      vs = null, vsp = null;
                SimulateDataModel sdmodel = vddict[name];
                switch (sdmodel.Type)
                {
                case "BIT":
                    vs       = new BitSegment();
                    vs.Value = Int32.Parse(args[2]);
                    break;

                case "WORD":
                    vs       = new WordSegment();
                    vs.Value = Int32.Parse(args[2]);
                    break;

                case "DWORD":
                    vs       = new DWordSegment();
                    vs.Value = Int64.Parse(args[2]);
                    break;

                case "FLOAT":
                    vs       = new FloatSegment();
                    vs.Value = float.Parse(args[2]);
                    break;
                }
                if (sdmodel.Values.Count() == 0)
                {
                    vsp           = vs.Clone();
                    vsp.Value     = 0;
                    vsp.TimeStart = (int)(timestart);
                    vs.TimeStart  = vsp.TimeEnd = time;
                    sdmodel.Add(vsp);
                    sdmodel.Add(vs);
                }
                else
                {
                    vsp          = sdmodel.Values.Last();
                    vs.TimeStart = vsp.TimeEnd = time;
                    sdmodel.Add(vs);
                }
            }
            foreach (SimulateDataModel sdmodel in vddict.Values)
            {
                if (sdmodel.Values.Count() > 0)
                {
                    sdmodel.Values.Last().TimeEnd = (int)(timeend);
                }
            }
        }
Пример #2
0
                public FloatAnimationCurve(EndianBinaryReader er)
                    : base(er)
                {
                    NrSegments     = er.ReadUInt32();
                    SegmentOffsets = new uint[NrSegments];
                    for (int i = 0; i < NrSegments; i++)
                    {
                        SegmentOffsets[i] = (uint)er.BaseStream.Position + er.ReadUInt32();
                    }
                    long curpos = er.BaseStream.Position;

                    Segments = new FloatSegment[NrSegments];
                    for (int i = 0; i < NrSegments; i++)
                    {
                        er.BaseStream.Position = SegmentOffsets[i];
                        Segments[i]            = new FloatSegment(er);
                    }
                    er.BaseStream.Position = curpos;
                }
Пример #3
0
        public void SetValue(SimulateDataModel sdmodel, object value, int timestart, int timeend)
        {
            RemoveValue(sdmodel, timestart, timeend);

            ValueSegment vseg;

            switch (sdmodel.Type)
            {
            case "BIT":
                BitSegment bseg = new BitSegment();
                bseg.Value = value;
                vseg       = bseg;
                break;

            case "WORD":
                WordSegment wseg = new WordSegment();
                wseg.Value = value;
                vseg       = wseg;
                break;

            case "DWORD":
                DWordSegment dseg = new DWordSegment();
                dseg.Value = value;
                vseg       = dseg;
                break;

            case "FLOAT":
                FloatSegment fseg = new FloatSegment();
                fseg.Value = value;
                vseg       = fseg;
                break;

            default:
                throw new ArgumentException();
            }
            vseg.TimeStart = timestart;
            vseg.TimeEnd   = timeend;
            sdmodel.Add(vseg);
        }
Пример #4
0
        public static Segment ToSegment(byte[] data, int startIndex)
        {
            var     segmentType = TypeConverter.ToSegmentType(data[startIndex]);
            Segment segment     = null;

            switch (segmentType)
            {
            case SegmentType.None:
                segment = new NoneSegment();
                break;

            case SegmentType.EmptyArray:
                segment = new EmptyArraySegment();
                break;

            case SegmentType.NonIndexedArray:
                segment = new NonIndexedArraySegment();
                break;

            case SegmentType.CompactArray:
                segment = new CompactArraySegment();
                break;

            case SegmentType.Illegal:
                segment = new IllegalSegment();
                break;

            case SegmentType.Null:
                segment = new NullSegment();
                break;

            case SegmentType.Boolean:
                segment = new BooleanSegment();
                break;

            case SegmentType.Float:
                segment = new FloatSegment();
                break;

            case SegmentType.Double:
                segment = new DoubleSegment();
                break;

            case SegmentType.NonSensical:
                segment = new NonSensicalSegment();
                break;

            case SegmentType.SmallInteger:
                segment = new SmallIntegerSegment();
                break;

            case SegmentType.SignedInteger:
                segment = new SignedIntegerSegment();
                break;

            case SegmentType.UnsignedInteger:
                segment = new UnsignedIntegerSegment();
                break;

            default:
                // TODO: throw custom exception
                throw new Exception("Segment type is not implemented.");
            }

            segment.ParseValue(data, startIndex);

            return(segment);
        }