Exemple #1
0
        public ReceiveDataHandler GetReceiveDataHandler(Topic topic)
        {
            ReceiveDataHandler rdh = this.receiveDataHandlerFactory.GetReceiveDataHandler(topic, this);

            if (rdh != null)
            {
                lock (partInfoData)
                {
                    partInfoData.subscribeTopics.Add(new TopicInfoData(topic));
                }
            }
            return(rdh);
        }
Exemple #2
0
        /// Protection is not needed since all calls go through the participant which is synched
        public ReceiveDataHandler GetReceiveDataHandler(Topic top, Participant participant)
        {
            // In the case that we use the same port for several topics, we need to find the receiver for the transport::address::port used
            string key = MakeKey(top);

            if (ReceiveDataHandlers.ContainsKey(key))
            {
                ReceiveDataHandler rdh = ReceiveDataHandlers[key];

                // Check if any of the topics have a sample size larger than MAX_SEGMENT_SIZE
                // This will lead to a problem when using the same port, if samples becomes > MAX_SEGMENT_SIZE
                if ((rdh.GetSampleMaxSize() > Globals.MAX_SEGMENT_SIZE) || (top.GetSampleMaxSize() > Globals.MAX_SEGMENT_SIZE))
                {
                    if (top.GetTransport().Equals(Topic.TRANSPORT_UDP))
                    {
                        Logger.ExceptionLogger.LogMessage("Warning: UDP transport is used with Topics with 'sampleMaxSize' > " + Globals.MAX_SEGMENT_SIZE);
                    }
                    else
                    {
                        Logger.ExceptionLogger.LogMessage("Warning: Same port (" + top.GetPort() + ") is used with Topics with 'sampleMaxSize' > " + Globals.MAX_SEGMENT_SIZE);
                    }
                }
                return(rdh);
            }

            // Get the local interface, doing a translation from subnet if necessary
            string localIF = InetAddress.DoSubnetTranslation(top.GetLocalInterface());

            // Didn't exist, create one if transport is known
            if ((top.GetTransport().Equals(Topic.TRANSPORT_MC)) || (top.GetTransport().Equals(Topic.TRANSPORT_TCP)))
            {
                ReceiveDataHandlers.Add(key,
                                        new ReceiveDataHandler(top, participant, ReceiverFactory.CreateReceiver(top, localIF)));
                return(ReceiveDataHandlers[key]);
            }
            else if (top.GetTransport().Equals(Topic.TRANSPORT_UDP))
            {
                IReceiver rec = ReceiverFactory.CreateReceiver(top, localIF);
                ReceiveDataHandlers.Add(key, new ReceiveDataHandler(top, participant, rec));

                if (key.Equals(Topic.TRANSPORT_UDP))
                {
                    participant.SetUdpTransportInfo(((UdpReceiver)rec).IP, ((UdpReceiver)rec).Port);
                }

                return(ReceiveDataHandlers[key]);
            }
            return(null);
        }
Exemple #3
0
        public void Start()
        {
            if (!this.active)
            {
                timeLastDataForTimeBase = System.DateTime.Now.Ticks;

                // A call to "SetDeadlineQoS" enables dead line notification if current timeout is > 0.
                SetDeadlineQoS(deadlineTimeout / 10000);

                receiveDataHandler = participant.GetReceiveDataHandler(topic);
                receiveDataHandler.AddSubscriber(this);
                inProcessTransport.AddSubscriber(this);
                this.active = true;
            }
        }
Exemple #4
0
        // The ReceiveDataHandler calls our "NotifyNewOPSMessage" from a synchronized context.
        // The "RemoveSubscriber" call below on receiveDataHandler is also synchronized in ReceiveDataHandler.
        // Both "Stop" and "NotifyNewOPSMessage" can therefore NOT be Synchronized (could lead to deadlock)
        // The same scenario is possible for the deadlineNotifier.
        // That's why we have commented the synchronize attribute below.
        /////[MethodImpl(MethodImplOptions.Synchronized)]
        public bool Stop()
        {
            bool retVal = true;

            if (this.active)
            {
                this.active = false;
                deadlineNotifier.Remove(this);
                inProcessTransport.RemoveSubscriber(this);
                retVal             = receiveDataHandler.RemoveSubscriber(this);
                receiveDataHandler = null;
                participant.ReleaseReceiveDataHandler(topic);
            }

            return(retVal);
        }
        /// Protection is not needed since all calls go through the participant which is synched
        public void ReleaseReceiveDataHandler(Topic top, Participant participant)
        {
            // In the case that we use the same port for several topics, we need to find the receiver for the transport::address::port used
            string key = MakeKey(top);

            if (ReceiveDataHandlers.ContainsKey(key))
            {
                ReceiveDataHandler rdh = ReceiveDataHandlers[key];

                if (rdh.GetNrOfSubscribers() == 0)
                {
                    ReceiveDataHandlers.Remove(key);

                    if (rdh.GetTransport().Equals(Topic.TRANSPORT_UDP))
                    {
                        participant.SetUdpTransportInfo("", 0);
                    }
                }
            }
        }
Exemple #6
0
        // The ReceiveDataHandler calls our "NotifyNewOPSMessage" from a synchronized context.
        // The "RemoveSubscriber" call below on receiveDataHandler is also synchronized in ReceiveDataHandler.
        // Both "Stop" and "NotifyNewOPSMessage" can therefore NOT be Synchronized (could lead to deadlock)
        // The same scenario is possible for the deadlineNotifier.
        // That's why we have commented the synchronize attribute below.
        /////[MethodImpl(MethodImplOptions.Synchronized)]
        public bool Stop()
        {
            bool retVal = true;

            if (this.active)
            {
                this.active = false;
                deadlineNotifier.Remove(this);
                inProcessTransport.RemoveSubscriber(this);
                retVal = receiveDataHandler.RemoveSubscriber(this);
                receiveDataHandler = null;
                participant.ReleaseReceiveDataHandler(topic);
            }

            return retVal;
        }
Exemple #7
0
        public void Start()
        {
            if (!this.active)
            {
                timeLastDataForTimeBase = System.DateTime.Now.Ticks;

                // A call to "SetDeadlineQoS" enables dead line notification if current timeout is > 0.
                SetDeadlineQoS(deadlineTimeout / 10000);

                receiveDataHandler = participant.GetReceiveDataHandler(topic);
                receiveDataHandler.AddSubscriber(this);
                inProcessTransport.AddSubscriber(this);
                this.active = true;
            }
        }