Ejemplo n.º 1
0
        private void ProcessValues(RecorderLineValue line)
        {
            var port = line.Port;

            // copy count as it might grow while doing the loop
            var cnt = port.Count;

            for (int i = 0; i < cnt; i++)
            {
                NodeSystemLib2.FormatValue.TimeLocatedValue <double> v;
                if (port.TryDequeue(out v))
                {
                    if (v.Stamp > Parent.GetCurrentClockTime())
                    {
                        // not time yet for this value, put back
                        port.Write(v);
                    }
                    else
                    {
                        foreach (var en in _portEnable.GetValueIterator(line.LastTimeStampCheck))
                        {
                            if (en.Value < 0.5)
                            {
                                line.StopRecording(en.Stamp);
                            }
                            else
                            {
                                line.StartRecording(en.Stamp);
                            }

                            if (en.Stamp > v.Stamp)
                            {
                                // even if there are more values in portEnable, not relevant for value v
                                break;
                            }
                        }
                        line.LastTimeStampCheck = v.Stamp;
                        if (line.Recording)
                        {
                            line.Write(v);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void CreateLine(PortDataType type)
        {
            Func <int> PortCount = () => _lines.Count(l => l.Port.DataType.Equals(type));

            RecorderLine line = null;

            if (type == PortDataTypes.TypeIdValueDouble)
            {
                var port = new NodeSystemLib2.FormatValue.InputPortValueDouble(this, $"{_portTypePrefix[type]}{PortCount()}");
                line = new RecorderLineValue(port, this);
            }
            else if (type == PortDataTypes.TypeIdSignal1D)
            {
                var port = new NodeSystemLib2.FormatData1D.InputPortData1D(this, $"{_portTypePrefix[type]}{PortCount()}");
                line = new RecorderLine1D(port, this);
            }
            else
            {
                throw new ArgumentException(nameof(type));
            }
            line.Port.ConnectionChanged += LineStateChanged;
            _lines.Add(line);
        }