16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 03:29:19 +02:00

additional train state data exposed to uart interface, minor bug fixes

This commit is contained in:
tmj-fstate
2018-09-15 16:35:03 +02:00
parent e881092ca0
commit 6c68cff4c5
9 changed files with 46 additions and 49 deletions

View File

@@ -1651,39 +1651,25 @@ TController::~TController()
CloseLog(); CloseLog();
}; };
std::string TController::Order2Str(TOrders Order) const // zamiana kodu rozkazu na opis
{ // zamiana kodu rozkazu na opis std::string TController::Order2Str(TOrders Order) const {
if (Order & Change_direction)
return "Change_direction"; // może być nałożona na inną i wtedy ma priorytet if( Order & Change_direction ) {
if (Order == Wait_for_orders) // może być nałożona na inną i wtedy ma priorytet
return "Wait_for_orders"; return "Change_direction";
if (Order == Prepare_engine) }
return "Prepare_engine"; switch( Order ) {
if (Order == Shunt) case Wait_for_orders: return "Wait_for_orders";
return "Shunt"; case Prepare_engine: return "Prepare_engine";
if (Order == Connect) case Release_engine: return "Release_engine";
return "Connect"; case Change_direction: return "Change_direction";
if (Order == Disconnect) case Connect: return "Connect";
return "Disconnect"; case Disconnect: return "Disconnect";
if (Order == Obey_train) case Shunt: return "Shunt";
return "Obey_train"; case Obey_train: return "Obey_train";
if (Order == Release_engine) case Jump_to_first_order: return "Jump_to_first_order";
return "Release_engine"; default: return "Undefined";
if (Order == Jump_to_first_order) }
return "Jump_to_first_order";
/* Ra: wersja ze switch nie działa prawidłowo (czemu?)
switch (Order)
{
Wait_for_orders: return "Wait_for_orders";
Prepare_engine: return "Prepare_engine";
Shunt: return "Shunt";
Change_direction: return "Change_direction";
Obey_train: return "Obey_train";
Release_engine: return "Release_engine";
Jump_to_first_order: return "Jump_to_first_order";
}
*/
return "Undefined!";
} }
std::string TController::OrderCurrent() const std::string TController::OrderCurrent() const
@@ -5611,7 +5597,7 @@ void TController::OrderPush(TOrders NewOrder)
if (OrderTop >= maxorders) if (OrderTop >= maxorders)
ErrorLog("Commands overflow: The program will now crash"); ErrorLog("Commands overflow: The program will now crash");
#if LOGORDERS #if LOGORDERS
WriteLog("--> OrderPush"); WriteLog("--> OrderPush: [" + Order2Str( NewOrder ) + "]");
OrdersDump(); // normalnie nie ma po co tego wypisywać OrdersDump(); // normalnie nie ma po co tego wypisywać
#endif #endif
} }

View File

@@ -947,14 +947,16 @@ void TSubModel::RaAnimation(TAnimType a)
case TAnimType::at_DigiClk: // animacja zegara cyfrowego case TAnimType::at_DigiClk: // animacja zegara cyfrowego
{ // ustawienie animacji w submodelach potomnych { // ustawienie animacji w submodelach potomnych
TSubModel *sm = ChildGet(); TSubModel *sm = ChildGet();
do do { // pętla po submodelach potomnych i obracanie ich o kąt zależy od czasu
{ // pętla po submodelach potomnych i obracanie ich o kąt zależy od czasu if( sm->pName.size() ) {
if (sm->pName.size()) // musi mieć niepustą nazwę
{ // musi mieć niepustą nazwę if( ( sm->pName[ 0 ] >= '0' )
if ((sm->pName[0]) >= '0') && ( sm->pName[ 0 ] <= '5') ) {
if ((sm->pName[0]) <= '5') // zegarek ma 6 cyfr maksymalnie // zegarek ma 6 cyfr maksymalnie
sm->SetRotate(float3(0, 1, 0), sm->SetRotate(
-Global.fClockAngleDeg[(sm->pName[0]) - '0']); float3( 0, 1, 0 ),
-Global.fClockAngleDeg[ sm->pName[ 0 ] - '0' ] );
}
} }
sm = sm->NextGet(); sm = sm->NextGet();
} while (sm); } while (sm);

View File

