Exemplo n.º 1
0
        private C3DFile(Stream stream)
        {
            C3DReader reader = null;

            try
            {
                reader = new C3DReader(stream);

                this._processorType       = reader.CreateProcessorType;
                this._header              = reader.ReadHeader();
                this._parameterDictionary = reader.ReadParameters();
                this._frameCollection     = new C3DFrameCollection();

                try
                {
                    C3DParameterCache paramCache = C3DParameterCache.CreateCache(this);
                    C3DFrame          frame      = null;
                    while ((frame = reader.ReadNextFrame(paramCache)) != null)
                    {
                        this._frameCollection.Add(frame);
                    }
                }
                catch { }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Exemplo n.º 2
0
 private C3DFile()
 {
     this._processorType       = C3DConstants.FILE_DEFAULT_PROCESSOR_TYPE;
     this._header              = new C3DHeader();
     this._parameterDictionary = C3DParameterDictionary.CreateNewParameterDictionary();
     this._frameCollection     = new C3DFrameCollection();
 }
Exemplo n.º 3
0
        public C3DHeader ReadHeader()
        {
            this._reader.BaseStream.Seek(0, SeekOrigin.Begin);

            Byte[]    headerData = this._reader.ReadBytes(C3DConstants.FILE_SECTION_SIZE);
            C3DHeader header     = new C3DHeader(this._processorType, headerData);

            return(header);
        }
Exemplo n.º 4
0
 private void LoadAnalogSamplesPerFrame(C3DHeader header, C3DParameterDictionary dictionary)
 {
     if (dictionary != null && dictionary.ContainsParameter("ANALOG", "RATE"))
     {
         this._analogSamplesPerFrame = (UInt16)(Convert.ToSingle(dictionary["ANALOG", "RATE"].GetData(0)) / this._frameRate);
     }
     else if (header != null)
     {
         this._analogSamplesPerFrame = header.AnalogSamplesPerFrame;
     }
     else
     {
         this._analogSamplesPerFrame = (UInt16)(C3DConstants.DEFAULT_ANALOG_RATE / C3DConstants.DEFAULT_POINT_RATE);
     }
 }
Exemplo n.º 5
0
 private void LoadAnalogChannelCount(C3DHeader header, C3DParameterDictionary dictionary)
 {
     if (dictionary != null && dictionary.ContainsParameter("ANALOG", "USED"))
     {
         this._analogChannelCount = (UInt16)Convert.ToInt16(dictionary["ANALOG", "USED"].GetData(0));
     }
     else if (header != null)
     {
         this._analogChannelCount = (UInt16)(header.AnalogSamplesPerFrame != 0 ? header.AnalogMeasurementCount / header.AnalogSamplesPerFrame : 0);
     }
     else
     {
         this._analogChannelCount = C3DConstants.DEFAULT_ANALOG_USED;
     }
 }
Exemplo n.º 6
0
 private void LoadFrameRate(C3DHeader header, C3DParameterDictionary dictionary)
 {
     if (dictionary != null && dictionary.ContainsParameter("POINT", "RATE"))
     {
         this._frameRate = Convert.ToSingle(dictionary["POINT", "RATE"].GetData(0));
     }
     else if (header != null)
     {
         this._frameRate = header.FrameRate;
     }
     else
     {
         this._frameRate = C3DConstants.DEFAULT_POINT_RATE;
     }
 }
Exemplo n.º 7
0
 private void LoadFrameCount(C3DHeader header, C3DParameterDictionary dictionary)
 {
     if (dictionary != null && dictionary.ContainsParameter("POINT", "FRAMES"))
     {
         this._frameCount = (UInt16)Convert.ToInt16(dictionary["POINT", "FRAMES"].GetData(0));
     }
     else if (header != null)
     {
         this._frameCount = (UInt16)(header.LastFrameIndex - header.FirstFrameIndex + 1);
     }
     else
     {
         this._frameCount = C3DConstants.DEFAULT_POINT_LAST_FRAME - C3DConstants.DEFAULT_POINT_FIRST_FRAME + 1;
     }
 }
Exemplo n.º 8
0
 private void LoadScaleFactor(C3DHeader header, C3DParameterDictionary dictionary)
 {
     if (dictionary != null && dictionary.ContainsParameter("POINT", "SCALE"))
     {
         this._scaleFactor = Convert.ToSingle(dictionary["POINT", "SCALE"].GetData(0));
     }
     else if (header != null)
     {
         this._scaleFactor = header.ScaleFactor;
     }
     else
     {
         this._scaleFactor = C3DConstants.DEFAULT_POINT_SCALE;
     }
 }
Exemplo n.º 9
0
 private void LoadPointCount(C3DHeader header, C3DParameterDictionary dictionary)
 {
     if (dictionary != null && dictionary.ContainsParameter("POINT", "USED"))
     {
         this._pointCount = (UInt16)Convert.ToInt16(dictionary["POINT", "USED"].GetData(0));
     }
     else if (header != null)
     {
         this._pointCount = header.PointCount;
     }
     else
     {
         this._pointCount = C3DConstants.DEFAULT_POINT_USED;
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// 初始化取参数缓存信息
        /// </summary>
        /// <param name="header">C3D文件头</param>
        /// <param name="dictionary">C3D参数字典</param>
        private C3DParameterCache(C3DHeader header, C3DParameterDictionary dictionary)
        {
            this.LoadFirstDataBlockPosition(header, dictionary);

            this.LoadPointCount(header, dictionary);
            this.LoadScaleFactor(header, dictionary);
            this.LoadFrameCount(header, dictionary);
            this.LoadFrameRate(header, dictionary);

            this.LoadAnalogChannelCount(header, dictionary);
            this.LoadAnalogSamplesPerFrame(header, dictionary);

            this.LoadAnalogGeneralScale(dictionary);
            this.LoadAnalogChannelScale(dictionary);
            this.LoadAnalogZeroOffset(dictionary);
        }
Exemplo n.º 11
0
        private void LoadFirstDataBlockPosition(C3DHeader header, C3DParameterDictionary dictionary)
        {
            this._firstDataBlockPosition = 0;

            if (dictionary != null && dictionary.ContainsParameter("POINT", "DATA_START"))
            {
                this._firstDataBlockPosition = ((UInt16)Convert.ToInt16(dictionary["POINT", "DATA_START"].GetData(0)) - 1) * C3DConstants.FILE_SECTION_SIZE;
            }

            if (header != null && this._firstDataBlockPosition <= 0)
            {
                this._firstDataBlockPosition = (header.FirstDataSectionID - 1) * C3DConstants.FILE_SECTION_SIZE;
            }

            if (this._firstDataBlockPosition <= 0)
            {
                this._firstDataBlockPosition = (C3DConstants.FILE_DEFAULT_FIRST_PARAM_SECTION - 1) * C3DConstants.FILE_SECTION_SIZE;
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// 从C3D文件头和参数字典中创建参数缓存
 /// </summary>
 /// <param name="header">C3D文件头</param>
 /// <param name="dictionary">C3D参数字典</param>
 public static C3DParameterCache CreateCache(C3DHeader header, C3DParameterDictionary dictionary)
 {
     return(new C3DParameterCache(header, dictionary));
 }
Exemplo n.º 13
0
 /// <summary>
 /// 从C3D文件头中创建参数缓存
 /// </summary>
 /// <param name="header">C3D文件头</param>
 public static C3DParameterCache CreateCache(C3DHeader header)
 {
     return(new C3DParameterCache(header, null));
 }
Exemplo n.º 14
0
 private void WriteHeader(C3DHeader header)
 {
     this._writer.Seek(0, SeekOrigin.Begin);
     this._writer.Write(header.ToArray());
 }