コード例 #1
0
        public void HandTimingsVM_DeleteHandTiming()
        {
            TestDataGenerator tg   = new TestDataGenerator();
            HandTimingVM      htVM = new HandTimingVM(HandTimingVMEntry.ETimeModus.EStartTime);

            List <RunResult> rr1 = new List <RunResult>
            {
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 0, 2), new TimeSpan(0, 8, 1, 2))
            };

            List <TimingData> hts1 = new List <TimingData>
            {
                new TimingData {
                    Time = new TimeSpan(0, 8, 0, 2, 301)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 5, 2, 300)
                }
            };

            htVM.AddRunResults(rr1);
            htVM.AddHandTimings(hts1);

            Assert.AreEqual(2, htVM.Items.Count);

            htVM.DeleteHandTimings();

            Assert.AreEqual(1, htVM.Items.Count);
            Assert.IsNull(htVM.Items[0].HandTime);
            Assert.IsNotNull(htVM.Items[0].StartTime);
        }
コード例 #2
0
        public void HandTimingsVM()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"1557MRBR_RH.mdb");
            string hsFilename = @"--Handzeit-Start.txt";
            string hfFilename = @"--Handzeit-Ziel.txt";

            Database db = new Database();

            db.Connect(dbFilename);
            AppDataModel model = new AppDataModel(db);

            FromFileHandTiming hsTiming = new FromFileHandTiming(hsFilename);
            FromFileHandTiming hfTiming = new FromFileHandTiming(hfFilename);

            hsTiming.Connect();
            hfTiming.Connect();

            List <TimingData> hsList = new List <TimingData>(hsTiming.TimingData());
            List <TimingData> hfList = new List <TimingData>(hfTiming.TimingData());


            HandTimingVM htVM = new HandTimingVM(HandTimingVMEntry.ETimeModus.EStartTime);

            htVM.AddRunResults(model.GetRace(0).GetRun(0).GetResultList());
            htVM.AddHandTimings(hsList);
        }
コード例 #3
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());
        }
コード例 #4
0
        public void HandTimingCalc_Report()
        {
            TestDataGenerator tg   = new TestDataGenerator();
            HandTimingVM      htVM = new HandTimingVM(HandTimingVMEntry.ETimeModus.EStartTime);

            List <RunResult> rr1 = new List <RunResult>
            {
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 0, 0), new TimeSpan(0, 8, 0, 10)),
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 1, 0), new TimeSpan(0, 8, 1, 20)),
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 2, 0), new TimeSpan(0, 8, 2, 30)),
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 3, 0), new TimeSpan(0, 8, 3, 40)),
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 4, 0), new TimeSpan(0, 8, 4, 50)),
                tg.createRunResult(tg.createRaceParticipant(), null, new TimeSpan(0, 8, 5, 45))
            };

            List <TimingData> hts1 = new List <TimingData>
            {
                new TimingData {
                    Time = new TimeSpan(0, 8, 0, 0, 100)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 1, 0, 200)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 2, 0, 300)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 3, 0, 100)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 4, 0, 200)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 5, 0, 300)
                }
            };

            htVM.AddRunResults(rr1);
            htVM.AddHandTimings(hts1);

            htVM.AssignStartNumber(htVM.Items[5], 6);

            HandTimingCalc hc = new HandTimingCalc(htVM.Items[5], htVM.Items);

            IPDFReport report = new HandTimingCalcReport(hc, tg.Model.GetRace(0));

            Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"HandTimingCalc_Report.pdf", 1));
        }
コード例 #5
0
        public void HandTimingsVM_Correlation()
        {
            TestDataGenerator tg = new TestDataGenerator();

            HandTimingVM htVM = new HandTimingVM(HandTimingVMEntry.ETimeModus.EStartTime);

            List <RunResult> rr1 = new List <RunResult>
            {
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 0, 2), new TimeSpan(0, 8, 1, 2)),
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 2, 2), new TimeSpan(0, 8, 3, 2)),
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 4, 2), null)
            };

            List <TimingData> hts1 = new List <TimingData>
            {
                new TimingData {
                    Time = new TimeSpan(0, 8, 0, 2, 301)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 2, 1, 299)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 2, 1, 300)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 4, 2, 1)
                }
            };

            htVM.AddRunResults(rr1);
            htVM.AddHandTimings(hts1);

            Assert.AreEqual(new TimeSpan(0, 8, 0, 2), htVM.Items[0].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 0, 2, 301), htVM.Items[0].HandTime);
            Assert.AreEqual(new TimeSpan(0, 0, 0, 0, 300), htVM.Items[0].HandTimeDiff);

            Assert.IsNull(htVM.Items[1].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 2, 1, 300), htVM.Items[1].HandTime);
            Assert.IsNull(htVM.Items[1].HandTimeDiff);

            Assert.AreEqual(new TimeSpan(0, 8, 2, 2), htVM.Items[2].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 2, 1, 299), htVM.Items[2].HandTime);
            Assert.AreEqual(new TimeSpan(0, 0, 0, 0, -710), htVM.Items[2].HandTimeDiff);

            Assert.AreEqual(new TimeSpan(0, 8, 4, 2), htVM.Items[3].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 4, 2, 1), htVM.Items[3].HandTime);
            Assert.AreEqual(new TimeSpan(0, 0, 0, 0, 0), htVM.Items[3].HandTimeDiff);
        }
