Пример #1
0
        public void Evaluate(int SpreadMax)
        {
            if (!FLink.PluginIO.IsConnected)
            {
                throw new Exception("Corrupt or missing Link. Frame must be used in conjunction with Delayer");
            }
            if (!FInput.IsChanged)
            {
                return;
            }

            try
            {
                var shortcut = FLink[0].RemotePin;

                if (FInit[0])
                {
                    FOutput.SliceCount  = 0;
                    shortcut.SliceCount = 0;
                }
                else
                {
                    FOutput.SliceCount = FInput.SliceCount;
                    FOutput.AssignFrom(FInput);


                    shortcut.SliceCount = FInput.SliceCount;
                    shortcut.AssignFrom(FInput);
                }
            } catch (Exception err) {
                err.ToString();                 // no warning
                throw new Exception("Corrupt or missing Link. Frame plugin must only be used in conjunction with Delayer plugin");
            }
        }
Пример #2
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            //for each frame empty the lists
            vertices.Clear();
            indices.Clear();
            distance.Clear();

            float radius = IRadius[0];

            //for every incoming vector...
            for (int i = 0; i < SpreadMax; i++)
            {
                //check every other incoming vector...
                for (int j = i + 1; j < SpreadMax; j++)
                {
                    float dist = (float)VMath.Dist(IInput[i], IInput[j]);
                    if (dist < radius)
                    {
                        vertices.Add(IInput[i]);
                        vertices.Add(IInput[j]);
                        indices.Add(i);
                        indices.Add(j);
                        distance.Add(dist / radius);
                    }
                }
            }

            OVertices.AssignFrom(vertices);
            OIndices.AssignFrom(indices);
            ODistance.AssignFrom(distance);
        }
Пример #3
0
 public void Evaluate(int SpreadMax)
 {
     if (DirectoryIn.IsChanged || UpdateIn.TryGetSlice(0))
     {
         ExistsOut.AssignFrom(DirectoryIn.Select(Directory.Exists));
     }
 }
Пример #4
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            FParams.Clear();
            for (int i = 0; i < SpreadMax; i++)
            {
                Widget widget = null;
                switch (FWidget[i].ToLower())
                {
                case "bang": widget = new BangWidget(); break;

                case "press": widget = new PressWidget(); break;

                case "toggle": widget = new ToggleWidget(); break;

                case "slider": widget = new SliderWidget(); break;

                case "endless": widget = new NumberboxWidget(); break;
                }

//				var param = new Parameter(FId[i].ToRCPId(), FDatatype[i], FTypeDefinition[i], FValue[i], FLabel[i], new byte[0]{}/*FParent[i].ToRCPId()*/, widget, FUserdata[i]);
//				FParams.Add(param);
            }

            FParameter.AssignFrom(FParams);
        }
Пример #5
0
        // write calib result to outputs
        private void WriteCalibDataToOutput(Calibration calibration)
        {
            List <CalibrationPlotItem> calibPlot    = calibration.Plot;
            List <Vector2D>            TrueXYPoints = new List <Vector2D>();

            FMapLeft.SliceCount = FMapRight.SliceCount = FTrue.SliceCount = FValidity.SliceCount = calibPlot.Count;

            for (int i = 0; i < calibPlot.Count; i++)
            {
                FMapLeft[i]  = MapValue_ETToVVVV(new Vector2D(calibPlot[i].MapLeftX, calibPlot[i].MapLeftY));
                FMapRight[i] = MapValue_ETToVVVV(new Vector2D(calibPlot[i].MapRightX, calibPlot[i].MapRightY));
                FTrue[i]     = MapValue_ETToVVVV(new Vector2D(calibPlot[i].TrueX, calibPlot[i].TrueY));
                FValidity[i] = new Vector2D(calibPlot[i].ValidityLeft, calibPlot[i].ValidityRight);


                Vector2D v      = MapValue_ETToVVVV(new Vector2D(calibPlot[i].TrueX, calibPlot[i].TrueY));
                bool     exists = false;
                int      c      = TrueXYPoints.Count;
                for (int j = 0; j < TrueXYPoints.Count; j++)
                {
                    if (v == TrueXYPoints[j])
                    {
                        exists = true;
                    }
                }
                // avoid double entries in List TrueXYPoints
                if (c == 0 || (c > 0 && !exists))
                {
                    TrueXYPoints.Add(v);
                }
            }
            FLoadedCalibrationPoints.AssignFrom(TrueXYPoints);
        }
