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);
        }
        private async Task CloseHandles()
        {
            ProcedureInformation.FlushDataAndCloseObject();
            SystemInformation.FlushDataAndCloseObject();
            CalibrationGroup.FlushDataAndCloseObject();
            //wait for writing all data before resetting
            if (EIT != null)
            {
                await EIT.WaitForDataWritten();

                EIT.Dispose();
            }

            if (ECG != null)
            {
                await ECG.WaitForDataWritten();

                ECG.Dispose();
            }
            if (SystemEvents != null)
            {
                await SystemEvents.WaitForDataWritten();

                SystemEvents.Dispose();
            }

            if (RPosition != null)
            {
                await RPosition.WaitForDataWritten();

                RPosition.Dispose();
            }
            if (Tags != null)
            {
                await Tags.WaitForDataWritten();

                Tags.Dispose();
            }
            if (UserEventsGroup != null)
            {
                await UserEventsGroup.WaitForDataWritten();

                UserEventsGroup.Dispose();
            }
            await Task.CompletedTask;
        }
 public void AppendUserEvent(UserEventRecord record) => UserEventsGroup.Enqueue(record);