Exemplo n.º 1
0
        /// <summary>
        ///     Accepts incoming data from a previous connection.
        ///     This is allowed to queue and store as needed.
        /// </summary>
        /// <param name="data">The data being pushed from the previous node</param>
        public override void AcceptIncomingData(StreamlineCore core, DataPacket data)
        {
            // Create the packet to return
            var toReturn = new DataPacket();

            toReturn.AddChannel();

            // Loop through until no data is available
            while ((BatchMode && data[0].Count > SmoothingFactor) || toReturn[0].Count == 0)
            {
                // Grab the required amount, but only pop off the earliest
                var fulldata = data.PeekRange(0, SmoothingFactor);
                data.Pop(0);

                // Calculate the average
                var currentData = 0.0;
                for (var j = 0; j < fulldata.Count; j++)
                {
                    currentData += fulldata[j];
                }
                toReturn[0].Add(currentData / fulldata.Count);
            }

            // Push the data
            core.PassDataToNextConnectable(this, toReturn);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Accepts incoming data from a previous connection.
        ///     If this is an input, it will throw.
        /// </summary>
        /// <param name="data">The data being pushed from the previous node</param>
        public void AcceptIncomingData(StreamlineCore core, DataPacket data)
        {
            // Throw if illegal
            if (!IsOutput)
            {
                throw new System.Exception("An input cannot accept data from other program nodes.");
            }

            // Don't accept anything if not enabled
            if (!Enabled)
            {
                data.Clear();
                return;
            }

            // Check if the data can be written directly
            if (Converter == null && MediaConnection.CanWriteDirect)
            {
                // Send the data directly
                MediaConnection.WriteDirect(data);
            }
            else
            {
                // Encode the data
                var encodedData = Converter.EncodeData(data);

                // Pass it on to be output
                MediaConnection.Write(encodedData, 0, encodedData.Length);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Accepts incoming data from a previous connection.
        ///     This is allowed to queue and store as needed.
        /// </summary>
        /// <param name="data">The data being pushed from the previous node</param>
        /// <param name="core">The Streamline program this is a part of</param>
        public override void AcceptIncomingData(StreamlineCore core, DataPacket data)
        {
            // Create the packet to return
            var toReturn = new DataPacket();

            toReturn.AddChannel();

            // Quantize all points in each channel
            // Loop through until no data is available
            while ((BatchMode && data[0].Count > 0) || toReturn[0].Count == 0)
            {
                var currentData = data.Pop(0);
                if (currentData < Minimum)
                {
                    toReturn[0].Add(Minimum);
                }
                else if (currentData > Maximum)
                {
                    toReturn[0].Add(Maximum);
                }
                else
                {
                    toReturn[0].Add(Math.Floor((currentData - Minimum) / StepSize) * StepSize + Minimum);
                }
            }


            // Push to the next node, and clear the saved data
            core.PassDataToNextConnectable(this, toReturn);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Polls the data connection for any new data.
        ///     This is specifically for the Polling Mechanism
        /// </summary>
        public void Poll(StreamlineCore core, int pollCount)
        {
            // Check if we can read directly
            if (Converter == null && MediaConnection.CanReadDirect)
            {
                // Read a data packet directly from the connection
                core.PassDataToNextConnectable(this, MediaConnection.ReadDirect(pollCount));
            }
            else
            {
                // Only grab new points if we went through the decoded data
                if (!_leftoverDecodedData.MinCountOnAllChannels(pollCount))
                {
                    // Grab all available bytes, and pass it to the decoder
                    var data = MediaConnection.ReadToEnd(pollCount);
                    if (_leftoverInputData != null)
                    {
                        _leftoverInputData = _leftoverInputData.Concat(data);
                    }
                    else
                    {
                        _leftoverInputData = data;
                    }
                    _leftoverDecodedData.Add(Converter.DecodeData(ref _leftoverInputData));
                }

                // Pass the data on to the next step
                core.PassDataToNextConnectable(this, _leftoverDecodedData.PopSubPacket(pollCount));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Creates a new Block Creator panel for the specified Streamline Core
        /// </summary>
        public BlockCreatorPanel(StreamlineCore core)
        {
            _core = core;

            InitializeComponent();
            RefreshBlockListings();
        }
Exemplo n.º 6
0
        static void Main()
        {
            // Create the Streamline Core object, and load the default plugins
            var core = new StreamlineCore();

            try
            {
                core.LoadCoreSettings("settings.ini");
            }
            catch { }
            var pluginErrors = new List <string>();

            core.LoadPluginsFromAssembly(typeof(RollingAverageFilter).Assembly, pluginErrors);
            core.LoadPluginsFromAssembly(typeof(Program).Assembly, pluginErrors);

            foreach (var line in pluginErrors)
            {
                Console.WriteLine("Plugin Error : " + line);
            }

            // Start the program GUI
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new ControlPanel(core));
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Creates a new Advanced Block panel with a given core
        /// </summary>
        /// <param name="core">The Streamline core this operates under</param>
        public AdvancedBlockPanel(StreamlineCore core)
        {
            _core = core;

            InitializeComponent();

            ListBlocks();
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Creates a new plugin panel for the corresponding Streamline Core
        /// </summary>
        public PluginPanel(StreamlineCore core)
        {
            _core = core;
            InitializeComponent();

            // List all of the plugins
            ListPlugins();
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Creates a new Settings Panel
        /// </summary>
        public SettingsPanel(StreamlineCore core)
        {
            _core = core;

            InitializeComponent();

            AttributeListEditor.SetComponent(_core.Settings);
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Accepts incoming data from a previous connection.
        ///     This is allowed to queue and store as needed.
        /// </summary>
        /// <param name="data">The data being pushed from the previous node</param>
        /// <param name="core">The Streamline program this is a part of</param>
        public override void AcceptIncomingData(StreamlineCore core, DataPacket data)
        {
            var toReturn = new DataPacket();

            toReturn.AddChannel();

            while ((BatchMode && data[0].Count > Delay) || toReturn[0].Count == 0)
            {
                toReturn[0].Add(data.Pop(0));
            }

            core.PassDataToNextConnectable(this, toReturn);
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Accepts incoming data from a previous connection.
        ///     This is allowed to queue and store as needed.
        /// </summary>
        /// <param name="data">The data being pushed from the previous node</param>
        /// <param name="core">The Streamline program this is a part of</param>
        public override void AcceptIncomingData(StreamlineCore core, DataPacket data)
        {
            // Push the multiplied value to the next node
            var toReturn = new DataPacket();

            toReturn.AddChannel();

            while ((BatchMode && data[0].Count > 0) || toReturn[0].Count == 0)
            {
                toReturn[0].Add(data.Pop(0) * Gain);
            }

            core.PassDataToNextConnectable(this, toReturn);
        }
Exemplo n.º 12
0
        /// <summary>
        ///     Creates a new Drawable Input from a specific DataConnection
        /// </summary>
        /// <param name="c">The connection to draw for</param>
        public DrawableInputOutput(StreamlineCore core, DataConnection c) : base(core, c)
        {
            Z = 2;

            // Change the texture to Input/Output
            if (IsOutput)
            {
                SetBitmap("Output");
            }
            else
            {
                SetBitmap("Input");
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///     Creates a new Drawable Input from a specific DataConnection
        /// </summary>
        /// <param name="c">The connection to draw for</param>
        public DrawableIConnectable(StreamlineCore core, T c) : base(core)
        {
            Object = c;

            // Try and get a bitmap to render
            var attrib = c.GetType().GetCustomAttribute <RenderIconAttribute>();

            if (attrib == null)
            {
                SetBitmap("Filter");
            }
            else
            {
                SetBitmap(attrib.Filename);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        ///     Creates a new IO Block Creator panel for the specified Streamline Core
        /// </summary>
        public IOBlockCreatorPanel(StreamlineCore core)
        {
            _core         = core;
            _current      = new DataConnection(core);
            _current.Name = _current.InternalName;

            InitializeComponent();

            _ignoreUpdate = true;
            InputOutputBox.SelectedIndex = 0;
            _current.IsOutput            = false;
            _ignoreUpdate = false;

            IOBlockViewer.AttributeList.AllowEnable = false;
            IOBlockViewer.SetViewingComponent(_current);
            RefreshBlockListings();
        }
Exemplo n.º 15
0
        /// <summary>
        ///     Sets the core to use with this editor
        /// </summary>
        /// <param name="core">The Streamline Core to use</param>
        public void SetCore(StreamlineCore core)
        {
            // Subscribe to everything needed in the core
            _core = core;
            _core.OnBlockAdded         += (e, o) => CreateBlock(o);
            _core.OnBlockDeleted       += (e, o) => DeleteBlock(o);
            _core.OnBlocksConnected    += (e, o) => ConnectBlocks(o.Item1, o.Item2);
            _core.OnBlocksDisconnected += (e, o) => DisconnectBlocks(o.Item1, o.Item2);
            _core.OnBlockEnabled       += (e, o) => Render();
            _core.OnBlockDisabled      += (e, o) => Render();
            _core.OnSchematicLoad      += (e, o) => Render();
            //_core.OnBlockActivated += (e, o) => SetBlockActive(o);

            // Create the line that is displayed when connecting component
            _movingLine         = new DrawableLine(core, Vector3.Zero, Vector3.Zero);
            _movingLine.Visible = false;
            _renderables.Add(_movingLine.Z, _movingLine);
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Accepts incoming data from a previous connection.
        ///     This is allowed to queue and store as needed.
        /// </summary>
        /// <param name="data">The data being pushed from the previous node</param>
        /// <param name="core">The Streamline program this is a part of</param>
        public override void AcceptIncomingData(StreamlineCore core, DataPacket data)
        {
            var toReturn = new DataPacket();

            toReturn.AddChannel();

            while ((BatchMode && data[0].Count > InputLength) || toReturn[0].Count == 0)
            {
                var nd = _b1 * data[0][1] + _b0 * data[0][0] + _a0 * _y0;
                _y0 = nd;

                // Remove the oldest data point
                data.Pop(0);
                toReturn[0].Add(nd);
            }
            // Push to the next node
            core.PassDataToNextConnectable(this, toReturn);
        }
Exemplo n.º 17
0
        /// <summary>
        ///     Creates a new central control panel using a given core
        /// </summary>
        public ControlPanel(StreamlineCore core)
        {
            Core = core;
            InitializeComponent();

            // Don't show debug if not a dev
            if (!Core.Settings.DebugMode)
            {
                debugToolStripMenuItem.Dispose();
            }

            // Hide the components until something is selected
            BlockViewer.Hide();
            IOBlockViewer.Hide();

            // Set up the block editor
            BlockSchematic.SetCore(Core);
            BlockSchematic.OnBlockSelected += DetermineViewingComponent;
        }
Exemplo n.º 18
0
        /// <summary>
        ///     Accepts incoming data from a previous connection.
        ///     This is allowed to queue and store as needed.
        /// </summary>
        /// <param name="data">The data being pushed from the previous node</param>
        /// <param name="core">The Streamline program this is a part of</param>
        public override void AcceptIncomingData(StreamlineCore core, DataPacket data)
        {
            var toReturn = new DataPacket();

            toReturn.AddChannel();

            // Sum every available channel
            while ((BatchMode && data.EnsureMinCountOnAllChannels(1, 0)) || (toReturn[0].Count == 0 && data.EnsureMinCountOnAllChannels(1, 0)))
            {
                var val = 0.0;
                for (var k = 0; k < data.ChannelCount; k++)
                {
                    val += data.Pop(k);
                }
                toReturn[0].Add(val);
            }

            // Push to the next node
            core.PassDataToNextConnectable(this, toReturn);
        }
Exemplo n.º 19
0
        /// <summary>
        ///     Accepts incoming data from a previous connection.
        ///     This is allowed to queue and store as needed.
        /// </summary>
        /// <param name="data">The data being pushed from the previous node</param>
        /// <param name="core">The Streamline program this is a part of</param>
        public override void AcceptIncomingData(StreamlineCore core, DataPacket data)
        {
            // Return a new packet with the sum
            var toReturn = new DataPacket();

            toReturn.AddChannel();

            while ((BatchMode && data[0].Count >= InputCount) || toReturn[0].Count == 0)
            {
                // Calculate the new point
                var nd = _samplingPeriod * data[0][1] - _samplingPeriod * data[0][0] - LastOutput;
                LastOutput = nd;
                toReturn[0].Add(nd);

                // Remove the oldest data point
                data.Pop(0);
            }

            // Push to the next node
            core.PassDataToNextConnectable(this, toReturn);
        }
Exemplo n.º 20
0
        /// <summary>
        ///     A test that creates a complete dummy workflow from start to finish
        ///     using random data inputs.
        /// </summary>
        /// <param name="core">The Streamline Core used in the test</param>
        public static void CreateDummyWorkflowTestA(StreamlineCore core)
        {
            // Create the random input object that is polled every 100ms
            var input = new DataConnection(core);

            input.MediaConnection = new RandomDataStream();
            input.Converter       = new SimpleStreamConverter();
            input.Poller          = new PeriodicPoller(core);
            core.AddConnectable(input);

            // Create the rolling average filter object and connect it

            /*
             * var rollingAverageFilter = new RollingAverageFilter();
             * input.NextConnections.Add(rollingAverageFilter);
             * core.AddConnectable(rollingAverageFilter);
             */

            // Create the quantizer filter object and connect it
            var quantizerFilter = new QuantizerFilter(core);

            input.NextConnections.Add(quantizerFilter);
            quantizerFilter.Maximum  = 64000;
            quantizerFilter.StepSize = 100;
            core.AddConnectable(quantizerFilter);

            // Create the console output object and connect it to the filter
            var output = new DataConnection(core);

            output.IsOutput        = true;
            output.MediaConnection = new ConsoleDataStream();
            output.Converter       = new SimpleStringConverter();
            output.Poller          = null;
            //rollingAverageFilter.NextConnections.Add(output);
            quantizerFilter.NextConnections.Add(output);
            core.AddConnectable(output);

            // At this point, the workflow should work entirely on its own
        }
Exemplo n.º 21
0
        /// <summary>
        ///     Accepts incoming data from a previous connection.
        ///     This is allowed to queue and store as needed.
        /// </summary>
        /// <param name="data">The data being pushed from the previous node</param>
        /// <param name="core">The Streamline program this is a part of</param>
        public override void AcceptIncomingData(StreamlineCore core, DataPacket data)
        {
            // Return a new packet with the sum
            var toReturn = new DataPacket();

            toReturn.AddChannel();

            while ((BatchMode && data[0].Count >= 3) || toReturn[0].Count == 0)
            {
                var nd = _b2 * data[0][2] + _b1 * data[0][1] + _b0 * data[0][0] + _a1 * _y1 + _a0 * _y2;
                _y2 = _y1;
                _y1 = nd;
                toReturn[0].Add(nd);


                // Remove the oldest data point
                data.Pop(0);
            }

            // Push to the next node
            core.PassDataToNextConnectable(this, toReturn);
        }
Exemplo n.º 22
0
 /// <summary>
 ///     Creates a new Low-Pass Filter
 /// </summary>
 public LowPassFilter(StreamlineCore core) : base(core)
 {
 }
Exemplo n.º 23
0
 /// <summary>
 ///     Creates a new DrawableObject attached to a given core
 /// </summary>
 /// <param name="core">The streamline core to use</param>
 /// <param name="start">The starting point of the line</param>
 /// <param name="end">The ending point of the line</param>
 public DrawableLine(StreamlineCore core, Vector3 start, Vector3 end) : base(core)
 {
     Start = start;
     End   = end;
     Z     = 0;
 }
Exemplo n.º 24
0
 /// <summary>
 ///     Creates a new Butterworth Low-Pass Filter
 /// </summary>
 public ButterworthLowPassFilter1(StreamlineCore core) : base(core)
 {
 }
Exemplo n.º 25
0
 /// <summary>
 ///     Creates a new High Pass Filter
 /// </summary>
 public HighPassFilter(StreamlineCore core) : base(core)
 {
 }
Exemplo n.º 26
0
 /// <summary>
 ///     Creates a new Periodic Poller
 /// </summary>
 /// <param name="core">The core that this reports back to</param>
 public PeriodicPoller(StreamlineCore core) : base(core)
 {
 }
Exemplo n.º 27
0
 /// <summary>
 ///     Creates a new Drawable Filter from a specific DataFilter
 /// </summary>
 /// <param name="filter">The filter to draw for</param>
 public DrawableFilter(StreamlineCore core, DataFilter filter) : base(core, filter)
 {
     Z = 2;
 }
Exemplo n.º 28
0
 /// <summary>
 ///     Creates a new Addition Filter
 /// </summary>
 public DelayFilter(StreamlineCore core) : base(core)
 {
 }
Exemplo n.º 29
0
 /// <summary>
 ///     Changes the connectable that is being edited
 /// </summary>
 /// <param name="core">The core the connectable belongs in</param>
 /// <param name="connectable">The connectable that is being edited</param>
 public void SetViewingComponent(StreamlineCore core, IConnectable connectable)
 {
     _core    = core;
     _current = connectable;
     ListBlockContent();
 }
Exemplo n.º 30
0
 /// <summary>
 ///     Creates a new Differentiator Filter
 /// </summary>
 public DifferentiatorFilter(StreamlineCore core) : base(core)
 {
 }