protected virtual void DoCreateNewFile(int nrSignals, bool overwrite) { Debug.Assert((nrSignals > 0), EdfConstants.NrSignalsShouldBeMoreThan0); if (Active) { throw new DataFileIsOpenException(DataFileConsts.DataFileIsOpen); } if (!UseMemoryStream) { if (FileName.Trim() == string.Empty) { throw new DataFileException(EdfConstants.NoFileName); } if (File.Exists(FileName)) { if (!overwrite) { throw new DataFileExistsException(DataFileConsts.DataFileDataExists); } File.Delete(FileName); } } OpenReadOnly = false; FileInfo = null; SignalInfo.Clear(); Creating = true; }
protected virtual void ReadSignalInfo() { Debug.Assert(FileHandle != null, DataFileConsts.DataFileIsNotOpen); SignalInfo.Clear(); int dummy; if (FileInfo.FieldValid[(int)EdfFileInfoBase.Field.NrSignals] || int.TryParse(FileInfo.EdfFileInfoRaw.NrSignals.Trim(), out dummy)) { List <EdfSignalInfoRaw> tmpSignalInfo = new List <EdfSignalInfoRaw>(); for (int i = 0; i < FileInfo.NrSignals; i++) { EdfSignalInfoBase newSignalDef = CreateSignalInfo(); newSignalDef.StrictChecking = StrictChecking; SignalInfo.Add(newSignalDef); tmpSignalInfo.Add(new EdfSignalInfoRaw()); } if (FileSize >= (FileInfo.NrSignals + 1) * 256) { lock (FileAccess) { FileHandle.Seek(256, SeekOrigin.Begin); for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].SignalLabel = ReadStringField(16); } for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].TransducerType = ReadStringField(80); } for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].PhysiDim = ReadStringField(8); } for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].PhysiMin = ReadStringField(8); } for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].PhysiMax = ReadStringField(8); } for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].DigiMin = ReadStringField(8); } for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].DigiMax = ReadStringField(8); } for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].PreFilter = ReadStringField(80); } for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].NrSamples = ReadStringField(8); } for (int i = 0; i < FileInfo.NrSignals; i++) { tmpSignalInfo[i].Reserved = ReadStringField(32); } } for (int i = 0; i < FileInfo.NrSignals; i++) { SignalInfo[i].SignalInfoRecord = tmpSignalInfo[i]; SignalInfo[i].DataExists = FileInfo.DataExists; } } CalculateDataBlockSize(); } }