Exemplo n.º 1
0
        internal bool addCallback <M>(SubscriptionCallbackHelper <M> helper, string md5sum, CallbackQueueInterface queue,
                                      uint queue_size, bool allow_concurrent_callbacks, string topiclol) where M : IRosMessage, new()
        {
            lock (md5sum_mutex)
            {
                if (this.md5sum == "*" && md5sum != "*")
                {
                    this.md5sum = md5sum;
                }
            }

            if (md5sum != "*" && md5sum != this.md5sum)
            {
                return(false);
            }

            lock (callbacks_mutex)
            {
                CallbackInfo <M> info = new CallbackInfo <M> {
                    helper = helper, callback = queue, subscription_queue = new Callback <M>(helper.callback().func, topiclol, queue_size, allow_concurrent_callbacks)
                };
                //if (!helper.isConst())
                //{
                ++nonconst_callbacks;
                //}

                callbacks.Add(info);

                if (latched_messages.Count > 0)
                {
                    lock (publisher_links_mutex)
                    {
                        foreach (PublisherLink link in publisher_links)
                        {
                            if (link.Latched)
                            {
                                if (latched_messages.ContainsKey(link))
                                {
                                    LatchInfo            latch_info = latched_messages[link];
                                    IMessageDeserializer des        = new IMessageDeserializer(helper, latch_info.message,
                                                                                               latch_info.connection_header);
                                    bool was_full = false;
                                    ((Callback <M>)info.subscription_queue).push((SubscriptionCallbackHelper <M>)info.helper, (MessageDeserializer <M>)des, true,
                                                                                 ref was_full,
                                                                                 latch_info.receipt_time);
                                    ((Callback <M>)info.subscription_queue).topic = topiclol;
                                    if (!was_full)
                                    {
                                        info.callback.addCallback(info.subscription_queue, info.Get());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
Exemplo n.º 2
0
 public MessageDeserializer <T> MakeDeserializer <T>(MsgTypes type, SubscriptionCallbackHelper <T> helper, T m,
                                                     IDictionary connection_header) where T : IRosMessage, new()
 {
     if (type == MsgTypes.Unknown)
     {
         return(null);
     }
     //return ROS.MakeDeserializer(ROS.MakeMessage(type));
     return(new MessageDeserializer <T>(helper, m, connection_header));
 }
Exemplo n.º 3
0
        internal bool addCallback <M>(SubscriptionCallbackHelper <M> helper, string md5sum, CallbackQueueInterface queue,
                                      uint queue_size, bool allow_concurrent_callbacks, string topiclol) where M : IRosMessage, new()
        {
            lock (md5sum_mutex)
            {
                if (this.md5sum == "*" && md5sum != "*")
                {
                    this.md5sum = md5sum;
                }
            }

            if (md5sum != "*" && md5sum != this.md5sum)
            {
                return(false);
            }

            lock (callbacks_mutex)
            {
                CallbackInfo <M> info = new CallbackInfo <M> {
                    helper = helper, callback = queue, subscription_queue = new Callback <M>(helper.callback().func, topiclol, queue_size, allow_concurrent_callbacks)
                };
                //if (!helper.isConst())
                //{
                ++nonconst_callbacks;
                //}

                callbacks.Add(info);

                if (latched_messages.Count > 0)
                {
                    MsgTypes ti = info.helper.type;
                    lock (publisher_links_mutex)
                    {
                        foreach (PublisherLink link in publisher_links)
                        {
                            if (link.Latched)
                            {
                                if (latched_messages.ContainsKey(link))
                                {
                                    LatchInfo latch_info         = latched_messages[link];
                                    bool      was_full           = false;
                                    bool      nonconst_need_copy = false; //callbacks.Count > 1;
                                    info.subscription_queue.pushitgood(info.helper, latched_messages[link].message, nonconst_need_copy, ref was_full, ROS.GetTime().data);
                                    if (!was_full)
                                    {
                                        info.callback.addCallback(info.subscription_queue, info.Get());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
Exemplo n.º 4
0
        public SubscribeOptions(string topic, uint queue_size, CallbackDelegate <T> CALL = null)
        {
            // TODO: Complete member initialization
            this.topic      = topic;
            this.queue_size = queue_size;
            if (CALL != null)
            {
                helper = new SubscriptionCallbackHelper <T>(new T().msgtype(), CALL);
            }
            else
            {
                helper = new SubscriptionCallbackHelper <T>(new T().msgtype());
            }


            Type msgtype = new T().GetType();

            string[] chunks = msgtype.FullName.Split('.');
            datatype = chunks[chunks.Length - 2] + "/" + chunks[chunks.Length - 1];
            md5sum   = new T().MD5Sum();
        }
Exemplo n.º 5
0
 public MessageDeserializer(SubscriptionCallbackHelper <M> helper, IRosMessage m, IDictionary connection_header)
     : base(helper, m, connection_header)
 {
 }
Exemplo n.º 6
0
 public CallbackInfo()
 {
     helper = new SubscriptionCallbackHelper <M>(new M().msgtype);
 }
Exemplo n.º 7
0
 public void push(SubscriptionCallbackHelper <T> helper, MessageDeserializer <T> deserializer, bool nonconst_need_copy,
                  ref bool was_full, TimeData receipt_time)
 {
     pushitgood(helper, deserializer, nonconst_need_copy, ref was_full, receipt_time);
 }
Exemplo n.º 8
0
 public void push(SubscriptionCallbackHelper <T> helper, MessageDeserializer <T> deserializer, bool nonconst_need_copy, ref bool was_full)
 {
     push(helper, deserializer, nonconst_need_copy, ref was_full, new TimeData());
 }