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); }
private void Help() { try { converter.waitForLoadingAllPlugins(); bool bHelp = true; if ((_OutType != null) && !_BadArgs) { ECGConfig cfg1 = null, cfg2 = null; IECGFormat format = converter.getFormat(_OutType); if (format != null) { bHelp = false; cfg1 = format.Config; } else { IECGManagementSystem manSys = converter.getECGManagementSystem(_OutType); if (manSys != null) { bHelp = false; cfg1 = manSys.Config; cfg2 = converter.getFormat(manSys.FormatName).Config; } } if (bHelp) { _Error = "Unknown type!"; Error(); } else { int nrItems = cfg1 != null ? cfg1.NrConfigItems : 0; if (cfg2 != null) { nrItems += cfg1.NrConfigItems; } if (nrItems == 0) { Console.WriteLine("Exporting type {0} has got zero configuration items!", _OutType); Console.WriteLine(); } else { Console.WriteLine("Exporting type {0} has got the following configuration items:", _OutType); nrItems = cfg1 != null ? cfg1.NrConfigItems : 0; for (int i = 0; i < nrItems; i++) { string name = cfg1[i], def = cfg1[name]; Console.Write(" {0}", name); if (def != null) { Console.Write(" (default value: \""); Console.Write(def); Console.Write("\")"); } Console.WriteLine(); } nrItems = cfg2 != null ? cfg2.NrConfigItems : 0; for (int i = 0; i < nrItems; i++) { string name = cfg2[i], def = cfg2[name]; Console.Write(" {0}", name); if (def != null) { Console.Write(" (default value: \""); Console.Write(def); Console.Write("\")"); } Console.WriteLine(); } } } } if (bHelp) { string outputTypes, outputECGMS; StringBuilder sb = new StringBuilder(); foreach (string str in converter.getSupportedFormatsList()) { if (sb.Length != 0) { sb.Append(", "); } sb.Append(str); } outputTypes = sb.ToString(); sb = new StringBuilder(); foreach (string str in converter.getSupportedManagementSystemsList()) { if (converter.hasECGManagementSystemSaveSupport(str)) { if (sb.Length != 0) { sb.Append(", "); } sb.Append(str); } } outputECGMS = sb.Length == 0 ? "(none)" : sb.ToString(); Console.WriteLine("Usage: ECGTool [-A] [-P patid] [-I intype] [-bsl nrsec] [-bol nrsec] [-C \"var=val\" [...]] filein [offset] outtype fileout"); Console.WriteLine(" ECGTool [-A] [-P patid] [-I intype] [-bsl nrsec] [-bol nrsec] [-C \"var=val\" [...]] filein [offset] outecgms"); Console.WriteLine(" ECGTool -h [outtype | outecgms | intype]"); Console.WriteLine(); Console.WriteLine(" filein path to input file"); Console.WriteLine(" offset offset in input file"); Console.WriteLine(" outtype type of ouput file: {0}", outputTypes); Console.WriteLine(" fileout path for output file"); Console.WriteLine(" outecgms type of output ECG Management System: {0}", outputECGMS); Console.WriteLine(" -A anonymize output"); Console.WriteLine(" -P patid specifiy a Patient ID for ECG"); Console.WriteLine(" -I intype specify an input type"); Console.WriteLine(" -bsl nrsec buffered seconds to load (add to value: s, m, h, d or w) or use: all"); Console.WriteLine(" -bol nrsec buffered seconds offset to load (add to value: s, m, h, d or w)"); Console.WriteLine(" -C var=val providing a configuration item"); } } catch (Exception ex) { Console.Error.WriteLine("Error: {0}", ex.ToString()); } }