17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 00:47:56 +01:00

Remake engine voltage value calculation

This commit is contained in:
2026-09-10 23:51:44 +02:00
parent fe63154ffa
commit 63f322fa7b
3 changed files with 38 additions and 21 deletions

View File

@@ -125,6 +125,10 @@ state_registry::state_registry()
add( "hv_current_1", value_type::float32, "A", -5000.0, 5000.0, []( state_snapshot const &s ) { return make_value( s, value_type::float32, s.train.hv_current[ 0 ], s.electric ); } ); add( "hv_current_1", value_type::float32, "A", -5000.0, 5000.0, []( state_snapshot const &s ) { return make_value( s, value_type::float32, s.train.hv_current[ 0 ], s.electric ); } );
add( "hv_current_2", value_type::float32, "A", -5000.0, 5000.0, []( state_snapshot const &s ) { return make_value( s, value_type::float32, s.train.hv_current[ 1 ], s.electric ); } ); add( "hv_current_2", value_type::float32, "A", -5000.0, 5000.0, []( state_snapshot const &s ) { return make_value( s, value_type::float32, s.train.hv_current[ 1 ], s.electric ); } );
add( "hv_current_3", value_type::float32, "A", -5000.0, 5000.0, []( state_snapshot const &s ) { return make_value( s, value_type::float32, s.train.hv_current[ 2 ], s.electric ); } ); add( "hv_current_3", value_type::float32, "A", -5000.0, 5000.0, []( state_snapshot const &s ) { return make_value( s, value_type::float32, s.train.hv_current[ 2 ], s.electric ); } );
// what the cab's engine voltage gauge shows: the supply voltage less the drop on the starting
// resistor, divided between the motor branches - and a current derived reading while the
// dynamic brake is applied, exactly as the needle in the cab behaves
add( "engine_voltage", value_type::float32, "V", 0.0, 40000.0, []( state_snapshot const &s ) { return make_value( s, value_type::float32, s.train.engine_voltage, s.electric ); } );
add( "lv_voltage", value_type::float32, "V", 0.0, 200.0, []( state_snapshot const &s ) { return make_value( s, value_type::float32, s.train.lv_voltage ); } ); add( "lv_voltage", value_type::float32, "V", 0.0, 200.0, []( state_snapshot const &s ) { return make_value( s, value_type::float32, s.train.lv_voltage ); } );
add( "distance", value_type::float64, "m", {}, {}, []( state_snapshot const &s ) { return make_value( s, value_type::float64, s.train.distance ); } ); add( "distance", value_type::float64, "m", {}, {}, []( state_snapshot const &s ) { return make_value( s, value_type::float64, s.train.distance ); } );

View File

@@ -922,6 +922,35 @@ std::shared_ptr<dictionary_source> TTrain::GetTrainState(dictionary_source const
return dict; return dict;
} }
// youBy - napiecie na silnikach
// liczone tutaj, a nie przy samym mierniku, zeby ten sam odczyt trafial rowniez do protokolu
// sprzetowego, takze w pojezdzie, ktorego model kabiny woltomierza silnikowego nie ma
double TTrain::get_engine_voltage() const
{
if (mvControlled == nullptr)
{
return 0.0;
}
if (true == mvControlled->DynamicBrakeFlag)
{
// przy hamowaniu oporowym ten sam miernik pokazuje prad silnikow, a nie napiecie
return std::abs(mvControlled->Im * 5);
}
auto const &circuit = mvControlled->RList[mvControlled->MainCtrlActualPos];
if ((circuit.Mn <= 0) || (std::abs(mvControlled->Im) <= 0))
{
// bez pradu w obwodzie nie ma czego wskazywac
return 0.0;
}
int const x = ((mvControlled->TrainType == dt_ET42) && (mvControlled->Imax == mvControlled->ImaxHi) ? 1 : 2);
// napiecie zasilania pomniejszone o spadek na rozruszniku, rozlozone na galezie silnikow
return x * (std::abs(mvControlled->EngineVoltage) - circuit.R * std::abs(mvControlled->Im)) / circuit.Mn;
}
TTrain::state_t TTrain::get_state() const TTrain::state_t TTrain::get_state() const
{ {
@@ -953,6 +982,7 @@ TTrain::state_t TTrain::get_state() const
static_cast<float>(mvPantographUnit->PantPress), static_cast<float>(mvPantographUnit->PantPress),
fHVoltage, fHVoltage,
{fHCurrent[mvControlled->TrainType & dt_EZT ? 0 : 1], fHCurrent[2], fHCurrent[3]}, {fHCurrent[mvControlled->TrainType & dt_EZT ? 0 : 1], fHCurrent[2], fHCurrent[3]},
static_cast<float>(get_engine_voltage()),
ggLVoltage.GetValue(), ggLVoltage.GetValue(),
mvOccupied->DistCounter, mvOccupied->DistCounter,
static_cast<std::uint8_t>(RadioChannel()), static_cast<std::uint8_t>(RadioChannel()),
@@ -8913,27 +8943,7 @@ bool TTrain::Update(double const Deltatime)
// youBy - napiecie na silnikach // youBy - napiecie na silnikach
if (ggEngineVoltage.SubModel) if (ggEngineVoltage.SubModel)
{ {
if (mvControlled->DynamicBrakeFlag) ggEngineVoltage.UpdateValue(get_engine_voltage());
{
ggEngineVoltage.UpdateValue(std::abs(mvControlled->Im * 5));
}
else
{
int x;
if (mvControlled->TrainType == dt_ET42 && mvControlled->Imax == mvControlled->ImaxHi)
x = 1;
else
x = 2;
if (mvControlled->RList[mvControlled->MainCtrlActualPos].Mn > 0 && std::abs(mvControlled->Im) > 0)
{
ggEngineVoltage.UpdateValue(x * (std::abs(mvControlled->EngineVoltage) - mvControlled->RList[mvControlled->MainCtrlActualPos].R * std::abs(mvControlled->Im)) /
mvControlled->RList[mvControlled->MainCtrlActualPos].Mn);
}
else
{
ggEngineVoltage.UpdateValue(0);
}
}
ggEngineVoltage.Update(); ggEngineVoltage.Update();
} }

View File

@@ -108,6 +108,7 @@ class TTrain {
float pantograph_pressure; float pantograph_pressure;
float hv_voltage; float hv_voltage;
std::array<float, 3> hv_current; std::array<float, 3> hv_current;
float engine_voltage;
float lv_voltage; float lv_voltage;
double distance; double distance;
std::uint8_t radio_channel; std::uint8_t radio_channel;
@@ -173,6 +174,8 @@ class TTrain {
bool LoadMMediaFile(std::string const &asFileName); bool LoadMMediaFile(std::string const &asFileName);
std::shared_ptr<dictionary_source> GetTrainState( dictionary_source const &Extraparameters ); std::shared_ptr<dictionary_source> GetTrainState( dictionary_source const &Extraparameters );
state_t get_state() const; state_t get_state() const;
// wskazanie woltomierza silnikowego; wspolne dla miernika w kabinie i protokolu sprzetowego
double get_engine_voltage() const;
inline float get_radiovolume() const { return m_radiovolume; } inline float get_radiovolume() const { return m_radiovolume; }
// basic_table interface // basic_table interface
inline inline