Ejemplo n.º 1
0
    static void Main(string[] argv) {
		
	WFDB_AnninfoArray an = new WFDB_AnninfoArray(2);
	string record = null, iann = null, oann = null;
	WFDB_Annotation annot =  new WFDB_Annotation();

	Console.Write("Type record name: ");
	record = Console.ReadLine();
	Console.Write("Type input annotator name: ");
	iann = Console.ReadLine();
	Console.Write("Type output annotator name: ");
	oann = Console.ReadLine();
	
	WFDB_Anninfo a = an.getitem(0);
	a.name = iann; a.stat =wfdb.WFDB_READ;
	an.setitem(0,a);
	a = an.getitem(1);
	a.name = oann; a.stat = wfdb.WFDB_WRITE;
	an.setitem(1,a);
	
	if ( wfdb.annopen(record, an.cast(), 2) < 0 ) Environment.Exit(1);
	while ( wfdb.getann(0, annot) == 0) {
	    if ( wfdb.wfdb_isqrs(annot.anntyp) != 0 ) {
		// Note that C# cannot cast an int (such as that returned by
		// isqrs) to a boolean, so omitting the comparison to 0, as in
		// other translations of this code, does not work in this case.
		annot.anntyp = wfdb.NORMAL;
		if ( wfdb.putann(0, annot) < 0) break;
	    }
	}

	wfdb.wfdbquit();
    }
Ejemplo n.º 2
0
    static void Main(string[] argv) {
	int stat;
	String record = null, annotator = null;
	
	if (argv.Length < 4) {
	    usage();
	    Environment.Exit(2);
	}
		
	for (int i = 0; i < argv.Length; i++) {
	    if (argv[i] == "-r") {
		record = argv[++i];
	    } else if (argv[i] == "-a") {
		annotator = argv[++i];
	    } else {
		usage();
	    }
	}
	
	if (record == null || annotator == null) {
	    usage();
	    Environment.Exit(2);
	}
	
	WFDB_AnninfoArray aiarray = new WFDB_AnninfoArray(1);
	WFDB_Anninfo ai = new WFDB_Anninfo();
	WFDB_Annotation annot = new WFDB_Annotation();
	
	ai.name = annotator;
	ai.stat = wfdb.WFDB_READ;
	aiarray.setitem(0,ai);
	
	stat = wfdb.annopen(record, aiarray.cast(), 1);
	if (stat < 0) {
	    usage();
	    Environment.Exit(2);
	}
	
	while (wfdb.getann(0, annot) == 0 ) {
	    Console.WriteLine(wfdb.mstimstr(-annot.time) + "\t" +
			      annot.time + "\t" + 
			      wfdb.annstr(annot.anntyp) + "\t" + 
			      annot.subtyp + "\t" + 
			      annot.chan + "\t" + 
			      annot.num + "\t" +
			      // print the aux string, excluding the first
			      // char, which is the length of the string
			      (annot.aux == null ? "" : 
			       annot.aux.Substring(1)));
	}

	wfdb.wfdbquit();
    }
Ejemplo n.º 3
0
    static void Main(string[] argv) {
	WFDB_AnninfoArray an = new WFDB_AnninfoArray(2);
	WFDB_Annotation annot = new WFDB_Annotation();
		
	if (argv.Length < 1) {
	    Console.WriteLine("usage: example2 record");
	    // Unlike C programs, Java programs do not have any foolproof way
	    // to discover their own names, so the name is given as a constant
	    // above.  The command needed to run this program within a VM
	    // is platform-dependent and likely to be more complex.
	    Environment.Exit(1);
	}
	WFDB_Anninfo a = an.getitem(0);
	a.name = "atr"; a.stat = wfdb.WFDB_READ;
	an.setitem(0, a);
	a = an.getitem(1);
	a.name = "aha"; a.stat = wfdb.WFDB_AHA_WRITE;
	an.setitem(1,a);
	if (wfdb.annopen(argv[0], an.cast(), 2) < 0) Environment.Exit(2);
	while (wfdb.getann(0, annot) == 0 && wfdb.putann(0, annot) == 0)
	    ;
	wfdb.wfdbquit();
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Opens a SINGLE annotation (closing any other open annotations), according to
 /// the passed parameters, and initializing and returning a WFDB_AnninfoArray object.
 /// </summary>
 /// <param name="record">Name of the record whose annotation we are opening.</param>
 /// <param name="aiArray">Annotation Info array (one element), built and populated
 ///                         by this method.</param>
 /// <param name="annotName">Name (i.e., file extension) of the Annotation.</param>
 /// <param name="openForRead">True to open for reading, False to open for writing.</param>
 /// <param name="errMsg">Contains any error messages relevant to failed execution.</param>
 /// <returns>True if successful, False if failed.  If failed, the cause is in errMsg.</returns>
 public static bool OpenAnnotation(
     string record,
     ref WFDB_AnninfoArray aiArray,
     string annotName,
     bool openForRead,
     ref string errMsg)
 {
     try
     {
         aiArray = new WFDB_AnninfoArray(1);
         WFDB_Anninfo annInfo = new WFDB_Anninfo();
         annInfo.name = annotName;
         if (openForRead)
         {
             annInfo.stat = wfdb.WFDB_READ;
         }
         else
         {
             annInfo.stat = wfdb.WFDB_WRITE;
         }
         aiArray.setitem(0, annInfo);
         wfdb.annopen(record, aiArray.cast(), 1);
     }
     catch (Exception annopenException)
     {
         while (annopenException.InnerException != null)
         {       // Drill down:
             annopenException = annopenException.InnerException;
         }
         errMsg += annopenException.ToString() + newLine;
         MessageBox.Show("Exception occurred trying annopen(...): \n"
                         + annopenException.ToString() + "\n");
         return(false);
     }
     // No exception?  Success!
     return(true);
 }