예제 #1
0
        public KamaAcquisitionFile(string filename, AcquisitionInterface acquisitionInterface, ILogger logger,
                                   int eitDefaultChunkSize = 24000, int ecgDefaultChunkSize = 10)
        {
            FileName            = filename;
            Logger              = logger;
            EITDefaultChunkSize = eitDefaultChunkSize;
            ECGDefaultChunkSize = ecgDefaultChunkSize;

            RecordNumber = 1;
            H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero);
            fileId               = Hdf5.CreateFile(filename);
            groupRoot            = fileId;
            groupEIT             = Hdf5.CreateOrOpenGroup(groupRoot, "eit");
            ProcedureInformation = new ProcedureInformation(fileId, groupRoot, logger)
            {
                ProcedureDirectory = Path.GetDirectoryName(filename),
                StartDateTime      = DateTime.Now,
                EndDateTime        = DateTime.Now
            };

            SystemInformation            = new SystemInformation(fileId, groupRoot, logger);
            SystemInformation.SystemType = acquisitionInterface.ToString();
            //  InjectionGroup = new InjectionGroup(fileId, groupRoot);
            CalibrationGroup = new CalibrationGroup(fileId, groupRoot, logger);
            SystemEvents     = new SystemEventGroup(fileId, groupRoot, logger);
            RPosition        = new RPositionGroup(fileId, groupRoot, logger);
            Tags             = new TagsGroup(fileId, groupRoot, logger);
            UserEventsGroup  = new UserEventsGroup(fileId, groupRoot, logger);
        }
예제 #2
0
        public void H5Eset_autoTest1()
        {
            H5E.auto_t cb          = null;
            IntPtr     client_data = IntPtr.Zero;

            Assert.IsTrue(
                H5E.set_auto(H5E.DEFAULT, cb, client_data) >= 0);
        }
예제 #3
0
        public bool EnableErrorReporting(bool enable)
        {
            ErrorLoggingEnable = enable;
            if (enable)
            {
                return(H5E.set_auto(H5E.DEFAULT, Hdf5Errors.ErrorDelegateMethod, IntPtr.Zero) >= 0);
            }

            return(H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero) >= 0);
        }
예제 #4
0
        public void H5EwalkTest1()
        {
            H5E.auto_t auto_cb = ErrorDelegateMethod;
            Assert.IsTrue(
                H5E.set_auto(H5E.DEFAULT, auto_cb, IntPtr.Zero) >= 0);

            H5E.walk_t walk_cb = WalkDelegateMethod;
            Assert.IsTrue(
                H5E.walk(H5E.DEFAULT, H5E.direction_t.H5E_WALK_DOWNWARD,
                         walk_cb, IntPtr.Zero) >= 0);
        }
예제 #5
0
        // private readonly ReaderWriterLockSlim lock_ = new ReaderWriterLockSlim();

        public Hdf5AcquisitionFileWriter(string filename, string groupName = "ROOT")
        {
            H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero);
            //lock_.EnterWriteLock();
            _filename  = filename;
            fileId     = Hdf5.CreateFile(filename);
            _groupName = groupName;
            _groupId   = Hdf5.CreateGroup(fileId, Hdf5Utils.NormalizedName(_groupName));

            Header       = new Hdf5AcquisitionFile();
            _nrOfRecords = 0;
            _sampleCount = 0;
            //lock_.ExitWriteLock();
        }
예제 #6
0
        // private readonly ReaderWriterLockSlim lock_ = new ReaderWriterLockSlim();

        public Hdf5AcquisitionFileWriter(string aFilename, string groupName = "/EEG")
        {
            H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero);
            //lock_.EnterWriteLock();
            _filename  = aFilename;
            fileId     = Hdf5.CreateFile(aFilename);
            _groupName = groupName;
            _groupId   = Hdf5.CreateGroup(fileId, _groupName);

            Header       = new Hdf5AcquisitionFile();
            _nrOfRecords = 0;
            _sampleCount = 0;
            //lock_.ExitWriteLock();
        }
예제 #7
0
        public static void SuppressErrors(Action action)
        {
            H5E.auto_t func;
            IntPtr     clientData;

            func       = null;
            clientData = IntPtr.Zero;

            H5E.get_auto(H5E.DEFAULT, ref func, ref clientData);
            H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero);

            action.Invoke();

            H5E.set_auto(H5E.DEFAULT, func, clientData);
        }
