public override Signals Clone() { BufferedSignals sigs = new BufferedSignals(this._Source, this.NrLeads); // copy of BufferedSignals items sigs.RealRhythmSamplesPerSecond = this.RealRhythmSamplesPerSecond; sigs.RealRhythmStart = this.RealRhythmStart; sigs.RealRhythmEnd = this.RealRhythmEnd; sigs.TemplateMedianSamplesPerSecond = this.TemplateMedianSamplesPerSecond; sigs.TemplateNrMedian = this.TemplateNrMedian; sigs.TemplateOccurance = this.TemplateOccurance; // copy of Signals items sigs.RhythmAVM = this.RhythmAVM; sigs.RhythmSamplesPerSecond = this.RhythmSamplesPerSecond; sigs.MedianAVM = this.MedianAVM; sigs.MedianLength = this.MedianLength; sigs.MedianSamplesPerSecond = this.MedianSamplesPerSecond; sigs.MedianFiducialPoint = this.MedianFiducialPoint; if (this.QRSZone != null) { sigs.QRSZone = new QRSZone[this.QRSZone.Length]; for (int i = 0; i < sigs.QRSZone.Length; i++) { sigs.QRSZone[i] = this.QRSZone[i].Clone(); } } for (byte i = 0; i < sigs.NrLeads; i++) { sigs[i] = this[i].Clone(); } return(sigs); }
public void Run() { try { if (_NoArgs) { Help(); } else if (_BadArgs) { Error(); Help(); } else { if (_InType != null) { converter.waitForLoadingAllPlugins(); } IECGReader reader = _InType == null ? new UnknownECGReader() : converter.getReader(_InType); if (reader == null) { Console.Error.WriteLine("Error: no reader provided by input type!"); return; } ECGConfig config1 = ECGConverter.Instance.getConfig(_InType); if (config1 != null) { for (int i = 0; i < _Config.Count; i++) { config1[(string)_Config.GetKey(i)] = (string)_Config.GetByIndex(i); } } IECGFormat src = reader.Read(_InFile, _InFileOffset, config1); if (src == null || !src.Works()) { Console.Error.WriteLine("Error: {0}", reader.getErrorMessage()); return; } if ((_BufferedSecondsToLoad > 0) || (_BufferedOffsetToLoad > 0)) { ECGConversion.ECGSignals.Signals sigs = null; if ((src.Signals.getSignals(out sigs) == 0) && sigs.IsBuffered) { ECGConversion.ECGSignals.BufferedSignals bs = (ECGConversion.ECGSignals.BufferedSignals)sigs; int start = 0, end = 0; start = bs.RealRhythmStart + (_BufferedOffsetToLoad * bs.RhythmSamplesPerSecond); end = (_BufferedSecondsToLoad == int.MaxValue) ? _BufferedSecondsToLoad : start + (_BufferedSecondsToLoad * bs.RhythmSamplesPerSecond); if (start > bs.RealRhythmEnd) { start = bs.RealRhythmEnd; } if (end > bs.RealRhythmEnd) { end = bs.RealRhythmEnd; } if (start < end) { bs.LoadSignal(start, end); src.Signals.setSignals(bs); } } } IECGManagementSystem manSys = _OutFile == null ? null : converter.getECGManagementSystem(_OutType); config1 = ECGConverter.Instance.getConfig(manSys == null ? _OutType : manSys.FormatName); ECGConfig config2 = manSys == null ? null : manSys.Config; for (int i = 0; i < _Config.Count; i++) { if (config1 != null) { config1[(string)_Config.GetKey(i)] = (string)_Config.GetByIndex(i); } if (config2 != null) { config2[(string)_Config.GetKey(i)] = (string)_Config.GetByIndex(i); } } if ((config1 != null) && !config1.ConfigurationWorks()) { Console.Error.WriteLine("Error: Bad Configuration for ECG Format!"); return; } if ((config2 != null) && !config2.ConfigurationWorks()) { Console.Error.WriteLine("Error: Bad Configuration for ECG Management System!"); return; } if (manSys == null) { IECGFormat dst = src.GetType() == ECGConverter.Instance.getType(_OutType) ? src : null; if (dst == null) { if ((src.Demographics != null) && (src.Demographics.PatientID == null)) { src.Demographics.PatientID = _PatientId; } ECGConverter.Instance.Convert(src, _OutType, config1, out dst); } if ((dst == null) || !dst.Works()) { Console.Error.WriteLine("Error: Conversion Failed!"); return; } if (_Anonymize) { dst.Anonymous(); } if ((_PatientId != null) && (dst.Demographics != null)) { dst.Demographics.PatientID = _PatientId; } ECGWriter.Write(dst, _OutFile, true); if (ECGWriter.getLastError() != 0) { Console.Error.WriteLine("Error: {0}", ECGWriter.getLastErrorMessage()); } } else { if (manSys.ConfiguredToSave()) { if (_Anonymize) { src.Anonymous(); } manSys.SaveECG(src, _PatientId, config1); } else { Console.Error.WriteLine("Error: Not configured to store!"); } } } } catch (Exception ex) { Console.Error.WriteLine("Error: {0}", ex.ToString()); } }