Ejemplo n.º 1
0
        private void btnDeviceLoad_Click(object sender, RoutedEventArgs e)
        {
            string device              = (cmbDevice.SelectedItem as CBItem)?.Value.ToString();
            string devicePort          = cmbDevicePort.SelectedValue?.ToString();
            string deviceStartOrFinish = (cmbCalcDeviceStartOrFinish.SelectedItem as CBItem)?.Value.ToString();

            if (device == "File")
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.DefaultExt = ".txt";
                openFileDialog.Filter     = "Textdatei|*.txt";
                if (openFileDialog.ShowDialog() == true)
                {
                    devicePort = openFileDialog.FileName;
                }
                else
                {
                    return;
                }
            }

            IHandTiming handTiming = HandTiming.CreateHandTiming(device, devicePort);

            Progress <StdProgress> progress    = new Progress <StdProgress>();
            StdProgressDlg         dlgProgress = new StdProgressDlg();

            dlgProgress.ShowAndClose(progress);

            handTiming.DoProgressReport(progress);

            Task.Run(() =>
            {
                using (handTiming)
                {
                    try
                    {
                        handTiming.Connect();
                        handTiming.StartGetTimingData();
                        _currentHandTimingVM.AddHandTimings(handTiming.TimingData());
                    }
                    catch (Exception)
                    { throw; }
                }
            }).ContinueWith((t) =>
            {
                if (t.IsFaulted)
                {
                    MessageBox.Show(
                        string.Format("Daten konnten nicht geladen werden.\n({0}).\nWeitere Details im Logfile.", t.Exception?.InnerException?.Message),
                        "Fehler",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error
                        );
                    Logger.Error(t.Exception, "loading handtime failed");
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Ejemplo n.º 2
0
 public void CreateHandTiming()
 {
     Assert.AreEqual(typeof(FromFileHandTiming), HandTiming.CreateHandTiming("File", "abc").GetType());
     Assert.AreEqual(typeof(TagHeuer), HandTiming.CreateHandTiming("TagHeuerPPro", "abc").GetType());
     Assert.AreEqual(typeof(ALGETimy), HandTiming.CreateHandTiming("ALGETimy", "abc").GetType());
 }