<commit_before>//!
//! @file   SignalFirstOrderFilter.hpp
//! @author <NAME> <<EMAIL>>
//! @date   2010-01-22
//!
//! @brief Contains a Signal First Order Filter Component using CoreUtilities
//!
//$Id$

#ifndef SIGNALFIRSTORDERFILTER_HPP_INCLUDED
#define SIGNALFIRSTORDERFILTER_HPP_INCLUDED

#include "../../ComponentEssentials.h"
#include "../../ComponentUtilities.h"

//!
//! @brief
//! @ingroup SignalComponents
//!
class SignalFirstOrderFilter : public ComponentSignal
{

private:
    FirstOrderFilter mFilter;
    double mWnum, mWden, mK;
    double mStartY;
    double mMin, mMax;
    Port *mpIn, *mpOut;

public:
    static Component *Creator()
    {
        return new SignalFirstOrderFilter("Filter");
    }

    SignalFirstOrderFilter(const string name) : ComponentSignal(name)
    {
        mTypeName = "SignalFirstOrderFilter";
        mStartY = 0.0;

        mMin = -1.5E+300;
        mMax = 1.5E+300;

        mpIn = addReadPort("in", "NodeSignal");
        mpOut = addWritePort("out", "NodeSignal");

        registerParameter("k", "Gain", "-", mK);
        registerParameter("wnum", "Numerator break frequency", "rad/s", mWnum);
        registerParameter("wden", "Denumerator break frequency", "rad/s", mWden);
    }


    void initialize()
    {
        //double u0 = mPortPtrs[in]->readNode(NodeSignal::VALUE);

        double num[2];
        double den[2];

        num[0] = mK/mWnum;
        num[1] = mK;
        den[0] = 1.0/mWden;
        den[1] = 1.0;
        //num[0] = 0.0;
        //num[1] = 1.0;
        //den[0] = 1.0E-10;
        //den[1] = 1.0;

        mFilter.initialize(mTime, mTimestep, num, den, mStartY, mStartY, mMin, mMax);
        //! @todo Write out values into node as well? (I think so) This is true for all components
    }


    void simulateOneTimestep()
    {
        //Get variable values from nodes
        double u = mpIn->readNode(NodeSignal::VALUE);

        //Write new values to nodes<commit_msg>Added min max parameter and some spelling<commit_after>//!
//! @file   SignalFirstOrderFilter.hpp
//! @author <NAME> <<EMAIL>>
//! @date   2010-01-22
//!
//! @brief Contains a Signal First Order Filter Component using CoreUtilities
//!
//$Id$

#ifndef SIGNALFIRSTORDERFILTER_HPP_INCLUDED
#define SIGNALFIRSTORDERFILTER_HPP_INCLUDED

#include "../../ComponentEssentials.h"
#include "../../ComponentUtilities.h"

//!
//! @brief
//! @ingroup SignalComponents
//!
class SignalFirstOrderFilter : public ComponentSignal
{

private:
    FirstOrderFilter mFilter;
    double mWnum, mWden, mK;
    double mStartY;
    double mMin, mMax;
    Port *mpIn, *mpOut;

public:
    static Component *Creator()
    {
        return new SignalFirstOrderFilter("Filter");
    }

    SignalFirstOrderFilter(const string name) : ComponentSignal(name)
    {
        mTypeName = "SignalFirstOrderFilter";
        mStartY = 0.0;

        mMin = -1.5E+300;
        mMax = 1.5E+300;

        mpIn = addReadPort("in", "NodeSignal");
        mpOut = addWritePort("out", "NodeSignal");

        registerParameter("k", "Gain", "-", mK);
        registerParameter("wnum", "Numerator break frequency", "rad/s", mWnum);
        registerParameter("wden", "Denominator break frequency", "rad/s", mWden);
        registerParameter("min", "Output Lower limit", "-", mMin);
        registerParameter("max", "Output Upper limit", "-", mMax);
    }


    void initialize()
    {
        double num[2];
        double den[2];

        num[0] = mK/mWnum;
        num[1] = mK;
        den[0] = 1.0/mWden;
        den[1] = 1.0;

        mFilter.initialize(mTime, mTimestep, num, den, mStartY, mStartY, mMin, mMax);

        //Writes out the value for time "zero"
        mpOut->writeNode(NodeSignal::VALUE, mStartY);
    }


    void simulateOneTimestep()
    {
        //Get variable values from nodes
        double u = mpIn->readNode(NodeSignal::VALUE);

        //Write new values to nodes
{'fraction_non_alphanumeric': 0.14417650076962546, 'fraction_numerical': 0.019240636223704463, 'mean_word_length': 2.5935483870967744, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7659523', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1258, 'n_words': 304}