/// <summary> /// Initializes a new instance of the <see cref="Processor"/> class. /// </summary> public Processor() { _projectManager = CoreSystem.Managers.Find(m => m.Name.Contains("ProjectManager")) as ProjectManager; _dataStorageManager = CoreSystem.Managers.Find(m => m.Name.Contains("DataStorageManager")) as DataStorageManager; _propertyManager = CoreSystem.Managers.Find(m => m.Name.Contains("PropertyManager")) as PropertyManager; _extensionManager = CoreSystem.Managers.Find(m => m.Name.Contains("ExtensionManager")) as ExtensionManager; _nexuses = new List<AsyncNanoProcessor>(); }
private void ResultsView_Loaded(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(this)) return; DataControl.ItemsSource = _collection; _propertyManager = CoreSystem.Managers.Find(m => m.Name.Contains("PropertyManager")) as PropertyManager; ProjectManager projectManager = CoreSystem.Managers.Find(m => m.Name.Contains("ProjectManager")) as ProjectManager; _guiManager = CoreSystem.Managers.Find(m => m.Name.Contains("GuiManager")) as GuiManager; _propertyManager.NodeAddedEvent += PropertyManagerNodeAddedEvent; _propertyManager.NodeRemovedEvent += PropertyManagerNodeRemovedEvent; projectManager.Loading += ProjectManagerLoading; _guiManager.SelectedItemChanged += guiManager_SelectedItemChanged; }
/// <summary> /// Initialze the Plugin. /// </summary> /// <returns> /// Success of the Operation. /// </returns> public override bool Initialize() { WebApp.Start<OwinStartup>(Address); _renderHubContext = GlobalHost.ConnectionManager.GetHubContext<RenderHub>(); _propertyManager = CoreSystem.Managers.Find(m => m.Name.Contains("PropertyManager")) as PropertyManager; _imageQueue = new Queue<ImageProperty>(); _thread = new Thread(new ThreadStart(() => this.ThreadLoop())); _thread.Start(); return true; }
/// <summary> /// Loads a new instance of ProjectManager. /// Will also override the old values of the currently loaded ProjectManager. /// </summary> /// <param name="path">Path to the configuration file.</param> /// <returns>Returns the instance of the ProjectManager if successful, else null.</returns> public override object Load(string path) { if (this.Loading != null) this.Loading(); ProjectManager manager = base.Load(path) as ProjectManager; this.Configuration.Name = manager.Configuration.Name; _pluginManager = CoreSystem.Managers.Find(m => m.Name.Contains("PluginManager")) as PluginManager; _deviceManager = CoreSystem.Managers.Find(m => m.Name.Contains("DeviceManager")) as DeviceManager; _propertyManager = CoreSystem.Managers.Find(m => m.Name.Contains("PropertyManager")) as PropertyManager; _displayManager = CoreSystem.Managers.Find(m => m.Name.Contains("DisplayManager")) as DisplayManager; _displayManager.Clear(); this.Configuration.Operations.Clear(); _propertyManager.Nodes.Clear(); List<Node> configuratedDevices = new List<Node>(); foreach (Device d in manager.Configuration.Devices) { Device device = _deviceManager.Plugins.Find(p => p.Fullname == d.Fullname && p.AssemblyFile == d.AssemblyFile) as Device; Device deviceClone = device.Clone() as Device; deviceClone.Name = d.Name; deviceClone.UID = d.UID; deviceClone.Cache = d.Cache; foreach (Property p in deviceClone.Childs) { if (p is ListProperty) { ListProperty lp = p as ListProperty; Property childProperty = d.Cache.Childs.Find(c => ((Node)c).Name == lp.Name) as Property; lp.Value = childProperty.Value; } } configuratedDevices.Add(deviceClone); } List<Device> devices = new List<Device>(); foreach (Device d in configuratedDevices) devices.Add(d); this.Configuration.Devices.AddRange(devices); _deviceManager.AddRange(configuratedDevices); foreach (Operation o in manager.Configuration.Operations) { Operation operation = _pluginManager.Plugins.Find(p => p.Fullname == o.Fullname && p.AssemblyFile == o.AssemblyFile) as Operation; Operation operationClone = operation.Clone() as Operation; operationClone.Name = o.Name; operationClone.UID = o.UID; operationClone.Cache = o.Cache; _displayManager.Add(operationClone); CloneProperties(o, operationClone); Trace.WriteLine("Loading opeartion: " + operationClone.Name + " (" + operationClone.UID + ")...", LogCategory.Debug); LoadToolChilds(o, operationClone); this.Configuration.Operations.Add(operationClone); _propertyManager.ConnectPropertiesByNode(operationClone); } if (this.Loaded != null) this.Loaded(); FileName = path; HasSavedProject = true; return this; }
/// <summary> /// Adds the node. /// </summary> /// <param name="node">The node.</param> /// <param name="parent">The parent.</param> public void Add(Node node, Node parent) { if(_propertyManager == null) _propertyManager = CoreSystem.Managers.Find(m => m.Name.Contains("PropertyManager")) as PropertyManager; bool enableProcessor = false; if (node is Tool && CoreSystem.Processor.IsRunning) { Trace.WriteLine("Stopping processor while attaching another tool ...", LogCategory.Info); CoreSystem.Processor.Stop(); enableProcessor = true; } AddChildNodes(node, parent); if (enableProcessor) { CoreSystem.Processor.Start(); Trace.WriteLine("... processor started again!", LogCategory.Info); } }
/// <summary> /// Initializes the specified is webservice. /// </summary> /// <param name="isWebservice">if set to <c>true</c> [is webservice].</param> /// <returns></returns> /// <exception cref="System.Exception"> /// Could not initialize ConfigurationManager! /// or /// Could not initialize PropertyManager! /// or /// Could not initialize PluginManager! /// or /// Could not initialize DisplayManager! /// or /// Could not initialize DataStorageManager! /// </exception> public static bool Initialize(bool isWebservice) { bool result = false; try { BaseManager.IsWebservice = isWebservice; //Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + BaseManager.AssemblyPath + Path.DirectorySeparatorChar + "Libs"); AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args) { // Find name (first argument) string assemblyName = args.Name.Substring(0, args.Name.IndexOf(',')); try { // Build the path to DLL and load it // WARNING: The path has to be absolute otherwise it will raise an ArgumentException (security) string libsPath = BaseManager.AssemblyPath + Path.DirectorySeparatorChar + "Libs" + Path.DirectorySeparatorChar + assemblyName + ".dll"; string basePath = BaseManager.AssemblyPath + Path.DirectorySeparatorChar + assemblyName + ".dll"; if (File.Exists(libsPath)) return Assembly.LoadFile(libsPath); else if (File.Exists(basePath)) return Assembly.LoadFile(basePath); else return null; } catch (Exception ex) { Trace.WriteLine(ex.Message, ex.StackTrace, LogCategory.Error); throw ex; } }; _traceListener = new TraceListener(BaseManager.LogPath, BaseManager.DaysToKeepLogFiles); _traceListener.SetLoggingCategoties(new List<string> { #if DEBUG LogCategory.Debug.GetDescription(), #endif LogCategory.Info.GetDescription(), LogCategory.Warning.GetDescription(), LogCategory.Error.GetDescription() }); System.Diagnostics.Trace.Listeners.Add(_traceListener); Trace.WriteLine("Initialize CoreSystem ...", LogCategory.Info); _managers.Clear(); // Default managers must be added to the CoreSystem. ProjectManager projectManager = new ProjectManager(); PropertyManager propertyManager = new PropertyManager(); PluginManager pluginManager = new PluginManager(); DisplayManager displayManager = new DisplayManager(); DataStorageManager dataStorageManager = new DataStorageManager(); _managers.Add(projectManager); _managers.Add(propertyManager); _managers.Add(pluginManager); _managers.Add(displayManager); _managers.Add(dataStorageManager); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); if (pluginManager.Initialize() == false) throw new Exception("Could not initialize PluginManager!"); if (propertyManager.Initialize() == false) throw new Exception("Could not initialize PropertyManager!"); if (projectManager.Initialize() == false) throw new Exception("Could not initialize ConfigurationManager!"); _traceListener.SetLoggingCategoties(projectManager.Configuration.LogConfiguration.Categories); if (displayManager.Initialize() == false) throw new Exception("Could not initialize DisplayManager!"); if (dataStorageManager.Initialize() == false) throw new Exception("Could not initialize DataStorageManager!"); ExtensionManager extensionManager = CoreSystem.Managers.Find(m => m.Name.Contains("ExtensionManager")) as ExtensionManager; if (extensionManager.Initialize() == false) throw new Exception("Could not initialize ExtensionManager!"); _processor = new Core.Processor(); _shell = new Core.Shell(); _shell.Initialize(); result = true; } catch (Exception ex) { Trace.WriteLine(ex.Message, ex.StackTrace, LogCategory.Error); throw ex; } return result; }