Exemple #1
0
        /// <summary>
        ///     Wrap a timer a with added functionality, and make sure it dies with this TimerManager
        ///     This DOES NOT START IT.
        /// </summary>
        /// <param name="cb">
        ///     The callback of the wrapped timer
        /// </param>
        /// <param name="d">
        ///     The delay it should have
        /// </param>
        /// <param name="p">
        ///     The period it should have
        /// </param>
        public WrappedTimer StartTimer(TimerCallback cb, int d = Timeout.Infinite, int p = Timeout.Infinite)
        {
            WrappedTimer wt = MakeTimer(cb, d, p);

            wt.Start();
            return(wt);
        }
Exemple #2
0
        /// <summary>
        ///     Wrap and start timer a with added functionality, and make sure it dies with this TimerManager
        ///     This DOES NOT START IT.
        /// </summary>
        /// <param name="cb">
        ///     The callback of the wrapped timer
        /// </param>
        /// <param name="d">
        ///     The delay it should have
        /// </param>
        /// <param name="p">
        ///     The period it should have
        /// </param>
        public WrappedTimer MakeTimer(TimerCallback cb, int d = Timeout.Infinite, int p = Timeout.Infinite)
        {
            WrappedTimer wt = new WrappedTimer(cb, d, p);

            MakeTimer(wt);
            return(wt);
        }
Exemple #3
0
        private void onConnectionDropped(Connection conn, Connection.DropReason reason)
        {
            ROS.Debug()($"[{ThisNode.Name}] TransportPublisherLink: onConnectionDropped from remote {conn.RemoteString} with reason {reason.ToString()}");

            if (dropping || conn != connection)
            {
                return;
            }
            if (reason == Connection.DropReason.TransportDisconnect)
            {
                needs_retry = true;
                next_retry  = DateTime.UtcNow.Add(retry_period);
                if (retry_timer == null)
                {
                    retry_timer = ROS.timerManager.StartTimer(onRetryTimer, 100);
                }
                else
                {
                    retry_timer.Restart();
                }
            }
            else
            {
                if (reason == Connection.DropReason.HeaderError)
                {
                    ROS.Error()($"[{ThisNode.Name}] Error in the Header: {( parent != null ? parent.name : "unknown" )}");
                }
                drop();
            }
        }
Exemple #4
0
        public void Start()
        {
            PollManager.Instance.AddPollThreadListener(RemoveDroppedConnections);

            listener = new TcpListener(IPAddress.Any, Network.TcpRosServerPort);
            listener.Start(16);
            acceptor = ROS.timerManager.StartTimer(CheckAndAccept, 100, 100);
        }
Exemple #5
0
 /// <summary>
 ///     Add a wrapped timer to the hashset
 /// </summary>
 /// <param name="t">the wrapped timer</param>
 public void MakeTimer(WrappedTimer t)
 {
     lock (timerList)
     {
         if (timerList.Contains(t))
         {
             throw new Exception("The same timer cannot be tracked twice");
         }
         timerList.Add(t);
     }
 }
 /// <summary>
 ///     Add a wrapped timer to the hashset
 /// </summary>
 /// <param name="t">the wrapped timer</param>
 public void MakeTimer(WrappedTimer t)
 {
     lock ( heardof )
     {
         if (heardof.Contains(t))
         {
             throw new Exception("The same timer cannot be tracked twice");
         }
         heardof.Add(t);
     }
 }
Exemple #7
0
 /// <summary>
 ///     Stop tracking a timer, and kill it
 /// </summary>
 /// <param name="t">The timer to forget and kill</param>
 public void RemoveTimer(ref WrappedTimer t)
 {
     lock (timerList)
     {
         if (timerList.Contains(t))
         {
             timerList.Remove(t);
         }
     }
     t.Dispose();
     t = null;
 }
 /// <summary>
 ///     Stop tracking a timer, and kill it
 /// </summary>
 /// <param name="t">The timer to forget and kill</param>
 public void RemoveTimer(ref WrappedTimer t)
 {
     lock ( heardof )
     {
         if (heardof.Contains(t))
         {
             heardof.Remove(t);
         }
     }
     t.Dispose();
     t = null;
 }