Example #1
0
        /// <summary>
        /// 在采集结束时才能设置
        /// </summary>
        /// <param name="sampleCount">每通道采样总数</param>
        public void SetAndClose(int sampleCount)
        {
            myHDF5Group.SetAttribute("SampleCount", HDF5AttributeTypes.DOUBLE, sampleCount);

            //关闭所有打开的 HDF5 项目
            foreach (var d in myHDF5Datasets)
            {
                d.Close();
            }
            myHDF5Group.Close();
            myHDF5File.Close();
        }
Example #2
0
        /// <summary>
        /// 依照 BinData 签名的构造函数
        /// </summary>
        /// <param name="dataFileDirectory">HDF5 文件所在文件夹</param>
        /// <param name="name">HDF5 文件名不带后缀</param>
        public DataReader(string dataFileDirectory, string name)
        {
            this.name         = name;
            this.dataFilePath = dataFileDirectory + name + ".hdf5";

            myH5File = new HDF5File();
            myH5File.Open(this.dataFilePath);
            myH5Group = myH5File.GetGroup("Attribute");

            // double 转 object 后,object 不能直接转 int,需要先转 double 再转 int
            double d = (double)myH5Group.GetAttribute("ChannelCount");

            channelCount = (int)d;
            d            = (double)myH5Group.GetAttribute("SampleCount");
            sampleCount  = (int)d;
            sampleRate   = (double)myH5Group.GetAttribute("SampleRate");
            startTime    = (double)myH5Group.GetAttribute("StartTime");
            createTime   = (double)myH5Group.GetAttribute("CreateTime");

            myH5Group.Close();
            myH5File.Close();
        }