Skip to content

Commit

Permalink
Add configuration for track conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarBLG committed Dec 20, 2024
1 parent 4a2bfe5 commit 47d3814
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 9 deletions.
14 changes: 14 additions & 0 deletions EVC/Config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ void load_config(std::string serie)
automatic_eddy_inhibition = cfg.value("AutomaticEddyCurrentBrakeInhibition", false);
automatic_magnetic_inhibition = cfg.value("AutomaticMagneticShoeBrakeInhibition", false);
automatic_regenerative_inhibition = cfg.value("AutomaticRegenerativeBrakeInhibition", false);
T_open_mps = cfg.value("OpenMainPowerSwitchTime", 11);
D_open_mps = cfg.value("OpenMainPowerSwitchDistance", 0);
T_lower_pantograph = cfg.value("LowerPantographTime", 20);
D_lower_pantograph = cfg.value("LowerPantographDistance", 0);
T_brake_inhibit = cfg.value("BrakeInhibitionTime", 11);
D_brake_inhibit = cfg.value("BrakeInhibitionDistance", 0);
T_air_tightness = cfg.value("AirTightnessTime", 11);
D_air_tightness = cfg.value("AirTightnessDistance", 0);
T_traction_system_change = cfg.value("TractionSystemChangeTime", 20);
D_traction_system_change = cfg.value("TractionSystemChangeDistance", 0);
T_current_consumption_change = cfg.value("CurrentConsumptionChangeTime", 11);
D_current_consumption_change = cfg.value("CurrentConsumptionChangeDistance", 0);
T_station_platform = cfg.value("StationPlatformTime", 0);
D_station_platform = cfg.value("StationPlatformDistance", 500);
asc_fitted = cfg.value("AutomaticSpeedControl", false);
L_antenna_front = cfg.value("AntennaOffset", 0.0);
L_locomotive = cfg.value("RearCabOffset", 0.0);
Expand Down
4 changes: 2 additions & 2 deletions EVC/OR_interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