Пример #6
0
        private void UpdateOutputPins()
        {
            var particleSystemData = ParticleSystemRegistry.Instance.GetByParticleSystemName(FParticleSystemName[0]);

            if (particleSystemData != null)
            {
                FOutDefines.SliceCount = 0;
                FOutDefines.Add("COMPOSITESTRUCT=" + particleSystemData.StructureDefinition);
                FOutDefines.Add("MAXPARTICLECOUNT=" + particleSystemData.ElementCount);

                foreach (string define in particleSystemData.GetDefines())
                {
                    if (define != "")
                    {
                        FOutDefines.Add(define);
                    }
                }

                FOutDefines.Flush();

                FOutBufferSemantics.SliceCount = 0;
                FOutBufferSemantics.AssignFrom(particleSystemData.BufferSemantics);
                FOutBufferSemantics.Flush();

                FElementCount[0] = particleSystemData.ElementCount;
                FElementCount.Flush();

                FStride[0] = particleSystemData.Stride;
                FStride.Flush();
            }
        }
Пример #7
0
        public void Evaluate(int SpreadMax)
        {
            if (!FInFieldTripFunction.IsChanged || !FEnabled[0])
            {
                return;
            }
            FHLSL[0] = "";
            FOutCustomSemantic.SliceCount   = 0;
            FOutResourceSemantic.SliceCount = 0;
            VF3D ftFunc = FInFieldTripFunction[0];

            if (ftFunc != null)
            {
                FHLSL[0] = ftFunc.HLSL;

                if (ftFunc.CustomSemantics.Count > 0)
                {
                    FOutCustomSemantic.AssignFrom(ftFunc.CustomSemantics);
                }

                if (ftFunc.ResourceSemantics.Count > 0)
                {
                    FOutResourceSemantic.AssignFrom(ftFunc.ResourceSemantics);
                }
            }
        }
Пример #8
0
        public void Evaluate(int SpreadMax)
        {
            //return null if one of the control inputs is null
            if (FDoInsert.IsAnyEmpty(FFrameCount, FReset))
            {
                FOutput.SliceCount = 0;
                return;
            }

            if (FReset[0])
            {
                FBuffer.Clear();
            }

            if (FDoInsert[0])
            {
                FBuffer.Insert(0, CloneInputSpread(FInput));
            }

            var frameCount = FFrameCount[0];

            if (frameCount >= 0 && FBuffer.Count > frameCount)
            {
                FBuffer.RemoveRange(frameCount, FBuffer.Count - frameCount);
            }

            FOutput.AssignFrom(FBuffer);
        }
Пример #9
0
        public void Evaluate(int SpreadMax)
        {
            if (In.IsChanged)
            {
                Values.SliceCount = PortNumber.SliceCount * 8;                 // 8 bits per port
                Port.SliceCount   = PortNumber.SliceCount;

                foreach (string msg in In)
                {
                    byte[] data = Encoding.GetEncoding(1252).GetBytes(msg);
                    if (!FirmataUtils.ContainsCommand(data, Command.DIGITALMESSAGE))
                    {
                        continue;                         //
                    }
                    int   port;
                    int[] values;
                    if (FirmataUtils.DecodePortMessage(data, out port, out values))
                    {
                        Port[0] = port;
                        Values.AssignFrom(values);
                        CachedValues = Values.Clone();
                    }
                    else
                    {
                        Values = CachedValues.Clone();
                    }
                }
            }
        }
