private void ThreadDelegate(HeartBeatType t, TimeWindow w , TDESample[] tde, AudioSample[] a) { try { var ign = Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { lock(accessLock) { beat++; if (w != null && tde != null && a != null) { var l = w.End(); if (t == HeartBeatType.BUFFERING) { l = w.Begin(); UpdateUI(t, w, tde, a); } UpdateUI(t, w, tde, a); //client.AddMessage(t, cc0, asdf0, peak0, max0, max1, ave0, ave1, ave_all, beat, b - lastTimeStamp, l - b); lastTimeStamp = l; } } }); } catch (Exception ex) { Error("ThreadDelegate: " + ex.ToString() + " " + ex.Message + " " + ex.HResult); } }
private void UpdateUI(HeartBeatType t, TimeWindow w , TDESample[] tde, AudioSample[] a) { try { SetLabels(t); text1.Text = client.HeartBeatText(t); text2.Text = beat.ToString(); text03.Text = tde[0].Value().ToString(); text04.Text = tde[1].Value().ToString(); text05.Text = tde[2].Value().ToString(); text06.Text = a[1].Align().ToString(); text07.Text = a[1].MaxAmplitude().ToString(); text08.Text = a[1].Average().ToString(); text13.Text = tde[3].Value().ToString(); text14.Text = tde[4].Value().ToString(); text15.Text = tde[5].Value().ToString(); text16.Text = a[2].Align().ToString(); text17.Text = a[2].MaxAmplitude().ToString(); text18.Text = a[2].Average().ToString(); text23.Text = tde[6].Value().ToString(); text24.Text = tde[7].Value().ToString(); text25.Text = tde[8].Value().ToString(); text06.Text = a[3].Align().ToString(); text07.Text = a[3].MaxAmplitude().ToString(); text08.Text = a[3].Average().ToString(); switch (t) { case HeartBeatType.DATA: case HeartBeatType.INVALID: case HeartBeatType.SILENCE: buffering = 0; rebootPending = false; break; case HeartBeatType.BUFFERING: buffering++; break; case HeartBeatType.DEVICE_ERROR: rebootPending = true; ResetEngine(10, "ERROR"); break; case HeartBeatType.NODEVICE: rebootPending = true; break; } if (buffering == 30) { rebootPending = true; } else if (buffering >= 10 && buffering % 10 == 0) { ResetEngine(10, "RESET"); } if (t != HeartBeatType.BUFFERING) canvas.Children.Clear(); if (t == HeartBeatType.DATA) { SoundDirection(w.Samples(), 0.3, -1 * tde[0].Value(), 600, 200, 0, 200, new SolidColorBrush(Colors.Red), 4); SoundDirection(w.Samples(), 0.3, -1 * tde[1].Value(), 600, 200, 0, 200, new SolidColorBrush(Colors.Green), 2); SoundDirection(w.Samples(), 0.3, -1 * tde[2].Value(), 600, 200, 0, 200, new SolidColorBrush(Colors.Blue), 1); samples++; } text9.Text = samples.ToString(); } catch (Exception ex) { Error("UpdateUI: " + ex.ToString() + " " + ex.Message + " " + ex.HResult); } }