예제 #8
0
        public static void CaptureHdfLibOutput(ITestOutputHelper logger)
        {
            H5E.set_auto(H5E.DEFAULT, ErrorDelegateMethod, IntPtr.Zero);

            int ErrorDelegateMethod(long estack, IntPtr client_data)
            {
                H5E.walk(estack, H5E.direction_t.H5E_WALK_DOWNWARD, WalkDelegateMethod, IntPtr.Zero);
                return(0);
            }

            int WalkDelegateMethod(uint n, ref H5E.error_t err_desc, IntPtr client_data)
            {
                logger.WriteLine($"{n}: {err_desc.desc}");
                return(0);
            }
        }
예제 #9
0
        public void H5EwalkTest2()
        {
            // H5E.set_auto(H5E.DEFAULT, ErrorDelegateMethod, IntPtr.Zero);
            Assert.IsTrue(
                H5E.set_auto(H5E.DEFAULT, ErrorDelegateMethod, IntPtr.Zero) >= 0);

            H5E.walk_t walk_cb = WalkDelegateMethod;
            Assert.IsTrue(
                H5E.push(H5E.DEFAULT, "hello.c", "sqrt", 77, H5E.ERR_CLS,
                         H5E.NONE_MAJOR, H5E.NONE_MINOR, "Hello, World!") >= 0);

            Assert.IsTrue(
                H5E.push(H5E.DEFAULT, "hello.c", "sqr", 78, H5E.ERR_CLS,
                         H5E.NONE_MAJOR, H5E.NONE_MINOR, "Hello, World!") >= 0);

            Assert.IsTrue(
                H5E.walk(H5E.DEFAULT, H5E.direction_t.H5E_WALK_DOWNWARD,
                         walk_cb, IntPtr.Zero) >= 0);
        }
예제 #10
0
        public static List <(string Path, string Name)> GetPathSet(long locationId, int maxDepth, bool includeGroups, bool includeDatasets)
        {
            ulong idx;
            List <(string Path, string Name)> datasetPathSet;

            H5E.auto_t func;
            IntPtr     clientData;

            idx            = default;
            datasetPathSet = new List <(string Path, string Name)>();
            func           = null;
            clientData     = IntPtr.Zero;

            H5E.get_auto(H5E.DEFAULT, ref func, ref clientData);
            H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero);
            H5L.iterate(locationId, H5.index_t.NAME, H5.iter_order_t.INC, ref idx, Callback, Marshal.StringToHGlobalAnsi("/"));
            H5E.set_auto(H5E.DEFAULT, func, clientData);

            return(datasetPathSet);

            int Callback(long groupId, IntPtr intPtrName, ref H5L.info_t info, IntPtr intPtrUserData)
            {
                long datasetId = -1;

                ulong idx2 = default;
                int   level;

                string name;
                string userData;

                H5O.type_t objectType;

                name     = Marshal.PtrToStringAnsi(intPtrName);
                userData = Marshal.PtrToStringAnsi(intPtrUserData);
                level    = userData.Split("/".ToArray()).Count();

                // this is necessary, since H5Oget_info_by_name is slow because it wants verbose object header data
                // and H5G_loc_info is not directly accessible
                // only chance is to modify source code (H5Oget_info_by_name) or use V2 B-tree
                datasetId = H5D.open(groupId, name);

                if (datasetId > -1)
                {
                    objectType = H5O.type_t.DATASET;
                }
                else
                {
                    groupId = H5G.open(groupId, name);

                    if (groupId > -1)
                    {
                        objectType = H5O.type_t.GROUP;
                    }
                    else
                    {
                        objectType = H5O.type_t.UNKNOWN;
                    }
                }

                switch (objectType)
                {
                case H5O.type_t.GROUP:

                    if (level <= maxDepth)
                    {
                        H5L.iterate(groupId, H5.index_t.NAME, H5.iter_order_t.INC, ref idx2, Callback, Marshal.StringToHGlobalAnsi(GeneralHelper.CombinePath(userData, name)));

                        if (includeGroups)
                        {
                            datasetPathSet.Add((userData, name));
                        }

                        H5G.close(groupId);
                    }

                    break;

                case H5O.type_t.DATASET:

                    if (includeDatasets)
                    {
                        datasetPathSet.Add((userData, name));
                    }

                    H5D.close(datasetId);
                    break;

                default:
                    break;
                }

                return(0);
            }
        }
예제 #11
0
 public static void DisableErrorPrinting()
 {
     H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero);
 }