mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 20:59:19 +02:00
Dodana lampka czuwaka/shp (2 w 1), dodany dźwięk/wskazówka stycznika EP zależny od stopnia zahamowania, poszerzenie zakresu informacji wyjściowych UART na potrzeby pulpitu EZT, poprawka dźwięku hamulca pomocniczego, poprawka pozycjonowania dźwięków w kabinach, dodane sterowanie procentowe po UART
This commit is contained in:
@@ -732,6 +732,12 @@ global_settings::ConfigParse(cParser &Parser) {
|
|||||||
Parser.getTokens(1);
|
Parser.getTokens(1);
|
||||||
Parser >> uart_conf.debug;
|
Parser >> uart_conf.debug;
|
||||||
}
|
}
|
||||||
|
else if (token == "uartmainpercentage")
|
||||||
|
{
|
||||||
|
Parser.getTokens(1);
|
||||||
|
Parser >> uart_conf.mainpercentage;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_EXTCAM_CAMERA
|
#ifdef USE_EXTCAM_CAMERA
|
||||||
else if (token == "extcam.cmd")
|
else if (token == "extcam.cmd")
|
||||||
|
|||||||
112
Train.cpp
112
Train.cpp
@@ -774,39 +774,50 @@ dictionary_source *TTrain::GetTrainState( dictionary_source const &Extraparamete
|
|||||||
TTrain::state_t
|
TTrain::state_t
|
||||||
TTrain::get_state() const {
|
TTrain::get_state() const {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
btLampkaSHP.GetValue(),
|
btLampkaSHP.GetValue(),
|
||||||
btLampkaCzuwaka.GetValue(),
|
(TestFlag(mvOccupied->SecuritySystem.Status, s_aware))
|
||||||
btLampkaRadioStop.GetValue(),
|
|| (TestFlag(mvOccupied->SecuritySystem.Status, s_CAtest)),
|
||||||
btLampkaOpory.GetValue(),
|
btLampkaRadioStop.GetValue(),
|
||||||
btLampkaWylSzybki.GetValue(),
|
btLampkaOpory.GetValue(),
|
||||||
btLampkaPrzekRozn.GetValue(),
|
btLampkaWylSzybki.GetValue(),
|
||||||
btLampkaNadmSil.GetValue(),
|
btLampkaPrzekRozn.GetValue(),
|
||||||
btLampkaStyczn.GetValue(),
|
btLampkaNadmSil.GetValue(),
|
||||||
btLampkaPoslizg.GetValue(),
|
btLampkaStyczn.GetValue(),
|
||||||
btLampkaNadmPrzetw.GetValue(),
|
btLampkaPoslizg.GetValue(),
|
||||||
btLampkaPrzetwOff.GetValue(),
|
btLampkaNadmPrzetw.GetValue(),
|
||||||
btLampkaNadmSpr.GetValue(),
|
btLampkaPrzetwOff.GetValue(),
|
||||||
btLampkaNadmWent.GetValue(),
|
btLampkaNadmSpr.GetValue(),
|
||||||
btLampkaWysRozr.GetValue(),
|
btLampkaNadmWent.GetValue(),
|
||||||
btLampkaOgrzewanieSkladu.GetValue(),
|
btLampkaWysRozr.GetValue(),
|
||||||
static_cast<std::uint8_t>( iCabn ),
|
btLampkaOgrzewanieSkladu.GetValue(),
|
||||||
btHaslerBrakes.GetValue(),
|
static_cast<std::uint8_t>(iCabn),
|
||||||
btHaslerCurrent.GetValue(),
|
btHaslerBrakes.GetValue(),
|
||||||
mvOccupied->SecuritySystem.is_beeping(),
|
btHaslerCurrent.GetValue(),
|
||||||
btLampkaHVoltageB.GetValue(),
|
mvOccupied->SecuritySystem.is_beeping(),
|
||||||
fTachoVelocity,
|
btLampkaHVoltageB.GetValue(),
|
||||||
static_cast<float>( mvOccupied->Compressor ),
|
fTachoVelocity,
|
||||||
static_cast<float>( mvOccupied->PipePress ),
|
static_cast<float>(mvOccupied->Compressor),
|
||||||
static_cast<float>( mvOccupied->BrakePress ),
|
static_cast<float>(mvOccupied->PipePress),
|
||||||
static_cast<float>( mvPantographUnit->PantPress ),
|
static_cast<float>(mvOccupied->BrakePress),
|
||||||
fHVoltage,
|
static_cast<float>(mvPantographUnit->PantPress),
|
||||||
{ fHCurrent[ ( mvControlled->TrainType & dt_EZT ) ? 0 : 1 ], fHCurrent[ 2 ], fHCurrent[ 3 ] },
|
fHVoltage,
|
||||||
ggLVoltage.GetValue(),
|
{ fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1], fHCurrent[2], fHCurrent[3] },
|
||||||
mvOccupied->DistCounter,
|
ggLVoltage.GetValue(),
|
||||||
static_cast<std::uint8_t>( RadioChannel() ),
|
mvOccupied->DistCounter,
|
||||||
btLampkaSpringBrakeActive.GetValue(),
|
static_cast<std::uint8_t>(RadioChannel()),
|
||||||
btLampkaNapNastHam.GetValue(),
|
btLampkaSpringBrakeActive.GetValue(),
|
||||||
|
btLampkaNapNastHam.GetValue(),
|
||||||
|
mvOccupied->DirActive > 0,
|
||||||
|
mvOccupied->DirActive < 0,
|
||||||
|
mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? side::right : side::left].open_permit,
|
||||||
|
mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? side::right : side::left].is_open,
|
||||||
|
mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? side::left : side::right].open_permit,
|
||||||
|
mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? side::left : side::right].is_open,
|
||||||
|
mvOccupied->Doors.step_enabled,
|
||||||
|
mvOccupied->Power24vIsAvailable,
|
||||||
|
0,
|
||||||
|
mvOccupied->LockPipe
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6766,11 +6777,13 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
btLampkaCzuwaka.Turn( false );
|
btLampkaCzuwaka.Turn( false );
|
||||||
|
|
||||||
btLampkaSHP.Turn( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) );
|
btLampkaSHP.Turn( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) );
|
||||||
|
btLampkaCzuwakaSHP.Turn( btLampkaSHP.GetValue() || btLampkaCzuwaka.GetValue() );
|
||||||
}
|
}
|
||||||
else // wylaczone
|
else // wylaczone
|
||||||
{
|
{
|
||||||
btLampkaCzuwaka.Turn( false );
|
btLampkaCzuwaka.Turn( false );
|
||||||
btLampkaSHP.Turn( false );
|
btLampkaSHP.Turn( false );
|
||||||
|
btLampkaCzuwakaSHP.Turn( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
btLampkaWylSzybki.Turn(
|
btLampkaWylSzybki.Turn(
|
||||||
@@ -6960,6 +6973,7 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
// wylaczone
|
// wylaczone
|
||||||
btLampkaCzuwaka.Turn( false );
|
btLampkaCzuwaka.Turn( false );
|
||||||
btLampkaSHP.Turn( false );
|
btLampkaSHP.Turn( false );
|
||||||
|
btLampkaCzuwakaSHP.Turn( false );
|
||||||
btLampkaWylSzybki.Turn( false );
|
btLampkaWylSzybki.Turn( false );
|
||||||
btLampkaWylSzybkiOff.Turn( false );
|
btLampkaWylSzybkiOff.Turn( false );
|
||||||
btLampkaMainBreakerReady.Turn( false );
|
btLampkaMainBreakerReady.Turn( false );
|
||||||
@@ -7607,7 +7621,7 @@ TTrain::update_sounds( double const Deltatime ) {
|
|||||||
// jesli nie FV4a
|
// jesli nie FV4a
|
||||||
// upuszczanie z PG
|
// upuszczanie z PG
|
||||||
if( rsHiss ) {
|
if( rsHiss ) {
|
||||||
fPPress = ( 4.0f * fPPress + std::max( mvOccupied->dpLocalValve, mvOccupied->dpMainValve ) ) / ( 4.0f + 1.0f );
|
fPPress = ( 4.0f * fPPress + std::max( 0.0, mvOccupied->dpMainValve ) ) / ( 4.0f + 1.0f );
|
||||||
volume = (
|
volume = (
|
||||||
fPPress > 0.0f ?
|
fPPress > 0.0f ?
|
||||||
2.0 * rsHiss->m_amplitudefactor * fPPress :
|
2.0 * rsHiss->m_amplitudefactor * fPPress :
|
||||||
@@ -7622,7 +7636,7 @@ TTrain::update_sounds( double const Deltatime ) {
|
|||||||
}
|
}
|
||||||
// napelnianie PG
|
// napelnianie PG
|
||||||
if( rsHissU ) {
|
if( rsHissU ) {
|
||||||
fNPress = ( 4.0f * fNPress + Min0R( mvOccupied->dpLocalValve, mvOccupied->dpMainValve ) ) / ( 4.0f + 1.0f );
|
fNPress = ( 4.0f * fNPress + Min0R( 0.0, mvOccupied->dpMainValve ) ) / ( 4.0f + 1.0f );
|
||||||
volume = (
|
volume = (
|
||||||
fNPress < 0.0f ?
|
fNPress < 0.0f ?
|
||||||
-1.0 * rsHissU->m_amplitudefactor * fNPress :
|
-1.0 * rsHissU->m_amplitudefactor * fNPress :
|
||||||
@@ -7958,6 +7972,7 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
|||||||
}
|
}
|
||||||
// NOTE: since radiosound is an incomplete template not using std::optional it gets a special treatment
|
// NOTE: since radiosound is an incomplete template not using std::optional it gets a special treatment
|
||||||
m_radiosound.owner( DynamicObject );
|
m_radiosound.owner( DynamicObject );
|
||||||
|
CabSoundLocations.clear();
|
||||||
|
|
||||||
cParser parser( asFileName, cParser::buffer_FILE, DynamicObject->asBaseDir );
|
cParser parser( asFileName, cParser::buffer_FILE, DynamicObject->asBaseDir );
|
||||||
// NOTE: yaml-style comments are disabled until conflict in use of # is resolved
|
// NOTE: yaml-style comments are disabled until conflict in use of # is resolved
|
||||||
@@ -8019,6 +8034,19 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
|||||||
rsHuntingNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
rsHuntingNoise->m_frequencyfactor /= (1 + mvOccupied->Vmax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
auto const nullvector{ glm::vec3() };
|
||||||
|
std::vector<std::reference_wrapper<std::optional<sound_source>>> sounds = {
|
||||||
|
dsbReverserKey, dsbNastawnikJazdy, dsbNastawnikBocz,
|
||||||
|
dsbSwitch, dsbPneumaticSwitch,
|
||||||
|
rsHiss, rsHissU, rsHissE, rsHissX, rsHissT, rsSBHiss, rsSBHissU,
|
||||||
|
rsFadeSound, rsRunningNoise, rsHuntingNoise,
|
||||||
|
dsbHasler, dsbBuzzer, dsbSlipAlarm, m_distancecounterclear, m_rainsound, m_radiostop
|
||||||
|
};
|
||||||
|
for (auto &sound : sounds) {
|
||||||
|
if (sound.get()) {
|
||||||
|
CabSoundLocations.emplace_back(sound, sound.get()->offset());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -8043,6 +8071,12 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_radiosound.offset( nullvector );
|
m_radiosound.offset( nullvector );
|
||||||
|
for (auto &sound : CabSoundLocations) {
|
||||||
|
if ((sound.first.get())
|
||||||
|
&& (sound.first.get()->offset() == nullvector)) {
|
||||||
|
sound.first.get()->offset(sound.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
// reset view angles
|
// reset view angles
|
||||||
pMechViewAngle = { 0.0, 0.0 };
|
pMechViewAngle = { 0.0, 0.0 };
|
||||||
|
|
||||||
@@ -9188,6 +9222,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
|
|||||||
{ "i-trainheating:", btLampkaOgrzewanieSkladu },
|
{ "i-trainheating:", btLampkaOgrzewanieSkladu },
|
||||||
{ "i-security_aware:", btLampkaCzuwaka },
|
{ "i-security_aware:", btLampkaCzuwaka },
|
||||||
{ "i-security_cabsignal:", btLampkaSHP },
|
{ "i-security_cabsignal:", btLampkaSHP },
|
||||||
|
{ "i-security_aware_cabsignal:", btLampkaCzuwakaSHP },
|
||||||
{ "i-door_left:", btLampkaDoorLeft },
|
{ "i-door_left:", btLampkaDoorLeft },
|
||||||
{ "i-door_right:", btLampkaDoorRight },
|
{ "i-door_right:", btLampkaDoorRight },
|
||||||
{ "i-departure_signal:", btLampkaDepartureSignal },
|
{ "i-departure_signal:", btLampkaDepartureSignal },
|
||||||
@@ -9652,6 +9687,13 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
|||||||
gauge.Load(Parser, DynamicObject, 0.1);
|
gauge.Load(Parser, DynamicObject, 0.1);
|
||||||
gauge.AssignDouble(&mvOccupied->SpringBrake.SBP);
|
gauge.AssignDouble(&mvOccupied->SpringBrake.SBP);
|
||||||
}
|
}
|
||||||
|
else if (Label == "epctrlvalue:")
|
||||||
|
{
|
||||||
|
// wskazowka sterowania sila hamulca ep
|
||||||
|
auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka
|
||||||
|
gauge.Load(Parser, DynamicObject, 0.1);
|
||||||
|
gauge.AssignDouble(&mvOccupied->EpForce);
|
||||||
|
}
|
||||||
else if ((Label == "compressor:") || (Label == "compressorb:"))
|
else if ((Label == "compressor:") || (Label == "compressorb:"))
|
||||||
{
|
{
|
||||||
// manometr sprezarki/zbiornika glownego
|
// manometr sprezarki/zbiornika glownego
|
||||||
|
|||||||
14
Train.h
14
Train.h
@@ -112,6 +112,16 @@ class TTrain {
|
|||||||
std::uint8_t radio_channel;
|
std::uint8_t radio_channel;
|
||||||
std::uint8_t springbrake_active;
|
std::uint8_t springbrake_active;
|
||||||
std::uint8_t epbrake_enabled;
|
std::uint8_t epbrake_enabled;
|
||||||
|
std::uint8_t dir_forward;
|
||||||
|
std::uint8_t dir_backward;
|
||||||
|
std::uint8_t doorleftallowed;
|
||||||
|
std::uint8_t doorleftopened;
|
||||||
|
std::uint8_t doorrightallowed;
|
||||||
|
std::uint8_t doorrightopened;
|
||||||
|
std::uint8_t doorstepallowed;
|
||||||
|
std::uint8_t battery;
|
||||||
|
std::uint8_t emergencybrake;
|
||||||
|
std::uint8_t lockpipe;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct screen_entry {
|
struct screen_entry {
|
||||||
@@ -671,7 +681,8 @@ public: // reszta może by?publiczna
|
|||||||
TButton btLampkaOgrzewanieSkladu;
|
TButton btLampkaOgrzewanieSkladu;
|
||||||
TButton btLampkaSHP;
|
TButton btLampkaSHP;
|
||||||
TButton btLampkaCzuwaka; // McZapkie-141102
|
TButton btLampkaCzuwaka; // McZapkie-141102
|
||||||
TButton btLampkaRezerwa;
|
TButton btLampkaCzuwakaSHP;
|
||||||
|
TButton btLampkaRezerwa;
|
||||||
// youBy - jakies dodatkowe lampki
|
// youBy - jakies dodatkowe lampki
|
||||||
TButton btLampkaNapNastHam;
|
TButton btLampkaNapNastHam;
|
||||||
TButton btLampkaSprezarka;
|
TButton btLampkaSprezarka;
|
||||||
@@ -753,6 +764,7 @@ public: // reszta może by?publiczna
|
|||||||
m_rainsound;
|
m_rainsound;
|
||||||
sound_source m_radiosound { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // cached template for radio messages
|
sound_source m_radiosound { sound_placement::internal, 2 * EU07_SOUND_CABCONTROLSCUTOFFRANGE }; // cached template for radio messages
|
||||||
std::vector<std::pair<int, std::shared_ptr<sound_source>>> m_radiomessages; // list of currently played radio messages
|
std::vector<std::pair<int, std::shared_ptr<sound_source>>> m_radiomessages; // list of currently played radio messages
|
||||||
|
std::vector<std::pair<std::reference_wrapper<std::optional<sound_source>>, glm::vec3>> CabSoundLocations; // list of offsets for manually located sounds;
|
||||||
float m_lastlocalbrakepressure { -1.f }; // helper, cached level of pressure in local brake cylinder
|
float m_lastlocalbrakepressure { -1.f }; // helper, cached level of pressure in local brake cylinder
|
||||||
float m_localbrakepressurechange { 0.f }; // recent change of pressure in local brake cylinder
|
float m_localbrakepressurechange { 0.f }; // recent change of pressure in local brake cylinder
|
||||||
/*
|
/*
|
||||||
|
|||||||
45
uart.cpp
45
uart.cpp
@@ -277,13 +277,28 @@ void uart_input::poll()
|
|||||||
|
|
||||||
if( true == conf.mainenable ) {
|
if( true == conf.mainenable ) {
|
||||||
// master controller
|
// master controller
|
||||||
relay.post(
|
if (false == conf.mainpercentage) {
|
||||||
user_command::mastercontrollerset,
|
//old method for direct positions
|
||||||
buffer[ 6 ],
|
relay.post(
|
||||||
0,
|
user_command::mastercontrollerset,
|
||||||
GLFW_PRESS,
|
buffer[6],
|
||||||
// TODO: pass correct entity id once the missing systems are in place
|
0,
|
||||||
0 );
|
GLFW_PRESS,
|
||||||
|
// TODO: pass correct entity id once the missing systems are in place
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto desiredpercent{ buffer[6] * 0.01 };
|
||||||
|
auto desiredposition{ desiredpercent > 0.01 ? 1 + ((simulation::Train->Occupied()->MainCtrlPosNo - 1) * desiredpercent) : buffer[6] };
|
||||||
|
relay.post(
|
||||||
|
user_command::mastercontrollerset,
|
||||||
|
desiredposition,
|
||||||
|
0,
|
||||||
|
GLFW_PRESS,
|
||||||
|
// TODO: pass correct entity id once the missing systems are in place
|
||||||
|
0);
|
||||||
|
simulation::Train->Occupied()->eimic_analog = desiredpercent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( true == conf.scndenable ) {
|
if( true == conf.scndenable ) {
|
||||||
// second controller
|
// second controller
|
||||||
@@ -357,10 +372,20 @@ void uart_input::poll()
|
|||||||
(uint8_t)(
|
(uint8_t)(
|
||||||
trainstate.epbrake_enabled << 0
|
trainstate.epbrake_enabled << 0
|
||||||
| trainstate.ventilator_overload << 1
|
| trainstate.ventilator_overload << 1
|
||||||
| trainstate.motor_overload_threshold << 2),
|
| trainstate.motor_overload_threshold << 2
|
||||||
|
| trainstate.emergencybrake << 3
|
||||||
|
| trainstate.lockpipe << 4
|
||||||
|
| trainstate.dir_forward << 5
|
||||||
|
| trainstate.dir_backward << 6),
|
||||||
//byte 3
|
//byte 3
|
||||||
(uint8_t)(
|
(uint8_t)(
|
||||||
trainstate.coupled_hv_voltage_relays << 0),
|
trainstate.coupled_hv_voltage_relays << 0
|
||||||
|
| trainstate.doorleftallowed << 1
|
||||||
|
| trainstate.doorleftopened << 2
|
||||||
|
| trainstate.doorrightallowed << 3
|
||||||
|
| trainstate.doorrightopened << 4
|
||||||
|
| trainstate.doorstepallowed << 5
|
||||||
|
| trainstate.battery << 6),
|
||||||
//byte 4
|
//byte 4
|
||||||
(uint8_t)(
|
(uint8_t)(
|
||||||
trainstate.train_heating << 0
|
trainstate.train_heating << 0
|
||||||
@@ -412,7 +437,7 @@ void uart_input::poll()
|
|||||||
(uint8_t)trainstate.radio_channel,
|
(uint8_t)trainstate.radio_channel,
|
||||||
//byte 34-35
|
//byte 34-35
|
||||||
SPLIT_INT16(pantograph_press),
|
SPLIT_INT16(pantograph_press),
|
||||||
//byte 36-48
|
//byte 36-47
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user