public static void tickmany(object o) { //System.Console.WriteLine("tick"); double[] signal = new double[10]; while (!UlazniBuffer.ReadMany(out signal, 1000)) { ; } for (int i = 0; i < 1000; i++) { //Console.Write("3"); if (signal[i] == Double.PositiveInfinity) { //stop the program timer.Change(Timeout.Infinite, 1); UlazniBuffer.Clear(); //System.Console.WriteLine("Exiting"); return; } else { MessageBox.Show(signal[i].ToString()); } } }
void worker_DoWork(object sender, DoWorkEventArgs e) { string line = ""; double signal; try { try { file = new StreamReader(fileName); } catch (Exception ex) { // vec je otvoren fajl MessageBox.Show("Greška u èitanju: " + ex.Message, "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error); } line = file.ReadLine(); while (!(line.Contains("0.000"))) { if (line == null) { break; } try { line = file.ReadLine(); } catch (Exception) { return; } } do { signal = (double.Parse(line.Split('\t')[channel])); signal = signal / 1000; //vrijemeEKG.Add(double.Parse(line.Split('\t')[0])); // DODANO while (!UlazniBuffer.Write(signal)) { System.Threading.Thread.Sleep(sleepInterval); } } while ((line = file.ReadLine()) != null); while (!UlazniBuffer.Write(double.PositiveInfinity)) { System.Threading.Thread.Sleep(sleepInterval); } } catch { } Stop(); }
public void DajNapon2(string filePath, EKGFileType type) { timer = new System.Threading.Timer(new TimerCallback(tick2)); try { UlazniBuffer.Open(filePath, 2, type); timer.Change(0, 60); // 30 Thread.Sleep(10000); //10000 } catch (Exception izuzetak) { MessageBox.Show(izuzetak.ToString()); } }
public void tick2(object o) //static { //System.Console.WriteLine("tick"); double[] signal = new double[40000]; //10 for (int i = 0; i < 40000; i++) // 10 { while (!UlazniBuffer.ReadOne(out signal[i])) { ; } //Console.Write("3"); if (signal[i] == Double.PositiveInfinity) { //stop the program timer.Change(Timeout.Infinite, 1); UlazniBuffer.Clear(); //System.Console.WriteLine("Exiting"); return; } napon2.Add(signal[i]); } }
void worker_DoWork(object sender, DoWorkEventArgs e) { long fileLength = 0; try { file = new FileStream(fileName, FileMode.Open); reader = new BinaryReader(file); fileLength = file.Length; } catch (Exception ex) { // vec je otvoren fajl, sve je OK MessageBox.Show("Izuzetak 1: " + ex.ToString()); } //fileLength = file.Length; short flag = 0; long low = 0, high = 0; byte[] buf = { 0, 0, 0 }; for (int i = 0; i < fileLength / 3; i++) { for (short j = 1; j <= 2; j++) { switch (flag) { case 0: try { buf = reader.ReadBytes(3); } catch (Exception) { return; } low = buf[1] & 0x0F; high = buf[1] & 0xF0; if (channel == j) { if (low > 7) { while (!UlazniBuffer.Write(Convert.ToDouble(buf[0] + (low << 8) - 4096))) { System.Threading.Thread.Sleep(sleepInterval); } } else { while (!UlazniBuffer.Write(Convert.ToDouble((buf[0] + (low << 8) - 1024) * 0.005))) { System.Threading.Thread.Sleep(sleepInterval); } } } flag = 1; break; case 1: if (channel == j) { if (high > 127) { while (!UlazniBuffer.Write(Convert.ToDouble(buf[2] + (high << 4) - 4096))) { System.Threading.Thread.Sleep(sleepInterval); } } else { while (!UlazniBuffer.Write(Convert.ToDouble((buf[2] + (high << 4) - 1024) * 0.005))) { System.Threading.Thread.Sleep(sleepInterval); } } } flag = 0; break; } } } while (!UlazniBuffer.Write(Double.PositiveInfinity)) { System.Threading.Thread.Sleep(sleepInterval); } Stop(); }