Exemplo n.º 1
0
        public View(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IConfigSource config)
            : base(tableFactory, queueFactory)
        {
            _factory          = primFactory;
            _displayingBoards = tableFactory.MakeKeyTable <IEnumerable <UUID> >();
            _moveQ            = queueFactory.MakeQueue();
            _deliverQ         = queueFactory.MakeQueue();
            //_moveQ = new SmartThreadPool(int.MaxValue, 30, 3);

            IConfig viewConfig = config.Configs["View"];

            if (viewConfig == null)
            {
                viewConfig = config.Configs[0];
            }

            _wait           = viewConfig.GetInt("Wait", _wait);
            _waitMultiplier = viewConfig.GetFloat("WaitMultiplier", 5f);
            _displayChannel = viewConfig.GetInt("ListeningChannel", -43);
            _autoUpdate     = viewConfig.GetBoolean("AutoUpdateTables", false);
            int tableResolution = viewConfig.GetInt("TableResolution", -1);

            if (tableResolution > 0)
            {
                VNode.SetTableResolution(tableResolution);
            }

            _moveQ.Start("View Move Queue" /*, viewConfig.GetInt("PacketsPerThread", PACKETS_PER_THREAD)*/);
            _deliverQ.Start("View Deliver Queue");
            //_moveQ.Start();

            VLink.MaxWidth              = viewConfig.GetFloat("maxLinkWidth", VLink.MaxWidth);
            VLink.MinWidth              = viewConfig.GetFloat("minLinkWidth", VLink.MinWidth);
            VPacket.MaxMovesPerUnit     = viewConfig.GetInt("maxNumPacketMovesPerUnit", VPacket.MaxMovesPerUnit);
            VPacket.MinMovesPerUnit     = viewConfig.GetInt("minNumPacketMovesPerUnit", VPacket.MinMovesPerUnit);
            VPacket.DefaultMovesPerUnit = viewConfig.GetInt("defaultNumPacketMovesPerUnit", VPacket.DefaultMovesPerUnit);

            _tickThread = new Thread(() => {
                _cont    = true;
                int wait = (int)(Wait * _waitMultiplier);
                int tick = 0;
                while (_cont)
                {
                    Util.Wait(wait, _cont && wait > 0, this);
                    DateTime start = DateTime.Now;
                    if (_cont && OnTick != null)
                    {
                        OnTick();
                    }
                    wait = (int)((Wait * _waitMultiplier) - DateTime.Now.Subtract(start).TotalMilliseconds);
                    tick++;
                }
            });
            _tickThread.Name = "View Tick Thread";
            _tickThread.Start();

            Logger.Info("View started.");
        }
Exemplo n.º 2
0
        /// <summary>
        /// The constructor for a helper. Takes the type of object being split and an array of the types of the arguments for the constructor.
        ///
        /// Creates proxies for each of the parameter types then invokes the constructor passing in these proxy objects and passes the result up to the
        /// base class to be wrapped.
        ///
        /// The result is an object where any method calls made on the object will cause a listener method to be called and any methods called
        /// on the parameters passed in to the constructor will also trigger listeners.
        /// </summary>
        /// <param name="toSplitType">The type of object to be split.</param>
        /// <param name="constructorParameters">Any parameters the constructor for toSplitType takes.</param>
        public SplitterChild(Type toSplitType, IAsynchQueueFactory queueFactory, object[] constructorParameters)
            : base(buildInstance <TToSplit>(toSplitType, queueFactory, constructorParameters), "Splitter")
        {
            _parameterCallQ        = new Queue <Pair <Pair <int, string>, Pair <int, object[]> > >();
            _methodProcessingQueue = queueFactory.MakeQueue();

            ListenToParams(constructorParameters);
        }
Exemplo n.º 3
0
 public LinkState(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IConfigSource config)
 {
     _tableFactory = tableFactory;
     _config       = config;
     //_dijkstraQ = queueFactory.MakeQueue();
     _dijkstraQ = queueFactory.SharedQueue;
     _eventQ    = queueFactory.MakeQueue();
     //_dijkstraQ.Start("Link State dijkstra queue");
     _eventQ.Start("Link State packet queue");
     _eventQ.UseStack     = true;
     Model.OnWaitChanged += (oldWait, wait, paused) => _eventQ.Paused = paused;
 }
Exemplo n.º 4
0
 public LinkState(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IConfigSource config)
 {
     _tableFactory = tableFactory;
     _config = config;
     //_dijkstraQ = queueFactory.MakeQueue();
     _dijkstraQ = queueFactory.SharedQueue;
     _eventQ = queueFactory.MakeQueue();
     //_dijkstraQ.Start("Link State dijkstra queue");
     _eventQ.Start("Link State packet queue");
     _eventQ.UseStack = true;
     Model.OnWaitChanged += (oldWait, wait, paused) => _eventQ.Paused = paused;
 }
Exemplo n.º 5
0
        public DV(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IConfigSource configSource)
        {
            _queue = queueFactory.MakeQueue();
            _tableFactory = tableFactory;
            _config = configSource;
            IConfig config = configSource.Configs["Algorithms"];
            if (config == null)
                config = configSource.Configs["DV"];
            if (config == null)
                config = configSource.Configs[0];

            _queue.Start("Distance Vector work Queue");
            _queue.UseStack = true;
            TTL = config.GetInt("TTL", 200);
            Model.OnWaitChanged += (oldWait, wait, paused) => _queue.Paused = paused;
        }
Exemplo n.º 6
0
        public DV(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IConfigSource configSource)
        {
            _queue        = queueFactory.MakeQueue();
            _tableFactory = tableFactory;
            _config       = configSource;
            IConfig config = configSource.Configs["Algorithms"];

            if (config == null)
            {
                config = configSource.Configs["DV"];
            }
            if (config == null)
            {
                config = configSource.Configs[0];
            }

            _queue.Start("Distance Vector work Queue");
            _queue.UseStack      = true;
            TTL                  = config.GetInt("TTL", 200);
            Model.OnWaitChanged += (oldWait, wait, paused) => _queue.Paused = paused;
        }
 public SequenceManager(IModule control, IControlUtil controlUtil, IConfig controlConfig, IPrimFactory primFactory, IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory)
     : this(control, controlUtil, controlConfig, primFactory, tableFactory, queueFactory.MakeQueue())
 {
 }