コード例 #6
0
        public void HandTimingCalc_Test3()
        {
            TestDataGenerator tg   = new TestDataGenerator();
            HandTimingVM      htVM = new HandTimingVM(HandTimingVMEntry.ETimeModus.EFinishTime);

            List <RunResult> rr1 = new List <RunResult>
            {
                tg.createRunResult(tg.createRaceParticipant(), null, new TimeSpan(0, 8, 0, 0)),
                tg.createRunResult(tg.createRaceParticipant(), null, new TimeSpan(0, 8, 1, 0)),
                tg.createRunResult(tg.createRaceParticipant(), null, new TimeSpan(0, 8, 2, 0)),
                tg.createRunResult(tg.createRaceParticipant(), null, new TimeSpan(0, 8, 3, 0)),
                tg.createRunResult(tg.createRaceParticipant(), null, new TimeSpan(0, 8, 4, 0)),
                tg.createRunResult(tg.createRaceParticipant(), null, null)
            };

            List <TimingData> hts1 = new List <TimingData>
            {
                new TimingData {
                    Time = new TimeSpan(0, 8, 0, 0, 100)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 1, 0, 200)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 2, 0, 300)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 3, 0, 100)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 4, 0, 200)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 5, 0, 300)
                }
            };

            htVM.AddRunResults(rr1);
            htVM.AddHandTimings(hts1);

            htVM.AssignStartNumber(htVM.Items[5], 6);

            HandTimingCalc hc = new HandTimingCalc(htVM.Items[5], htVM.Items);

            Assert.AreEqual(new TimeSpan(0, 8, 5, 0, 120), hc.CalculatedTime);
        }
コード例 #7
0
        public void HandTimingsVM_Dissolve()
        {
            TestDataGenerator tg = new TestDataGenerator();

            HandTimingVM htVM = new HandTimingVM(HandTimingVMEntry.ETimeModus.EStartTime);

            List <RunResult> rr1 = new List <RunResult>
            {
                tg.createRunResult(tg.createRaceParticipant(), new TimeSpan(0, 8, 0, 2), new TimeSpan(0, 8, 1, 2))
            };

            List <TimingData> hts1 = new List <TimingData>
            {
                new TimingData {
                    Time = new TimeSpan(0, 8, 0, 2, 301)
                }
            };

            htVM.AddRunResults(rr1);
            htVM.AddHandTimings(hts1);

            // Check Pre-Condition
            Assert.AreEqual(new TimeSpan(0, 8, 0, 2), htVM.Items[0].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 0, 2, 301), htVM.Items[0].HandTime);
            Assert.AreEqual(new TimeSpan(0, 0, 0, 0, 300), htVM.Items[0].HandTimeDiff);

            // Operation
            htVM.Dissolve(htVM.Items[0]);

            // Check Post-Condition
            Assert.AreEqual(new TimeSpan(0, 8, 0, 2), htVM.Items[0].ATime);
            Assert.IsNull(htVM.Items[0].HandTime);
            Assert.IsNull(htVM.Items[0].HandTimeDiff);

            Assert.IsNull(htVM.Items[1].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 0, 2, 301), htVM.Items[1].HandTime);
            Assert.IsNull(htVM.Items[1].HandTimeDiff);
        }
