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); }
private void ProcessSignal1D(RecorderLine1D line, int samples) { var buffer = line.Port.Read(samples); foreach (var tuple in buffer.ZipWithValueInput(_portEnable)) { if (line.Recording) { if (tuple.Scalar < 0.5) { line.StopRecording(tuple.Stamp); } else { line.Write(tuple.Sample); } } else if (tuple.Scalar >= 0.5) { line.StartRecording(tuple.Stamp); line.Write(tuple.Sample); } } }