@@ -40,7 +40,7 @@ public:
return false; } return false; }
// locates item with specified name. returns pointer to the item, or nullptr // locates item with specified name. returns pointer to the item, or nullptr
Type_ * Type_ *
find( std::string const &Name ) { find( std::string const &Name ) const {
auto lookup = m_itemmap.find( Name ); auto lookup = m_itemmap.find( Name );
return ( return (
lookup != m_itemmap.end() ? lookup != m_itemmap.end() ?

View File

@@ -596,6 +596,7 @@ TTrain::get_state() const {
btHaslerBrakes.GetValue(), btHaslerBrakes.GetValue(),
btHaslerCurrent.GetValue(), btHaslerCurrent.GetValue(),
( TestFlag( mvOccupied->SecuritySystem.Status, s_CAalarm ) || TestFlag( mvOccupied->SecuritySystem.Status, s_SHPalarm ) ), ( TestFlag( mvOccupied->SecuritySystem.Status, s_CAalarm ) || TestFlag( mvOccupied->SecuritySystem.Status, s_SHPalarm ) ),
btLampkaHVoltageB.GetValue(),
fTachoVelocity, fTachoVelocity,
static_cast<float>( mvOccupied->Compressor ), static_cast<float>( mvOccupied->Compressor ),
static_cast<float>( mvOccupied->PipePress ), static_cast<float>( mvOccupied->PipePress ),

View File

@@ -85,6 +85,7 @@ class TTrain
std::uint8_t recorder_braking; std::uint8_t recorder_braking;
std::uint8_t recorder_power; std::uint8_t recorder_power;
std::uint8_t alerter_sound; std::uint8_t alerter_sound;
std::uint8_t coupled_hv_voltage_relays;
float velocity; float velocity;
float reservoir_pressure; float reservoir_pressure;
float pipe_pressure; float pipe_pressure;

View File

@@ -200,7 +200,7 @@ commanddescription_sequence Commands_descriptions = {
{ "instrumentlighttoggle", command_target::vehicle }, { "instrumentlighttoggle", command_target::vehicle },
{ "instrumentlightenable", command_target::vehicle }, { "instrumentlightenable", command_target::vehicle },
{ "instrumentlightdisable", command_target::vehicle }, { "instrumentlightdisable", command_target::vehicle },
{ "dshboardlighttoggle", command_target::vehicle }, { "dashboardlighttoggle", command_target::vehicle },
{ "timetablelighttoggle", command_target::vehicle }, { "timetablelighttoggle", command_target::vehicle },
{ "generictoggle0", command_target::vehicle }, { "generictoggle0", command_target::vehicle },
{ "generictoggle1", command_target::vehicle }, { "generictoggle1", command_target::vehicle },

View File

@@ -348,10 +348,16 @@ void CSkyDome::RebuildColors() {
if( m_coloursbuffer != -1 ) { if( m_coloursbuffer != -1 ) {
// the colour buffer was already initialized, so on this run we update its content // the colour buffer was already initialized, so on this run we update its content
// cache entry state
::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT );
// begin
::glEnableClientState( GL_VERTEX_ARRAY );
// update
::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer ); ::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer );
::glBufferSubData( GL_ARRAY_BUFFER, 0, m_colours.size() * sizeof( glm::vec3 ), m_colours.data() ); ::glBufferSubData( GL_ARRAY_BUFFER, 0, m_colours.size() * sizeof( glm::vec3 ), m_colours.data() );
// cleanup
::glPopClientAttrib();
} }
} }
//******************************************************************************// //******************************************************************************//

View File

@@ -195,10 +195,10 @@ init() {
" pantograf: %.2f%cZG", " pantograf: %.2f%cZG",
"Sily:\n napedna: %.1f, hamowania: %.1f, tarcie: %.2f%s\nPrzyspieszenia:\n styczne: %.2f, normalne: %.2f (promien: %s)\nPredkosc: %.2f, pokonana odleglosc: %.2f\nPozycja: [%.2f, %.2f, %.2f]", "Sily:\n napedna: %.1f, hamowania: %.1f, tarcie: %.2f%s\nPrzyspieszenia:\n styczne: %.2f, normalne: %.2f (promien: %s)\nPredkosc: %.2f, pokonana odleglosc: %.2f\nPozycja: [%.2f, %.2f, %.2f]",
"nastawnik", "nastawnik jazdy",
"nastawnik dodatkowy", "nastawnik dodatkowy",
"sterowanie analogowe", "sterowanie analogowe",
"nastawnik jazdy", "nastawnik kierunku",
"hamulec zespolony", "hamulec zespolony",
"hamulec pomocniczy", "hamulec pomocniczy",
"hamulec reczny", "hamulec reczny",
@@ -224,7 +224,7 @@ init() {
"syrena (ton niski)", "syrena (ton niski)",
"syrena (ton wysoki)", "syrena (ton wysoki)",
"gwizdawka", "gwizdawka",
"przekaznik nadmiarowy motorow trakcyjnych", "przekaznik nadmiarowy silnikow trakcyjnych",
"przekaznik nadmiarowy przetwornicy", "przekaznik nadmiarowy przetwornicy",
"styczniki liniowe", "styczniki liniowe",
"drzwi lewe", "drzwi lewe",

View File

@@ -253,7 +253,8 @@ void uart_input::poll()
trainstate.ventilator_overload << 1 trainstate.ventilator_overload << 1
| trainstate.motor_overload_threshold << 2), | trainstate.motor_overload_threshold << 2),
//byte 3 //byte 3
0, (uint8_t)(
trainstate.coupled_hv_voltage_relays << 0),
//byte 4 //byte 4
(uint8_t)( (uint8_t)(
trainstate.train_heating << 0 trainstate.train_heating << 0