예제 #1
0
        public void HandleMessage(IMessageData messageData)
        {
            var msgData = messageData as VesselPositionMsgData;

            if (msgData == null)
            {
                return;
            }

            var update = new VesselPositionAltUpdate(msgData);

            var vesselId = update.VesselId;

            if (!VesselPositionAltSystem.CurrentVesselUpdate.TryGetValue(update.VesselId, out var existingPositionUpdate))
            {
                VesselPositionAltSystem.CurrentVesselUpdate.TryAdd(vesselId, update);
            }
            else
            {
                if (existingPositionUpdate.SentTime < update.SentTime)
                {
                    update.Vessel = VesselPositionAltSystem.CurrentVesselUpdate[vesselId].Vessel;
                    update.Body   = VesselPositionAltSystem.CurrentVesselUpdate[vesselId].Body;
                    VesselPositionAltSystem.CurrentVesselUpdate[vesselId] = update;
                }
            }
        }
예제 #2
0
        public void SendVesselPositionUpdate(VesselPositionAltUpdate update)
        {
            if (SystemsContainer.Get <VesselRemoveSystem>().VesselWillBeKilled(update.VesselId))
            {
                return;
            }

            SendMessage(update.AsSimpleMessage());
        }
        public void HandleMessage(IMessageData messageData)
        {
            var msgData = messageData as VesselPositionMsgData;

            if (msgData == null)
            {
                return;
            }

            var update = new VesselPositionAltUpdate(msgData);

            var vesselId = update.VesselId;

            if (SystemsContainer.Get <VesselRemoveSystem>().VesselWillBeKilled(vesselId))
            {
                return;
            }

            if (!VesselPositionAltSystem.CurrentVesselUpdate.TryGetValue(vesselId, out var existingPositionUpdate))
            {
                VesselPositionAltSystem.CurrentVesselUpdate.TryAdd(vesselId, update);
                VesselPositionAltSystem.TargetVesselUpdate.TryAdd(vesselId, update);
            }
            else
            {
                if (existingPositionUpdate.SentTime < update.SentTime &&
                    (existingPositionUpdate.InterpolationFinished || !existingPositionUpdate.InterpolationStarted))
                {
                    update.Body = existingPositionUpdate.Body;

                    if (VesselPositionAltSystem.TargetVesselUpdate.TryGetValue(vesselId, out var existingTargetPositionUpdate))
                    {
                        VesselPositionAltSystem.CurrentVesselUpdate.AddOrUpdate(vesselId, existingTargetPositionUpdate,
                                                                                (key, existingVal) => existingTargetPositionUpdate);

                        VesselPositionAltSystem.TargetVesselUpdate.AddOrUpdate(vesselId, update,
                                                                               (key, existingVal) => update);
                    }
                }
            }
        }
예제 #4
0
        public void SendVesselPositionUpdate(Vessel vessel)
        {
            var update = new VesselPositionAltUpdate(vessel);

            TaskFactory.StartNew(() => SendVesselPositionUpdate(update));
        }
예제 #5
0
 public void SendVesselPositionUpdate(VesselPositionAltUpdate update)
 {
     SendMessage(update.GetParsedMessage());
 }
예제 #6
0
        public void SendVesselPositionUpdate(Vessel vessel)
        {
            var update = new VesselPositionAltUpdate(vessel);

            SendVesselPositionUpdate(update);
        }