Permalink
Browse files

import

  • Loading branch information...
1 parent 1a1814a commit 6edd8afff0dc349163cb1deb5d536f1dc78a8c13 @mrvux committed Oct 2, 2011
Showing with 3,527 additions and 0 deletions.
  1. +97 −0 VVVV/VVVV.CV.Factories/Evaluator/ThreadedStreamEvaluator.cs
  2. +9 −0 VVVV/VVVV.CV.Factories/Model/StreamNodeInstance.cs
  3. +36 −0 VVVV/VVVV.CV.Factories/Properties/AssemblyInfo.cs
  4. +226 −0 VVVV/VVVV.CV.Factories/StreamProcessorFactory.cs
  5. +43 −0 VVVV/VVVV.CV.Factories/StreamProcessorLocator.cs
  6. +123 −0 VVVV/VVVV.CV.Factories/Utils/AttributesHelper.cs
  7. +58 −0 VVVV/VVVV.CV.Factories/Utils/BaseTypeLocator.cs
  8. +23 −0 VVVV/VVVV.CV.Factories/Utils/EventArgs.cs
  9. +23 −0 VVVV/VVVV.CV.Factories/Utils/GenericsHelper.cs
  10. +64 −0 VVVV/VVVV.CV.Factories/Utils/TypeLookup.cs
  11. +124 −0 VVVV/VVVV.CV.Factories/VVVV.CV.Factories.csproj
  12. +104 −0 VVVV/VVVV.CV.Lib/ClassDiagram1.cd
  13. +12 −0 VVVV/VVVV.CV.Lib/DataTypes/Outputs/IOutputData.cs
  14. +49 −0 VVVV/VVVV.CV.Lib/DataTypes/Outputs/OutputData.cs
  15. +12 −0 VVVV/VVVV.CV.Lib/DataTypes/Parameters/IParameter.cs
  16. +51 −0 VVVV/VVVV.CV.Lib/DataTypes/Parameters/Parameter.cs
  17. +13 −0 VVVV/VVVV.CV.Lib/DataTypes/Streams/BaseInputStream.cs
  18. +22 −0 VVVV/VVVV.CV.Lib/DataTypes/Streams/Data/IDoubleStream.cs
  19. +22 −0 VVVV/VVVV.CV.Lib/DataTypes/Streams/Data/ImageStream.cs
  20. +16 −0 VVVV/VVVV.CV.Lib/DataTypes/Streams/IBaseStream.cs
  21. +58 −0 VVVV/VVVV.CV.Lib/DataTypes/Streams/InputStream.cs
  22. +15 −0 VVVV/VVVV.CV.Lib/DataTypes/Streams/InternalStream.cs
  23. +38 −0 VVVV/VVVV.CV.Lib/DataTypes/Streams/OutputStream.cs
  24. +19 −0 VVVV/VVVV.CV.Lib/Host/IStreamHost.cs
  25. +109 −0 VVVV/VVVV.CV.Lib/Host/StreamHostNode.cs
  26. +24 −0 VVVV/VVVV.CV.Lib/Interfaces/IStreamProcessor.cs
  27. +36 −0 VVVV/VVVV.CV.Lib/Properties/AssemblyInfo.cs
  28. +109 −0 VVVV/VVVV.CV.Lib/VVVV.CV.Lib.csproj
  29. +64 −0 VVVV/VVVV.CV.Nodes/FileTest1.cs
  30. +60 −0 VVVV/VVVV.CV.Nodes/InfoTest1.cs
  31. +58 −0 VVVV/VVVV.CV.Nodes/ProcessorTest1.cs
  32. +36 −0 VVVV/VVVV.CV.Nodes/Properties/AssemblyInfo.cs
  33. +53 −0 VVVV/VVVV.CV.Nodes/SinkTest1.cs
  34. +50 −0 VVVV/VVVV.CV.Nodes/SourceTest1.cs
  35. +67 −0 VVVV/VVVV.CV.Nodes/TestWindow1.cs
  36. +92 −0 VVVV/VVVV.CV.Nodes/VVVV.CV.Nodes.csproj
  37. +38 −0 VVVV/VVVV.Nodes.CV.sln
  38. +215 −0 VVVV/VVVV.SubGraphBuilder/Builder/AbstractGraphBuilder.cs
  39. +262 −0 VVVV/VVVV.SubGraphBuilder/Builder/viGraphBuilder2.cs
  40. +108 −0 VVVV/VVVV.SubGraphBuilder/Listeners/HdeNodeListener.cs
  41. +219 −0 VVVV/VVVV.SubGraphBuilder/Listeners/PinInstanceListener.cs
  42. +16 −0 VVVV/VVVV.SubGraphBuilder/Model/Actions/IGraphAction.cs
  43. +52 −0 VVVV/VVVV.SubGraphBuilder/Model/Actions/LinkGraphActions.cs
  44. +49 −0 VVVV/VVVV.SubGraphBuilder/Model/Actions/NodeGraphActions.cs
  45. +27 −0 VVVV/VVVV.SubGraphBuilder/Model/Actions/PinGraphActions.cs
  46. +78 −0 VVVV/VVVV.SubGraphBuilder/Model/viGraph.cs
  47. +39 −0 VVVV/VVVV.SubGraphBuilder/Model/viInputPin.cs
  48. +16 −0 VVVV/VVVV.SubGraphBuilder/Model/viInternalLink.cs
  49. +13 −0 VVVV/VVVV.SubGraphBuilder/Model/viLink.cs
  50. +93 −0 VVVV/VVVV.SubGraphBuilder/Model/viNode.cs
  51. +20 −0 VVVV/VVVV.SubGraphBuilder/Model/viOutputPin.cs
  52. +26 −0 VVVV/VVVV.SubGraphBuilder/Model/viPin.cs
  53. +36 −0 VVVV/VVVV.SubGraphBuilder/Properties/AssemblyInfo.cs
  54. +67 −0 VVVV/VVVV.SubGraphBuilder/Utils/HdeExtentions.cs
  55. +106 −0 VVVV/VVVV.SubGraphBuilder/VVVV.SubGraphBuilder.csproj
  56. +32 −0 VVVV/VVVV.SubGraphBuilder/VVVV.SubGraphBuilder.sln
  57. BIN VVVV/_Externals/Emgu.CV.UI.dll
  58. BIN VVVV/_Externals/Emgu.CV.dll
  59. BIN VVVV/_Externals/Emgu.Util.dll
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using VVVV.SubGraphBuilder.Model;
+using VVVV.CV.Lib.Host;
+using VVVV.CV.Lib.Interfaces;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Diagnostics;
+
+namespace VVVV.CV.Factories.Evaluator
+{
+ public class ThreadedStreamEvaluator
+ {
+ private Thread thr;
+ private bool m_brunning = false;
+
+ public viGraph graph;
+ public Dictionary<viNode, IStreamProcessor> processors = new Dictionary<viNode, IStreamProcessor>();
+
+ private List<viNode> processednodes = new List<viNode>();
+
+ public void Start()
+ {
+ if (!this.m_brunning)
+ {
+ thr = new Thread(new ThreadStart(this.Run));
+ this.m_brunning = true;
+ thr.Start();
+ }
+ }
+
+ private void Run()
+ {
+ while (m_brunning)
+ {
+ Debug.WriteLine("Process Frame");
+ if (this.graph != null)
+ {
+ this.processednodes.Clear();
+ List<viNode> nodes = new List<viNode>(this.graph.Nodes);
+
+ foreach (viNode node in nodes)
+ {
+ this.ProcessNode(node);
+ }
+ }
+ Thread.Sleep(10);
+ }
+
+ }
+
+ private void ProcessNode(viNode node)
+ {
+ //Change that later
+ if (!this.processednodes.Contains(node))
+ {
+ if (this.processors.ContainsKey(node))
+ {
+ foreach (viInputPin ip in node.InputPins)
+ {
+ if (ip.IsConnected)
+ {
+ this.ProcessNode(ip.ParentPin.ParentNode);
+ }
+ }
+
+ this.processors[node].Process();
+ }
+ this.processednodes.Add(node);
+ }
+
+ }
+
+ public void Test()
+ {
+ if (this.graph != null)
+ {
+ List<viNode> nodes = new List<viNode>(this.graph.Nodes);
+
+ foreach (viNode node in nodes)
+ {
+ StreamHostNode host = node.Instance<StreamHostNode>();
+ host.Processor.Process();
+ }
+ }
+ }
+
+ public void Stop()
+ {
+ this.m_brunning = false;
+ }
+ }
+}
@@ -0,0 +1,9 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace VVVV.CV.Factories.Model
+{
+
+}
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("VVVV.CV.Factories")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("MrVux")]
+[assembly: AssemblyProduct("VVVV.CV.Factories")]
+[assembly: AssemblyCopyright("Copyright © MrVux 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("5d379fc3-132b-4109-87fc-5c55ad2be9a4")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,226 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.ComponentModel.Composition.Hosting;
+using System.ComponentModel.Composition.Primitives;
+using System.ComponentModel.Composition.ReflectionModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text.RegularExpressions;
+
+using VVVV.Core;
+using VVVV.Core.Logging;
+using VVVV.Core.Model;
+using VVVV.Core.Runtime;
+using VVVV.Hosting;
+using VVVV.PluginInterfaces.V1;
+using VVVV.PluginInterfaces.V2;
+using VVVV.Imaging.Poc.Factory;
+using VVVV.CV.Lib.Interfaces;
+using VVVV.CV.Lib.Host;
+using VVVV.SubGraphBuilder.Builder;
+using VVVV.CV.Lib.DataTypes;
+using VVVV.CV.Factories.Evaluator;
+using VVVV.SubGraphBuilder.Model;
+using VVVV.CV.Lib.DataTypes.Streams;
+using VVVV.CV.Lib.DataTypes.Streams.Data;
+
+
+namespace VVVV.Hosting.Factories
+{
+ [Export(typeof(IAddonFactory))]
+ [ComVisible(false)]
+ public class StreamProcessorFactory : AbstractFileFactory<IInternalPluginHost>
+ {
+ //[Import]
+ protected IHDEHost FHdeHost;
+
+ [Import]
+ protected DotNetPluginFactory FDNFactory;
+
+ private viGraphBuilder2<IStreamProcessor> graphbuilder;
+
+ private Dictionary<viNode, IStreamProcessor> processors = new Dictionary<viNode, IStreamProcessor>();
+ private Dictionary<IPluginIO, BaseInputStream> inputstreams = new Dictionary<IPluginIO, BaseInputStream>();
+ private Dictionary<IPluginIO, object> outputstreams = new Dictionary<IPluginIO, object>();
+
+ private ThreadedStreamEvaluator evaluator;
+
+ private StreamProcessorLocator filterlocator = new StreamProcessorLocator();
+
+ //private int nodecount =0;
+
+ #region Constructor
+ [ImportingConstructor]
+ public StreamProcessorFactory(CompositionContainer parentContainer,IHDEHost hdeHost)
+ : this(parentContainer, ".dll")
+ {
+ this.graphbuilder = new viGraphBuilder2<IStreamProcessor>(hdeHost);
+
+ this.graphbuilder.RegisterPinType<InternalStream<DoubleStream>>();
+ this.graphbuilder.RegisterPinType<InternalStream<ImageStream>>();
+
+
+ this.graphbuilder.NodeAdded += new NodeEventDelegate(graphbuilder_NodeAdded);
+ this.graphbuilder.NodeRemoved += new NodeEventDelegate(graphbuilder_NodeRemoved);
+ this.graphbuilder.LinkAdded += new LinkEventDelegate(graphbuilder_LinkAdded);
+ this.graphbuilder.LinkRemoved += new LinkEventDelegate(graphbuilder_LinkRemoved);
+
+
+ this.evaluator = new ThreadedStreamEvaluator();
+ this.evaluator.graph = this.graphbuilder.Graph;
+ this.evaluator.processors = this.processors;
+ this.evaluator.Start();
+
+ this.FHdeHost = hdeHost;
+ //FHost.RootNode.Pins.ToArray()[0].
+ }
+
+ void graphbuilder_LinkRemoved(viLink link)
+ {
+ BaseInputStream bs = StreamHostNode.INPUTS[link.Sink.ComInstance];
+ //object os = StreamHostNode.OUTPUTS[link.Source.ComInstance];
+ bs.Disconnect();
+ //bs.Disconnect();
+ }
+
+ void graphbuilder_LinkAdded(viLink link)
+ {
+ BaseInputStream bs = StreamHostNode.INPUTS[link.Sink.ComInstance];
+ object os = StreamHostNode.OUTPUTS[link.Source.ComInstance];
+ bs.Connect(os);
+ }
+
+ void graphbuilder_NodeRemoved(VVVV.SubGraphBuilder.Model.viNode node)
+ {
+ this.processors.Remove(node);
+ }
+
+ void graphbuilder_NodeAdded(VVVV.SubGraphBuilder.Model.viNode node)
+ {
+ this.processors.Add(node, node.Instance<StreamHostNode>().Processor);
+ }
+
+ protected StreamProcessorFactory(CompositionContainer parentContainer, string fileExtension)
+ : base(fileExtension)
+ {
+
+ }
+ #endregion
+
+
+ #region IAddonFactory
+
+ public override string JobStdSubPath
+ {
+ get
+ {
+ return "streams";
+ }
+ }
+
+ protected override void AddSubDir(string dir, bool recursive)
+ {
+ // Ignore obj directories used by C# IDEs
+ if (dir.EndsWith(@"\obj\x86") || dir.EndsWith(@"\obj\x64")) return;
+
+ base.AddSubDir(dir, recursive);
+ }
+
+ protected override bool CreateNode(INodeInfo nodeInfo, IInternalPluginHost pluginHost)
+ {
+ //dispose previous plugin
+ var plugin = pluginHost.Plugin;
+ if (plugin != null)
+ {
+ if (plugin is IDisposable)
+ {
+ ((IDisposable)plugin).Dispose();
+ }
+ }
+
+ //make the host mark all its pins for possible deletion
+ pluginHost.Plugin = null;
+
+ var filter = (IStreamProcessor)Activator.CreateInstance((Type)nodeInfo.UserData);
+
+ var node = new StreamHostNode(pluginHost);
+
+
+ node.SetProcessor(filter);
+ pluginHost.Plugin = node;
+
+ return true;
+ }
+
+ protected override bool DeleteNode(INodeInfo nodeInfo, IInternalPluginHost pluginHost)
+ {
+ var plugin = pluginHost.Plugin;
+
+ if (plugin != null)
+ {
+ if (plugin is IDisposable)
+ {
+ ((IDisposable)plugin).Dispose();
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ /// <summary>
+ /// Called by AbstractFileFactory to extract all node infos in given file.
+ /// </summary>
+ protected override IEnumerable<INodeInfo> LoadNodeInfos(string filename)
+ {
+ //Try this random hack
+ var nodeInfos = new List<INodeInfo>();
+ LoadNodeInfosFromFile(filename, filename, ref nodeInfos, true);
+ return nodeInfos;
+ }
+
+ protected void LoadNodeInfosFromFile(string filename, string sourcefilename, ref List<INodeInfo> nodeInfos, bool commitUpdates)
+ {
+ var assembly = Assembly.LoadFrom(filename);
+
+ this.filterlocator.Scan(assembly);
+
+ foreach (string key in this.filterlocator.RegisteredTypes.Keys)
+ {
+ Type t = this.filterlocator.RegisteredTypes[key];
+ var nodeInfo = FNodeInfoFactory.CreateNodeInfo(key, "Imaging", String.Empty, filename, true);
+ nodeInfo.Arguments = Assembly.GetExecutingAssembly().Location.ToLower();
+ nodeInfo.Factory = this;
+ nodeInfo.Type = NodeType.Plugin;
+ nodeInfo.UserData = t;
+
+ nodeInfo.CommitUpdate();
+ nodeInfo.UserData = t;
+ nodeInfos.Add(nodeInfo);
+ }
+
+ foreach (var nodeInfo in nodeInfos)
+ {
+ nodeInfo.Factory = this;
+ if (commitUpdates)
+ nodeInfo.CommitUpdate();
+ }
+ }
+ #endregion
+
+
+ protected virtual string GetAssemblyLocation(INodeInfo nodeInfo)
+ {
+ return nodeInfo.Filename;
+ }
+
+
+
+
+
+ }
+}
Oops, something went wrong.

0 comments on commit 6edd8af

Please sign in to comment.