/// <summary> /// Adds the specified node. /// </summary> /// <param name="node">The node.</param> public override void Add(Node node) { if (_deviceManager == null) _deviceManager = CoreSystem.Managers.Find(m => m.Name.Contains("DeviceManager")) as DeviceManager; if (_displayManager == null) _displayManager = CoreSystem.Managers.Find(m => m.Name.Contains("DisplayManager")) as DisplayManager; if (!Nodes.Contains(node)) { if (node is DeviceProperty) { List<Node> devices = new List<Node>(); foreach (Plugin plugin in _deviceManager.Plugins) { if (plugin is Device) devices.Add(plugin as Device); } DeviceProperty deviceProperty = node as DeviceProperty; deviceProperty.AddDeviceList(devices.DeepClone(), _deviceManager); } if (node is Property) { Property property = node as Property; property.PropertyChanged += PropertyPropertyChanged; if (property.IsMonitored) { if (_dataStorageManager == null) _dataStorageManager = CoreSystem.Managers.Find(m => m.Name.Contains("DataStorageManager")) as DataStorageManager; _dataStorageManager.Add(property); } } _displayManager.Add(node); Nodes.Add(node); Trace.WriteLine("Property added: " + node.ToString(), LogCategory.Debug); OnNodeAdded(node); } }
/// <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>(); }
public NanoProcessor(Operation operation, DataStorageManager dataStorageManager) { _operation = operation; _operation.PropertyChanged += OperationPropertyChanged; _dataStorageManager = dataStorageManager; }
/// <summary> /// Base Constructor. /// </summary> /// <param name="operation">The Operation to run.</param> public NanoProcessor(Operation operation) { _operation = operation; _operation.PropertyChanged += OperationPropertyChanged; _dataStorageManager = CoreSystem.Managers.Find(m => m.Name.Contains("DataStorageManager")) as DataStorageManager; }
/// <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; }
private void PropertyPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "IsMonitored") { if(_dataStorageManager == null) _dataStorageManager = CoreSystem.Managers.Find(m => m.Name.Contains("DataStorageManager")) as DataStorageManager; Property property = sender as Property; if(property.IsMonitored) _dataStorageManager.Add(property); else _dataStorageManager.Remove(property); } }