Example #1
0
        public void AddInput(InputPort port)
        {
            port.InputConnectionChanged += Input_InputConnectionChanged;

            switch (port.DataType)
            {
            case PortDataType.Array:
                ((DataInputPort)port).DataAvailable     += Input_DataAvailable;
                ((DataInputPort)port).SamplerateChanged += Input_SamplerateChanged;
                break;

            case PortDataType.FFT:
                ((FFTInputPort)port).DataAvailable     += Input_DataAvailable;
                ((FFTInputPort)port).SamplerateChanged += Input_SamplerateChanged;
                ((FFTInputPort)port).FFTSizeChanged    += Input_FFTSizeChanged;
                break;

            case PortDataType.Value:
                ((ValueInputPort)port).ValueAvailable += Node_ValueAvailable;
                _valueInputs.Add((ValueInputPort)port);
                break;
            }

            port.Parent = this;
            _inputs.Add(port);
            PortAdded?.Invoke(this, port);
        }
Example #2
0
 public void AddOutput(OutputPort port)
 {
     port.OutputConnectionsChanged += Output_OutputConnectionsChanged;
     port.Parent = this;
     _outputs.Add(port);
     PortAdded?.Invoke(this, port);
 }
Example #3
0
 protected T AddPort <T>(T port)
     where T : IPort
 {
     AddPortImpl(port);
     PortAdded?.Invoke(this, port);
     return(port);
 }
Example #4
0
        public void AddInput(InputPort port, int index = -1)
        {
            if (InputPorts.Any(i => i.Name == port.Name))
            {
                throw new ArgumentException("Name of port ambiguous");
            }

            port.InputConnectionChanged += Input_InputConnectionChanged;

            // TODO: cleanup? Cause scheduler does DataAvailable and ValueAvailable now
            switch (port.DataType)
            {
            case PortDataType.Array:
                ((DataInputPort)port).DataAvailable     += Input_DataAvailable;
                ((DataInputPort)port).SamplerateChanged += Input_SamplerateChanged;
                break;

            case PortDataType.FFT:
                ((FFTInputPort)port).DataAvailable     += Input_DataAvailable;
                ((FFTInputPort)port).SamplerateChanged += Input_SamplerateChanged;
                ((FFTInputPort)port).FFTSizeChanged    += Input_FFTSizeChanged;
                break;

            case PortDataType.Value:
                ((ValueInputPort)port).ValueAvailable += Node_ValueAvailable;
                _valueInputs.Add((ValueInputPort)port);
                break;
            }

            port.Parent = this;
            if (index > -1)
            {
                _inputs.Insert(index, port);
            }
            else
            {
                _inputs.Add(port);
            }
            PortAdded?.Invoke(this, new PortChangedEventArgs {
                Port = port, Index = index
            });
        }
Example #5
0
 /// <summary>
 /// Adds a port to the collection of input ports
 /// </summary>
 /// <param name="port"></param>
 /// <param name="index">Index at which to insert port</param>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 public void AddPort(InputPort port, int index)
 {
     if (port == null)
     {
         throw new ArgumentNullException();
     }
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException();
     }
     if (!_inputs.Contains(port))
     {
         _inputs.Insert(index, port);
         port.ConnectionChanged += Port_ConnectionChanged;
         PortAdded?.Invoke(this, new PortChangedEventArgs(port, index, PortChangedEventArgs.Modifier.Added));
     }
     else
     {
         throw new ArgumentException("Port already exists in collection");
     }
 }
Example #6
0
        public void AddOutput(OutputPort port, int index = -1)
        {
            if (OutputPorts.Any(i => i.Name == port.Name))
            {
                throw new ArgumentException("Name of port ambiguous");
            }

            port.OutputConnectionsChanged += Output_OutputConnectionsChanged;
            port.Parent = this;
            if (index > -1)
            {
                _outputs.Insert(index, port);
            }
            else
            {
                _outputs.Add(port);
            }
            PortAdded?.Invoke(this, new PortChangedEventArgs {
                Port = port, Index = index
            });
        }
Example #7
0
 protected void OnPortAdded(int port)
 {
     PortAdded?.Invoke(this, new PortListEventArgs(port));
 }