Example #1
0
        internal ulong handleMessage(IRosMessage msg, bool ser, bool nocopy, IDictionary connection_header,
                                     PublisherLink link)
        {
            IRosMessage t            = null;
            ulong       drops        = 0;
            TimeData    receipt_time = ROS.GetTime().data;

            if (msg.Serialized != null) //will be null if self-subscribed
            {
                msg.Deserialize(msg.Serialized);
            }
            lock (callbacks_mutex)
            {
                foreach (ICallbackInfo info in callbacks)
                {
                    MsgTypes ti = info.helper.type;
                    if (nocopy || ser)
                    {
                        t = msg;
                        t.connection_header = msg.connection_header;
                        t.Serialized        = null;
                        bool was_full           = false;
                        bool nonconst_need_copy = callbacks.Count > 1;
                        info.subscription_queue.pushitgood(info.helper, t, nonconst_need_copy, ref was_full, receipt_time);
                        if (was_full)
                        {
                            ++drops;
                        }
                        else
                        {
                            info.callback.addCallback(info.subscription_queue, info.Get());
                        }
                    }
                }
            }

            if (t != null && link.Latched)
            {
                LatchInfo li = new LatchInfo
                {
                    message           = t,
                    link              = link,
                    connection_header = connection_header,
                    receipt_time      = receipt_time
                };
                if (latched_messages.ContainsKey(link))
                {
                    latched_messages[link] = li;
                }
                else
                {
                    latched_messages.Add(link, li);
                }
            }

            return(drops);
        }
Example #2
0
 public void headerReceived(PublisherLink link, Header header)
 {
     lock (md5sum_mutex)
     {
         if (md5sum == "*")
         {
             md5sum = link.md5sum;
         }
     }
 }
Example #3
0
 public void removePublisherLink(PublisherLink pub)
 {
     lock (publisher_links_mutex)
     {
         if (publisher_links.Contains(pub))
         {
             publisher_links.Remove(pub);
         }
         if (pub.Latched)
         {
             latched_messages.Remove(pub);
         }
     }
 }
Example #4
0
        internal ulong handleMessage(IRosMessage msg, bool ser, bool nocopy, IDictionary connection_header,
                                     PublisherLink link)
        {
            lock (callbacks_mutex)
            {
                ulong drops = 0;
                cached_deserializers.Clear();
                TimeData receipt_time = ROS.GetTime().data;
                foreach (ICallbackInfo info in callbacks)
                {
                    MsgTypes ti = info.helper.type;
                    if (nocopy || ser)
                    {
                        IMessageDeserializer deserializer = null;
                        if (cached_deserializers.ContainsKey(ti))
                        {
                            deserializer = cached_deserializers[ti];
                        }
                        else
                        {
                            deserializer = MakeDeserializer(ti, info.helper, msg, connection_header);
                            cached_deserializers.Add(ti, deserializer);
                        }
                        bool was_full           = false;
                        bool nonconst_need_copy = callbacks.Count > 1;
                        //info.helper.callback().func(msg);
                        //info.helper.callback().pushitgood(info.helper, deserializer, nonconst_need_copy, ref was_full, receipt_time);
                        info.subscription_queue.pushitgood(info.helper, deserializer, nonconst_need_copy, ref was_full, receipt_time);
                        //push(info.helper, deserializer, nonconst_need_copy, ref was_full,receipt_time);
                        if (was_full)
                        {
                            ++drops;
                        }
                        else
                        {
                            info.callback.addCallback(info.subscription_queue, info.Get());
                        }
                    }
                }

                if (link.Latched)
                {
                    LatchInfo li = new LatchInfo
                    {
                        message           = msg,
                        link              = link,
                        connection_header = connection_header,
                        receipt_time      = receipt_time
                    };
                    if (latched_messages.ContainsKey(link))
                    {
                        latched_messages[link] = li;
                    }
                    else
                    {
                        latched_messages.Add(link, li);
                    }
                }

                cached_deserializers.Clear();
                return(drops);
            }
        }
Example #5
0
 public void addPublisherLink(PublisherLink pub)
 {
     publisher_links.Add(pub);
 }