diff --git a/software/src/modules/phase_switcher/multi_value_history.cpp b/software/src/modules/phase_switcher/multi_value_history.cpp index 8ebee9ce0..eab55abaa 100644 --- a/software/src/modules/phase_switcher/multi_value_history.cpp +++ b/software/src/modules/phase_switcher/multi_value_history.cpp @@ -51,22 +51,19 @@ void MultiValueHistory::setup() for(int j = 0; j < MULTI_VALUE_HISTORY_NUMBER_OF_VALUES; ++j){ for (size_t i = 0; i < history[i].size(); ++i) { -// !!! FIXME - float f = 5000.0f * sinf(static_cast(PI)/120.0f * static_cast(i)) + 5000.0f; - switch(j){ - case 0: - val_min = static_cast(f); - break; - - case 1: - val_min = static_cast(f * -1.0f + 10000.0f); - break; - - default: - val_min = static_cast((i) / 240 * 3000); - } - -// !!! FIXME + // float f = 5000.0f * sinf(static_cast(PI)/120.0f * static_cast(i)) + 5000.0f; + // switch(j){ + // case 0: + // val_min = static_cast(f); + // break; + + // case 1: + // val_min = static_cast(f * -1.0f + 10000.0f); + // break; + + // default: + // val_min = static_cast((i) / 240 * 3000); + // } // Use negative state to mark that these are pre-filled. history[j].push(val_min); } @@ -173,7 +170,7 @@ void MultiValueHistory::add_sample(float sample[MULTI_VALUE_HISTORY_NUMBER_OF_VA for(int j = 0; j < MULTI_VALUE_HISTORY_NUMBER_OF_VALUES; ++j){ val[j] = clamp(static_cast(MULTI_VALUE_HISTORY_VALUE_MIN), - static_cast(roundf(sample[MULTI_VALUE_HISTORY_NUMBER_OF_VALUES])), + static_cast(roundf(sample[j])), static_cast(MULTI_VALUE_HISTORY_VALUE_MAX)); live[j].push(val[j]); } diff --git a/software/src/modules/phase_switcher/multi_value_history.h b/software/src/modules/phase_switcher/multi_value_history.h index 1e95f6d26..ed9e0dd72 100644 --- a/software/src/modules/phase_switcher/multi_value_history.h +++ b/software/src/modules/phase_switcher/multi_value_history.h @@ -29,8 +29,9 @@ #include "task_scheduler.h" #include "web_server.h" +// !!! FIXME // How many hours to keep the coarse history for -#define MULTI_VALUE_HISTORY_HOURS 48 +#define MULTI_VALUE_HISTORY_HOURS 36 // How many minutes to keep the fine history for. // This also controls the coarseness of the coarse history. // For example 4 means that we accumulate 4 minutes of samples @@ -39,7 +40,8 @@ // When we have 4 minutes worth of samples, we take the average // and add it to the coarse history. // #define MULTI_VALUE_HISTORY_MINUTE_INTERVAL 4 -#define MULTI_VALUE_HISTORY_MINUTE_INTERVAL 4 +// !!! FIXME +#define MULTI_VALUE_HISTORY_MINUTE_INTERVAL 3 #define MULTI_VALUE_RING_BUF_SIZE (MULTI_VALUE_HISTORY_HOURS * 60 / MULTI_VALUE_HISTORY_MINUTE_INTERVAL) diff --git a/software/src/modules/phase_switcher/phase_switcher.h b/software/src/modules/phase_switcher/phase_switcher.h index 526d28f41..11f996cb6 100644 --- a/software/src/modules/phase_switcher/phase_switcher.h +++ b/software/src/modules/phase_switcher/phase_switcher.h @@ -27,7 +27,6 @@ #include "delay_timer.h" #include "multi_value_history.h" -// #include "../meter/value_history.h" #define EVSE_START_TIMEOUT 60000 #define EVSE_START_RETRIES 3 @@ -170,9 +169,5 @@ class PhaseSwitcher final : public IModule bool contactor_error; MultiValueHistory power_history; - // ValueHistory available_charging_power_history; - // ValueHistory actual_charging_power_history; - // ValueHistory requested_phases_history; - }; diff --git a/software/web/src/modules/phase_switcher/main.tsx b/software/web/src/modules/phase_switcher/main.tsx index d9a836a21..4c614289d 100644 --- a/software/web/src/modules/phase_switcher/main.tsx +++ b/software/web/src/modules/phase_switcher/main.tsx @@ -479,7 +479,7 @@ function calculate_live_data(offset: number, samples_per_second: number, samples } function calculate_history_data(offset: number, samples: number[][]): UplotData { - const HISTORY_MINUTE_INTERVAL = 4; + const HISTORY_MINUTE_INTERVAL = 3; let data: UplotData = {timestamps: new Array(samples[0].length), samples: samples}; let now = Date.now(); @@ -491,14 +491,6 @@ function calculate_history_data(offset: number, samples: number[][]): UplotData // sampling interval let start = Math.round((now - (samples[0].length - 1) * step - offset) / step) * step; -// FIXME - for(let i = 1; i < samples.length; ++i){ - if (samples[i].length != samples[0].length) { - console.log("ERROR: phase_switcher calculate_live_data: samples arrays do not have the same length!") - } - } -// FIXME - for(let i = 0; i < samples[0].length; ++i) { data.timestamps[i] = (start + i * step) / 1000; } @@ -580,39 +572,20 @@ export class PhaseSwitcher extends ConfigComponent<'phase_switcher/config', {}, if (this.state.chart_selected == "history") { this.update_uplot(); } -// !!! FIXME - console.log("phase_switcher/history:"); - for (let i = 0; i<3; ++i){ - console.log("phase_switcher/history:" + this.history_data.samples[i]); - console.log("--"); - } -// !!! FIXME }); util.addApiEventListener("phase_switcher/history_samples", () => { let history = API.get("phase_switcher/history_samples"); - let samples: number[][]; + let samples: number[][] = [[], [], []]; - console.log("phase_switcher/history_samples 1"); for(let value_index = 0; value_index < history.samples.length; ++value_index){ - console.log("phase_switcher/history_samples 1 loop " + value_index); samples[value_index] = array_append(this.history_data.samples[value_index], history.samples[value_index], 720); } - console.log("phase_switcher/history_samples 2"); this.history_data = calculate_history_data(0, samples); - console.log("phase_switcher/history_samples 3"); if (this.state.chart_selected == "history") { - console.log("phase_switcher/history_samples 4"); this.update_uplot(); } -// !!! FIXME - console.log("phase_switcher/history_samples:"); - for (let i = 0; i<3; ++i){ - console.log("phase_switcher/history_samples:" + this.history_data.samples[i]); - console.log("--"); - } -// !!! FIXME }); this.state = {