Esempio n. 1
0
        void IDispatcher.UpdateTrainData(TrainDataMessage pMessage)
        {
            MessageReceived = true;
            SyncContext.Post((object state) => {
                // Try to find an existing train to update.
                bool found = false;
                for (int i = 0; i != Trains.Count; ++i)
                {
                    if (Trains[i].ID == pMessage.Train.TrainID)
                    {
                        found = true;
                        Trains[i].UpdateFromRun8(pMessage.Train);
                        break;
                    }
                }

                if (!found)
                {
                    // No existing train found; add a new one.
                    Train t = new Train(pMessage.Train, this);
                    Trains.Add(t);
                    if (ShouldEmitTrainEntered)
                    {
                        TrainEntered?.Invoke(t);
                    }
                }
                else
                {
                    // This is the second or subsequent update of a particular train. Under the assumption that Run8 always sends updates for trains in the same order, that means we must have seen every train that was in the area. So any train we see in future which we haven't seen already must be a newly entered train, not just one that was in the area when IECC8 booted.
                    ShouldEmitTrainEntered = true;
                }
            }, null);
        }
Esempio n. 2
0
        void IDispatcher.UpdateTrainData(TrainDataMessage pMessage)
        {
            IDispatcher target;

            lock (this) {
                target = Target;
            }
            if (target != null)
            {
                target.UpdateTrainData(pMessage);
            }
        }
Esempio n. 3
0
 public virtual void UpdateTrainData(TrainDataMessage pMessage)
 {
 }