Exemplo n.º 1
0
    private void ObserveRaceRun(RaceRun previousRaceRun, RaceRun raceRun)
    {
        // Only the list of the current run is allowed to be sent.
        // => Startlist needs to be send in following cases:
        // a) Start list itself changes
        // b) The previous run completed so that the next run needs to be send
        ItemsChangedNotifier startListNotifier = new ItemsChangedNotifier(raceRun.GetStartListProvider().GetViewList());

        startListNotifier.CollectionChanged += (o, e) =>
        {
            updateStartList(previousRaceRun, raceRun);
        };
        updateStartList(previousRaceRun, raceRun); // Initial update
        _notifier.Add(startListNotifier);

        if (previousRaceRun != null)
        {
            IsCompleteObserver completeObserver = new IsCompleteObserver(previousRaceRun, raceRun, updateStartList);
            _notifier.Add(completeObserver);
        }

        // Results
        ItemsChangedNotifier resultsNotifier = new ItemsChangedNotifier(raceRun.GetResultList());

        resultsNotifier.ItemChanged += (o, e) =>
        {
            _liveTiming.UpdateResults(raceRun);
        };
        _liveTiming.UpdateResults(raceRun); // Initial update
        _notifier.Add(resultsNotifier);
    }
        private void ListenToCurrentRaceRun()
        {
            if (_currentRace != _dm.GetCurrentRaceRun())
            {
                if (_notifier != null)
                {
                    _notifier.CollectionChanged -= StartListChanged;
                    _notifier.ItemChanged       -= StartListItemChanged;
                    _notifier = null;
                }
                _rslVP = null;



                Application.Current.Dispatcher.Invoke(() =>
                {
                    RaceRun raceRun = _dm.GetCurrentRaceRun();
                    _rslVP          = new RemainingStartListViewProvider();
                    _rslVP.Init(raceRun.GetStartListProvider(), raceRun);

                    _notifier = new ItemsChangedNotifier(_rslVP.GetView());
                    _notifier.CollectionChanged += StartListChanged;
                    _notifier.ItemChanged       += StartListItemChanged;
                });

                _currentRace = _dm.GetCurrentRaceRun();

                SendStartList();
            }
        }
        private void processStartListTill(RaceParticipant participant)
        {
            // Copy starters (copy to avoid any side effects)
            StartListEntry[] starters = _raceRun.GetStartListProvider().GetViewList().ToArray();

            // Participant enters track
            if (participant != null)
            {
                // Loop over StartList until the starter has been found, remember all not started participants
                List <StartListEntry> toPurge = new List <StartListEntry>();
                foreach (StartListEntry se in starters)
                {
                    if (se.Participant == participant)
                    {
                        break;
                    }

                    toPurge.Add(se);
                }

                // Loop
                for (int i = 0; i < toPurge.Count() - Math.Abs(_startersTillAutoNaS); i++)
                {
                    RaceParticipant rp = toPurge[i].Participant;
                    if (!_raceRun.IsOrWasOnTrack(rp))
                    {
                        _raceRun.SetResultCode(rp, RunResult.EResultCode.NaS);
                    }
                }
            }
        }
Exemplo n.º 4
0
 private void updateNextStarter(RaceRun raceRun)
 {
     // Find current starter
     foreach (var sle in raceRun.GetStartListProvider().GetViewList())
     {
         if (!raceRun.IsOrWasOnTrack(sle.Participant))
         {
             _liveTiming.UpdateOnStart(raceRun, sle.Participant);
             break;
         }
     }
 }
Exemplo n.º 5
0
        internal string getXmlStartList(RaceRun raceRun)
        {
            using (var sw = new Utf8StringWriter())
            {
                using (var xw = XmlWriter.Create(sw, _xmlSettings))
                {
                    xw.WriteStartDocument();
                    xmlWriteStartElementLivetiming(xw);

                    xw.WriteStartElement("startlist");
                    xw.WriteAttributeString("runno", raceRun.Run.ToString());

                    StartListViewProvider slp = raceRun.GetStartListProvider();
                    var startList             = slp.GetViewList();

                    int i = 1;
                    foreach (var sle in startList)
                    {
                        // Skip participants which are not "FIS compliant"
                        if (checkParticipantFisCompliant(sle.Participant))
                        {
                            xw.WriteStartElement("racer");
                            xw.WriteAttributeString("order", i.ToString());

                            xw.WriteElementString("bib", sle.StartNumber.ToString());
                            xw.WriteElementString("lastname", sle.Name);
                            xw.WriteElementString("firstname", sle.Firstname);
                            xw.WriteElementString("nat", sle.Nation);
                            xw.WriteElementString("fiscode", sle.Code);

                            xw.WriteEndElement(); // racer
                            i++;
                        }
                    }

                    xw.WriteEndElement(); // startlist

                    xw.WriteEndElement(); // Livetiming
                    xw.WriteEndDocument();
                }
                return(sw.ToString());
            }
        }
Exemplo n.º 6
0
        private void observeRaceRun(RaceRun previousRaceRun, RaceRun raceRun)
        {
            ItemsChangedNotifier startListNotifier = new ItemsChangedNotifier(raceRun.GetStartListProvider().GetViewList());

            startListNotifier.CollectionChanged += (o, e) =>
            {
                updateStartList(previousRaceRun, raceRun);
            };
            updateStartList(previousRaceRun, raceRun); // Initial update
            _notifier.Add(startListNotifier);

            if (previousRaceRun != null)
            {
                IsCompleteObserver completeObserver = new IsCompleteObserver(previousRaceRun, raceRun, updateStartList);
                _notifier.Add(completeObserver);
            }

            // Results
            _liveTiming.UpdateResults(raceRun); // Initial update


            ItemsChangedNotifier resultsNotifier = new ItemsChangedNotifier(raceRun.GetResultList());

            resultsNotifier.ItemChanged += (sender, e) =>
            {
                if (sender is RunResult rr)
                {
                    Task.Delay(new TimeSpan(0, 0, 0, 0, 200)).ContinueWith(o =>
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(() =>
                        {
                            _liveTiming.UpdateInFinish(raceRun, rr.Participant);
                            updateNextStarter(raceRun);
                        });
                    });
                }
            };
            _notifier.Add(resultsNotifier);

            raceRun.OnTrackChanged += raceRun_OnTrackChanged;
        }
Exemplo n.º 7
0
    internal string getStartListData(RaceRun raceRun)
    {
        string result = "";

        StartListViewProvider slp = raceRun.GetStartListProvider();
        var startList             = slp.GetViewList();

        foreach (var sle in startList)
        {
            string item;

            item = string.Format("{0,3}", sle.Participant.Id);

            if (!string.IsNullOrEmpty(result))
            {
                result += "\n";
            }

            result += item;
        }

        return(result);
    }