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); }
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); }
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 + "."); } }; }
public MNode(INode node, ForwardDelegate forwardMethod, String defaultAlgorithm, IAlgorithm[] algorithms, IKeyTableFactory tableFactory) : base(node) { _passDownMethod = forwardMethod; _tableFactory = tableFactory; _links = tableFactory.MakeKeyTable <IMLink>(); _neighbours = tableFactory.MakeKeyTable <IMNodeInternal>(); _algorithms = new Dictionary <string, IAlgorithmNode>(); foreach (IAlgorithm alg in algorithms) { IAlgorithmNode algNode = alg.MakeNode(this, SendPacket); _algorithms.Add(alg.Name, algNode); algNode.OnRouteChange += RouteChangeListener; algNode.IsCurrentAlgorithm = alg.Name.Equals(defaultAlgorithm); if (algNode.IsCurrentAlgorithm) { _currentAlgorithm = algNode; } } if (_currentAlgorithm == null) { throw new Exception("Test Node unable to set algorithm. '" + defaultAlgorithm + "' is not a valid algorithm."); } _currentAlgorithmName = defaultAlgorithm; _passDownMethod = forwardMethod; OnPacketReceived += (at, p) => { IMPacket packet = p as IMPacket; if (packet != null && packet.Type == PTypes.data) { ReceiveData(packet); } else if (packet != null && _algorithms.ContainsKey(packet.Algorithm)) { _algorithms[packet.Algorithm].ProcessPacket(packet); } }; _weightDelegate = (id, newWeight) => { if (OnWeightChange != null) { OnWeightChange(id, newWeight); Logger.Debug(Name + " triggered OnWeightChange for '" + Links[id].Name + "'."); } }; _highlightDelegate = () => ResetHighlightAll(); OnHighlightReset += _highlightDelegate; }
public MNode(INode node, ForwardDelegate forwardMethod, String defaultAlgorithm, IAlgorithm[]algorithms, IKeyTableFactory tableFactory) : base(node) { _passDownMethod = forwardMethod; _tableFactory = tableFactory; _links = tableFactory.MakeKeyTable<IMLink>(); _neighbours = tableFactory.MakeKeyTable<IMNodeInternal>(); _algorithms = new Dictionary<string, IAlgorithmNode>(); foreach (IAlgorithm alg in algorithms) { IAlgorithmNode algNode = alg.MakeNode(this, SendPacket); _algorithms.Add(alg.Name, algNode); algNode.OnRouteChange += RouteChangeListener; algNode.IsCurrentAlgorithm = alg.Name.Equals(defaultAlgorithm); if (algNode.IsCurrentAlgorithm) _currentAlgorithm = algNode; } if (_currentAlgorithm == null) throw new Exception("Test Node unable to set algorithm. '" + defaultAlgorithm + "' is not a valid algorithm."); _currentAlgorithmName = defaultAlgorithm; _passDownMethod = forwardMethod; OnPacketReceived += (at, p) => { IMPacket packet = p as IMPacket; if (packet != null && packet.Type == PTypes.data) ReceiveData(packet); else if (packet != null && _algorithms.ContainsKey(packet.Algorithm)) _algorithms[packet.Algorithm].ProcessPacket(packet); }; _weightDelegate = (id, newWeight) => { if (OnWeightChange != null) { OnWeightChange(id, newWeight); Logger.Debug(Name + " triggered OnWeightChange for '" + Links[id].Name + "'."); } }; _highlightDelegate = () => ResetHighlightAll(); OnHighlightReset += _highlightDelegate; }
public IAlgorithmNode MakeNode(IMNodeInternal node, ForwardDelegate forwardMethod) { return(new LinkStateNode(node, _tableFactory, _dijkstraQ, _eventQ, forwardMethod, _config)); }
public IAlgorithmNode MakeNode(IMNodeInternal node, ForwardDelegate forwardMethod) { return(new DVNode(node, forwardMethod, _queue, _tableFactory, TTL, _config)); }
public IAlgorithmNode MakeNode(IMNodeInternal node, ForwardDelegate forwardMethod) { return new DVNode(node, forwardMethod, _queue, _tableFactory, TTL, _config); }
public static void Initialize() { _GetFov = Helper.Magic.RegisterDelegate<GetFovDelegate>(Helper.Magic.GetObjectVtableFunction(Pointer, 0)); _Forward = Helper.Magic.RegisterDelegate<ForwardDelegate>(Helper.Magic.GetObjectVtableFunction(Pointer, 1)); _Right = Helper.Magic.RegisterDelegate<RightDelegate>(Helper.Magic.GetObjectVtableFunction(Pointer, 2)); _Up = Helper.Magic.RegisterDelegate<UpDelegate>(Helper.Magic.GetObjectVtableFunction(Pointer, 3)); }
public IAlgorithmNode MakeNode(IMNodeInternal node, ForwardDelegate forwardMethod) { return new LinkStateNode(node, _tableFactory, _dijkstraQ, _eventQ, forwardMethod, _config); }