示例#1
0
        private void shutdown()
        {
            cont = false;
            shutdownProxy();
            world.OnChat -= chatDelegate;

            if (chatQ != null)
            {
                chatQ.stop();
            }
            if (touchQ != null)
            {
                touchQ.stop();
            }
            if (touchAddQ != null)
            {
                touchAddQ.stop();
            }

            chatQ     = null;
            touchQ    = null;
            touchAddQ = null;

            DB.Print("Entry Point shut down queues", Levels.SCRIPTS);
        }
示例#2
0
        internal DVNode(IMNodeInternal node, ForwardDelegate forwardMethod, IAsynchQueue queue, IKeyTableFactory tableFactory, int TTL, IConfigSource config)
            : base(node, tableFactory, config)
        {
            _queue         = queue;
            _forwardMethod = forwardMethod;
            this.TTL       = TTL;

            distanceVector = new DistanceVector();

            neighbourVectors    = tableFactory.MakeKeyTable <DistanceVector>();
            highlightParameters = new Parameters(new object[] { "HColour", node.Colour });

            IConfig dvConfig = config.Configs["DV"];

            if (dvConfig == null)
            {
                dvConfig = config.Configs["DistanceVector"];
            }
            if (dvConfig == null)
            {
                dvConfig = config.Configs["Algorithm"];
            }
            if (dvConfig == null)
            {
                dvConfig = config.Configs[0];
            }

            _poison            = dvConfig.GetBoolean("PoisonReverse", true);
            _everPrint         = dvConfig.GetBoolean("EverPrint", false);
            _alwaysPrint       = dvConfig.GetBoolean("AlwaysPrint", false);
            highlightPrintText = dvConfig.GetBoolean("HighlightPrint", false);
        }
示例#3
0
        internal DVNode(IMNodeInternal node, ForwardDelegate forwardMethod, IAsynchQueue queue, IKeyTableFactory tableFactory, int TTL, IConfigSource config)
            : base(node, tableFactory, config)
        {
            _queue = queue;
            _forwardMethod = forwardMethod;
            this.TTL = TTL;

            distanceVector = new DistanceVector();

            neighbourVectors = tableFactory.MakeKeyTable<DistanceVector>();
            highlightParameters = new Parameters(new object[] { "HColour", node.Colour });

            IConfig dvConfig = config.Configs["DV"];
            if (dvConfig == null)
                dvConfig = config.Configs["DistanceVector"];
            if (dvConfig == null)
                dvConfig = config.Configs["Algorithm"];
            if (dvConfig == null)
                dvConfig = config.Configs[0];

            _poison = dvConfig.GetBoolean("PoisonReverse", true);
            _everPrint = dvConfig.GetBoolean("EverPrint", false);
            _alwaysPrint = dvConfig.GetBoolean("AlwaysPrint", false);
            highlightPrintText = dvConfig.GetBoolean("HighlightPrint", false);
        }
示例#4
0
        public LinkStateNode(IMNodeInternal node, IKeyTableFactory tableFactory, IAsynchQueue dijkstraQ, IAsynchQueue packetQ, ForwardDelegate forwardMethod, IConfigSource config)
            : base(node, tableFactory, dijkstraQ, config)
        {
            _eventQ          = packetQ;
            _forwardMethod   = forwardMethod;
            _processedEvents = new HashSet <int>();

            OnRouteChange += (alg, target, oldRoute, newRoute, oldDistance, distance) => {
                _changed = true;
                if (!Model.IsPaused)
                {
                    return;
                }
                if (oldRoute != null && newRoute != null)
                {
                    Say("Link State changed route to " + target.Name + " from " + oldRoute.OtherEnd(Node).Name + " to " + newRoute.OtherEnd(Node).Name + ".");
                }
                else if (oldRoute == null)
                {
                    Say("Link State added route to " + target.Name + " via " + newRoute.OtherEnd(Node).Name + " with distance " + distance + ".");
                }
                else if (newRoute == null)
                {
                    Say("Link State removed route to " + target.Name + ". " + oldRoute.OtherEnd(Node).Name + " is no longer a valid first hop and no other route was found.");
                }
                else
                {
                    Say("Link State changed weight of route to " + target.Name + " from " + oldDistance + " to " + distance + ".");
                }
            };
        }
        /// <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);
        }
示例#6
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.");
        }
示例#7
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;
 }
