Beispiel #1
0
        public ECG(long fileId, long groupRoot, int chunkSize, int sampleRate, ILogger logger) : base(fileId, groupRoot, "ecg", logger)
        {
            ChunkSize = chunkSize;
            var pool = ArrayPool <ECGFrame> .Shared;

            SamplingRate = sampleRate;
            if (sampleRate == 0)
            {
                logger.LogCritical("No sample rate was supplied");
            }
            EcgSamplesData = new BlockingCollectionQueue <ECGFrame>();
            Parameters     = new Dictionary <string, string>();
            Header         = new Dictionary <string, string>();
            UnFiltered     = new ChunkedDataset <double>("Signals_unfiltered", GroupId);
            Filtered       = new ChunkedDataset <double>("Signals_filtered", GroupId);
            Filtered       = new ChunkedDataset <double>("Signals_filtered", GroupId);
            Timestamps     = new ChunkedDataset <long>("timestamps", GroupId);
            PacketIds      = new ChunkedDataset <ulong>("packetids", GroupId);
            KalpaClocks    = new ChunkedDataset <ulong>("kalpaclocks", GroupId);
            EcgTaskWriter  = Task.Factory.StartNew(() =>
            {
                var buffer = pool.Rent(ChunkSize);
                completed  = false;
                int count  = 0;
                foreach (ECGFrame data in EcgSamplesData.GetConsumingEnumerable())
                {
                    buffer[count++] = data;
                    if (count == ChunkSize)
                    {
                        AppendSample(buffer, chunkSize);
                        count = 0;
                    }
                }
                if (count != 0)
                {
                    AppendSample(buffer, count);
                }
                FlushData();//end of data samples. flush data
                pool.Return(buffer);
            });
        }
Beispiel #2
0
        public EIT(int recordNumber, int chunkSize, string acquisitionProtocol, long fileId, long groupRoot, ILogger logger) : base(fileId, groupRoot, "d" + recordNumber, logger)
        {
            ChunkSize = chunkSize;
            var pool = ArrayPool <ElectrodeFrame> .Shared;

            ElectrodeSamplesData = new BlockingCollectionQueue <ElectrodeFrame>();
            Configuration        = acquisitionProtocol;
            VoltagesReal         = new ChunkedDataset <float>("voltages.re", GroupId);
            VoltagesIm           = new ChunkedDataset <float>("voltages.im", GroupId);
            CurrentsReal         = new ChunkedDataset <float>("currents.re", GroupId);
            CurrentsIm           = new ChunkedDataset <float>("currents.im", GroupId);
            Saturation           = new ChunkedDataset <ulong>("saturations", GroupId);
            Timestamps           = new ChunkedDataset <long>("timestamps", GroupId);
            PacketIds            = new ChunkedDataset <ulong>("packetids", GroupId);
            KalpaClocks          = new ChunkedDataset <ulong>("kalpaclocks", GroupId);
            ElectrodeTaskWriter  = Task.Factory.StartNew(() =>
            {
                var buffer = pool.Rent(ChunkSize);
                completed  = false;
                int count  = 0;
                foreach (ElectrodeFrame data in ElectrodeSamplesData.GetConsumingEnumerable())
                {
                    buffer[count++] = data;
                    if (count == ChunkSize)
                    {
                        EndDateTime = data.timestamp;
                        AppendSample(buffer, chunkSize);
                        count = 0;
                    }
                }

                if (count != 0)
                {
                    EndDateTime = buffer[count - 1].timestamp;
                    AppendSample(buffer, count);
                }
                FlushData();//end of data samples. flush data
                pool.Return(buffer);
            });
        }