示例#1
0
        public void Startup(RouterContext routerContext)
        {
            var num  = 0;
            var name = string.Empty;

            if (routerContext.Initialized)
            {
                Shutdown(routerContext);
            }
            try {
                routerContext.Initialized = false;
                foreach (var outputPlugIn in routerContext.OutputPluginList)
                {
                    var eventDrivenOutputPlugIn = outputPlugIn.PlugIn as IEventDrivenOutputPlugIn;
                    if (eventDrivenOutputPlugIn != null)
                    {
                        eventDrivenOutputPlugIn.Initialize(routerContext.ExecutableObject, routerContext.PluginData, outputPlugIn.SetupDataNode);
                    }
                    //else {
                    //    ((IEventlessOutputPlugIn) outputPlugIn.PlugIn).Initialize(routerContext.ExecutableObject, routerContext.PluginData,
                    //        outputPlugIn.SetupDataNode, routerContext.TickSource);
                    //}
                }
                var executable = (IExecutable)Host.Communication["CurrentObject"];
                var str2       = string.Empty;
                if (executable != null)
                {
                    str2 = executable.Key.ToString(CultureInfo.InvariantCulture);
                }
                try {
                    foreach (var outputPlugIn in routerContext.OutputPluginList)
                    {
                        name = outputPlugIn.PlugIn.Name;
                        var plugInData = routerContext.PluginData.GetPlugInData(num.ToString(CultureInfo.InvariantCulture));
                        if (executable != null)
                        {
                            Host.Communication["SetupNode_" + str2] = plugInData;
                        }
                        outputPlugIn.PlugIn.Startup();
                        Host.Communication.Remove("SetupNode_" + str2);
                        num++;
                    }
                }
                catch (Exception exception) {
                    throw new Exception(string.Format(Resources.RouterStartupError, exception.Message), exception);
                }
                routerContext.Initialized = true;
            }
            catch (Exception exception2) {
                MessageBox.Show(string.Format("{0}:\n\n{1}", name, exception2.Message), Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
示例#2
0
 public RouterContext CreateContext(byte[] engineBuffer, SetupData pluginData, IExecutable executableObject)
 {
     var item = new RouterContext(engineBuffer, pluginData, executableObject);
     var newSize = Math.Max((_data == null) ? 0 : _data.Length, item.EngineBuffer.Length);
     if (_data == null) {
         _data = new byte[newSize];
     }
     else if (_data.Length < newSize) {
         Array.Resize(ref _data, newSize);
     }
     foreach (var outputPlugIn in item.OutputPluginList) {
         lock (_outputPlugins) {
             _outputPlugins.Add(outputPlugIn);
         }
     }
     _instances.Add(item);
     return item;
 }
示例#3
0
        public RouterContext CreateContext(byte[] engineBuffer, SetupData pluginData, IExecutable executableObject)
        {
            var item    = new RouterContext(engineBuffer, pluginData, executableObject);
            var newSize = Math.Max((_data == null) ? 0 : _data.Length, item.EngineBuffer.Length);

            if (_data == null)
            {
                _data = new byte[newSize];
            }
            else if (_data.Length < newSize)
            {
                Array.Resize(ref _data, newSize);
            }
            foreach (var outputPlugIn in item.OutputPluginList)
            {
                lock (_outputPlugins) {
                    _outputPlugins.Add(outputPlugIn);
                }
            }
            _instances.Add(item);
            return(item);
        }
示例#4
0
 public void Shutdown(RouterContext routerContext)
 {
     try {
         if ((routerContext == null) || !routerContext.Initialized)
         {
             return;
         }
         routerContext.Initialized = false;
         if (!_instances.Contains(routerContext))
         {
             return;
         }
         var clearAtEnd = ((ISystem)Interfaces.Available["ISystem"]).UserPreferences.GetBoolean("ClearAtEndOfSequence");
         if (clearAtEnd)
         {
             BeginUpdate();
             Array.Clear(routerContext.EngineBuffer, 0, routerContext.EngineBuffer.Length);
             EndUpdate();
         }
         lock (_outputPlugins) {
             foreach (var outputPlugIn in routerContext.OutputPluginList)
             {
                 outputPlugIn.PlugIn.Shutdown();
                 _outputPlugins.Remove(outputPlugIn);
             }
         }
         lock (_instances) {
             _instances.Remove(routerContext);
         }
         if (_instances.Count == 0)
         {
             _data = null;
         }
     }
     catch (Exception exception) {
         MessageBox.Show(string.Format(Resources.RouterError, exception.Message, exception.StackTrace), Resources.PluginError,
                         MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
示例#5
0
 public void Startup(RouterContext routerContext)
 {
     var num = 0;
     var name = string.Empty;
     if (routerContext.Initialized) {
         Shutdown(routerContext);
     }
     try {
         routerContext.Initialized = false;
         foreach (var outputPlugIn in routerContext.OutputPluginList) {
             var eventDrivenOutputPlugIn = outputPlugIn.PlugIn as IEventDrivenOutputPlugIn;
             if (eventDrivenOutputPlugIn != null) {
                 eventDrivenOutputPlugIn.Initialize(routerContext.ExecutableObject, routerContext.PluginData, outputPlugIn.SetupDataNode);
             }
             //else {
             //    ((IEventlessOutputPlugIn) outputPlugIn.PlugIn).Initialize(routerContext.ExecutableObject, routerContext.PluginData,
             //        outputPlugIn.SetupDataNode, routerContext.TickSource);
             //}
         }
         var executable = (IExecutable) Host.Communication["CurrentObject"];
         var str2 = string.Empty;
         if (executable != null) {
             str2 = executable.Key.ToString(CultureInfo.InvariantCulture);
         }
         try {
             foreach (var outputPlugIn in routerContext.OutputPluginList) {
                 name = outputPlugIn.PlugIn.Name;
                 var plugInData = routerContext.PluginData.GetPlugInData(num.ToString(CultureInfo.InvariantCulture));
                 if (executable != null) {
                     Host.Communication["SetupNode_" + str2] = plugInData;
                 }
                 outputPlugIn.PlugIn.Startup();
                 Host.Communication.Remove("SetupNode_" + str2);
                 num++;
             }
         }
         catch (Exception exception) {
             throw new Exception(string.Format(Resources.RouterStartupError, exception.Message), exception);
         }
         routerContext.Initialized = true;
     }
     catch (Exception exception2) {
         MessageBox.Show(string.Format("{0}:\n\n{1}", name, exception2.Message), Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
 }
示例#6
0
 public void Shutdown(RouterContext routerContext)
 {
     try {
         if ((routerContext == null) || !routerContext.Initialized) {
             return;
         }
         routerContext.Initialized = false;
         if (!_instances.Contains(routerContext)) {
             return;
         }
         var clearAtEnd = ((ISystem) Interfaces.Available["ISystem"]).UserPreferences.GetBoolean("ClearAtEndOfSequence");
         if (clearAtEnd) {
             BeginUpdate();
             Array.Clear(routerContext.EngineBuffer, 0, routerContext.EngineBuffer.Length);
             EndUpdate();
         }
         lock (_outputPlugins) {
             foreach (var outputPlugIn in routerContext.OutputPluginList) {
                 outputPlugIn.PlugIn.Shutdown();
                 _outputPlugins.Remove(outputPlugIn);
             }
         }
         lock (_instances) {
             _instances.Remove(routerContext);
         }
         if (_instances.Count == 0) {
             _data = null;
         }
     }
     catch (Exception exception) {
         MessageBox.Show(string.Format(Resources.RouterError, exception.Message, exception.StackTrace), Resources.PluginError,
             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }