Commit ec827d64 authored by Thomas Edwards's avatar Thomas Edwards
Browse files

Removed try/catch logic, condsensed filter selection logic

parent d43ca3e8
......@@ -364,17 +364,8 @@ int Filter_Obs::lowpass_PLASMON_1Hz(buffer_obs* buffer_in,
// --------------------------------------------------------------
std::cerr << "-----------------------------------" << std::endl;
timestamp=tofilter1.back()->get_time("%Y-%m-%d %H:%M:%S",true);
// std::cerr << "Latest timestamp: " << timestamp << " | ";
// std::cerr << "No. Rec: " << tofilter1.size() << " | ";
// std::cerr << "Elapsed time: ";
// std::cerr << elapsed_time_last_block << " | ";
// Assume 128 Hz being downsampled to 16 Hz. That means 1 block ever 1e9/16 ns
// int num_blocks = round(elapsed_time_last_block/(1e9/16));
float num_blocks = (elapsed_time_last_block/(1e9/16.));
// std::cerr << "Expected blocks: " << num_blocks << " | ";
// Assume we can run a filter every 16 blocks
total_blocks += num_blocks;
// std::cerr << "Filters: " << total_blocks/16. << std::endl;
std::cerr << "Total blocks: " << total_blocks << std::endl;
std::cerr << "Data in que: " << tofilter1.size() << std::endl;
......@@ -395,20 +386,18 @@ int Filter_Obs::lowpass_PLASMON_1Hz(buffer_obs* buffer_in,
int points_to_drop = 0;
// Check if we have (8*(blocks) +/- 1) data in the filter que
time_block_check = round(8*(total_blocks));
// bool run_the_filter = (tofilter1.size() == (time_block_check)) && (int(total_blocks/16) >= 1) && (tofilter1.size() >= 129);
bool run_the_filter = ((tofilter1.size() <= (time_block_check + 1)) && (tofilter1.size() >= (time_block_check - 1))) && (int(total_blocks/16) >= 1) && (tofilter1.size() >= 129);
// std::cerr << "Data in que: " << tofilter1.size() << " | blocks*8: " << time_block_check << " | Run the filter?: " << run_the_filter << std::endl;
while (run_the_filter) {
// Try to just run as normal
try {
if (tofilter1.size() != 129) {
throw std::out_of_range("Filter not perfect");
}
filter1_win = &filter1_wins.at(129);
// Filter data
filter_data_temp->filter_fir_sym(&tofilter1, filter1_win);
points_to_drop = 8+filter1_win->size()-128;
} catch (const std::out_of_range &oor) {
// try {
// if (tofilter1.size() != 129) {
// throw std::out_of_range("Filter not perfect");
// }
// filter1_win = &filter1_wins.at(129);
// // Filter data
// filter_data_temp->filter_fir_sym(&tofilter1, filter1_win);
// points_to_drop = 8+filter1_win->size()-128;
// } catch (const std::out_of_range &oor) {
// Use the time_block_check information to assume if we are over or under
// this is just the +/- part, so we can expand or reduce the filter to match
int filter_jitter = 0;
......@@ -440,14 +429,14 @@ int Filter_Obs::lowpass_PLASMON_1Hz(buffer_obs* buffer_in,
std::cerr << "OOR err, Filter Jitter: " << filter_jitter << " | ";
// Filter data
filter1_win = &filter1_wins.at(128+filter_jitter+1);
filter1_slice = std::vector<data_obs*>(tofilter1.begin(), tofilter1.begin()+128+filter_jitter+1);
filter1_win = &filter1_wins.at(129+filter_jitter);
filter1_slice = std::vector<data_obs*>(tofilter1.begin(), tofilter1.begin()+129+filter_jitter);
filter_data_temp->filter_fir_sym(&filter1_slice, filter1_win);
points_to_drop = 8+filter_jitter;
// Debug printing
std::cerr << "points_to_drop: " << points_to_drop << std::endl;
}
// }
// Append this data to the queue for filter 2
tofilter2.push_back(new data_obs_vector(filter_data_temp));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment