public override IECGFormat Read(Stream input, int offset, ECGConfig cfg) { IECGFormat ret = null; LastError = 0; if ((input != null) && input.CanRead && input.CanSeek) { long pos = input.Position; int i = 0; ECGConverter converter = ECGConverter.Instance; for (; i < converter.getNrSupportedFormats(); i++) { if (converter.hasUnknownReaderSupport(i)) { try { ret = converter.getFormat(i); if ((ret != null) && ret.CheckFormat(input, offset + converter.getExtraOffset(i))) { ret.Read(input, offset + converter.getExtraOffset(i)); if (ret.Works()) { break; } } input.Position = pos; } catch {} if (ret != null) { ret.Dispose(); ret = null; } } } if (i == converter.getNrSupportedFormats()) { LastError = 2; } } else { LastError = 1; } return(ret); }
public override IECGFormat Read(byte[] buffer, int offset, ECGConfig cfg) { IECGFormat ret = null; LastError = 0; if (buffer != null) { int i = 0; ECGConverter converter = ECGConverter.Instance; for (; i < converter.getNrSupportedFormats(); i++) { if (converter.hasUnknownReaderSupport(i)) { try { ret = converter.getFormat(i); if ((ret != null) && ret.CheckFormat(buffer, offset + converter.getExtraOffset(i))) { ret.Read(buffer, offset + converter.getExtraOffset(i)); if (ret.Works()) { break; } } } catch {} if (ret != null) { ret.Dispose(); ret = null; } } } if (i == converter.getNrSupportedFormats()) { LastError = 2; } } else { LastError = 1; } return(ret); }
public override IECGFormat Read(Stream input, int offset, ECGConfig cfg) { LastError = 0; IECGFormat ret = null; if ((input != null) && input.CanRead && (_nrleads != -1) && (_nrsamplesperlead != -1)) { RawECGFormat MyFormat = new RawECGFormat(); MyFormat.setNrLeads(_nrleads); MyFormat.setNrOfSamplePerLead(_nrsamplesperlead); MyFormat.setLitteEndian(_littleEndian); MyFormat.setSampleRate(_samplerate); MyFormat.setECGLSBperMV(_ECGLSBperMV); MyFormat.setIsADCFormat(_bIsADCFormat); MyFormat.setLeadConfiguration(_theLeadConfig); if (ret.Config != null) { ret.Config.Set(cfg); if (!ret.Config.ConfigurationWorks()) { LastError = 3; return(null); } } ret = (IECGFormat)MyFormat; if (ret.CheckFormat(input, offset)) { LastError = (ret.Read(input, offset) << 2); } if (!ret.Works()) { LastError = 2; ret = null; } } else { LastError = 1; } return(ret); }