Пример #10
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if ((FUpdate.IsChanged && FUpdate[0]) && (t.Status != TaskStatus.Running))
            {
                //list & process all available printers if FPrinterName is empty
                if (FInput[0] == "")
                {
                    int i = 0;
                    FPrinterName.SliceCount = System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count;
                    foreach (var printerNameItem in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
                    {
                        //if(printerNameItem  == "") continue;
                        FPrinterName[i] = printerNameItem.ToString();
                        i++;
                    }
                }
                else
                {
                    FPrinterName.AssignFrom(FInput);
                }

                FDone[0] = false;
                if (t.IsCompleted)                //run it again
                {
                    t.Dispose();
                    t = new Task(new Action(taskEval));
                }

                t.Start();
                t.ContinueWith(result => { FDone[0] = true; }, TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent);
            }
        }
Пример #11
0
        public void Evaluate(int maxSpread)
        {
            if (Data.IsChanged)
            {
                if (Data.SliceCount < 2)
                {
                    return;
                }

                int _address = FirmataUtils.GetValueFromBytes(Data[1], Data[0]);
                if (_address != Address[0] && Data.SliceCount < 4)
                {
                    return;
                }

                int[] empty = {};
                ParsedRegister.AssignFrom(empty);
                ParsedData.AssignFrom(empty);

                for (int i = 2; i < Data.SliceCount - 4; i += 4)
                {
                    ParsedRegister.Add(FirmataUtils.GetValueFromBytes(Data[i + 1], Data[i]));
                    ParsedData.Add(FirmataUtils.GetValueFromBytes(Data[i + 3], Data[i + 2]));
                }
            }
        }
Пример #12
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FInput.IsAnyInvalid() || FIndex.IsAnyInvalid())
            {
                if (FOutput.SliceCount > 0)
                {
                    FOutput.SliceCount = 0;
                    FOutput.Flush();
                }
                return;
            }

            if (!FInput.IsChanged && !FIndex.IsChanged)
            {
                return;
            }

            FOutput.SliceCount = 0;

            var search = from message in FInput
                         let track = (message["TrackId"] as Bin <int>).First
                                     where FIndex.Contains(track)
                                     select message;

            FOutput.AssignFrom(search);

            FOutput.Flush();
        }
Пример #13
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (!FSearchPaths.IsChanged)
            {
                return;
            }

            foreach (var p in FLastPaths)
            {
                NodeCollection.RemoveCombined(p);
            }

            FLastPaths.Clear();

            foreach (var p in FSearchPaths)
            {
                NodeCollection.AddCombined(p, true);
                FLastPaths.Add(p);
            }

            NodeCollection.Collect();

            var nodeInfos =
                from nodeInfo in FNodesInfoFactory.NodeInfos
                where !nodeInfo.Ignore
                select nodeInfo.Systemname;

            FNodes.AssignFrom(nodeInfos);
            FCollectedPaths.AssignFrom(NodeCollection.Paths.Select(sp => sp.Dir));
        }
Пример #14
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FUpdate[0])
            {
                var authors = NodeCollection.NodeInfoFactory.NodeInfos.SelectMany(ni => ni.Author.Split(',', '&')).Select(a => a.Trim());
                authors = authors.Where(a => !string.IsNullOrEmpty(a) && a != "unknown" && a != "vvvv group");

                var weightedAuthors = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase);
                foreach (var author in authors)
                {
                    if (weightedAuthors.ContainsKey(author))
                    {
                        weightedAuthors[author] = weightedAuthors[author] + 1;
                    }
                    else
                    {
                        weightedAuthors[author] = 0;
                    }
                }

                FAuthors.AssignFrom(weightedAuthors.OrderBy(a => a.Value).Select(kv => kv.Key).Reverse());

                FCollectedPaths.AssignFrom(NodeCollection.Paths.Select(sp => sp.Dir).Distinct().OrderBy(d => d));
            }
        }
