Exemplo n.º 1
0
        public override void addCallback(CallbackInterface cb, UInt64 owner_id)
        {
            ICallbackInfo info = new ICallbackInfo {
                Callback = cb, removal_id = owner_id
            };

            lock (mutex)
            {
                if (!enabled)
                {
                    return;
                }
                callbacks.Add(info);
                Count++;
            }
            lock (id_info_mutex)
            {
                if (!id_info.ContainsKey(owner_id))
                {
                    id_info.Add(owner_id, new IDInfo {
                        calling_rw_mutex = new object(), id = owner_id
                    });
                }
            }
            notify_one();
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Creates a subscriber
        /// </summary>
        /// <typeparam name="M">Topic type</typeparam>
        /// <param name="topic">Topic name</param>
        /// <param name="queue_size">How many messages to qeueue</param>
        /// <param name="cb">Function to fire when a message is recieved</param>
        /// <param name="allow_concurrent_callbacks">Probably breaks things when true</param>
        /// <returns>A subscriber</returns>
        public Subscriber <M> subscribe <M>(string topic, uint queue_size, CallbackInterface cb, bool allow_concurrent_callbacks)
            where M : IRosMessage, new()
        {
            if (_callback == null)
            {
                _callback = ROS.GlobalCallbackQueue;
            }
            SubscribeOptions <M> ops = new SubscribeOptions <M>(topic, queue_size, cb.func)
            {
                callback_queue = _callback, allow_concurrent_callbacks = allow_concurrent_callbacks
            };

            ops.callback_queue.addCallback(cb);
            return(subscribe(ops));
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Creates a subscriber
        /// </summary>
        /// <typeparam name="M">Topic type</typeparam>
        /// <param name="topic">Topic name</param>
        /// <param name="queue_size">How many messages to qeueue</param>
        /// <param name="cb">Function to fire when a message is recieved</param>
        /// <param name="thisisveryverybad">internal use</param>
        /// <returns>A subscriber</returns>
        public Subscriber <M> subscribe <M>(string topic, uint queue_size, CallbackInterface cb, string thisisveryverybad)
            where M : IRosMessage, new()
        {
            if (_callback == null)
            {
                _callback = ROS.GlobalCallbackQueue;
            }
            SubscribeOptions <M> ops = new SubscribeOptions <M>(topic, queue_size, cb.func)
            {
                callback_queue = _callback
            };

            ops.callback_queue.addCallback(cb);
            return(subscribe(ops));
        }
Exemplo n.º 4
0
        public CallOneResult callOneCB(TLS tls)
        {
            ICallbackInfo info = tls.head;

            if (info == null)
            {
                return(CallOneResult.Empty);
            }
            IDInfo idinfo = null;

            idinfo = getIDInfo(info.removal_id);
            if (idinfo != null)
            {
                CallbackInterface cb = info.Callback;
                lock (idinfo.calling_rw_mutex)
                {
                    CallbackInterface.CallResult result = CallbackInterface.CallResult.Invalid;
                    tls.spliceout(info);
                    if (!info.marked_for_removal)
                    {
                        result = cb.Call();
                    }
                    if (result == CallbackInterface.CallResult.TryAgain && !info.marked_for_removal)
                    {
                        lock (mutex)
                        {
                            callbacks.Add(info);
                            Count++;
                        }
                        return(CallOneResult.TryAgain);
                    }
                }
                return(CallOneResult.Called);
            }
            ICallbackInfo cbi = tls.spliceout(info);

            if (cbi != null)
            {
                cbi.Callback.Call();
            }
            return(CallOneResult.Called);
        }
Exemplo n.º 5
0
 public virtual void addCallback(CallbackInterface callback, UInt64 owner_id)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public virtual void addCallback(CallbackInterface callback)
 {
     addCallback(callback, callback.Get());
 }
Exemplo n.º 7
0
 /// <summary>
 ///     Creates a subscriber
 /// </summary>
 /// <typeparam name="M">Topic type</typeparam>
 /// <param name="topic">Topic name</param>
 /// <param name="queue_size">How many messages to qeueue</param>
 /// <param name="cb">Function to fire when a message is recieved</param>
 /// <returns>A subscriber</returns>
 public Subscriber <M> subscribe <M>(string topic, uint queue_size, CallbackInterface cb)
     where M : IRosMessage, new()
 {
     return(subscribe <M>(topic, queue_size, cb, null));
 }
Exemplo n.º 8
0
 public virtual void addCallback(CallbackInterface callback)
 {
     addCallback(callback, ROS.getPID());
 }
 public virtual CallbackInterface callback(CallbackInterface cb)
 {
     _callback = cb;
     return(_callback);
 }
 protected ISubscriptionCallbackHelper(CallbackInterface Callback)
 {
     //EDB.WriteLine("ISubscriptionCallbackHelper: 1 arg constructor");
     //throw new NotImplementedException();
     _callback = Callback;
 }
 public SubscriptionCallbackHelper(CallbackInterface q)
     : base(q)
 {
     //EDB.WriteLine("SubscriptionCallbackHelper: callbackinterface constructor");
 }
Exemplo n.º 12
0
 public SubscriptionCallbackHelper(CallbackInterface q)
     : base(q)
 {
 }