using std::string;
extern double V_est;
double V_set;
int V_set_display = -1;
extern double V_set;
extern int V_set_display;
extern int data_entry_type;
extern int data_entry_type_tiu;
extern bool bot_driver;
Expand Down
12 changes: 6 additions & 6 deletions EVC/TrackConditions/track_conditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void update_track_conditions()
}
}
} else if (c->condition == TrackConditions::PowerLessSectionSwitchMainPowerSwitch) {
distance pointC = c->start - V_est * 10;
distance pointC = c->start - std::max(V_est * T_open_mps, D_open_mps);
dist_base max = d_maxsafefront(c->start);
dist_base min = d_minsafefront(c->start);
distance &pointD = c->start;
Expand All @@ -127,7 +127,7 @@ void update_track_conditions()
c->order = false;
}
} else if (c->condition == TrackConditions::PowerLessSectionLowerPantograph) {
distance pointC = c->start - V_est * 20;
distance pointC = c->start - std::max(V_est * T_lower_pantograph, D_lower_pantograph);
dist_base max = d_maxsafefront(c->start);
dist_base min = d_minsafefront(c->start);
distance &pointD = c->start;
Expand Down Expand Up @@ -184,7 +184,7 @@ void update_track_conditions()
c->order = false;
}
} else if (c->condition == TrackConditions::ChangeOfTractionSystem) {
distance pointC = c->start - V_est * 20;
distance pointC = c->start - std::max(V_est * T_traction_system_change, D_traction_system_change);
dist_base max = d_maxsafefront(c->start);
dist_base min = d_minsafefront(c->start) - L_TRAIN;
distance &pointF = c->start;
Expand All @@ -208,7 +208,7 @@ void update_track_conditions()
c->order = true;
}
} else if (c->condition == TrackConditions::ChangeOfAllowedCurrentConsumption) {
distance pointC = c->start - V_est * 20;
distance pointC = c->start - std::max(V_est * T_current_consumption_change, D_current_consumption_change);
dist_base max = d_maxsafefront(c->start);
dist_base min = d_minsafefront(c->start) - L_TRAIN;
distance &pointF = c->start;
Expand All @@ -231,7 +231,7 @@ void update_track_conditions()
c->condition == TrackConditions::SwitchOffEddyCurrentServiceBrake ||
c->condition == TrackConditions::SwitchOffMagneticShoe ||
c->condition == TrackConditions::SwitchOffRegenerativeBrake) {
distance pointC = c->start - V_est * 20;
distance pointC = c->start - std::max(V_est * T_brake_inhibit, D_brake_inhibit);
dist_base max = d_maxsafefront(c->start);
dist_base min = d_minsafefront(c->start) - L_TRAIN;
distance &pointD = c->start;
Expand All @@ -257,7 +257,7 @@ void update_track_conditions()
c->order = false;
}
} else if (c->condition == TrackConditions::StationPlatform) {
distance pointC = c->start - V_est * 20;
distance pointC = c->start - std::max(V_est * T_station_platform, D_station_platform);
dist_base max = d_maxsafefront(c->start);
dist_base min = d_minsafefront(c->start) - L_TRAIN;
distance &pointD = c->start;
Expand Down
17 changes: 16 additions & 1 deletion EVC/TrainSubsystems/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,24 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "power.h"
bool automatic_close_power_switch=true;
bool automatic_open_power_switch=true;
bool automatic_raise_pantograph=false;
bool automatic_lower_pantograph=false;
bool automatic_traction_system_change=false;
bool traction_cutoff_implemented=true;
bool traction_cutoff_implemented=true;
double T_open_mps = 11;
double D_open_mps;
double T_lower_pantograph = 20;
double D_lower_pantograph;
double T_brake_inhibit;
double D_brake_inhibit;
double T_air_tightness=11;
double D_air_tightness;
double T_traction_system_change = 20;
double D_traction_system_change;
double T_current_consumption_change = 5;
double D_current_consumption_change;
double T_station_platform;
double D_station_platform = 500;
15 changes: 15 additions & 0 deletions EVC/TrainSubsystems/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,25 @@
*/
#include "../Position/distance.h"
#include "../optional.h"
#include "../TrackConditions/track_condition.h"
extern bool automatic_close_power_switch;
extern bool automatic_open_power_switch;
extern bool automatic_raise_pantograph;
extern bool automatic_lower_pantograph;
extern bool automatic_traction_system_change;
extern bool traction_cutoff_implemented;
extern double T_open_mps;
extern double D_open_mps;
extern double T_lower_pantograph;
extern double D_lower_pantograph;
extern double T_brake_inhibit;
extern double D_brake_inhibit;
extern double T_air_tightness;
extern double D_air_tightness;
extern double T_traction_system_change;
extern double D_traction_system_change;
extern double T_current_consumption_change;
extern double D_current_consumption_change;
extern double T_station_platform;
extern double D_station_platform;
void update_power_status();
57 changes: 57 additions & 0 deletions EVC/TrainSubsystems/train_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ bool isolated;
bool failed;
bool SB_command;
bool EB_command;
int V_set_display = -1;
double V_set;
double brake_pressure;
int reverser_direction;
extern int data_entry_type;
extern int data_entry_type_tiu;
bool traction_cutoff_active;
bool ep_brake_available=true;
bool eddy_brake_available=true;
Expand Down Expand Up @@ -153,4 +157,57 @@ void update_train_interface()
obu_json["OBU_TR_ServiceBrake"] = SB_command;

obu_tr_status = obu_json.dump();
}
void handle_tr_inputs(json &j)
{
if (j.contains("TR_OBU_TrainSleep") && j.contains("TR_OBU_TrainSleep_Not"))
sl_signal = j["TR_OBU_Train_Sleep"] && !j["TR_OBU_TrainSleep_Not"];
if (j.contains("TR_OBU_PassiveShunting"))
ps_signal = j["TR_OBU_PassiveShunting"];
if (j.contains("TR_OBU_NLEnabled"))
nl_signal = j["TR_OBU_NLEnabled"];
if (j.contains("TR_OBU_CabStatusA"))
cab_active[0] = j["TR_OBU_CabStatusA"];
if (j.contains("TR_OBU_CabStatusB"))
cab_active[1] = j["TR_OBU_CabStatusB"];
if (j.contains("TR_OBU_TypeTrainData_S1") && j.contains("TR_OBU_TypeTrainData_S2")) {
data_entry_type_tiu = j["TR_OBU_TypeTrainData_S1"].get<bool>()*2 + j["TR_OBU_TypeTrainData_S2"].get<bool>() - 1;
if (data_entry_type_tiu >= 0) {
if (platform->read_file(traindata_file))
data_entry_type = data_entry_type_tiu;
else
data_entry_type = 0;
}
}
//if (j.contains("TR_OBU_TractionStatus"))
//if (j.contains("TR_OBU_AirTightFitted"))
if (j.contains("TR_OBU_SetSpeedDisplay"))
V_set_display = j["TR_OBU_SetSpeedDisplay"];
if (j.contains("TR_OBU_BrakePressure"))
brake_pressure = j["TR_OBU_BrakePressure"];
if (j.contains("TR_OBU_Brake_Status")) {
json &stat = j["TR_OBU_Brake_Status"];
if (stat.contains("EP_S") && stat.contains("EP_S_NOT"))
ep_brake_available = stat["EP_S"] && !stat["EP_S_NOT"];
if (stat.contains("EC_S") && stat.contains("EC_S_NOT"))
eddy_brake_available = stat["EC_S"] && !stat["EC_S_NOT"];
if (stat.contains("RB_S") && stat.contains("RB_S_NOT"))
regenerative_brake_available = stat["RB_S"] && !stat["RB_S_NOT"];
if (stat.contains("MG_S") && stat.contains("MG_S_NOT"))
magnetic_brake_available = stat["MG_S"] && !stat["MG_S_NOT"];
}
if (j.contains("TR_OBU_NTCIsolated")) {
for (auto &ntc : j["TR_OBU_NTCIsolated"]) {
int id = ntc["NID_NTC"];
bool isolated = ntc["T_IS"];
if (installed_stms.count(id))
installed_stms[id]->isolated = isolated;
}
}
if (j.contains("TR_OBU_SetSpeedValue"))
V_set = j["TR_OBU_SetSpeedValue"];
}
void handle_tr_train_data(json &data)
{

}

0 comments on commit 47d3814

Please sign in to comment.