/// <summary> /// Function to set configuration based on configration of same kind /// </summary> /// <param name="conf">configuration to set current to</param> /// <returns>true if successful</returns> public bool Set(ECGConfig conf) { if (conf == this) { return(true); } if ((conf != null) && (conf._Configs != null) && (_Configs != null) && (conf._PossibleConfigs.Length == _PossibleConfigs.Length) && (conf._MustValue == _MustValue)) { for (int i = 0; i < _PossibleConfigs.Length; i++) { if (string.Compare(conf._PossibleConfigs[i], _PossibleConfigs[i]) != 0) { return(false); } } _Configs.Clear(); for (int i = 0; i < conf._Configs.Count; i++) { _Configs.Add(conf._Configs.GetKey(i), conf._Configs.GetByIndex(i)); } return(true); } return(false); }
public override int SaveECG(IECGFormat ecg, string patid, ECGConfig cfg) { if (Works() && (_Config["AESCU"] != null) && (_Config["AESCP"] != null) && (_Config["Port"] != null)) { if ((ecg != null) && ecg.Works() && (ecg.GetType() != typeof(DICOM.DICOMFormat))) { IECGFormat dst = null; int ret = ECGConverter.Instance.Convert(ecg, FormatName, cfg, out dst); if (ret != 0) { return(2); } if ((dst != null) && dst.Works()) { ecg = dst; } } if ((ecg != null) && ecg.Works() && (ecg.GetType() == typeof(DICOM.DICOMFormat))) { if (patid != null) { ecg.Demographics.PatientID = patid; } try { DICOM.DICOMFormat dcm = (DICOM.DICOMFormat)ecg; BasicSCU scu = new BasicSCU(_Config["AESCU"], _Config["AESCP"], _Config["Server"], int.Parse(_Config["Port"]), 5000); if (!scu.CStore(dcm.DICOMData)) { return(4); } return(0); } catch {} return(3); } return(2); } return(1); }
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); }
/// <summary> /// Clone configuration /// </summary> /// <param name="bFull">to do a deep copy.</param> /// <returns>an configuration</returns> public ECGConfig Clone(bool bFull) { ECGConfig ret = new ECGConfig(_PossibleConfigs, _MustValue, _CheckConfig); if (bFull) { ret._Configs = new SortedList(_Configs); } return(ret); }
public PACS() { string[] must = { "Server", "AESCU", "AESCP", "Port" }, poss = { "WADO URL" }; _Config = new ECGConfig(must, poss, new ECGConfig.CheckConfigFunction(this._Works)); _Config["Server"] = "127.0.0.1"; _Config["AESCU"] = "STORESCU"; _Config["AESCP"] = "STORESCP"; _Config["Port"] = "104"; }
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); }
public override IECGFormat Read(string file, int offset, ECGConfig cfg) { LastError = 0; IECGFormat ret = null; if (file != null) { try { Stream input = new FileStream(file, FileMode.Open, FileAccess.Read); ret = Read(input, offset, cfg); } catch { LastError = 1; } } return(ret); }
/// <summary> /// Conver to this supported format. /// </summary> /// <param name="src">source format.</param> /// <param name="cfg">configuration to set format to</param> /// <param name="dst">output of destination format.</param> /// <returns>0 on successful</returns> public int Convert(IECGFormat src, ECGConfig cfg, out IECGFormat dst) { dst = null; if (_FormatType == null) { return(1); } if (_ConvertFunction.Length == 0) { dst = (IECGFormat)Activator.CreateInstance(_FormatType); if ((cfg != null) && ((dst.Config == null) || !dst.Config.Set(cfg))) { return(2); } return(ECGConverter.Convert(src, dst) << 2); } try { object[] args = new object[] { src, cfg, null }; int ret = (int)_FormatType.GetMethod(_ConvertFunction).Invoke(null, args); if (args[2] != null) { dst = (IECGFormat)args[2]; } return(ret << 2); } catch { } return(1); }
public override IECGFormat Read(Stream input, int offset, ECGConfig cfg) { LastError = 0; IECGFormat ret = null; if ((input != null) && (input.CanRead)) { ret = new OmronECGFormat(); if (ret.Config != null) { ret.Config.Set(cfg); if (!ret.Config.ConfigurationWorks()) { LastError = 3; return(null); } } if (ret.CheckFormat(input, offset)) { LastError = (ret.Read(input, offset) << 2); } if (!ret.Works()) { LastError = 2; ret = null; } } else { LastError = 1; } return(ret); }
public override IECGFormat Read(byte[] buffer, int offset, ECGConfig cfg) { LastError = 0; IECGFormat ret = null; if (buffer != null) { ret = new OmronECGFormat(); if (ret.Config != null) { ret.Config.Set(cfg); if (!ret.Config.ConfigurationWorks()) { LastError = 3; return(null); } } if (ret.CheckFormat(buffer, offset)) { LastError = (ret.Read(buffer, offset) << 2); } if (!ret.Works()) { LastError = 2; ret = null; } } else { LastError = 1; } return(ret); }
/// <summary> /// Function to read ECG file. /// </summary> /// <param name="input">stream to read from</param> /// <param name="offset">position to start reading</param> /// <param name="cfg">configuration for reading type</param> /// <returns>ECG file</returns> public abstract IECGFormat Read(Stream input, int offset, ECGConfig cfg);
/// <summary> /// Function to read ECG file. /// </summary> /// <param name="file">file path to read from</param> /// <param name="offset">position to start reading</param> /// <param name="cfg">configuration for reading type</param> /// <returns>ECG file</returns> public abstract IECGFormat Read(string file, int offset, ECGConfig cfg);
/// <summary> /// Function to read ECG file. /// </summary> /// <param name="buffer">buffer to read from</param> /// <param name="offset">position to start reading</param> /// <param name="cfg">configuration for reading type</param> /// <returns>ECG file</returns> public abstract IECGFormat Read(byte[] buffer, int offset, ECGConfig cfg);
public virtual void Dispose() { _Config = null; }