mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 11:19: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 >> uart_conf.debug;
|
||||
}
|
||||
else if (token == "uartmainpercentage")
|
||||
{
|
||||
Parser.getTokens(1);
|
||||
Parser >> uart_conf.mainpercentage;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef USE_EXTCAM_CAMERA
|
||||
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::get_state() const {
|
||||
|
||||
return {
|
||||
btLampkaSHP.GetValue(),
|
||||
btLampkaCzuwaka.GetValue(),
|
||||
btLampkaRadioStop.GetValue(),
|
||||
btLampkaOpory.GetValue(),
|
||||
btLampkaWylSzybki.GetValue(),
|
||||
btLampkaPrzekRozn.GetValue(),
|
||||
btLampkaNadmSil.GetValue(),
|
||||
btLampkaStyczn.GetValue(),
|
||||
btLampkaPoslizg.GetValue(),
|
||||
btLampkaNadmPrzetw.GetValue(),
|
||||
btLampkaPrzetwOff.GetValue(),
|
||||
btLampkaNadmSpr.GetValue(),
|
||||
btLampkaNadmWent.GetValue(),
|
||||
btLampkaWysRozr.GetValue(),
|
||||
btLampkaOgrzewanieSkladu.GetValue(),
|
||||
static_cast<std::uint8_t>( iCabn ),
|
||||
btHaslerBrakes.GetValue(),
|
||||
btHaslerCurrent.GetValue(),
|
||||
mvOccupied->SecuritySystem.is_beeping(),
|
||||
btLampkaHVoltageB.GetValue(),
|
||||
fTachoVelocity,
|
||||
static_cast<float>( mvOccupied->Compressor ),
|
||||
static_cast<float>( mvOccupied->PipePress ),
|
||||
static_cast<float>( mvOccupied->BrakePress ),
|
||||
static_cast<float>( mvPantographUnit->PantPress ),
|
||||
fHVoltage,
|
||||
{ fHCurrent[ ( mvControlled->TrainType & dt_EZT ) ? 0 : 1 ], fHCurrent[ 2 ], fHCurrent[ 3 ] },
|
||||
ggLVoltage.GetValue(),
|
||||
mvOccupied->DistCounter,
|
||||
static_cast<std::uint8_t>( RadioChannel() ),
|
||||
btLampkaSpringBrakeActive.GetValue(),
|
||||
btLampkaNapNastHam.GetValue(),
|
||||
return {
|
||||
btLampkaSHP.GetValue(),
|
||||
(TestFlag(mvOccupied->SecuritySystem.Status, s_aware))
|
||||
|| (TestFlag(mvOccupied->SecuritySystem.Status, s_CAtest)),
|
||||
btLampkaRadioStop.GetValue(),
|
||||
btLampkaOpory.GetValue(),
|
||||
btLampkaWylSzybki.GetValue(),
|
||||
btLampkaPrzekRozn.GetValue(),
|
||||
btLampkaNadmSil.GetValue(),
|
||||
btLampkaStyczn.GetValue(),
|
||||
btLampkaPoslizg.GetValue(),
|
||||
btLampkaNadmPrzetw.GetValue(),
|
||||
btLampkaPrzetwOff.GetValue(),
|
||||
btLampkaNadmSpr.GetValue(),
|
||||
btLampkaNadmWent.GetValue(),
|
||||
btLampkaWysRozr.GetValue(),
|
||||
btLampkaOgrzewanieSkladu.GetValue(),
|
||||
static_cast<std::uint8_t>(iCabn),
|
||||
btHaslerBrakes.GetValue(),
|
||||
btHaslerCurrent.GetValue(),
|
||||
mvOccupied->SecuritySystem.is_beeping(),
|
||||
btLampkaHVoltageB.GetValue(),
|
||||
fTachoVelocity,
|
||||
static_cast<float>(mvOccupied->Compressor),
|
||||
static_cast<float>(mvOccupied->PipePress),
|
||||
static_cast<float>(mvOccupied->BrakePress),
|
||||
static_cast<float>(mvPantographUnit->PantPress),
|
||||
fHVoltage,
|
||||
{ fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1], fHCurrent[2], fHCurrent[3] },
|
||||
ggLVoltage.GetValue(),
|
||||
mvOccupied->DistCounter,
|
||||
static_cast<std::uint8_t>(RadioChannel()),
|
||||
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 );
|
||||
|
||||
btLampkaSHP.Turn( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) );
|
||||
btLampkaCzuwakaSHP.Turn( btLampkaSHP.GetValue() || btLampkaCzuwaka.GetValue() );
|
||||
}
|
||||
else // wylaczone
|
||||
{
|
||||
btLampkaCzuwaka.Turn( false );
|
||||
btLampkaSHP.Turn( false );
|
||||
btLampkaCzuwakaSHP.Turn( false );
|
||||
}
|
||||
|
||||
btLampkaWylSzybki.Turn(
|
||||
@@ -6960,6 +6973,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
// wylaczone
|
||||
btLampkaCzuwaka.Turn( false );
|
||||
btLampkaSHP.Turn( false );
|
||||
btLampkaCzuwakaSHP.Turn( false );
|
||||
btLampkaWylSzybki.Turn( false );
|
||||
btLampkaWylSzybkiOff.Turn( false );
|
||||
btLampkaMainBreakerReady.Turn( false );
|
||||
@@ -7607,7 +7621,7 @@ TTrain::update_sounds( double const Deltatime ) {
|
||||
// jesli nie FV4a
|
||||
// upuszczanie z PG
|
||||
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 = (
|
||||
fPPress > 0.0f ?
|
||||
2.0 * rsHiss->m_amplitudefactor * fPPress :
|
||||
@@ -7622,7 +7636,7 @@ TTrain::update_sounds( double const Deltatime ) {
|
||||
}
|
||||
// napelnianie PG
|
||||
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 = (
|
||||
fNPress < 0.0f ?
|
||||
-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
|
||||
m_radiosound.owner( DynamicObject );
|
||||
CabSoundLocations.clear();
|
||||
|
||||
cParser parser( asFileName, cParser::buffer_FILE, DynamicObject->asBaseDir );
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -8043,6 +8071,12 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
}
|
||||
}
|
||||
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
|
||||
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-security_aware:", btLampkaCzuwaka },
|
||||
{ "i-security_cabsignal:", btLampkaSHP },
|
||||
{ "i-security_aware_cabsignal:", btLampkaCzuwakaSHP },
|
||||
{ "i-door_left:", btLampkaDoorLeft },
|
||||
{ "i-door_right:", btLampkaDoorRight },
|
||||
{ "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.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:"))
|
||||
{
|
||||
// manometr sprezarki/zbiornika glownego
|
||||
|
||||
14
Train.h
14
Train.h
@@ -112,6 +112,16 @@ class TTrain {
|
||||
std::uint8_t radio_channel;
|
||||
std::uint8_t springbrake_active;
|
||||
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 {
|
||||
@@ -671,7 +681,8 @@ public: // reszta może by?publiczna
|
||||
TButton btLampkaOgrzewanieSkladu;
|
||||
TButton btLampkaSHP;
|
||||
TButton btLampkaCzuwaka; // McZapkie-141102
|
||||
TButton btLampkaRezerwa;
|
||||
TButton btLampkaCzuwakaSHP;
|
||||
TButton btLampkaRezerwa;
|
||||
// youBy - jakies dodatkowe lampki
|
||||
TButton btLampkaNapNastHam;
|
||||
TButton btLampkaSprezarka;
|
||||
@@ -753,6 +764,7 @@ public: // reszta może by?publiczna
|
||||
m_rainsound;
|
||||
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<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_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 ) {
|
||||
// master controller
|
||||
relay.post(
|
||||
user_command::mastercontrollerset,
|
||||
buffer[ 6 ],
|
||||
0,
|
||||
GLFW_PRESS,
|
||||
// TODO: pass correct entity id once the missing systems are in place
|
||||
0 );
|
||||
if (false == conf.mainpercentage) {
|
||||
//old method for direct positions
|
||||
relay.post(
|
||||
user_command::mastercontrollerset,
|
||||
buffer[6],
|
||||
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 ) {
|
||||
// second controller
|
||||
@@ -357,10 +372,20 @@ void uart_input::poll()
|
||||
(uint8_t)(
|
||||
trainstate.epbrake_enabled << 0
|
||||
| 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
|
||||
(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
|
||||
(uint8_t)(
|
||||
trainstate.train_heating << 0
|
||||
@@ -412,7 +437,7 @@ void uart_input::poll()
|
||||
(uint8_t)trainstate.radio_channel,
|
||||
//byte 34-35
|
||||
SPLIT_INT16(pantograph_press),
|
||||
//byte 36-48
|
||||
//byte 36-47
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user