diff --git a/source/base/CMakeLists.txt b/source/base/CMakeLists.txt index 9f88995..34d7b53 100644 --- a/source/base/CMakeLists.txt +++ b/source/base/CMakeLists.txt @@ -3,7 +3,7 @@ set(GLOBALS_DIR ${PROJECT_SOURCE_DIR}/source/charging_models) option(ICM "compile caldera_ICM library" OFF) if(ICM) - add_library(Caldera_ICM_lib datatypes_module.cpp ac_to_dc_converter.cpp helper.cpp battery_calculate_limits.cpp + add_library(Caldera_ICM_lib STATIC datatypes_module.cpp ac_to_dc_converter.cpp helper.cpp battery_calculate_limits.cpp battery_integrate_X_in_time.cpp battery.cpp vehicle_charge_model.cpp supply_equipment_load.cpp supply_equipment_control.cpp supply_equipment.cpp supply_equipment_group.cpp charge_profile_library.cpp SE_EV_factory_charge_profile.cpp charge_profile_downsample_fragments.cpp ICM_interface.cpp @@ -23,7 +23,7 @@ if(ICM) DESTINATION ${INSTALL_DIR}) endif() -add_library(Caldera_ICM_Aux_lib datatypes_module.cpp ac_to_dc_converter.cpp helper.cpp battery_calculate_limits.cpp +add_library(Caldera_ICM_Aux_lib STATIC datatypes_module.cpp ac_to_dc_converter.cpp helper.cpp battery_calculate_limits.cpp battery_integrate_X_in_time.cpp battery.cpp vehicle_charge_model.cpp supply_equipment_load.cpp supply_equipment_control.cpp supply_equipment.cpp charge_profile_library.cpp SE_EV_factory_charge_profile.cpp charge_profile_downsample_fragments.cpp Aux_interface.cpp diff --git a/source/base/charge_profile_library.h b/source/base/charge_profile_library.h index 110ef54..5eeb824 100644 --- a/source/base/charge_profile_library.h +++ b/source/base/charge_profile_library.h @@ -51,6 +51,11 @@ class pev_charge_profile_aux { return this->setpoint_P3kW < x.setpoint_P3kW; } + + bool operator<(pev_charge_profile_aux& x) const + { + return this->setpoint_P3kW < x.setpoint_P3kW; + } }; diff --git a/source/base/helper.h b/source/base/helper.h index 7a33db7..356352a 100644 --- a/source/base/helper.h +++ b/source/base/helper.h @@ -21,7 +21,12 @@ struct line_segment double y_LB() const {return this->a*this->x_LB + this->b;} double y(double x) const {return this->a*x + this->b;} - bool operator < (const line_segment& rhs) const + bool operator<(const line_segment& rhs) const + { + return this->x_LB < rhs.x_LB; + } + + bool operator<(line_segment& rhs) const { return this->x_LB < rhs.x_LB; } @@ -53,7 +58,12 @@ struct poly_segment double d; double e; - bool operator<(const poly_segment &rhs) + bool operator<(const poly_segment &rhs) const + { + return x_LB < rhs.x_LB; + } + + bool operator<(poly_segment &rhs) const { return x_LB < rhs.x_LB; } @@ -304,6 +314,11 @@ struct dcfc_charge_event { return arrival_unix_time < x.arrival_unix_time; } + + bool operator<(dcfc_charge_event& x) const + { + return arrival_unix_time < x.arrival_unix_time; + } }; diff --git a/source/base/supply_equipment_control.cpp b/source/base/supply_equipment_control.cpp index 43b5ef9..f0edf22 100644 --- a/source/base/supply_equipment_control.cpp +++ b/source/base/supply_equipment_control.cpp @@ -32,7 +32,7 @@ void ES100_control_strategy::update_parameters_for_CE(double target_P3kW_, const double arrival_unix_time = charge_status.arrival_unix_time; double departure_unix_time = charge_status.departure_unix_time; - + pev_charge_profile_result Z = charge_profile->find_result_given_startSOC_and_endSOC(this->target_P3kW, charge_status.now_soc, charge_status.departure_SOC); double min_time_to_charge_sec = 3600*Z.total_charge_time_hrs; @@ -86,12 +86,18 @@ void ES100_control_strategy::update_parameters_for_CE(double target_P3kW_, const double time_ahead_of_midnight_sec = fmod(arrival_unix_time, 24.0*3600.0); double midnight_nearest_arrival_unix_time = arrival_unix_time - time_ahead_of_midnight_sec; - if(time_ahead_of_midnight_sec > 12.0*3600.0) - midnight_nearest_arrival_unix_time += 24.0*3600.0; + + // midnight_nearest_arrival_unix_time moves a day ahead when it crosses 12, doesn't work with intra day TOU period + //if(time_ahead_of_midnight_sec > 12.0*3600.0) + // midnight_nearest_arrival_unix_time += 24.0*3600.0; double beginning_of_TofU_rate_period_unix_time = midnight_nearest_arrival_unix_time + beginning_of_TofU_rate_period__time_from_midnight_sec; double end_of_TofU_rate_period_unix_time = midnight_nearest_arrival_unix_time + end_of_TofU_rate_period__time_from_midnight_sec; + // Fixes TOU rate period when end TOU is smaller than start TOU. i.e intra day TOU. e.g. (8, -6) aka (8, 18) + if (end_of_TofU_rate_period_unix_time < beginning_of_TofU_rate_period_unix_time) + end_of_TofU_rate_period_unix_time += 24.0 * 3600; + //----------------------------------------- // Calculate this->charge_start_unix_time //----------------------------------------- diff --git a/source/charging_models/CMakeLists.txt b/source/charging_models/CMakeLists.txt index 333b069..29ba7ba 100644 --- a/source/charging_models/CMakeLists.txt +++ b/source/charging_models/CMakeLists.txt @@ -1,5 +1,5 @@ -add_library(Caldera_global_lib datatypes_global.cpp ${PROJECT}/datatypes_global_SE_EV_definitions.cpp) +add_library(Caldera_global_lib STATIC datatypes_global.cpp ${PROJECT}/datatypes_global_SE_EV_definitions.cpp) target_include_directories(Caldera_global_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(Caldera_global_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT}) diff --git a/source/charging_models/DirectXFC/SE_EV_factory.h b/source/charging_models/DirectXFC/SE_EV_factory.h index b922492..ba6a277 100644 --- a/source/charging_models/DirectXFC/SE_EV_factory.h +++ b/source/charging_models/DirectXFC/SE_EV_factory.h @@ -50,7 +50,12 @@ class factory_EV_charge_model double puVrms; double P2_val; - bool operator<(const point_P2_vs_puVrms& rhs) + bool operator<(const point_P2_vs_puVrms& rhs) const + { + return (this->puVrms < rhs.puVrms); + } + + bool operator<(point_P2_vs_puVrms& rhs) const { return (this->puVrms < rhs.puVrms); } diff --git a/source/charging_models/DirectXFC/datatypes_global_SE_EV_definitions.cpp b/source/charging_models/DirectXFC/datatypes_global_SE_EV_definitions.cpp index 8811b71..af5d456 100644 --- a/source/charging_models/DirectXFC/datatypes_global_SE_EV_definitions.cpp +++ b/source/charging_models/DirectXFC/datatypes_global_SE_EV_definitions.cpp @@ -93,16 +93,16 @@ std::pair get_supply_equipment_enum(const std::stri if (!std::isspace(str_val[i])) tmp_str += str_val[i]; - if (tmp_str == "1") SE_enum = L1_1440; - else if (tmp_str == "2") SE_enum = L2_3600; - else if (tmp_str == "3") SE_enum = L2_7200; - else if (tmp_str == "4") SE_enum = L2_9600; - else if (tmp_str == "5") SE_enum = L2_11520; - else if (tmp_str == "20") SE_enum = L2_17280; + if (tmp_str == "1" || tmp_str == "L1_1440") SE_enum = L1_1440; + else if (tmp_str == "2" || tmp_str == "L2_3600") SE_enum = L2_3600; + else if (tmp_str == "3" || tmp_str == "L2_7200") SE_enum = L2_7200; + else if (tmp_str == "4" || tmp_str == "L2_9600") SE_enum = L2_9600; + else if (tmp_str == "5" || tmp_str == "L2_11520") SE_enum = L2_11520; + else if (tmp_str == "20" || tmp_str == "L2_17280") SE_enum = L2_17280; - else if (tmp_str == "6") SE_enum = dcfc_50; - else if (tmp_str == "7") SE_enum = xfc_150; - else if (tmp_str == "8") SE_enum = xfc_350; + else if (tmp_str == "6" || tmp_str == "dcfc_50") SE_enum = dcfc_50; + else if (tmp_str == "7" || tmp_str == "xfc_150") SE_enum = xfc_150; + else if (tmp_str == "8" || tmp_str == "xfc_350") SE_enum = xfc_350; else { conversion_successfull = false; @@ -164,22 +164,22 @@ std::pair get_vehicle_enum(const std::string str_val) tmp_str += str_val[i]; // Recharge - if (tmp_str == "1") pev_enum = bev250_ld2_300kW; - else if (tmp_str == "2") pev_enum = bev200_ld4_150kW; - else if (tmp_str == "3") pev_enum = bev275_ld1_150kW; - else if (tmp_str == "4") pev_enum = bev250_ld1_75kW; - else if (tmp_str == "5") pev_enum = bev150_ld1_50kW; - else if (tmp_str == "6") pev_enum = phev_SUV; - else if (tmp_str == "7") pev_enum = phev50; - else if (tmp_str == "8") pev_enum = phev20; + if (tmp_str == "1" || tmp_str == "bev250_ld2_300kW") pev_enum = bev250_ld2_300kW; + else if (tmp_str == "2" || tmp_str == "bev200_ld4_150kW") pev_enum = bev200_ld4_150kW; + else if (tmp_str == "3" || tmp_str == "bev275_ld1_150kW") pev_enum = bev275_ld1_150kW; + else if (tmp_str == "4" || tmp_str == "bev250_ld1_75kW") pev_enum = bev250_ld1_75kW; + else if (tmp_str == "5" || tmp_str == "bev150_ld1_50kW") pev_enum = bev150_ld1_50kW; + else if (tmp_str == "6" || tmp_str == "phev_SUV") pev_enum = phev_SUV; + else if (tmp_str == "7" || tmp_str == "phev50") pev_enum = phev50; + else if (tmp_str == "8" || tmp_str == "phev20") pev_enum = phev20; // DirectXFC - else if (tmp_str == "9") pev_enum = bev250_400kW; - else if (tmp_str == "10") pev_enum = bev300_575kW; - else if (tmp_str == "11") pev_enum = bev300_400kW; - else if (tmp_str == "12") pev_enum = bev250_350kW; - else if (tmp_str == "13") pev_enum = bev300_300kW; - else if (tmp_str == "14") pev_enum = bev150_150kW; + else if (tmp_str == "9" || tmp_str == "bev250_400kW") pev_enum = bev250_400kW; + else if (tmp_str == "10" || tmp_str == "bev300_575kW") pev_enum = bev300_575kW; + else if (tmp_str == "11" || tmp_str == "bev300_400kW") pev_enum = bev300_400kW; + else if (tmp_str == "12" || tmp_str == "bev250_350kW") pev_enum = bev250_350kW; + else if (tmp_str == "13" || tmp_str == "bev300_300kW") pev_enum = bev300_300kW; + else if (tmp_str == "14" || tmp_str == "bev150_150kW") pev_enum = bev150_150kW; else { conversion_successfull = false; diff --git a/source/charging_models/EVs_at_Risk/SE_EV_factory.h b/source/charging_models/EVs_at_Risk/SE_EV_factory.h index 6613a13..8ff67a1 100644 --- a/source/charging_models/EVs_at_Risk/SE_EV_factory.h +++ b/source/charging_models/EVs_at_Risk/SE_EV_factory.h @@ -50,7 +50,12 @@ class factory_EV_charge_model double puVrms; double P2_val; - bool operator<(const point_P2_vs_puVrms& rhs) + bool operator<(const point_P2_vs_puVrms& rhs) const + { + return (this->puVrms < rhs.puVrms); + } + + bool operator<(point_P2_vs_puVrms& rhs) const { return (this->puVrms < rhs.puVrms); } diff --git a/source/charging_models/datatypes_global.h b/source/charging_models/datatypes_global.h index 13d438c..65b1ac5 100644 --- a/source/charging_models/datatypes_global.h +++ b/source/charging_models/datatypes_global.h @@ -338,6 +338,11 @@ struct charge_event_data { return this->arrival_unix_time < rhs.arrival_unix_time; } + + bool operator<(charge_event_data& rhs) const + { + return this->arrival_unix_time < rhs.arrival_unix_time; + } }; std::ostream& operator<<(std::ostream& out, const charge_event_data& x); @@ -554,7 +559,12 @@ struct pev_charge_fragment pev_charge_fragment() {}; pev_charge_fragment(double soc_, double E1_kWh_, double E2_kWh_, double E3_kWh_, double cumQ3_kVARh_, double time_since_charge_began_hrs_); - bool operator<(const pev_charge_fragment &rhs) + bool operator<(const pev_charge_fragment &rhs) const + { + return (this->time_since_charge_began_hrs < rhs.time_since_charge_began_hrs); + } + + bool operator<(pev_charge_fragment &rhs) const { return (this->time_since_charge_began_hrs < rhs.time_since_charge_began_hrs); } diff --git a/source/charging_models/eMosaic/SE_EV_factory.h b/source/charging_models/eMosaic/SE_EV_factory.h index 0f70a82..616eb84 100644 --- a/source/charging_models/eMosaic/SE_EV_factory.h +++ b/source/charging_models/eMosaic/SE_EV_factory.h @@ -50,7 +50,12 @@ class factory_EV_charge_model double puVrms; double P2_val; - bool operator<(const point_P2_vs_puVrms& rhs) + bool operator<(const point_P2_vs_puVrms& rhs) const + { + return (this->puVrms < rhs.puVrms); + } + + bool operator<(point_P2_vs_puVrms& rhs) const { return (this->puVrms < rhs.puVrms); } diff --git a/source/pev_charge_profile_factory/create_library/pev_charge_profile_factory.h b/source/pev_charge_profile_factory/create_library/pev_charge_profile_factory.h index a634b46..ab88233 100644 --- a/source/pev_charge_profile_factory/create_library/pev_charge_profile_factory.h +++ b/source/pev_charge_profile_factory/create_library/pev_charge_profile_factory.h @@ -63,7 +63,12 @@ struct Ppu_vs_soc_point double P_pu; Ppu_vs_soc_point_type point_type; - bool operator<(const Ppu_vs_soc_point& rhs) + bool operator<(const Ppu_vs_soc_point& rhs) const + { + return soc < rhs.soc; + } + + bool operator<(Ppu_vs_soc_point& rhs) const { return soc < rhs.soc; } @@ -80,7 +85,12 @@ struct line_segment double y_UB() {return a*x_UB + b;} double y_LB() {return a*x_LB + b;} - bool operator < (const line_segment& rhs) + bool operator<(const line_segment& rhs) const + { + return this->x_LB < rhs.x_LB; + } + + bool operator<(line_segment& rhs) const { return this->x_LB < rhs.x_LB; } @@ -101,7 +111,12 @@ class Ppu_vs_soc_curve double get_current_rate_amps(double bat_capacity_Ah_1C); const std::vector& get_points(); - bool operator<(const Ppu_vs_soc_curve& rhs) + bool operator<(const Ppu_vs_soc_curve& rhs) const + { + return C_rate < rhs.C_rate; + } + + bool operator<(Ppu_vs_soc_curve& rhs) const { return C_rate < rhs.C_rate; }