示例#8
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;
 }
        public DijkstraNode(IMNodeInternal node, IKeyTableFactory tableFactory, IAsynchQueue queue, IConfigSource config)
            : base(node, tableFactory, config)
        {
            _queue     = queue;
            _distances = tableFactory.MakeKeyTable <float>();
            _wipRoute  = tableFactory.MakeKeyTable <IMLink>();
            _prev      = tableFactory.MakeKeyTable <DijkstraNode>();

            _confirmed = new LinkedList <DijkstraNode>();
            _tentative = new LinkedList <DijkstraNode>();
            _links     = new LinkedList <IMLink>();

            SetDistanceFromRoot(ID, 0f, null, null);
        }
示例#10
0
        protected AbstractModule(IKeyTableFactory keyTableFactory, IAsynchQueueFactory queueFactory)
        {
            TableFactory = keyTableFactory;
            Logger       = LogManager.GetLogger(GetType());

            _nodes = keyTableFactory.MakeKeyTable <TNode>();
            _links = keyTableFactory.MakeKeyTable <TLink>();

            _neighbours  = keyTableFactory.MakeKeyTable <IKeyTable <TNode> >();
            _connections = keyTableFactory.MakeKeyTable <IKeyTable <TLink> >();

            //_queue = queueFactory.MakeQueue();
            //Queue.Start(GetType().Name + " module queue");
            _queue = queueFactory.SharedQueue;
        }
示例#11
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;
        }
示例#12
0
        public Dijkstra(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IConfigSource config)
        {
            _tableFactory = tableFactory;
            //_queue = queueFactory.MakeQueue();
            //_queue.Start("Dijkstra Queue");
            _queue = queueFactory.SharedQueue;
            _config = config;
            Model.OnWaitChanged += (oldWait, newWait, paused) => {
                if (DijkstraNode.VisualisedNode != null && oldWait == newWait && !paused)
                    Util.Wake(DijkstraNode.VisualisedNode);
            };

            IConfig dijkstraConfig = config.Configs["Dijkstra"];
            AlwaysPrint = dijkstraConfig != null && dijkstraConfig.GetBoolean("AlwaysPrint", false);
            EverPrint = dijkstraConfig != null && dijkstraConfig.GetBoolean("EverPrint", false);
        }
示例#13
0
        private void start()
        {
            clearup();
            DB.Print("Starting root", Levels.SCRIPTS);
            try {
                proxy.start(host, world);
                if (proxy.Shutdown)
                {
                    shutdownProxy("Shutdown flagged after starting root");
                }
                else
                {
                    if (chatQ != null)
                    {
                        chatQ.stop();
                        chatQ = new AsynchQueue <Pair <IEntity, String> >();
                    }
                    if (touchQ != null)
                    {
                        touchQ.stop();
                        touchQ = new AsynchQueue <Pair <UUID, TouchEventArgs> >();
                    }
                    if (touchAddQ != null)
                    {
                        touchAddQ.stop();
                        touchAddQ = new AsynchQueue <UUID>();
                    }

                    chatQ     = new AsynchQueue <Pair <IEntity, String> >();
                    touchQ    = new AsynchQueue <Pair <UUID, TouchEventArgs> >();
                    touchAddQ = new AsynchQueue <UUID>();

                    chatQ.start(proxy.chat, "Chat Event Process", Levels.SCRIPTS);
                    touchQ.start(proxy.touched, "Touch Event Process", Levels.SCRIPTS);
                    touchAddQ.start(addTouchListener, "Touch Add Process", Levels.SCRIPTS);

                    Thread t = new Thread(checkThread);
                    t.Name = "Entry point check shutdown thread";
                    t.Start();
                    DB.Print("Root started", Levels.SCRIPTS);
                }
            } catch (Exception e) {
                DB.Exception(e, "Problem starting up root", Levels.SCRIPTS);
                shutdownProxy("Exception starting up root");
            }
        }
