/// <summary> /// Create a splitter which will create an instance of TToSplitType in appDomain creating it with parameters which are proxies to the objects in constructorParams. /// Will also start a thread to check for method calls to the parameter proxies and relay them back to the actual parameter objects in the parent application domain. /// TODO Add more constructors for the various arguments CreateInstanceAndUnwrap can have. /// </summary> /// <param name="appDom">The application domain to create the new object in.</param> /// <param name="queueFactory">The queue factory which will be used to do any asynchronous processing in the new application domain. /// It will be used to process method calls from the proxy in this application domain to the instance in the child application domain.</param> /// <param name="toSplitType">The type of object to be instantiated in the new application domain.</param> /// <param name="constructorParams">Any parameters for the constructor of TToSplitType.</param> internal Splitter(AppDomain appDom, Type toSplitType, IAsynchQueueFactory queueFactory, object[] constructorParams) { _parameters = new Dictionary <int, object>(); Type helperType = typeof(SplitterChild <TToSplit>);//BuildRemoteType(toSplitType, constructorParams); object[] args = BuildArgs(toSplitType, queueFactory, constructorParams); _childProxy = appDom.CreateInstanceAndUnwrap( helperType.Assembly.FullName, helperType.FullName, false, BindingFlags.CreateInstance, null, args, null, null) as SplitterChild <TToSplit>; ISpy <TToSplit> spy = new Spy <TToSplit>(_childProxy.Instance); Instance = spy.Instance; spy.OnEventAdd += (source, evt, listener) => AddListener(evt.Name, listener.Method); spy.OnEventRemove += (source, evt, listener) => RemoveListener(evt.Name, listener.Method); spy.OnMethodEvent += (source, method, ret, parameters) => AddParamEventListeners(parameters); _cont = true; Thread thread = new Thread(CheckThread); thread.Name = toSplitType.Name + "CheckThread"; thread.Start(); }
public SandboxControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { _tableFactory = tableFactory; //IsOn int chatChannel = ControlConfig.GetInt("PublicInputChannel", 46); if (chatChannel < 0) { chatChannel = 46; } Dialog.SetChatChannel(chatChannel); //Misc _reposition = ControlConfig.GetBoolean("RepositionControls", false); float scale = ControlConfig.GetFloat("DefaultScale", .5f); if (ControlConfig.GetBoolean("AutoRecord", false)) { Record.StartRecording(); } InitControls(); }
public override void Stop() { foreach (var system in _liveSystems.Values) { Stop(system); } IAsynchQueueFactory _queueFactory = _k.Get <IAsynchQueueFactory>(); _queueFactory.ShutdownAll(); Console.WriteLine(_queueFactory.Queues.Count + " Queues:"); foreach (IAsynchQueue q in _queueFactory.Queues) { Console.WriteLine("{0,-40} - Active: {1,7:0.###}% - Mean time per task: {2,8:0.###}ms - Helpers (Max: {3,2}, Tot: {4,6}) - {5,-40}" /* - Time: {6,-18} - Helper Time: {7,17}"*/, q.IsRunning ? q.Name : "(" + q.Name + ")", q.Statistics.PercentageActive, q.Statistics.MeanProcessTime, q.Statistics.MaxHelperThreads, q.Statistics.TotalHelpersSpawned, string.Format(q.Statistics.UnprocessedTasks > 0 ? "# Tasks: {0,-6} - # Unprocessed Tasks: {1}" : "# Tasks: {0}", q.Statistics.QueuedTasks, q.Statistics.UnprocessedTasks)/*, * q.Statistics.Time, * q.Statistics.TotalHelperTime*/ ); } }
public AutosaveHUD(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { _autosaveFile = Path.Combine(Topology.GetFolder(Factory.Owner), AUTOSAVE_NAME); if (File.Exists(_autosaveFile)) Topology.LoadTopology(Factory.Owner, Factory.Host.Owner, _autosaveFile); }
internal void Start(IKernel k, IConfig config, string configFile, UUID hostID, bool stopQueues) { Host.Object.Say("Starting MRMSystem."); string oldDir = Environment.CurrentDirectory; _shutdown = false; _stopQueues = stopQueues; BindClasses(k, config, configFile, hostID); _queueFactory = k.Get <IAsynchQueueFactory>(); _primFactory = k.Get <IPrimFactory>() as MRMPrimFactory; k.Get <IView>(); Logger.Debug("View created."); k.Get <IModel>(); Logger.Debug("Model created."); _controller = k.Get <IControl>(); Logger.Debug("Control created."); //World.OnChat += (world, args) => { // if (args.Sender.GlobalID.Equals(Host.Object.OwnerId) && args.Text.ToUpper().Equals("CLEAR")) // _controller.Clear(args.Sender.Name, args.Sender.GlobalID); //}; if (Host.Object.Exists) { Host.Object.Say(AppDomain.CurrentDomain.FriendlyName + " started."); } }
public CreateTopologyControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { /* //Touch Button IButton floor = Factory.MakeButton("Floor", Permissions, HostPrim.ID); floor.OnTouched += (source, args) => AddRouter(args.AvatarName, args.AvatarID, args.TouchPosition); */ IConfig controlConfig = config.Configs["Control"]; string god = controlConfig.Get(GOD_KEY, GOD); string topologyDefault = controlConfig.Get(TOPOLOGY_KEY, GOD); _listener = (name, id, text, channel) => { string[] args = text.Split(' '); if (id.Equals(HostPrim.Owner) && args[0].ToUpper().Equals("SAVE")) { if (args.Length > 1) { HostPrim.Say("Saving topology as " + args[1]); Topology.SaveTopology(name, id, args[1]); } else { HostPrim.Say("Showing Dialog"); SaveDialog save = new SaveDialog(HostPrim, primFactory, "Topology", topologyDefault, user => Topology.GetUserFolder(god)); save.OnSave += (userName, userID, file) => Topology.SaveTopology(name, id, file); save.Show(name, id); } } }; primFactory.OnChat += _listener; }
public CreateTopologyControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { /* * //Touch Button * IButton floor = Factory.MakeButton("Floor", Permissions, HostPrim.ID); * floor.OnTouched += (source, args) => AddRouter(args.AvatarName, args.AvatarID, args.TouchPosition); */ IConfig controlConfig = config.Configs["Control"]; string god = controlConfig.Get(GOD_KEY, GOD); string topologyDefault = controlConfig.Get(TOPOLOGY_KEY, GOD); _listener = (name, id, text, channel) => { string[] args = text.Split(' '); if (id.Equals(HostPrim.Owner) && args[0].ToUpper().Equals("SAVE")) { if (args.Length > 1) { HostPrim.Say("Saving topology as " + args[1]); Topology.SaveTopology(name, id, args[1]); } else { HostPrim.Say("Showing Dialog"); SaveDialog save = new SaveDialog(HostPrim, primFactory, "Topology", topologyDefault, user => Topology.GetUserFolder(god)); save.OnSave += (userName, userID, file) => Topology.SaveTopology(name, id, file); save.Show(name, id); } } }; primFactory.OnChat += _listener; }
/// <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); }
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."); }
public AdvancedControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, UUID hostID, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, hostID, config) { IConfig controlConfig = config.Configs["Control"]; if (controlConfig == null) controlConfig = config.Configs[0]; _defaultTopologyName = controlConfig.Get("DefaultTopologyName", "Topology"); _defaultRecordingName = controlConfig.Get("DefaultSequenceName", "Sequence"); }
/// <summary> /// Create an instance of the given class which will be instantiated in a new AppDomain but the parameters passed into its constructor will remain in this application domain and will be accessible from the new application domain. /// /// Will check to see that there is a constructor for TToSplitType which has a signature matching the objects passed in as constructorParams /// </summary> /// <param name="domainName">The name of the new AppDomain.</param> public static TToSplit Build <TToSplit>(AppDomain appDom, Type toSplitType, IAsynchQueueFactory queueFactory, params object[] constructorParams) where TToSplit : class { if (toSplitType.IsInterface || toSplitType.IsAbstract) { throw new ArgumentException(toSplitType.Name + " is an " + (toSplitType.IsInterface ? "interface" : "abstract class") + ". The type to split must be a class that can be instantiated."); } return(new Splitter <TToSplit>(appDom, toSplitType, queueFactory, constructorParams).Instance); }
public AutosaveHUD(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { _autosaveFile = Path.Combine(Topology.GetUserFolder(Factory.Owner), AUTOSAVE_NAME); if (File.Exists(_autosaveFile)) { Topology.LoadTopology(Factory.Owner, Factory.Host.Owner, _autosaveFile); } }
public SequenceControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { IConfig controlConfig = config.Configs[CONTROL_CONFIG]; if (controlConfig == null) controlConfig = config.Configs[0]; Init(controlConfig, HostPrim.Owner, this, Factory); }
/// <summary> /// Build the array of arguments that will be passed in to the constructor of the dynamically created class in the application domain. /// /// The arguments are: /// 0: The type object for the object being split /// 1: An IAsynchQueueFactory used for decoupling where necessary /// 3: An array of all the types of the parameters passed in /// </summary> /// <param name="toSplitType">The type object for the object being split.</param> /// <param name="queueFactory">An IAsynchQueueFactory used for decoupling where necessary.</param> /// <param name="constructorParams">An array of all the types of the parameters passed in.</param> /// <returns>Any array of objects which can be passed in to the invoke method when creating the root in the child application domain.</returns> private object[] BuildArgs(Type toSplitType, IAsynchQueueFactory queueFactory, object[] constructorParams) { List <object> args = new List <object>(); args.Add(toSplitType); args.Add(queueFactory); args.Add(constructorParams); AddParamEventListeners(constructorParams); return(args.ToArray()); }
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 AdvancedControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, UUID hostID, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, hostID, config) { IConfig controlConfig = config.Configs["Control"]; if (controlConfig == null) { controlConfig = config.Configs[0]; } _defaultTopologyName = controlConfig.Get("DefaultTopologyName", "Topology"); _defaultRecordingName = controlConfig.Get("DefaultSequenceName", "Sequence"); }
public SequenceControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { IConfig controlConfig = config.Configs[CONTROL_CONFIG]; if (controlConfig == null) { controlConfig = config.Configs[0]; } Init(controlConfig, HostPrim.Owner, this, Factory); }
public CreateSequenceControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { IConfig controlConfig = config.Configs["Control"]; string god = controlConfig.Get(GOD_KEY, GOD); string topology = controlConfig.Get(TOPOLOGY_KEY, null); string sequenceDefault = controlConfig.Get(SEQUENCE_KEY, SEQUENCE); if (topology != null) { Topology.LoadTopology(god, Factory.Host.Owner, topology); } _listener = (name, id, text, channel) => { string[] args = text.Split(' '); if (id.Equals(HostPrim.Owner) && args[0].ToUpper().Equals("SAVE")) { if (args.Length > 1) { HostPrim.Say("Saving sequence as " + args[1]); if (topology != null) { Record.SaveRecording(god, args[1], topology); } else { Record.SaveRecording(god, args[1]); } } else { HostPrim.Say("Showing Dialog"); SaveDialog save = new SaveDialog(HostPrim, primFactory, "Sequence", sequenceDefault, user => Record.GetUserFolder(god)); save.OnSave += (user, userID, file) => { if (topology == null) { Record.SaveRecording(god, file); } else { Record.SaveRecording(god, file, topology); } }; save.Show(name, id); } } }; primFactory.OnChat += _listener; Record.StartRecording(); }
public Control(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory) { ControlConfig = config.Configs[CONTROL_CONFIG]; IConfig commonConfig = config.Configs["Common"]; if (ControlConfig == null) { ControlConfig = config.Configs[0]; } if (commonConfig == null) { commonConfig = config.Configs[0]; } _toggleGlow = ControlConfig.GetDouble("ToggleGlow", .15); _fade = ControlConfig.GetDouble("Fade", .8); _defaultRecordingName = ControlConfig.Get("DefaultSequenceName", "Sequence"); _defaultTopologyName = ControlConfig.Get("DefaultTopologyName", "Topology"); _multiNumber = ControlConfig.GetInt("MultiSendNumber", 10); _multiSendDelay = ControlConfig.GetInt("MultiSendDelay", 750); _wait = commonConfig.GetInt("Wait", 50); _factory = primFactory; _record = MakeRecord(ControlConfig, tableFactory, queueFactory, primFactory); _topology = MakeTopology(ControlConfig); _permissions = MakePermissions(tableFactory, config); _state = MakeState(tableFactory, config); _model = Record.Make <IModel>(model, false); string tableName = ControlConfig.Get(TABLE_KEY, null); int tableCount = ControlConfig.GetInt(TABLE_COUNT, 1); _tables = new List <RoutingTable>(); if (tableName != null && tableCount > 1) { for (int i = 1; i <= tableCount; i++) { _tables.Add(new RoutingTable(Factory.MakeButton(tableName + i, Permissions), this, Factory)); } } else if (tableName != null) { _tables.Add(new RoutingTable(Factory.MakeButton(tableName, Permissions), this, Factory)); } _tables.Add(new RoutingTable(Factory.MakeButton(ControlConfig.Get(TABLE_HUD_KEY, "TableDisplayHUD"), Permissions), this, Factory)); Logger.Info("Control started."); }
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; }
public OriginalControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, UUID hostID, IConfigSource config) : base(tableFactory, queueFactory) { _hostPrim = primFactory[hostID]; _readerMap = new Dictionary <string, UUID>(); _writerMap = tableFactory.MakeKeyTable <string>(); _paused = tableFactory.MakeKeyTable <bool>(); IConfig controlConfig = config.Configs["Control"]; IConfig commonConfig = config.Configs["Common"]; if (controlConfig == null) { controlConfig = config.Configs[0]; } if (commonConfig == null) { commonConfig = config.Configs[0]; } _wait = commonConfig.GetInt("Wait", 50); _userFolder = controlConfig.Get("UserFolder", "."); _recordingEnabled = controlConfig.GetBoolean("RecordingEnabled", false); _timing = controlConfig.GetBoolean("TimedPlayback", true); _schemaFile = controlConfig.GetString("TopologySchema", null); _reader = new OpenSimLogReader(_readerMap, model, HostPrim.Pos); _reader.MapInstance <IModule>(this); _writers = tableFactory.MakeKeyTable <IXmlLogWriter>(); _factory = primFactory; if (_recordingEnabled) { _modelWriter = new OpenSimLogWriter <IModel>(_writerMap, model, HostPrim.Pos, true, false); _model = _modelWriter.Instance; IXmlLogWriter <IModule> baseWriter = new OpenSimLogWriter <IModule>(_writerMap, this, HostPrim.Pos, true); _recordingBase = baseWriter.Instance; _writers.Add(hostID, baseWriter); } else { _model = model; } Namespace = controlConfig.Get("Namespace", Namespace); Logger.Info("Control started."); }
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 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 Model(IView view, IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IConfigSource config, params IAlgorithm[] algorithms) : base(tableFactory, queueFactory) { if (algorithms.Length == 0) { view.Stop(); throw new Exception("Unable to start model layer, default algorithm " + _currentAlgorithm + " is not a valid algorithm"); } _knownNodes = tableFactory.MakeKeyTable <IMNodeInternal>(); _view = view; _algorithms = algorithms; IConfig commonConfig = config.Configs["Common"]; IConfig modelConfig = config.Configs["Model"]; if (modelConfig == null) { modelConfig = config.Configs[0]; } if (commonConfig == null) { commonConfig = config.Configs[0]; } _wait = commonConfig.GetInt("Wait", 50); _waitMult = modelConfig.GetInt("WaitMult", 5); _currentAlgorithm = modelConfig.GetString("Algorithm", algorithms.First().Name); if (_algorithms.Count(alg => alg.Name.Equals(_currentAlgorithm)) == 0) { _currentAlgorithm = algorithms.First().Name; Logger.Debug("Specified Current Algorithm ('" + modelConfig.GetString("Algorithm") + "') invalid. Using '" + _currentAlgorithm + "'."); } if (!modelConfig.Contains("Algorithm")) { Logger.Debug("Current Algorithm not specified. Using '" + _currentAlgorithm + "'."); } Logger.Info("Model started with " + algorithms.Length + " algorithms."); foreach (IAlgorithm alg in algorithms) { Logger.Info(alg.Name + (alg.Name.Equals(_currentAlgorithm) ? " (default)" :"")); } }
public TopologyControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { IConfig control = config.Configs[CONTROL_CONFIG]; if (control == null) { control = config.Configs[0]; } _reposition = !control.GetBoolean("RotateWithHost", true) && control.GetBoolean("Reposition", true); _hostPos = HostPrim.Pos; _hostRot = HostPrim.Rotation; string topology = control.GetString(TOPOLOGY_KEY); string godName = control.GetString(GOD_KEY, GOD); if (topology == null) { HostPrim.Say("Unable to start topology control. No topology file specified."); throw new Exception("Unable to start topology control. No topology file specified."); } Topology.LoadTopology(godName, HostPrim.Owner, topology); HostPrim.Say("Started Topology Control."); Factory.AddLinkSetRoot(Factory.Host.ID); IButton PauseButton = MakeButton("Pause"); IButton StepButton = MakeButton("Step"); IToggle PauseToggle = new Toggle(PauseButton, 1, ToggleGlow); foreach (var pause in PauseToggle.Prims) { pause.Colour = Color.White; } PauseToggle.OnToggled += (source, args) => { Record.Paused = PauseToggle.IsOn; foreach (var prim in PauseToggle.Prims) { prim.Glow = PauseToggle.IsOn ? .1d : 0d; prim.Colour = Color.White; } }; StepButton.OnTouched += (source, args) => Model.Step(); }
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 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 CreateSequenceControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { IConfig controlConfig = config.Configs["Control"]; string god = controlConfig.Get(GOD_KEY, GOD); string topology = controlConfig.Get(TOPOLOGY_KEY, null); string sequenceDefault = controlConfig.Get(SEQUENCE_KEY, SEQUENCE); if (topology != null) Topology.LoadTopology(god, Factory.Host.Owner, topology); _listener = (name, id, text, channel) => { string[] args = text.Split(' '); if (id.Equals(HostPrim.Owner) && args[0].ToUpper().Equals("SAVE")) { if (args.Length > 1) { HostPrim.Say("Saving sequence as " + args[1]); if (topology != null) Record.SaveRecording(god, args[1], topology); else Record.SaveRecording(god, args[1]); } else { HostPrim.Say("Showing Dialog"); SaveDialog save = new SaveDialog(HostPrim, primFactory, "Sequence", sequenceDefault, user => Record.GetUserFolder(god)); save.OnSave += (user, userID, file) => { if (topology == null) Record.SaveRecording(god, file); else Record.SaveRecording(god, file, topology); }; save.Show(name, id); } } }; primFactory.OnChat += _listener; Record.StartRecording(); }
public TopologyControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { IConfig control = config.Configs[CONTROL_CONFIG]; if (control == null) control = config.Configs[0]; _reposition = !control.GetBoolean("RotateWithHost", true) && control.GetBoolean("Reposition", true); _hostPos = HostPrim.Pos; _hostRot = HostPrim.Rotation; string topology = control.GetString(TOPOLOGY_KEY); string godName = control.GetString(GOD_KEY, GOD); if (topology == null) { HostPrim.Say("Unable to start topology control. No topology file specified."); throw new Exception("Unable to start topology control. No topology file specified."); } Topology.LoadTopology(godName, HostPrim.Owner, topology); HostPrim.Say("Started Topology Control."); Factory.AddLinkSetRoot(Factory.Host.ID); IButton PauseButton = MakeButton("Pause"); IButton StepButton = MakeButton("Step"); IToggle PauseToggle = new Toggle(PauseButton, 1, ToggleGlow); foreach (var pause in PauseToggle.Prims) pause.Colour = Color.White; PauseToggle.OnToggled += (source, args) => { Record.Paused = PauseToggle.IsOn; foreach (var prim in PauseToggle.Prims) { prim.Glow = PauseToggle.IsOn ? .1d : 0d; prim.Colour = Color.White; } }; StepButton.OnTouched += (source, args) => Model.Step(); }
public IndividualControl(IHost host, IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, UUID hostID, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, hostID, config) { _owner = host.Object.OwnerId; }
protected virtual ISequenceManager MakeRecord(IConfig config, IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory) { return(new SequenceManager(this, this, config, primFactory, tableFactory, Queue)); }
public HudControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, UUID hostID, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, hostID, config) { }
public FullHudControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { }
internal void Start(IKernel k, IConfig config, string configFile, UUID hostID, bool stopQueues) { Host.Object.Say("Starting MRMSystem."); string oldDir = Environment.CurrentDirectory; _shutdown = false; _stopQueues = stopQueues; BindClasses(k, config, configFile, hostID); _queueFactory = k.Get<IAsynchQueueFactory>(); _primFactory = k.Get<IPrimFactory>() as MRMPrimFactory; k.Get<IView>(); Logger.Debug("View created."); k.Get<IModel>(); Logger.Debug("Model created."); _controller = k.Get<IControl>(); Logger.Debug("Control created."); //World.OnChat += (world, args) => { // if (args.Sender.GlobalID.Equals(Host.Object.OwnerId) && args.Text.ToUpper().Equals("CLEAR")) // _controller.Clear(args.Sender.Name, args.Sender.GlobalID); //}; if (Host.Object.Exists) Host.Object.Say(AppDomain.CurrentDomain.FriendlyName + " started."); }
private static TToBuild buildInstance <TToBuild>(Type toSplitType, IAsynchQueueFactory queueFactory, params object[] constructorParameters) where TToBuild : class { return(Activator.CreateInstance(toSplitType, ReplaceParameters(constructorParameters)) as TToBuild); }
/// <summary> /// TODO use spy to check on calls made to proxy. If adding or removing listener use listener manager instead. /// /// Create an instance of the given class which will be instantiated in a new AppDomain but the parameters passed into its constructor will remain in this application domain and will be accessible from the new application domain. /// </summary> /// <param name="domainName">The name of the new AppDomain.</param> public static TToSplit Build <TToSplit>(AppDomain appDom, IAsynchQueueFactory queueFactory, params object[] constructorParams) where TToSplit : class { return(Build <TToSplit> (appDom, typeof(TToSplit), queueFactory, constructorParams)); }
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(); }
public LockedWallSandbox(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { _lockWait = config.Configs[CONTROL_CONFIG] != null ? config.Configs[CONTROL_CONFIG].GetInt("ControlsLockTimeout", 300000) : 300000; }
public SandboxControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config) : base(tableFactory, queueFactory, primFactory, model, config) { _tableFactory = tableFactory; //IsOn int chatChannel = ControlConfig.GetInt("PublicInputChannel", 46); if (chatChannel < 0) chatChannel = 46; Dialog.SetChatChannel(chatChannel); //Misc _reposition = ControlConfig.GetBoolean("RepositionControls", false); float scale = ControlConfig.GetFloat("DefaultScale", .5f); if (ControlConfig.GetBoolean("AutoRecord", false)) Record.StartRecording(); InitControls(); }
public SequenceManager(IModule control, IControlUtil controlUtil, IConfig controlConfig, IPrimFactory primFactory, IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory) : this(control, controlUtil, controlConfig, primFactory, tableFactory, queueFactory.MakeQueue()) { }