mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
bug fixes for python bindings and .fiz loader
This commit is contained in:
29
DynObj.cpp
29
DynObj.cpp
@@ -3986,25 +3986,32 @@ void TDynamicObject::RenderSounds()
|
||||
else
|
||||
rsSilnik.Stop();
|
||||
}
|
||||
enginevolume = (enginevolume + vol) / 2;
|
||||
if (enginevolume < 0.01)
|
||||
enginevolume = (enginevolume + vol) * 0.5;
|
||||
if( enginevolume < 0.01 ) {
|
||||
rsSilnik.Stop();
|
||||
if ((MoverParameters->EngineType == ElectricSeriesMotor) ||
|
||||
(MoverParameters->EngineType == ElectricInductionMotor) && rsWentylator.AM != 0)
|
||||
}
|
||||
if ( ( MoverParameters->EngineType == ElectricSeriesMotor )
|
||||
|| ( MoverParameters->EngineType == ElectricInductionMotor )
|
||||
&& ( rsWentylator.AM != 0 ) )
|
||||
{
|
||||
if (MoverParameters->RventRot > 0.1)
|
||||
{
|
||||
if (MoverParameters->RventRot > 0.1) {
|
||||
// play ventilator sound if the ventilators are rotating fast enough...
|
||||
freq = rsWentylator.FM * MoverParameters->RventRot + rsWentylator.FA;
|
||||
rsWentylator.AdjFreq(freq, dt);
|
||||
if (MoverParameters->EngineType == ElectricInductionMotor)
|
||||
vol =
|
||||
rsWentylator.AM * sqrt(fabs(MoverParameters->dizel_fill)) + rsWentylator.AA;
|
||||
else
|
||||
if( MoverParameters->EngineType == ElectricInductionMotor ) {
|
||||
|
||||
vol = rsWentylator.AM * std::sqrt( std::fabs( MoverParameters->dizel_fill ) ) + rsWentylator.AA;
|
||||
}
|
||||
else {
|
||||
|
||||
vol = rsWentylator.AM * MoverParameters->RventRot + rsWentylator.AA;
|
||||
}
|
||||
rsWentylator.Play(vol, DSBPLAY_LOOPING, MechInside, GetPosition());
|
||||
}
|
||||
else
|
||||
else {
|
||||
// ...otherwise shut down the sound
|
||||
rsWentylator.Stop();
|
||||
}
|
||||
}
|
||||
if (MoverParameters->TrainType == dt_ET40)
|
||||
{
|
||||
|
||||
@@ -3819,7 +3819,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (ActiveDir != 0 && RList[MainCtrlActualPos].R > RVentCutOff)
|
||||
if ((ActiveDir != 0) && (RList[MainCtrlActualPos].R > RVentCutOff))
|
||||
RventRot += (RVentnmax - RventRot) * RVentSpeed * dt;
|
||||
else
|
||||
RventRot *= (1.0 - RVentSpeed * dt);
|
||||
@@ -3835,7 +3835,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
RventRot += (RVentnmax * Im / ImaxLo - RventRot) * RVentSpeed * dt;
|
||||
else
|
||||
{
|
||||
RventRot = RventRot * (1.0 - RVentSpeed * dt);
|
||||
RventRot *= (1.0 - RVentSpeed * dt);
|
||||
if (RventRot < 0.1)
|
||||
RventRot = 0;
|
||||
}
|
||||
@@ -4213,7 +4213,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
PosRatio = (MainCtrlPos / MainCtrlPosNo);
|
||||
PosRatio = static_cast<double>( MainCtrlPos ) / static_cast<double>( MainCtrlPosNo );
|
||||
eimv[eimv_Fzad] = PosRatio;
|
||||
if ((Flat) && (eimc[eimc_p_F0] * eimv[eimv_Fful] > 0))
|
||||
PosRatio = Min0R(PosRatio * eimc[eimc_p_F0] / eimv[eimv_Fful], 1);
|
||||
@@ -4288,12 +4288,12 @@ double TMoverParameters::TractionForce(double dt)
|
||||
Transmision.Ratio * NPoweredAxles * 2.0 / WheelDiameter;
|
||||
if ((dizel_fill < 0))
|
||||
{
|
||||
eimv[eimv_Fful] = Min0R(eimc[eimc_p_Ph] * 3.6 / Vel,
|
||||
Min0R(eimc[eimc_p_Fh], eimv[eimv_FMAXMAX]));
|
||||
eimv[eimv_Fful] = std::min(eimc[eimc_p_Ph] * 3.6 / (Vel != 0.0 ? Vel : 0.001),
|
||||
std::min(eimc[eimc_p_Fh], eimv[eimv_FMAXMAX]));
|
||||
eimv[eimv_Fmax] =
|
||||
-Sign(V) * (DirAbsolute)*Min0R(
|
||||
eimc[eimc_p_Ph] * 3.6 / Vel,
|
||||
Min0R(-eimc[eimc_p_Fh] * dizel_fill, eimv[eimv_FMAXMAX]));
|
||||
-Sign(V) * (DirAbsolute)*std::min(
|
||||
eimc[eimc_p_Ph] * 3.6 / (Vel != 0.0 ? Vel : 0.001),
|
||||
std::min(-eimc[eimc_p_Fh] * dizel_fill, eimv[eimv_FMAXMAX]));
|
||||
//*Min0R(1,(Vel-eimc[eimc_p_Vh0])/(eimc[eimc_p_Vh1]-eimc[eimc_p_Vh0]))
|
||||
}
|
||||
else
|
||||
@@ -6406,7 +6406,7 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) {
|
||||
CompressorPower =
|
||||
lookup != compressorpowers.end() ?
|
||||
lookup->second :
|
||||
0;
|
||||
1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6925,7 +6925,7 @@ void TMoverParameters::LoadFIZ_RList( std::string const &Input ) {
|
||||
|
||||
if( RVentType > 0 ) {
|
||||
|
||||
extract_value( RVentnmax, "RVentmax", Input, "" );
|
||||
extract_value( RVentnmax, "RVentnmax", Input, "" );
|
||||
RVentnmax /= 60.0;
|
||||
extract_value( RVentCutOff, "RVentCutOff", Input, "" );
|
||||
}
|
||||
|
||||
56
PyInt.cpp
56
PyInt.cpp
@@ -289,10 +289,22 @@ void TPythonScreenRenderer::updateTexture()
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glBindTexture(GL_TEXTURE_2D, _textureId);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE,
|
||||
textureData);
|
||||
// setup texture parameters
|
||||
if( GLEW_VERSION_1_4 ) {
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
||||
glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -1.0 );
|
||||
}
|
||||
else {
|
||||
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
}
|
||||
// build texture
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, textureData);
|
||||
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
GLenum status = glGetError();
|
||||
switch (status)
|
||||
@@ -407,7 +419,7 @@ void TPythonScreens::reset(void *train)
|
||||
_terminationFlag = true;
|
||||
if (_thread != NULL)
|
||||
{
|
||||
WriteLog("Awaiting python thread to end");
|
||||
// WriteLog("Awaiting python thread to end");
|
||||
WaitForSingleObject(_thread, INFINITE);
|
||||
_thread = NULL;
|
||||
}
|
||||
@@ -428,61 +440,43 @@ void TPythonScreens::reset(void *train)
|
||||
|
||||
void TPythonScreens::init(cParser &parser, TModel3d *model, std::string const &name, int const cab)
|
||||
{
|
||||
char buff[255];
|
||||
std::string asSubModelName, asPyClassName;
|
||||
parser.getTokens( 2, false );
|
||||
parser
|
||||
>> asSubModelName
|
||||
>> asPyClassName;
|
||||
char *subModelName = (char *)calloc(asSubModelName.length() + 1, sizeof(char));
|
||||
strcpy(subModelName, ToLower( asSubModelName).c_str());
|
||||
char *pyClassName = (char *)calloc(asPyClassName.length() + 1, sizeof(char));
|
||||
strcpy(pyClassName, ToLower( asPyClassName ).c_str());
|
||||
TSubModel *subModel = model->GetFromName(subModelName);
|
||||
std::string subModelName = ToLower( asSubModelName );
|
||||
std::string pyClassName = ToLower( asPyClassName );
|
||||
TSubModel *subModel = model->GetFromName(subModelName.c_str());
|
||||
if (subModel == NULL)
|
||||
{
|
||||
sprintf(buff, "Python Screen: submodel %s not found - Ignoring screen", subModelName);
|
||||
WriteLog(buff);
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
WriteLog( "Python Screen: submodel " + subModelName + " not found - Ignoring screen" );
|
||||
return; // nie ma takiego sub modelu w danej kabinie pomijamy
|
||||
}
|
||||
int textureId = subModel->GetTextureId();
|
||||
if (textureId <= 0)
|
||||
{
|
||||
sprintf(buff, "Python Screen: invalid texture id %d - Ignoring screen", textureId);
|
||||
WriteLog(buff);
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
WriteLog( "Python Screen: invalid texture id " + std::to_string(textureId) + " - Ignoring screen" );
|
||||
return; // sub model nie posiada tekstury lub tekstura wymienna - nie obslugiwana
|
||||
}
|
||||
TPythonInterpreter *python = TPythonInterpreter::getInstance();
|
||||
python->loadClassFile(_lookupPath, pyClassName);
|
||||
PyObject *args = Py_BuildValue("(ssi)", _lookupPath, name.c_str(), cab);
|
||||
PyObject *args = Py_BuildValue("(ssi)", _lookupPath.c_str(), name.c_str(), cab);
|
||||
if (args == NULL)
|
||||
{
|
||||
WriteLog("Python Screen: cannot create __init__ arguments");
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
return;
|
||||
}
|
||||
PyObject *pyRenderer = python->newClass(pyClassName, args);
|
||||
Py_CLEAR(args);
|
||||
if (pyRenderer == NULL)
|
||||
{
|
||||
sprintf(buff, "Python Screen: null renderer for %s - Ignoring screen", pyClassName);
|
||||
WriteLog(buff);
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
WriteLog( "Python Screen: null renderer for " + pyClassName + " - Ignoring screen" );
|
||||
return; // nie mozna utworzyc obiektu Pythonowego
|
||||
}
|
||||
TPythonScreenRenderer *renderer = new TPythonScreenRenderer(textureId, pyRenderer);
|
||||
_screens.push_back(renderer);
|
||||
sprintf(buff, "Created python screen %s on submodel %s (%d)", pyClassName, subModelName,
|
||||
textureId);
|
||||
WriteLog(buff);
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
WriteLog( "Created python screen " + pyClassName + " on submodel " + subModelName + " (" + std::to_string(textureId) + ")" );
|
||||
}
|
||||
|
||||
void TPythonScreens::update()
|
||||
|
||||
2
PyInt.h
2
PyInt.h
@@ -36,7 +36,7 @@ class TPythonInterpreter
|
||||
TPythonInterpreter();
|
||||
~TPythonInterpreter() {}
|
||||
static TPythonInterpreter *_instance;
|
||||
int _screenRendererPriority;
|
||||
int _screenRendererPriority = 0;
|
||||
// std::set<const char *, ltstr> _classes;
|
||||
std::set<std::string> _classes;
|
||||
PyObject *_main;
|
||||
|
||||
224
Train.cpp
224
Train.cpp
@@ -186,6 +186,27 @@ TTrain::TTrain()
|
||||
dsbBufferClamp = NULL;
|
||||
iRadioChannel = 0;
|
||||
fTachoTimer = 0.0; // włączenie skoków wskazań prędkościomierza
|
||||
|
||||
//
|
||||
for( int i = 0; i < 8; i++ ) {
|
||||
bMains[ i ] = false;
|
||||
fCntVol[ i ] = 0.0f;
|
||||
bPants[ i ][ 0 ] = false;
|
||||
bPants[ i ][ 1 ] = false;
|
||||
bFuse[ i ] = false;
|
||||
bBatt[ i ] = false;
|
||||
bConv[ i ] = false;
|
||||
bComp[ i ][ 0 ] = false;
|
||||
bComp[ i ][ 1 ] = false;
|
||||
bHeat[ i ] = false;
|
||||
}
|
||||
for( int i = 0; i < 9; ++i )
|
||||
for( int j = 0; j < 10; ++j )
|
||||
fEIMParams[ i ][ j ] = 0.0;
|
||||
|
||||
for( int i = 0; i < 20; ++i )
|
||||
for( int j = 0; j < 3; ++j )
|
||||
fPress[ i ][ j ] = 0.0;
|
||||
}
|
||||
|
||||
TTrain::~TTrain()
|
||||
@@ -267,139 +288,98 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d)
|
||||
return true;
|
||||
}
|
||||
|
||||
PyObject *TTrain::GetTrainState()
|
||||
{
|
||||
PyObject *TTrain::GetTrainState() {
|
||||
PyObject *dict = PyDict_New();
|
||||
if (dict == NULL)
|
||||
{
|
||||
if( dict == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyDict_SetItemString(dict, "direction", PyGetInt(DynamicObject->MoverParameters->ActiveDir));
|
||||
PyDict_SetItemString(dict, "cab", PyGetInt(DynamicObject->MoverParameters->ActiveCab));
|
||||
PyDict_SetItemString(dict, "slipping_wheels",
|
||||
PyGetBool(DynamicObject->MoverParameters->SlippingWheels));
|
||||
PyDict_SetItemString(dict, "converter",
|
||||
PyGetBool(DynamicObject->MoverParameters->ConverterFlag));
|
||||
PyDict_SetItemString(dict, "main_ctrl_actual_pos",
|
||||
PyGetInt(DynamicObject->MoverParameters->MainCtrlActualPos));
|
||||
PyDict_SetItemString(dict, "scnd_ctrl_actual_pos",
|
||||
PyGetInt(DynamicObject->MoverParameters->ScndCtrlActualPos));
|
||||
PyDict_SetItemString(dict, "fuse", PyGetBool(DynamicObject->MoverParameters->FuseFlag));
|
||||
PyDict_SetItemString(dict, "converter_overload",
|
||||
PyGetBool(DynamicObject->MoverParameters->ConvOvldFlag));
|
||||
PyDict_SetItemString(dict, "voltage", PyGetFloat(DynamicObject->MoverParameters->Voltage));
|
||||
PyDict_SetItemString(dict, "velocity", PyGetFloat(DynamicObject->MoverParameters->Vel));
|
||||
PyDict_SetItemString(dict, "im", PyGetFloat(DynamicObject->MoverParameters->Im));
|
||||
PyDict_SetItemString(dict, "compress",
|
||||
PyGetBool(DynamicObject->MoverParameters->CompressorFlag));
|
||||
PyDict_SetItemString(dict, "hours", PyGetInt(GlobalTime->hh));
|
||||
PyDict_SetItemString(dict, "minutes", PyGetInt(GlobalTime->mm));
|
||||
PyDict_SetItemString(dict, "seconds", PyGetInt(GlobalTime->mr));
|
||||
PyDict_SetItemString(dict, "velocity_desired", PyGetFloat(DynamicObject->Mechanik->VelDesired));
|
||||
char *TXTT[10] = {"fd", "fdt", "fdb", "pd", "pdt", "pdb", "itothv", "1", "2", "3"};
|
||||
char *TXTC[10] = {"fr", "frt", "frb", "pr", "prt", "prb", "im", "vm", "ihv", "uhv"};
|
||||
char *TXTP[3] = {"bc", "bp", "sp"};
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
PyDict_SetItemString(dict, std::string("eimp_t_" + std::string(TXTT[j])).c_str(),
|
||||
PyGetFloatS(fEIMParams[0][j]));
|
||||
PyDict_SetItemString( dict, "direction", PyGetInt( DynamicObject->MoverParameters->ActiveDir ) );
|
||||
PyDict_SetItemString( dict, "cab", PyGetInt( DynamicObject->MoverParameters->ActiveCab ) );
|
||||
PyDict_SetItemString( dict, "slipping_wheels",
|
||||
PyGetBool( DynamicObject->MoverParameters->SlippingWheels ) );
|
||||
PyDict_SetItemString( dict, "converter",
|
||||
PyGetBool( DynamicObject->MoverParameters->ConverterFlag ) );
|
||||
PyDict_SetItemString( dict, "main_ctrl_actual_pos",
|
||||
PyGetInt( DynamicObject->MoverParameters->MainCtrlActualPos ) );
|
||||
PyDict_SetItemString( dict, "scnd_ctrl_actual_pos",
|
||||
PyGetInt( DynamicObject->MoverParameters->ScndCtrlActualPos ) );
|
||||
PyDict_SetItemString( dict, "fuse", PyGetBool( DynamicObject->MoverParameters->FuseFlag ) );
|
||||
PyDict_SetItemString( dict, "converter_overload",
|
||||
PyGetBool( DynamicObject->MoverParameters->ConvOvldFlag ) );
|
||||
PyDict_SetItemString( dict, "voltage", PyGetFloat( DynamicObject->MoverParameters->Voltage ) );
|
||||
PyDict_SetItemString( dict, "velocity", PyGetFloat( DynamicObject->MoverParameters->Vel ) );
|
||||
PyDict_SetItemString( dict, "im", PyGetFloat( DynamicObject->MoverParameters->Im ) );
|
||||
PyDict_SetItemString( dict, "compress",
|
||||
PyGetBool( DynamicObject->MoverParameters->CompressorFlag ) );
|
||||
PyDict_SetItemString( dict, "hours", PyGetInt( GlobalTime->hh ) );
|
||||
PyDict_SetItemString( dict, "minutes", PyGetInt( GlobalTime->mm ) );
|
||||
PyDict_SetItemString( dict, "seconds", PyGetInt( GlobalTime->mr ) );
|
||||
PyDict_SetItemString( dict, "velocity_desired", PyGetFloat( DynamicObject->Mechanik->VelDesired ) );
|
||||
char* TXTT[ 10 ] = { "fd", "fdt", "fdb", "pd", "pdt", "pdb", "itothv", "1", "2", "3" };
|
||||
char* TXTC[ 10 ] = { "fr", "frt", "frb", "pr", "prt", "prb", "im", "vm", "ihv", "uhv" };
|
||||
char* TXTP[ 3 ] = { "bc", "bp", "sp" };
|
||||
for( int j = 0; j<10; j++ )
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_t_" ) + std::string( TXTT[ j ] ) ).c_str(), PyGetFloatS( fEIMParams[ 0 ][ j ] ) );
|
||||
for( int i = 0; i<8; i++ ) {
|
||||
for( int j = 0; j<10; j++ )
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_" ) + std::string( TXTC[ j ] ) ).c_str(), PyGetFloatS( fEIMParams[ i + 1 ][ j ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_ms" ) ).c_str(), PyGetBool( bMains[ i ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_cv" ) ).c_str(), PyGetFloatS( fCntVol[ i ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_u" ) + std::to_string( i + 1 ) + std::string( "_pf" ) ).c_str(), PyGetBool( bPants[ i ][ 0 ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_u" ) + std::to_string( i + 1 ) + std::string( "_pr" ) ).c_str(), PyGetBool( bPants[ i ][ 1 ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_fuse" ) ).c_str(), PyGetBool( bFuse[ i ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_batt" ) ).c_str(), PyGetBool( bBatt[ i ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_conv" ) ).c_str(), PyGetBool( bConv[ i ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_u" ) + std::to_string( i + 1 ) + std::string( "_comp_a" ) ).c_str(), PyGetBool( bComp[ i ][ 0 ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_u" ) + std::to_string( i + 1 ) + std::string( "_comp_w" ) ).c_str(), PyGetBool( bComp[ i ][ 1 ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_heat" ) ).c_str(), PyGetBool( bHeat[ i ] ) );
|
||||
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
PyDict_SetItemString(
|
||||
dict,
|
||||
(std::string("eimp_c") + std::to_string(i + 1) + "_" + std::string(TXTC[j]))
|
||||
.c_str(),
|
||||
PyGetFloatS(fEIMParams[i + 1][j]));
|
||||
}
|
||||
PyDict_SetItemString(dict, (std::string("eimp_c") + std::to_string(i + 1) + "_ms").c_str(),
|
||||
PyGetBool(bMains[i]));
|
||||
PyDict_SetItemString(dict, (std::string("eimp_c") + std::to_string(i + 1) + "_cv").c_str(),
|
||||
PyGetFloatS(fCntVol[i]));
|
||||
PyDict_SetItemString(dict, (std::string("eimp_u") + std::to_string(i + 1) + "_pf").c_str(),
|
||||
PyGetBool(bPants[i][0]));
|
||||
PyDict_SetItemString(dict, (std::string("eimp_u") + std::to_string(i + 1) + "_pr").c_str(),
|
||||
PyGetBool(bPants[i][1]));
|
||||
PyDict_SetItemString(dict,
|
||||
(std::string("eimp_c") + std::to_string(i + 1) + "_fuse").c_str(),
|
||||
PyGetBool(bFuse[i]));
|
||||
PyDict_SetItemString(dict,
|
||||
(std::string("eimp_c") + std::to_string(i + 1) + "_batt").c_str(),
|
||||
PyGetBool(bBatt[i]));
|
||||
PyDict_SetItemString(dict,
|
||||
(std::string("eimp_c") + std::to_string(i + 1) + "_conv").c_str(),
|
||||
PyGetBool(bConv[i]));
|
||||
PyDict_SetItemString(dict,
|
||||
(std::string("eimp_u") + std::to_string(i + 1) + "_comp_a").c_str(),
|
||||
PyGetBool(bComp[i][0]));
|
||||
PyDict_SetItemString(dict,
|
||||
(std::string("eimp_u") + std::to_string(i + 1) + "_comp_w").c_str(),
|
||||
PyGetBool(bComp[i][1]));
|
||||
PyDict_SetItemString(dict,
|
||||
(std::string("eimp_c") + std::to_string(i + 1) + "_heat").c_str(),
|
||||
PyGetBool(bHeat[i]));
|
||||
}
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
PyDict_SetItemString(
|
||||
dict,
|
||||
(std::string("eimp_pn") + std::to_string(i + 1) + "_" + std::string(TXTP[j]))
|
||||
.c_str(),
|
||||
PyGetFloatS(fPress[i][j]));
|
||||
for( int i = 0; i<20; i++ ) {
|
||||
for( int j = 0; j<3; j++ )
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_pn" ) + std::to_string( i + 1 ) + std::string( "_" ) + std::string( TXTP[ j ] ) ).c_str(),
|
||||
PyGetFloatS( fPress[ i ][ j ] ) );
|
||||
}
|
||||
bool bEP, bPN;
|
||||
bEP = ( mvControlled->LocHandle->GetCP() > 0.2 ) || ( fEIMParams[0][2] > 0.01 );
|
||||
PyDict_SetItemString(dict, "dir_brake", PyGetBool(bEP));
|
||||
if (typeid(mvControlled->Hamulec) == typeid(TLSt) ||
|
||||
typeid(mvControlled->Hamulec) == typeid(TEStED))
|
||||
{
|
||||
bEP = ( mvControlled->LocHandle->GetCP()>0.2 ) || ( fEIMParams[ 0 ][ 2 ]>0.01 );
|
||||
PyDict_SetItemString( dict, "dir_brake", PyGetBool( bEP ) );
|
||||
if( ( typeid( *mvControlled->Hamulec ) == typeid( TLSt ) )
|
||||
|| ( typeid( *mvControlled->Hamulec ) == typeid( TEStED ) ) ) {
|
||||
|
||||
TBrake* temp_ham = mvControlled->Hamulec.get();
|
||||
// TLSt* temp_ham2 = temp_ham;
|
||||
bPN = ( static_cast<TLSt *>( mvControlled->Hamulec.get() )->GetEDBCP() > 0.2 );
|
||||
bPN = ( static_cast<TLSt*>( temp_ham )->GetEDBCP()>0.2 );
|
||||
}
|
||||
else
|
||||
bPN = false;
|
||||
PyDict_SetItemString(dict, "indir_brake", PyGetBool(bPN));
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
PyDict_SetItemString(dict, (std::string("doors_") + std::to_string(i + 1)).c_str(),
|
||||
PyGetFloatS(bDoors[i][0]));
|
||||
PyDict_SetItemString(dict, (std::string("doors_r_") + std::to_string(i + 1)).c_str(),
|
||||
PyGetFloatS(bDoors[i][1]));
|
||||
PyDict_SetItemString(dict, (std::string("doors_l_") + std::to_string(i + 1)).c_str(),
|
||||
PyGetFloatS(bDoors[i][2]));
|
||||
PyDict_SetItemString(dict, (std::string("doors_no_") + std::to_string(i + 1)).c_str(),
|
||||
PyGetInt(iDoorNo[i]));
|
||||
PyDict_SetItemString(
|
||||
dict, (std::string("code_") + std::to_string(i + 1)).c_str(),
|
||||
PyGetString(std::string(std::to_string(iUnits[i]) + cCode[i]).c_str()));
|
||||
PyDict_SetItemString(dict, (std::string("car_name") + std::to_string(i + 1)).c_str(),
|
||||
PyGetString(asCarName[i].c_str()));
|
||||
PyDict_SetItemString( dict, "indir_brake", PyGetBool( bPN ) );
|
||||
for( int i = 0; i<20; i++ ) {
|
||||
PyDict_SetItemString( dict, ( std::string( "doors_" ) + std::to_string( i + 1 ) ).c_str(), PyGetFloatS( bDoors[ i ][ 0 ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "doors_r_" ) + std::to_string( i + 1 ) ).c_str(), PyGetFloatS( bDoors[ i ][ 1 ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "doors_l_" ) + std::to_string( i + 1 ) ).c_str(), PyGetFloatS( bDoors[ i ][ 2 ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "doors_no_" ) + std::to_string( i + 1 ) ).c_str(), PyGetInt( iDoorNo[ i ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "code_" ) + std::to_string( i + 1 ) ).c_str(), PyGetString( std::string( std::to_string( iUnits[ i ] ) +
|
||||
cCode[ i ] ).c_str() ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "car_name" ) + std::to_string( i + 1 ) ).c_str(), PyGetString( asCarName[ i ].c_str() ) );
|
||||
}
|
||||
PyDict_SetItemString(dict, "car_no", PyGetInt(iCarNo));
|
||||
PyDict_SetItemString(dict, "power_no", PyGetInt(iPowerNo));
|
||||
PyDict_SetItemString(dict, "unit_no", PyGetInt(iUnitNo));
|
||||
PyDict_SetItemString(dict, "universal3", PyGetBool(LampkaUniversal3_st));
|
||||
PyDict_SetItemString(dict, "ca",
|
||||
PyGetBool(TestFlag(mvOccupied->SecuritySystem.Status, s_aware)));
|
||||
PyDict_SetItemString(dict, "shp",
|
||||
PyGetBool(TestFlag(mvOccupied->SecuritySystem.Status, s_active)));
|
||||
PyDict_SetItemString(dict, "manual_brake", PyGetBool(mvOccupied->ManualBrakePos > 0));
|
||||
PyDict_SetItemString(dict, "pantpress", PyGetFloat(mvControlled->PantPress));
|
||||
PyDict_SetItemString(dict, "trainnumber",
|
||||
PyGetString(DynamicObject->Mechanik->TrainName().c_str()));
|
||||
PyDict_SetItemString(dict, "velnext", PyGetFloat(DynamicObject->Mechanik->VelNext));
|
||||
PyDict_SetItemString(dict, "actualproximitydist",
|
||||
PyGetFloat(DynamicObject->Mechanik->ActualProximityDist));
|
||||
PyDict_SetItemString(dict, "velsignallast", PyGetFloat(DynamicObject->Mechanik->VelSignalLast));
|
||||
PyDict_SetItemString(dict, "vellimitlast", PyGetFloat(DynamicObject->Mechanik->VelLimitLast));
|
||||
PyDict_SetItemString(dict, "velroad", PyGetFloat(DynamicObject->Mechanik->VelRoad));
|
||||
PyDict_SetItemString(dict, "velsignalnext", PyGetFloat(DynamicObject->Mechanik->VelSignalNext));
|
||||
PyDict_SetItemString(dict, "battery", PyGetBool(mvControlled->Battery));
|
||||
PyDict_SetItemString(dict, "tractionforce", PyGetFloat(DynamicObject->MoverParameters->Ft));
|
||||
PyDict_SetItemString( dict, "car_no", PyGetInt( iCarNo ) );
|
||||
PyDict_SetItemString( dict, "power_no", PyGetInt( iPowerNo ) );
|
||||
PyDict_SetItemString( dict, "unit_no", PyGetInt( iUnitNo ) );
|
||||
PyDict_SetItemString( dict, "universal3", PyGetBool( LampkaUniversal3_st ) );
|
||||
PyDict_SetItemString( dict, "ca", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_aware ) ) );
|
||||
PyDict_SetItemString( dict, "shp", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) ) );
|
||||
PyDict_SetItemString( dict, "manual_brake", PyGetBool( mvOccupied->ManualBrakePos > 0 ) );
|
||||
PyDict_SetItemString( dict, "pantpress", PyGetFloat( mvControlled->PantPress ) );
|
||||
PyDict_SetItemString( dict, "trainnumber", PyGetString( DynamicObject->Mechanik->TrainName().c_str() ) );
|
||||
PyDict_SetItemString( dict, "velnext", PyGetFloat( DynamicObject->Mechanik->VelNext ) );
|
||||
PyDict_SetItemString( dict, "actualproximitydist", PyGetFloat( DynamicObject->Mechanik->ActualProximityDist ) );
|
||||
PyDict_SetItemString( dict, "velsignallast", PyGetFloat( DynamicObject->Mechanik->VelSignalLast ) );
|
||||
PyDict_SetItemString( dict, "vellimitlast", PyGetFloat( DynamicObject->Mechanik->VelLimitLast ) );
|
||||
PyDict_SetItemString( dict, "velroad", PyGetFloat( DynamicObject->Mechanik->VelRoad ) );
|
||||
PyDict_SetItemString( dict, "velsignalnext", PyGetFloat( DynamicObject->Mechanik->VelSignalNext ) );
|
||||
PyDict_SetItemString( dict, "battery", PyGetBool( mvControlled->Battery ) );
|
||||
PyDict_SetItemString( dict, "tractionforce", PyGetFloat( DynamicObject->MoverParameters->Ft ) );
|
||||
|
||||
return dict;
|
||||
}
|
||||
@@ -5030,6 +5010,8 @@ bool TTrain::Update( double const Deltatime )
|
||||
// wyprowadzenie sygnałów dla haslera na PoKeys (zaznaczanie na taśmie)
|
||||
btHaslerBrakes.Turn(DynamicObject->MoverParameters->BrakePress > 0.4); // ciśnienie w cylindrach
|
||||
btHaslerCurrent.Turn(DynamicObject->MoverParameters->Im != 0.0); // prąd na silnikach
|
||||
|
||||
m_updated = true;
|
||||
return true; //(DynamicObject->Update(dt));
|
||||
} // koniec update
|
||||
|
||||
|
||||
Reference in New Issue
Block a user