示例#14
0
        public Dijkstra(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IConfigSource config)
        {
            _tableFactory = tableFactory;
            //_queue = queueFactory.MakeQueue();
            //_queue.Start("Dijkstra Queue");
            _queue               = queueFactory.SharedQueue;
            _config              = config;
            Model.OnWaitChanged += (oldWait, newWait, paused) => {
                if (DijkstraNode.VisualisedNode != null && oldWait == newWait && !paused)
                {
                    Util.Wake(DijkstraNode.VisualisedNode);
                }
            };

            IConfig dijkstraConfig = config.Configs["Dijkstra"];

            AlwaysPrint = dijkstraConfig != null && dijkstraConfig.GetBoolean("AlwaysPrint", false);
            EverPrint   = dijkstraConfig != null && dijkstraConfig.GetBoolean("EverPrint", false);
        }
        public SequenceManager(IModule control, IControlUtil controlUtil, IConfig controlConfig, IPrimFactory factory, IKeyTableFactory tableFactory, IAsynchQueue queue)
            : base(controlConfig)
        {
            _queue       = queue;
            _controlUtil = controlUtil;
            _hostPrim    = controlUtil.HostPrim;

            _readerMap        = new Dictionary <string, UUID>();
            _writerMap        = tableFactory.MakeKeyTable <string>();
            _recordingEnabled = controlConfig.GetBoolean("RecordingEnabled", false);
            _sequenceFolder   = controlConfig.Get(FOLDER_KEY, ".");
            _timing           = controlConfig.GetBoolean("TimedPlayback", true);

            _reader = new OpenSimLogReader(_readerMap, control, _hostPrim.Pos);
            _reader.MapInstance <IModule>(control);
            _writers = tableFactory.MakeKeyTable <IXmlLogWriter>();

            _control = Make <IModule>(new RecordControl(control), true);
        }
示例#16
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;
        }
示例#17
0
        public VPacket(IPacket packet, IVNode from, IVNode to, IVLink link, IPrimFactory primFactory, IAsynchQueue queue, View view)
            : base(primFactory, from.Pos, packet.Name, packet.Colour, packet.Selected, packet.Parameters)
        {
            Prim.Editable = false;
            _packet = packet;
            _from = from;
            _to = to;
            _link = link;
            _step = 0;
            _view = view;
            Selected = packet.Selected;
            Configure();

            _deleteListener = id => Dropped("Visualisation layer dropped " + Name + ".");

            _from.OnWorldMove += (id, oldPos, newPos) => Reconfigure();
            _to.OnWorldMove += (id, oldPos, newPos) => Reconfigure();
            _from.OnAPIMove += (id, oldPos, newPos) => Reconfigure();
            _to.OnAPIMove += (id, oldPos, newPos) => Reconfigure();

            link.OnWeightChanged += (id, weight) => Reconfigure();
            link.OnWorldDelete += _deleteListener;
            link.OnSystemDelete += _deleteListener;

            //_tickListener = () => queue.QueueWorkItem(state => UpdatePosition());
            _tickListener = () => queue.QWork("Move Packet", () => UpdatePosition());
            view.OnTick += _tickListener;
        }
示例#18
0
        private void start()
        {
            clearup();
            DB.Print("Starting root", Levels.SCRIPTS);
            try {
                proxy.start(host, world);
                if (proxy.Shutdown)
                    shutdownProxy("Shutdown flagged after starting root");
                else {
                    if (chatQ != null) {
                        chatQ.stop();
                        chatQ = new AsynchQueue<Pair<IEntity, String>>();
                    }
                    if (touchQ != null) {
                        touchQ.stop();
                        touchQ = new AsynchQueue<Pair<UUID, TouchEventArgs>>();
                    }
                    if (touchAddQ != null) {
                        touchAddQ.stop();
                        touchAddQ = new AsynchQueue<UUID>();
                    }

                    chatQ = new AsynchQueue<Pair<IEntity, String>>();
                    touchQ = new AsynchQueue<Pair<UUID, TouchEventArgs>>();
                    touchAddQ = new AsynchQueue<UUID>();

                    chatQ.start(proxy.chat, "Chat Event Process", Levels.SCRIPTS);
                    touchQ.start(proxy.touched, "Touch Event Process", Levels.SCRIPTS);
                    touchAddQ.start(addTouchListener, "Touch Add Process", Levels.SCRIPTS);

                    Thread t = new Thread(checkThread);
                    t.Name = "Entry point check shutdown thread";
                    t.Start();
                    DB.Print("Root started", Levels.SCRIPTS);
                }
            } catch (Exception e) {
                DB.Exception(e, "Problem starting up root", Levels.SCRIPTS);
                shutdownProxy("Exception starting up root");
            }
        }
示例#19
0
        private void shutdown()
        {
            cont = false;
            shutdownProxy();
            world.OnChat -= chatDelegate;

            if (chatQ != null)
                chatQ.stop();
            if (touchQ != null)
                touchQ.stop();
            if (touchAddQ != null)
                touchAddQ.stop();

            chatQ = null;
            touchQ = null;
            touchAddQ = null;

            DB.Print("Entry Point shut down queues", Levels.SCRIPTS);
        }
