Ejemplo n.º 1
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();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FCount.IsChanged)
            {
                ringPointer = 0;
                buffer.Clear();
                for (int i = 0; i < FCount[0]; i++)
                {
                    buffer.Add(new Spread <PathGeometry>(0));
                }
            }

            if (FInsert[0])
            {
                buffer[ringPointer] = FGeometryIn.Clone();

                for (int i = 0; i < FGeometryIn.SliceCount; i++)
                {
                    buffer[ringPointer].SliceCount = 0;
                    buffer[ringPointer].Add(FGeometryIn[i].Clone());
                }
                ringPointer = (ringPointer + 1) % FCount[0];

                FGeometryOut.SliceCount = FBinSize.SliceCount = 0;

                for (int i = 0; i < FCount[0]; i++)
                {
                    for (int j = 0; j < buffer[(ringPointer + i) % FCount[0]].SliceCount; j++)
                    {
                        FGeometryOut.Add(buffer[(ringPointer + i) % FCount[0]][j]);
                    }
                    FBinSize.Add(buffer[(ringPointer + i) % FCount[0]].SliceCount);
                }
            }
        }
Ejemplo n.º 3
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, FInput.Clone() as ISpread <T>);
            }

            var frameCount = FFrameCount[0];

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

            FOutput.AssignFrom(FBuffer);
        }
Ejemplo n.º 4
0
        public void Evaluate(int SpreadMax)
        {
            //return null if one of the control inputs is null
            if (FDoSet.IsAnyEmpty(FFrameCount, FReset))
            {
                FOutput.SliceCount       = 0;
                FPhase.SliceCount        = 0;
                FCurrentFrame.SliceCount = 0;
                return;
            }

            if ((FFirstFrame) || (FReset[0]))
            {
                FOutput.SliceCount = 0;
                FCurrentPos        = -1;
            }

            var frameCount    = FFrameCount[0];
            var oldframecount = FOutput.SliceCount;

            FOutput.SliceCount       = frameCount;
            FPhase.SliceCount        = 1;
            FCurrentFrame.SliceCount = 1;

            if (oldframecount < frameCount)
            {
                for (int i = oldframecount; i < frameCount; i++)
                {
                    FOutput[i] = new Spread <T>(0);
                }
            }

            if (FDoSet[0])
            {
                FCurrentPos++;
                if (FCurrentPos > frameCount - 1)
                {
                    FCurrentPos = 0;
                }
                FOutput[FCurrentPos] = FInput.Clone() as ISpread <T>;
            }

            FCurrentFrame[0] = Math.Min(Math.Max(FCurrentPos, 0), frameCount - 1);
            FPhase[0]        = frameCount > 1 ? FCurrentFrame[0] / (double)(frameCount - 1) : 1;

            FFirstFrame = false;
        }
        //private Dictionary<int, VideoRecordInstance> FWritersByIndex = new Dictionary<int, VideoRecordInstance>();

        public override void Evaluate(int spreadMax)
        {
            base.Evaluate(spreadMax);

            int codec = CvInvoke.CV_FOURCC(FCodec[0][0], FCodec[0][1], FCodec[0][2], FCodec[0][3]);

            for (int i = 0; i < spreadMax; i++)
            {
                if (FInput[i] == null || !FRecord[i])
                {
                    InstancesByIndex[i].Close();
                }
                else if (FRecord[i] && !FPRecord[i])
                {
                    //Start record
                    InstancesByIndex[i].Initialise(FInput[i], FPath[i], codec);
                }
            }

            FPRecord = (Spread <bool>)FRecord.Clone();
        }
Ejemplo n.º 6
0
 protected virtual ISpread <T> CloneInputSpread(ISpread <T> spread)
 {
     return(spread.Clone() as ISpread <T>);
 }
Ejemplo n.º 7
0
        public void Evaluate(int SpreadMax)
        {
            //return null if one of the control inputs is null
            if (FDoInsert.IsAnyEmpty(FReset))
            {
                FOutput.SliceCount = 0;
                return;
            }

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

            if (FRemove[0])
            {
                if (FFramesRecorded.SliceCount > 0)
                {
                    foreach (int i in FIndex.Select(x => x % FFramesRecorded.SliceCount).Distinct().OrderByDescending(x => x))
                    {
                        int offset = 0;
                        for (int j = 0; j < i; j++)
                        {
                            offset += FFramesRecorded[j];
                        }

                        if (FFramesRecorded.SliceCount > 1)
                        {
                            FBuffer.RemoveRange(offset, FFramesRecorded[i]);
                        }
                        else
                        {
                            FBuffer.RemoveRange(0, FFramesRecorded[i]);
                        }

                        FFramesRecorded.RemoveAt(i);
                    }
                }
            }

            if (FDoInsert[0])
            {
                // is empty, so insert new slice
                if (FFramesRecorded.SliceCount < 1)
                {
                    FFramesRecorded.Insert(0, 0);
                }
                // new slice for FFramesRecorded reqested
                else if (FDoSplit[0])
                {
                    // duplicate current slice and insert in old queue
                    if (FSplitDuplicate[0])
                    {
                        if (!FAppend[0])
                        {
                            FBuffer.Insert(0, FInput.Clone());
                            FFramesRecorded[0]++;
                        }
                        else
                        {
                            // search beginning of last queue
                            int count = 0;
                            for (int i = 0; i < FFramesRecorded.SliceCount - 1; i++)
                            {
                                count += FFramesRecorded[i];
                            }

                            FBuffer.Insert(count, FInput.Clone());
                            FFramesRecorded[FFramesRecorded.SliceCount - 1]++;
                        }
                    }
                    if (!FAppend[0])
                    {
                        FFramesRecorded.Insert(0, 0);
                    }
                    else
                    {
                        FFramesRecorded.Add(0);
                    }
                }

                if (!FAppend[0])
                {
                    FBuffer.Insert(0, FInput.Clone());
                    FFramesRecorded[0]++;
                }
                else
                {
                    // search beginning of last queue
                    int count = 0;
                    for (int i = 0; i < FFramesRecorded.SliceCount - 1; i++)
                    {
                        count += FFramesRecorded[i];
                    }

                    FBuffer.Insert(count, FInput.Clone());
                    FFramesRecorded[FFramesRecorded.SliceCount - 1]++;
                }
            }

            FOutput.AssignFrom(FBuffer);

            if (FOutput.SliceCount == 0)
            {
                FFramesRecorded.SliceCount = 0;
            }

            // combines all recorded queues to one big queue
            if (FConsolidate[0] == true)
            {
                int count = 0;

                foreach (int current in FFramesRecorded)
                {
                    count += current;
                }

                FFramesRecorded.SliceCount = 1;
                FFramesRecorded[0]         = count;
            }
        }