Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.2.1 #29

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanups and added descriptions to low pass filter
manoj1511 committed Nov 14, 2024
commit 695442d9672fce406ead674c60f96ab720aa62e3
3 changes: 1 addition & 2 deletions source/base/supply_equipment_control.cpp
Original file line number Diff line number Diff line change
@@ -764,8 +764,7 @@ supply_equipment_control::supply_equipment_control( const bool building_charge_p

int max_window_size = this->manage_L2_control->get_LPF_max_window_size();
double initial_raw_data_value = 1.0;
LPF_kernel X(max_window_size, initial_raw_data_value);
this->LPF = X;
this->LPF = LPF_kernel{ max_window_size, initial_raw_data_value };

LPF_parameters LPF_params;
LPF_params.window_size = 1;
24 changes: 16 additions & 8 deletions source/globals/helper.cpp
Original file line number Diff line number Diff line change
@@ -327,16 +327,24 @@ bool rand_val::rand_is_initialized = false;
// Low Pass Filter
//#############################################################################

LPF_kernel::LPF_kernel()
: max_window_size{ 1 },
raw_data{ std::vector<double>(this->max_window_size, 1.0) },
cur_raw_data_index{ 0 },
window_type{ LPF_window_enum::Rectangular },
window_size{ 1 },
window{ std::vector<double>(1, 1.0) },
window_area{ 1.0 }
{

}


LPF_kernel::LPF_kernel(int max_window_size, double initial_raw_data_value)
{
this->cur_raw_data_index = 0;

for(int i=0; i<max_window_size; i++)
{
this->raw_data.push_back(initial_raw_data_value);
}

: cur_raw_data_index{ 0 },
max_window_size{ max_window_size },
raw_data{std::vector<double>(max_window_size, initial_raw_data_value)}
{
LPF_parameters LPF_params{};
LPF_params.window_size = 1;
LPF_params.window_type = LPF_window_enum::Rectangular;
13 changes: 11 additions & 2 deletions source/globals/helper.h
Original file line number Diff line number Diff line change
@@ -192,17 +192,26 @@ class rand_val
class LPF_kernel
{
private:

int max_window_size;

// raw_data has a max length of max_window_size.
// new value added to the raw_data is added in a round-robin fashin.
std::vector<double> raw_data;

// cur_raw_data_index tracks the latest info added to the round-robin raw_data.
int cur_raw_data_index;

// Options are Hanning, Blackmann, and Rectangular.
LPF_window_enum window_type;
int window_size;

int window_size;

std::vector<double> window;
double window_area;

public:
LPF_kernel() {};
LPF_kernel();
LPF_kernel(int max_window_size, double initial_raw_data_value);
void update_LPF(LPF_parameters& LPF_params);
void add_raw_data_value(double next_input_value);