예제 #1
0
        private void InitFromUAGTMAReceiver()
        {
            Channel = Connection.CreateModel();
            Channel.ExchangeDeclare(exchange: "TrackData", type: ExchangeType.Fanout);
            Channel.QueueDeclare("UAGTrackDataQueue");
            Channel.QueueBind(queue: "UAGTrackDataQueue",
                              exchange: "TrackData",
                              routingKey: "");

            TMAConsumer           = new EventingBasicConsumer(Channel);
            TMAConsumer.Received += (model, ea) =>
            {
                var body    = ea.Body;
                var message = Encoding.UTF8.GetString(body);

                TMAOriginalMessage tmaMessage = JsonConvert.DeserializeObject <TMAOriginalMessage>(message);


                DataHandler.ReceiveTMAData(tmaMessage);
            };

            Channel.BasicConsume(queue: "UAGTrackDataQueue",
                                 autoAck: true,
                                 consumer: TMAConsumer);
        }
예제 #2
0
        // Handle a TMA message
        public void HandleTMAMessage(TMAOriginalMessage message)
        {
            SystemTracks sysTracks = new SystemTracks();

            sysTracks.timeStamp = convertTime(message.timeStamp);

            sysTracks.systemTracks = new List <TrackData>();

            foreach (OriginalSystemTrack OrigTrack in message.systemTracks)
            {
                // if track exists
                if (OrigTrack.trackId != 0)
                {
                    TrackData newTrackData = new TrackData();

                    newTrackData.trackID = OrigTrack.trackId;

                    newTrackData.relativeBearing = OrigTrack.bearing;

                    if (OrigTrack.bearingRate.valid)
                    {
                        newTrackData.relativeBearingRate = OrigTrack.bearingRate.value;
                    }

                    // if new track
                    if (!isKnownTarget[OrigTrack.trackId - 1])
                    {
                        isKnownTarget[OrigTrack.trackId - 1] = true;
                        creationTime[OrigTrack.trackId - 1]  = OrigTrack.timeStamp;

                        newTrackData.trackState   = State.NewTrack;
                        newTrackData.creationTime = convertTime(OrigTrack.timeStamp);
                    }
                    // if old track
                    else
                    {
                        newTrackData.trackState   = State.UpdateTrack;
                        newTrackData.creationTime = convertTime(creationTime[OrigTrack.trackId - 1]);
                    }

                    sysTracks.systemTracks.Add(newTrackData);
                }
            }

            if (lastTracksMessage != null)
            {
                foreach (var currTrack in lastTracksMessage.systemTracks)
                {
                    if (currTrack.trackId != 0)
                    {
                        // check if track was deleted
                        if (!sysTracks.systemTracks.Exists(x => x.trackID == currTrack.trackId))
                        {
                            isKnownTarget[currTrack.trackId - 1] = false;
                            TrackData newTrack = new TrackData()
                            {
                                trackID    = currTrack.trackId,
                                trackState = State.DeleteTrack
                            };

                            sysTracks.systemTracks.Add(newTrack);
                        }
                    }
                }
            }

            lastTracksMessage = message;

            // send to stiching
            sender.SendTrackData(sysTracks);

            // save to db
            db.saveRecord(sysTracks, "SystemTrack");
        }
예제 #3
0
 // Recieves a string in a Json format.
 // Handle the Received TMA message
 public void ReceiveTMAData(TMAOriginalMessage receivedMessage)
 {
     HandleTMAMessage(receivedMessage);
 }