Пример #15
0
        public void Evaluate(int SpreadMax)
        {
            for (int i = 0; i < SpreadMax; i++)
            {
                if (!FTrig[i])
                {
                    continue;
                }
                var id = FId[i] < 0 ? Math.Max(autoid, FId.Max() + 1) : FId[i];
                Pulses.Add(new Pulse
                {
                    Duration = FTime[i],
                    Id       = id
                });
                autoid = id;
            }

            FPulse.AssignFrom(from pulse in Pulses where pulse.Clock.Elapsed.TotalSeconds <= pulse.Duration select pulse);
            FOutput.SliceCount = FOutputInv.SliceCount = FIdOut.SliceCount = FPulse.SliceCount;
            for (int i = 0; i < FPulse.SliceCount; i++)
            {
                FOutput[i]    = FPulse[i].Clock.Elapsed.TotalSeconds / FPulse[i].Duration;
                FOutputInv[i] = 1.0 - FOutput[i];
                FIdOut[i]     = FPulse[i].Id;
            }

            Pulses = FPulse.ToList();
        }
Пример #16
0
        protected void TestSpread <T>(ISpread <T> spread, T[] sampleData)
        {
            spread.SliceCount = 0;
            Assert.True(spread.SliceCount == 0, "SliceCount can't be set to 0.");

            spread.AssignFrom(sampleData);
            Assert.AreEqual(sampleData.Length, spread.SliceCount, "SliceCount differs from Length of sample data.");
            for (int i = 0; i < spread.SliceCount; i++)
            {
                Assert.AreEqual(sampleData[i], spread[i], "Spread data differs from sample data.");
                Assert.AreEqual(spread[i], spread[spread.SliceCount + i], "Modulo property doesn't hold in spread.");
            }

            var spreadAsList = spread.ToList();

            for (int i = 0; i < sampleData.Length; i++)
            {
                Assert.AreEqual(sampleData[i], spreadAsList[i], "List created with spread.ToList() differs from sample data.");
            }

            spread.SliceCount = sampleData.Length;
            Assert.True(spread.SliceCount == sampleData.Length);

            // Test writing
            for (int i = 0; i < sampleData.Length; i++)
            {
                spread[i] = sampleData[i];
            }

            // Test writing with index above SliceCount
            for (int i = 0; i < sampleData.Length; i++)
            {
                spread[spread.SliceCount + i] = sampleData[i];
            }

            // Test writing with index below SliceCount
            for (int i = 0; i < sampleData.Length; i++)
            {
                spread[i - spread.SliceCount] = sampleData[i];
            }

            // Test reading
            for (int i = 0; i < spread.SliceCount; i++)
            {
                Assert.True(spread[i].Equals(sampleData[i]));
                Assert.True(spread[i].Equals(spread[spread.SliceCount + i]));
            }

            // Data should not get lost by increasing SliceCount
            spread.SliceCount++;
            for (int i = 0; i < sampleData.Length; i++)
            {
                Assert.AreEqual(sampleData[i], spread[i]);
            }

            // Data should not get lost by decreasing SliceCount
            spread.SliceCount = 1;
            Assert.AreEqual(1, spread.SliceCount);
            Assert.AreEqual(sampleData[0], spread[0], "After decreasing slice count data at index 0 didn't match anymore.");
        }
Пример #17
0
        public static void SetIsNew(ISpread <Blob> blobs, ISpread <Blob> pBlobs)
        {
            if (pBlobs.SliceCount == 0)
            {
                for (var i = 0; i < blobs.SliceCount; i++)
                {
                    blobs[i] = new Blob {
                        Position = blobs[i].Position, HitId = blobs[i].HitId, Id = blobs[i].Id, IsNew = true
                    };
                }
            }
            else
            {
                for (var i = 0; i < blobs.SliceCount; i++)
                {
                    //TODO: Proper new blob detection
                    blobs[i] = new Blob {
                        Position = blobs[i].Position, HitId = blobs[i].HitId, Id = blobs[i].Id, IsNew = pBlobs.All(blob => blob.Id != blobs[i].Id)
                    };
                }
            }

            pBlobs.SliceCount = blobs.SliceCount;
            pBlobs.AssignFrom(blobs);
        }
Пример #18
0
        #pragma warning restore
        #endregion fields & pins

        public void Evaluate(int spreadMax)
        {
            if (FSetIn[0])
            {
                FInput.Sync();
                FOutput.AssignFrom(FInput);
            }
        }
