/// <summary> /// Function to convert to SCP. /// </summary> /// <param name="src">an ECG file to convert</param> /// <param name="dst">SCP file returned</param> /// <returns>0 on success</returns> public static int ToSCP(IECGFormat src, ECGConfig cfg, out IECGFormat dst) { dst = null; if (src != null) { dst = new SCPFormat(); if ((cfg != null) && ((dst.Config == null) || !dst.Config.Set(cfg))) { return(1); } int err = ECGConverter.Convert(src, dst); if (err != 0) { return(err); } ((SCPFormat)dst).setPointers(); return(0); } return(1); }
/// <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 void Run() { try { if (!converter.waitForFormatSupport("PDF")) { Console.Error.WriteLine("Error: PDF plug-in is not available!"); return; } if (_NoArgs) { Help(); } else if (_BadArgs) { Error(); Help(); } else { UnknownECGReader reader = new UnknownECGReader(); IECGFormat src = reader.Read(_InFile, _InFileOffset); if ((src == null) || !src.Works()) { Console.Error.WriteLine("Error: {0}", reader.getErrorMessage()); return; } ECGConfig config = converter.getConfig("PDF"); for (int i = 0; i < _Config.Count; i++) { if (config != null) { config[(string)_Config.GetKey(i)] = (string)_Config.GetByIndex(i); } } if ((config != null) && !config.ConfigurationWorks()) { Console.Error.WriteLine("Error: Bad Configuration for ECG Format!"); return; } IECGFormat dst = null; converter.Convert(src, "PDF", config, out dst); if ((dst == null) || !dst.Works()) { Console.Error.WriteLine("Error: Creating PDF failed!"); return; } if (_Anonymize) { dst.Anonymous(); } if ((_PatientId != null) && (dst.Demographics != null)) { dst.Demographics.PatientID = _PatientId; } string outfile = Path.GetTempFileName(); ECGWriter.Write(dst, outfile, true); if (ECGWriter.getLastError() != 0) { Console.Error.WriteLine("Error: {0}", ECGWriter.getLastErrorMessage()); return; } if (!PrintPdf(outfile, _Silence)) { Console.Error.WriteLine("Error: Using acrobat to print failed!"); return; } try { File.Delete(outfile); } catch { } } } catch (Exception ex) { Console.Error.WriteLine("Error: {0}", ex.ToString()); } }