示例#20
0
        public DijkstraNode(IMNodeInternal node, IKeyTableFactory tableFactory, IAsynchQueue queue, IConfigSource config)
            : base(node, tableFactory, config)
        {
            _queue = queue;
            _distances = tableFactory.MakeKeyTable<float>();
            _wipRoute = tableFactory.MakeKeyTable<IMLink>();
            _prev = tableFactory.MakeKeyTable<DijkstraNode>();

            _confirmed = new LinkedList<DijkstraNode>();
            _tentative = new LinkedList<DijkstraNode>();
            _links = new LinkedList<IMLink>();

            SetDistanceFromRoot(ID, 0f, null, null);
        }
示例#21
0
        public VPacket(IPacket packet, IVNode from, IVNode to, IVLink link, IPrimFactory primFactory, IAsynchQueue queue, View view)
            : base(primFactory, from.Pos, packet.Name, packet.Colour, packet.Selected, packet.Parameters)
        {
            Prim.Editable = false;
            _packet       = packet;
            _from         = from;
            _to           = to;
            _link         = link;
            _step         = 0;
            _view         = view;
            Selected      = packet.Selected;
            Configure();

            _deleteListener = id => Dropped("Visualisation layer dropped " + Name + ".");

            _from.OnWorldMove += (id, oldPos, newPos) => Reconfigure();
            _to.OnWorldMove   += (id, oldPos, newPos) => Reconfigure();
            _from.OnAPIMove   += (id, oldPos, newPos) => Reconfigure();
            _to.OnAPIMove     += (id, oldPos, newPos) => Reconfigure();


            link.OnWeightChanged += (id, weight) => Reconfigure();
            link.OnWorldDelete   += _deleteListener;
            link.OnSystemDelete  += _deleteListener;

            //_tickListener = () => queue.QueueWorkItem(state => UpdatePosition());
            _tickListener = () => queue.QWork("Move Packet", () => UpdatePosition());
            view.OnTick  += _tickListener;
        }
示例#22
0
        public MRMPrimFactory(IHost host, IWorld world, IAsynchQueueFactory queueFactory, IKeyTableFactory tableFactory, IConfigSource config, UUID hostID)
        {
            IConfig mrmConfig = config.Configs["MRM"];

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

            _world = world;
            _host  = host;

            _logger        = LogManager.GetLogger(typeof(MRMPrimFactory));
            _prims         = new MapKeyTable <IPrim>();
            _createdPrims  = new List <UUID>();
            _freeObjects   = new Dictionary <UUID, IObject>();
            _chatListeners = new Dictionary <int, List <ChatDelegate> >();

            //_factoryQ = queueFactory.MakeQueue();
            _factoryQ = queueFactory.SharedQueue;

            CheckWait = mrmConfig.GetInt("CheckWait", CheckWait);
            _recycle  = mrmConfig.GetBoolean("Recycle", true);

            try {
                _hostPrim = new MRMPrim(hostID, this);
            } catch (Exception e) {
                _hostPrim = null;
                throw new Exception("Problem getting Host Prim: " + e.Message + "\n" + e.StackTrace);
            }

            _chatListener += (sender, args) => {
                _world = sender;
                if (_chatListeners.ContainsKey(args.Channel))
                {
                    lock (_chatListeners)
                        foreach (var listener in _chatListeners[args.Channel])
                        {
                            listener(args.Sender.Name, args.Sender.GlobalID, args.Text, args.Channel);
                        }
                }
                if (OnChat != null)
                {
                    OnChat(args.Sender.Name, args.Sender.GlobalID, args.Text, args.Channel);
                }
            };
            _world.OnChat += _chatListener;

            _checkThread      = new Thread(CheckThread);
            _checkThread.Name = "MRMPrimFactory Check Thread";
            _checkThread.Start();



            _linkButtons = new Dictionary <uint, TouchButton>();
            _chatButtons = new Dictionary <UUID, TouchButton>();

            _knowButtons = new Dictionary <string, HashSet <UUID> >();
            _pingChannel = mrmConfig.GetInt("PingChannel", -50);
            _ping        = mrmConfig.Get("ButtonPing", "Ping");
            _pingAck     = mrmConfig.Get("ButtonPingAck", "Pong");
            _chanAck     = mrmConfig.Get("ButtonChannelAck", "ACK");
            InitTouchButtons();
        }