Пример #19
0
 //called when data for any output pin is requested
 public void Evaluate(int SpreadMax)
 {
     if (FParameters.SliceCount == 0 || FParameters[0] == null)
     {
         FParametersOut.SliceCount = 0;
     }
     else if (string.IsNullOrWhiteSpace(FGroup[0]))
     {
         FParametersOut.AssignFrom(FParameters);
     }
     else
     {
         var groups         = FParameters.Where(p => p.Datatype == "Group");
         var groupsToFilter = FGroup.ToList();
         FParametersOut.AssignFrom(FParameters.Where(p => groupsToFilter.Contains(p.Group)));
     }
 }
Пример #20
0
 public void Evaluate(int SpreadMax)
 {
     FOutput.Stream.IsChanged = false;
     if (Initial)
     {
         FOutput.AssignFrom(FDefault);
         Initial = false;
         FOutput.Flush();
         FOutput.Stream.IsChanged = true;
     }
     if (FEval[0])
     {
         FInput.Sync();
         FOutput.AssignFrom(FInput);
         FOutput.Flush();
         FOutput.Stream.IsChanged = true;
     }
 }
Пример #21
0
 public static void FlushResult <T>(this ISpread <T> spread, IEnumerable <T> result)
 {
     spread.SliceCount = 0;
     if (result != null)
     {
         spread.AssignFrom(result);
     }
     spread.Flush();
 }
Пример #22
0
        public void Evaluate(int spreadMax)
        {
            FSubscriptions.ResizeAndDispose(
                spreadMax,
                slice =>
            {
                return(new Subscription <Keyboard, KeyCodeNotification>(
                           keyboard => keyboard.KeyNotifications.OfType <KeyCodeNotification>(),
                           (keyboard, notification) =>
                {
                    var keyCodeOut = FKeyCodeOut[slice];
                    var keyCodeValue = (int)notification.KeyCode;
                    switch (notification.Kind)
                    {
                    case KeyNotificationKind.KeyDown:
                        if (!keyCodeOut.Contains(keyCodeValue))
                        {
                            keyCodeOut.Add(keyCodeValue);
                        }
                        break;

                    case KeyNotificationKind.KeyUp:
                        keyCodeOut.Remove(keyCodeValue);
                        break;
                    }
                    FCapsOut[slice] = keyboard.CapsLock;
                    FTimeOut[slice] = FTimeOut[slice] + 1;
                }
                           ));
            }
                );

            FKeyCodeOut.SliceCount = spreadMax;
            FCapsOut.SliceCount    = spreadMax;
            FTimeOut.SliceCount    = spreadMax;

            for (int i = 0; i < spreadMax; i++)
            {
                FSubscriptions[i].Update(FInput[i]);
            }

            //KeyOut returns the keycodes symbolic names
            //it is a spread parallel to the keycodes
            //didn't want to create an extra binsize output, so...
            var keys = new List <string>();

            foreach (var bin in FKeyCodeOut)
            {
                foreach (var slice in bin)
                {
                    var key = (Keys)slice;
                    keys.Add(key.ToString());
                }
            }
            FKeyOut.AssignFrom(keys);
        }
Пример #23
0
        public void Evaluate(int SpreadMax)
        {
            FOutBuffers.SliceCount = FInBuffers.SliceCount;
            FOutBuffers.AssignFrom(FInBuffers);

            for (int i = 0; i < FInIndex.SliceCount; i++)
            {
                FOutBuffers[FInIndex[i]] = FInBuffersNew[i];
            }
        }
Пример #24
0
 //called when data for any output pin is requested
 public void Evaluate(int SpreadMax)
 {
     FArcXY.Clear();
     FArcRadius.Clear();
     FArcLevel.Clear();
     drawBranch(FX[0], FY[0], FRadius[0], FLevel[0]);
     FOutput1.AssignFrom(FArcXY);
     FOutput2.AssignFrom(FArcRadius);
     FOutput3.AssignFrom(FArcLevel);
 }
