static void Main(string[] argv) { int i, nsig, nsamp = 1000; if (argv.Length < 1) { Console.WriteLine("usage: example6 record"); // Unlike C programs, C# 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); } if ((nsig = wfdb.isigopen(argv[0], null, 0)) <= 0) Environment.Exit(2); WFDB_SiginfoArray s = new WFDB_SiginfoArray(nsig); WFDB_SampleArray vin = new WFDB_SampleArray(nsig); WFDB_SampleArray vout = new WFDB_SampleArray(nsig); if (wfdb.isigopen(argv[0], s.cast(), nsig) != nsig) Environment.Exit(2); if (wfdb.osigopen("8l", s.cast(), (uint)nsig) <= 0) Environment.Exit(3); while (nsamp-- > 0 && wfdb.getvec(vin.cast()) > 0) { for (i = 0; i < nsig; i++) { vout.setitem(i, vout.getitem(i) - vin.getitem(i)); } if (wfdb.putvec(vout.cast()) < 0) break; for (i = 0; i < nsig; i++) { vout.setitem(i, vin.getitem(i)); } } wfdb.newheader("dif"); wfdb.wfdbquit(); }
static void Main(string[] argv) { double[] c; double vv; int i, j, nc = argv.Length - 4, nsig, nsamp, t; if (argv.Length < 3) { Console.WriteLine( "usage: example7 record start duration [ coefficients ... ]"); // Unlike C programs, C# 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); } if (nc < 1) { nc = 1; c = new double[1]; c[0] = 1.0; } else { c = new double[nc]; } for (i = 0; i < nc; i++) c[i] = Double.Parse(argv[i+3]); if ((nsig = wfdb.isigopen(argv[0], null, 0)) < 1) Environment.Exit(3); WFDB_SiginfoArray s = new WFDB_SiginfoArray(nsig); WFDB_SampleArray v = new WFDB_SampleArray(nsig); if (wfdb.isigopen(argv[0], s.cast(), nsig) != nsig) Environment.Exit(3); if (wfdb.isigsettime(wfdb.strtim(argv[1])) < 0) Environment.Exit(4); if ((nsamp = wfdb.strtim(argv[2])) < 1) { Console.WriteLine("example7: inappropriate value for duration"); Environment.Exit(5); } if (wfdb.osigopen("16l", s.cast(), (uint)nsig) != nsig) Environment.Exit(6); wfdb.sample(0, 0); for (t = 0; t < nsamp && wfdb.sample_valid() == 1; t++) { for (j = 0; j < nsig; j++) { for (i = 0, vv = 0.0; i < nc; i++) if (c[i] != 0.0) vv += c[i]*wfdb.sample((uint)j, t+i); v.setitem(j, (int)vv); } if (wfdb.putvec(v.cast()) < 0) break; } wfdb.newheader("out"); wfdb.wfdbquit(); }