예제 #1
0
        private void AppendSample(ElectrodeFrame[] samples, int length)
        {
            float[,] vReData        = new float[length, samples[0].ComplexVoltageMatrix.Length];
            float[,] vImData        = new float[length, samples[0].ComplexVoltageMatrix.Length];
            float[,] cReData        = new float[length, samples[0].ComplexCurrentMatrix.Length];
            float[,] cImData        = new float[length, samples[0].ComplexCurrentMatrix.Length];
            ulong[,] saturationData = new ulong[length, 1];
            long[,] timestampData   = new long[length, 1];
            // Write packet id, kalpa clock only if exist => value != Uint64.MaxValue (default value)
            ulong[,] packetIdData   = samples[0].PacketId == UInt64.MaxValue ? null : new ulong[length, 1];
            ulong[,] kalpaClockData = samples[0].KalpaClock == UInt64.MaxValue ? null : new ulong[length, 1];

            for (var i = 0; i < length; i++)
            {
                ElectrodeFrame electrodeFrame = samples[i];
                for (int j = 0; j < electrodeFrame.ComplexVoltageMatrix.Length; j++)
                {
                    vReData[i, j] = electrodeFrame.ComplexVoltageMatrix[j].Re;
                    vImData[i, j] = electrodeFrame.ComplexVoltageMatrix[j].Im;
                }

                for (int j = 0; j < electrodeFrame.ComplexCurrentMatrix.Length; j++)
                {
                    cReData[i, j] = electrodeFrame.ComplexCurrentMatrix[j].Re;
                    cImData[i, j] = electrodeFrame.ComplexCurrentMatrix[j].Im;
                }

                saturationData[i, 0] = electrodeFrame.SaturationMask;
                timestampData[i, 0]  = electrodeFrame.timestamp;
                if (packetIdData != null)
                {
                    packetIdData[i, 0] = electrodeFrame.PacketId;
                }

                if (kalpaClockData != null)
                {
                    kalpaClockData[i, 0] = electrodeFrame.KalpaClock;
                }
            }
            VoltagesReal.AppendOrCreateDataset(vReData);
            VoltagesIm.AppendOrCreateDataset(vImData);
            CurrentsReal.AppendOrCreateDataset(cReData);
            CurrentsIm.AppendOrCreateDataset(cImData);
            Saturation.AppendOrCreateDataset(saturationData);
            Timestamps.AppendOrCreateDataset(timestampData);
            if (packetIdData != null)
            {
                PacketIds.AppendOrCreateDataset(packetIdData);
            }

            if (kalpaClockData != null)
            {
                KalpaClocks.AppendOrCreateDataset(kalpaClockData);
            }
        }