public override void PrepareProcessing() { _active = TristateActive.Inactive; _portIn.PrepareProcessing(); _portThreshHigh.PrepareProcessing(); _portThreshLow.PrepareProcessing(); _portOut.PrepareProcessing(); }
public override void PrepareProcessing() { _active = TristateActive.Inactive; _timeBecomeInactive = TimeStamp.Zero; _portIn.PrepareProcessing(); _portThresh.PrepareProcessing(); _portOut.PrepareProcessing(); }
public override void Process() { if (_attrStartAt.TypedGet() == SustainMode.StartAtFallingEdge) { foreach (var tuple in _portIn.Read().ZipWithValueInput(_portThresh)) { if (tuple.Sample >= tuple.Scalar) { _timeBecomeInactive = tuple.Stamp.Increment(_attrActiveDurationMillis.TypedGet() / 1000.0); if (_active == TristateActive.Inactive) { _active = TristateActive.Active; _portOut.BufferForTransfer(new TimeLocatedValue <double>(1, tuple.Stamp)); } } else { if (_active == TristateActive.Active && _timeBecomeInactive <= tuple.Stamp) { _active = TristateActive.Inactive; _portOut.BufferForTransfer(new TimeLocatedValue <double>(0, tuple.Stamp)); } } } } else if (_attrStartAt.TypedGet() == SustainMode.StartAtRisingEdge) { foreach (var tuple in _portIn.Read().ZipWithValueInput(_portThresh)) { if (tuple.Sample >= tuple.Scalar) { if (_active == TristateActive.Inactive) { _timeBecomeInactive = tuple.Stamp.Increment(_attrActiveDurationMillis.TypedGet() / 1000.0); _active = TristateActive.Active; _portOut.BufferForTransfer(new TimeLocatedValue <double>(1, tuple.Stamp)); } } else { if (_active == TristateActive.BecomingInactive) { _active = TristateActive.Inactive; } } if (_active == TristateActive.Active && _timeBecomeInactive <= tuple.Stamp) { _active = TristateActive.BecomingInactive; _portOut.BufferForTransfer(new TimeLocatedValue <double>(0, tuple.Stamp)); } } } }
public override void Process() { foreach (var tuple in _portIn.Read().ZipWithValueInput(_portThreshLow, _portThreshHigh)) { switch (_active) { case TristateActive.Active: if (tuple.Sample < tuple.Scalar && tuple.Scalar < tuple.Scalar2) { _active = TristateActive.Inactive; _portOut.BufferForTransfer(new TimeLocatedValue <double>(0, tuple.Stamp)); } break; case TristateActive.Inactive: if (tuple.Sample > tuple.Scalar2 && tuple.Scalar < tuple.Scalar2) { _active = TristateActive.Active; _portOut.BufferForTransfer(new TimeLocatedValue <double>(1, tuple.Stamp)); } break; } } }