Пример #25
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            //check transforms
            if (FTransformIn.IsChanged)
            {
                //assign size and clear group list
                FOutput.SliceCount = FTransformIn.SliceCount;
                FGroups.Clear();

                //create groups and add matrix to it
                for (int i = 0; i < FTransformIn.SliceCount; i++)
                {
                    var g = new SvgGroup();
                    g.Transforms = new SvgTransformCollection();

                    var m   = FTransformIn[i];
                    var mat = new SvgMatrix(new List <float>()
                    {
                        m.M11, m.M12, m.M21, m.M22, m.M41, m.M42
                    });

                    g.Transforms.Add(mat);

                    FGroups.Add(g);
                }
            }

            //add all elements to each group
            if (FInput.IsChanged || FTransformIn.IsChanged || FEnabledIn.IsChanged)
            {
                foreach (var g in FGroups)
                {
                    g.Children.Clear();

                    if (FEnabledIn[0])
                    {
                        for (int i = 0; i < FInput.SliceCount; i++)
                        {
                            var pin = FInput[i];
                            for (int j = 0; j < pin.SliceCount; j++)
                            {
                                var elem = pin[j];
                                if (elem != null)
                                {
                                    g.Children.Add(elem);
                                }
                            }
                        }
                    }
                }
                //write groups to output
                FOutput.AssignFrom(FGroups);
            }
        }
Пример #26
0
                #pragma warning restore
        #endregion fields & pins

        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FInput.IsChanged || FIndex.IsChanged)
            {
                FOutput.AssignFrom(FInput);
                foreach (int i in FIndex.Select(x => x % FInput.SliceCount).Distinct().OrderByDescending(x => x))
                {
                    FOutput.RemoveAt(i);
                }
            }
        }
        protected override void WriteToIO <T>(Field field, ISpread <T> source, ISpread <T> destination)
        {
            destination.AssignFrom(source);
            dynamic src = source;
            dynamic dst = destination;

            for (int i = 0; i < src.SliceCount; i++)
            {
                dst[i].Assign(src[i]);
            }
        }
Пример #28
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (!this.FInWorld.PluginIO.IsConnected)
            {
                FOutCursorsOnCanvas.SliceCount = 0;
                return;
            }

            var world = FInWorld[0];

            FOutCursorsOnCanvas.AssignFrom(world.CursorsOnCanvas);
        }
Пример #29
0
        //updates all parameters
        private void UpdateOutputs()
        {
            var parameters = FParamIds.Select(id => FRCPClient.GetParameter(id)).OrderBy(p => p.Order);
            var ps         = new List <Parameter>();

            foreach (var p in parameters)
            {
                ps.Add(GetParameter(p));
            }

            FParameters.AssignFrom(ps);
        }
Пример #30
0
 protected override void Evaluate(int spreadMax, bool enabled)
 {
     if (enabled)
     {
         if (FKeyboardOut[0] != FKeyboardState)
         {
             FKeyboardOut[0] = FKeyboardState;
             FLegacyKeyStringOut.AssignFrom(FKeyboardState.KeyCodes.Select(k => LegacyKeyboardHelper.VirtualKeycodeToString(k)));
             FKeyboardSplitNode.Evaluate(spreadMax);
         }
     }
 }
Пример #31
0
        public static void SetIsNew(ISpread<Blob> blobs, ISpread<Blob> pBlobs)
        {
            if (pBlobs.SliceCount == 0)
            {
                for (var i = 0; i < blobs.SliceCount; i++)
                {
                    blobs[i] = new Blob{Position = blobs[i].Position, HitId = blobs[i].HitId, Id = blobs[i].Id, IsNew = true};
                }
            }
            else
            {
                for (var i = 0; i < blobs.SliceCount; i++)
                {
                    //TODO: Proper new blob detection
                    blobs[i] = new Blob { Position = blobs[i].Position, HitId = blobs[i].HitId, Id = blobs[i].Id, IsNew = pBlobs.All(blob => blob.Id != blobs[i].Id)};
                }
            }

            pBlobs.SliceCount = blobs.SliceCount;
            pBlobs.AssignFrom(blobs);
        }