private void ProcessValues(NodeSystemLib2.FormatValue.InputPortValueDouble port) { if (_recording && port != _portEn) { NodeSystemLib2.FormatValue.TimeLocatedValue <double> value; // copy Count as it could change throughout the loop var count = port.Count; for (int i = 0; i < count; i++) { if (port.TryDequeue(out value)) { if (_recording) { var writer = _writers[port]; if (value.Stamp >= _firstWrittenSampleTime) { ((Stream2DWriter)writer.Writer).WriteSample(value); writer.SetNewStamp(value.Stamp); } } } else { break; } } } }
private void Recorder2_PortConnectionChanged(object sender, ConnectionModifiedEventArgs e) { if (changingConnections) { return; } changingConnections = true; UpdateInputPorts(); var dataInputs = InputPorts.OfType <NodeSystemLib2.FormatData1D.InputPortData1D>(); if (dataInputs.All(d => d.Connection != null)) { var p = new NodeSystemLib2.FormatData1D.InputPortData1D(this, $"DIn {dataInputs.Count() + 1}"); AddPort(p, EnablePortIndex); } var valueInputs = InputPorts.OfType <NodeSystemLib2.FormatValue.InputPortValueDouble>().Except(new [] { _portEn }); if (valueInputs.All(d => d.Connection != null)) { var p = new NodeSystemLib2.FormatValue.InputPortValueDouble(this, $"VIn {valueInputs.Count() + 1}"); AddPort(p, EnablePortIndex); } changingConnections = false; }
public Recorder2(Graph g) : base("Recorder 2", g) { _firstDataIn = new NodeSystemLib2.FormatData1D.InputPortData1D(this, "DIn 1"); _firstValueIn = new NodeSystemLib2.FormatValue.InputPortValueDouble(this, "VIn 1"); _portEn = new NodeSystemLib2.FormatValue.InputPortValueDouble(this, "En"); this.PortConnectionChanged += Recorder2_PortConnectionChanged; }
public Recorder3(Graph g) : base("Recorder 3", g) { CreateLine(PortDataTypes.TypeIdSignal1D); CreateLine(PortDataTypes.TypeIdValueDouble); _portEnable = new NodeSystemLib2.FormatValue.InputPortValueDouble(this, "Enable"); _attrPrebufferLengthMs = new AttributeValueDouble(this, "PreBuffer", "ms", 1000); _attrNumOfLines1D = new AttributeValueInt(this, "NumOfLines1D", 1); _attrNumOfLines2D = new AttributeValueInt(this, "NumOfLines2D", 1); _attrNumOfLines1D.SetRuntimeReadonly(); _attrNumOfLines2D.SetRuntimeReadonly(); _attrNumOfLines1D.Changed += _numOfLines1D_Changed; _attrNumOfLines2D.Changed += _numOfLines2D_Changed; }
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); }
public RecorderLineValue(NodeSystemLib2.FormatValue.InputPortValueDouble port, Recorder3 parent) : base(port, parent) { }