protected int ReadTALs(object sender, int blockNr, ref bool readOk)
        {
            int result = -1;

            if (Active)
            {
                if ((blockNr >= 0) && (blockNr < FileInfo.NrDataRecords))
                {
                    try
                    {
                        // Add a new block to TAL if necessary, set onset to NAN
                        TAL.AddBlock(blockNr, double.NaN); // To avoid recursive calls by ReadDataBlock
                        DoReadDataBlock(blockNr, ref _talDataBuffer);
                        DoReadTALs(blockNr, _talDataBuffer, ref readOk);
                        result = blockNr;
                    }
                    catch { }
                }
                if (result < 0)
                {
                    readOk = false;
                    result = FileInfo.NrDataRecords;
                }
            }
            return(result);
        }
 public void WriteDataBlock(int blockNr, double onset)
 {
     base.WriteDataBlock(blockNr);
     Debug.Assert(DataBuffer == null, "Object is not initialized");
     if (blockNr == 0)
     {
         if ((onset < 0) || (onset >= 1))
         {
             throw new DataFileInvalidBlock0OnsetException(DataFileConsts.DataFileInvalidBlock0Onset);
         }
         FileInfo.FirstDataBlockOnset = onset;
     }
     if (FileInfo.SignalDataIsContinuous && (FileInfo.FirstDataBlockOnset + blockNr * FileInfo.SampleRecDuration != onset))
     {
         throw new DataFileContinuousException(DataFileConsts.DataFileContinuous);
     }
     TAL.AddBlock(blockNr, onset); // overwrites offset if block already exists
     // Write data to file
     if (!DoWriteDataBlock(blockNr, DataBuffer))
     {
         throw new DataFileWriteDataException(DataFileConsts.DataFileWriteData);
     }
 }
Example #3
0
 public override void WriteDataBlock(int blockNr)
 {
     base.WriteDataBlock(blockNr);
     Debug.Assert(DataBuffer != null, "Object is not initialized");
     // Update TAL list
     if (!TAL.BlockInMemory(blockNr))
     {
         if (!FileInfo.SignalDataIsContinuous)
         {
             throw new DataFileNotContinuousException(DataFileConsts.DataFileNotContinuous);
         }
         TAL.AddBlock(blockNr, blockNr * FileInfo.SampleRecDuration);
         if (blockNr == 0)
         {
             FileInfo.FirstDataBlockOnset = 0;
         }
     }
     // Write data to file
     if (!DoWriteDataBlock(blockNr, DataBuffer))
     {
         throw new DataFileWriteDataException(DataFileConsts.DataFileWriteData);
     }
 }