コード例 #8
0
        public void HandTimingVMManager_StoreAndLoad()
        {
            TestDataGenerator tg = new TestDataGenerator();

            tg.Model.GetRace(0).GetRun(0).SetStartFinishTime(tg.createRaceParticipant(), new TimeSpan(0, 8, 0, 2), new TimeSpan(0, 8, 1, 2));
            tg.Model.GetRace(0).GetRun(0).SetStartFinishTime(tg.createRaceParticipant(), new TimeSpan(0, 8, 2, 2), new TimeSpan(0, 8, 3, 2));
            tg.Model.GetRace(0).GetRun(0).SetStartFinishTime(tg.createRaceParticipant(), new TimeSpan(0, 8, 4, 2), null);
            tg.Model.GetRace(0).GetRun(0).SetStartFinishTime(tg.createRaceParticipant(), new TimeSpan(0, 8, 6, 2), new TimeSpan(0, 8, 7, 2));


            HandTimingVMManager mgr   = new HandTimingVMManager(tg.Model);
            HandTimingVM        htVMS = mgr.GetHandTimingVM(tg.Model.GetRace(0), tg.Model.GetRace(0).GetRun(0), HandTimingVMEntry.ETimeModus.EStartTime);
            HandTimingVM        htVMF = mgr.GetHandTimingVM(tg.Model.GetRace(0), tg.Model.GetRace(0).GetRun(0), HandTimingVMEntry.ETimeModus.EFinishTime);

            List <TimingData> hts = new List <TimingData>
            {
                new TimingData {
                    Time = new TimeSpan(0, 8, 0, 2, 100)
                },
                //new TimingData{Time = new TimeSpan(0, 8,  2, 2, 200)},
                new TimingData {
                    Time = new TimeSpan(0, 8, 4, 2, 300)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 6, 2, 400)
                }
            };

            htVMS.AddHandTimings(hts);

            List <TimingData> htf = new List <TimingData>
            {
                new TimingData {
                    Time = new TimeSpan(0, 8, 1, 2, 100)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 3, 2, 200)
                },
                //new TimingData{Time = new TimeSpan(0, 8,  5, 2, 300)},
                new TimingData {
                    Time = new TimeSpan(0, 8, 7, 2, 400)
                }
            };

            htVMF.AddHandTimings(htf);


            mgr.SaveHandTimingToFile();



            HandTimingVMManager mgr2   = new HandTimingVMManager(tg.Model);
            HandTimingVM        htVMS2 = mgr2.GetHandTimingVM(tg.Model.GetRace(0), tg.Model.GetRace(0).GetRun(0), HandTimingVMEntry.ETimeModus.EStartTime);
            HandTimingVM        htVMF2 = mgr2.GetHandTimingVM(tg.Model.GetRace(0), tg.Model.GetRace(0).GetRun(0), HandTimingVMEntry.ETimeModus.EFinishTime);

            mgr2.LoadHandTimingFromFile();

            for (int i = 0; i < htVMS2.Items.Count; i++)
            {
                Assert.AreEqual(htVMS.Items[i].HandTime, htVMS2.Items[i].HandTime);
            }
            for (int i = 0; i < htVMF2.Items.Count; i++)
            {
                Assert.AreEqual(htVMF.Items[i].HandTime, htVMF2.Items[i].HandTime);
            }
        }
コード例 #9
0
        public void HandTimingsVM_AssignStartNumber()
        {
            TestDataGenerator tg = new TestDataGenerator();

            HandTimingVM htVM = new HandTimingVM(HandTimingVMEntry.ETimeModus.EStartTime);

            List <RunResult> rr1 = new List <RunResult>
            {
                tg.createRunResult(tg.createRaceParticipant(), null, new TimeSpan(0, 8, 1, 2))
            };

            List <TimingData> hts1 = new List <TimingData>
            {
                new TimingData {
                    Time = new TimeSpan(0, 8, 0, 2, 301)
                },
                new TimingData {
                    Time = new TimeSpan(0, 8, 5, 2, 300)
                }
            };

            htVM.AddRunResults(rr1);
            htVM.AddHandTimings(hts1);

            // ***** Case 1: Merge entries ****

            // Check Pre-Condition
            Assert.IsNull(htVM.Items[0].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 0, 2, 301), htVM.Items[0].HandTime);
            Assert.IsNull(htVM.Items[0].HandTimeDiff);

            Assert.AreEqual(1U, htVM.Items[2].StartNumber);
            Assert.IsNull(htVM.Items[2].ATime);
            Assert.IsNull(htVM.Items[2].HandTime);
            Assert.IsNull(htVM.Items[2].HandTimeDiff);

            Assert.AreEqual(3, htVM.Items.Count);

            // Operation
            htVM.AssignStartNumber(htVM.Items[0], 1);

            // Check Post-Condition
            Assert.AreEqual(1U, htVM.Items[0].StartNumber);
            Assert.IsNull(htVM.Items[0].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 0, 2, 301), htVM.Items[0].HandTime);
            Assert.IsNull(htVM.Items[0].HandTimeDiff);
            Assert.IsNull(htVM.Items[0].StartTime);
            Assert.AreEqual(new TimeSpan(0, 8, 1, 2), htVM.Items[0].FinishTime);

            Assert.AreEqual(2, htVM.Items.Count);



            // ***** Case 2: Adjust entry ****

            // Check Pre-Condition
            Assert.IsNull(htVM.Items[1].StartNumber);
            Assert.IsNull(htVM.Items[1].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 5, 2, 300), htVM.Items[1].HandTime);
            Assert.IsNull(htVM.Items[1].HandTimeDiff);

            // Operation
            htVM.AssignStartNumber(htVM.Items[1], 2);

            // Check Post-Condition
            Assert.AreEqual(2U, htVM.Items[1].StartNumber);
            Assert.IsNull(htVM.Items[1].ATime);
            Assert.AreEqual(new TimeSpan(0, 8, 5, 2, 300), htVM.Items[1].HandTime);
            Assert.IsNull(htVM.Items[1].HandTimeDiff);
            Assert.IsNull(htVM.Items[1].StartTime);
            Assert.IsNull(htVM.Items[1].FinishTime);

            Assert.AreEqual(2, htVM.Items.Count);
        }