16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-23 14:29:18 +02:00

basic patches for most of discovered memory leaks, fixes for brake system components

This commit is contained in:
tmj-fstate
2017-01-18 07:56:51 +01:00
parent 4da7fedfe1
commit 6ab550831d
33 changed files with 824 additions and 929 deletions

View File

@@ -10,7 +10,6 @@ http://mozilla.org/MPL/2.0/.
#ifndef AdvSoundH #ifndef AdvSoundH
#define AdvSoundH #define AdvSoundH
#include "Sound.h"
#include "RealSound.h" #include "RealSound.h"
#include "parser.h" #include "parser.h"

View File

@@ -298,7 +298,7 @@ std::string TSpeedPos::TableText()
{ // pozycja tabelki pr<70>dko<6B>ci { // pozycja tabelki pr<70>dko<6B>ci
if (iFlags & spEnabled) if (iFlags & spEnabled)
{ // o ile pozycja istotna { // o ile pozycja istotna
return "Flags=#" + to_hex_str(iFlags, 8) + ", Dist=" + to_string(fDist, 1, 7) + return "Flags=" + to_hex_str(iFlags, 6) + ", Dist=" + to_string(fDist, 1, 7) +
", Vel=" + std::to_string(fVelNext) + ", Name=" + GetName(); ", Vel=" + std::to_string(fVelNext) + ", Name=" + GetName();
//if (iFlags & spTrack) // je<6A>li tor //if (iFlags & spTrack) // je<6A>li tor
// return "Flags=#" + IntToHex(iFlags, 8) + ", Dist=" + FloatToStrF(fDist, ffFixed, 7, 1) + // return "Flags=#" + IntToHex(iFlags, 8) + ", Dist=" + FloatToStrF(fDist, ffFixed, 7, 1) +
@@ -495,12 +495,9 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
pTrack = sSpeedTable[iLast].trTrack; // ostatnio sprawdzony tor pTrack = sSpeedTable[iLast].trTrack; // ostatnio sprawdzony tor
if (!pTrack) if (!pTrack)
return; // koniec toru, to nie ma co sprawdza<7A> (nie ma prawa tak by<62>) return; // koniec toru, to nie ma co sprawdza<7A> (nie ma prawa tak by<62>)
fLastDir = sSpeedTable[iLast].iFlags & spReverse ? fLastDir = (sSpeedTable[iLast].iFlags & spReverse) ? -1.0 : 1.0; // flaga ustawiona, gdy Point2 toru jest bli<6C>ej
-1.0 :
1.0; // flaga ustawiona, gdy Point2 toru jest bli<6C>ej
fCurrentDistance = sSpeedTable[iLast].fDist; // aktualna odleg<65>o<EFBFBD><6F> do jego Point1 fCurrentDistance = sSpeedTable[iLast].fDist; // aktualna odleg<65>o<EFBFBD><6F> do jego Point1
fTrackLength = fTrackLength = (sSpeedTable[iLast].iFlags & (spElapsed | spEnd)) ? 0.0 : pTrack->Length(); // nie dolicza<7A> d<>ugo<67>ci gdy:
sSpeedTable[iLast].iFlags & (spElapsed | spEnd) ? 0.0 : pTrack->Length(); // nie dolicza<7A> d<>ugo<67>ci gdy:
// 32-mini<6E>ty pocz<63>tek, // 32-mini<6E>ty pocz<63>tek,
// 64-jazda do ko<6B>ca toru // 64-jazda do ko<6B>ca toru
} }

View File

@@ -1886,11 +1886,11 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
{ {
} }
} // koniec hamulce } // koniec hamulce
else if (ActPar.substr(0, 1) == "") // tu mozna wpisac inny prefiks i inne rzeczy /* else if (ActPar.substr(0, 1) == "") // tu mozna wpisac inny prefiks i inne rzeczy
{ {
// jakies inne prefiksy // jakies inne prefiksy
} }
*/
} // koniec while kropka } // koniec while kropka
if (MoverParameters->CategoryFlag & 2) // jeśli samochód if (MoverParameters->CategoryFlag & 2) // jeśli samochód
@@ -5748,19 +5748,10 @@ int TDynamicObject::RouteWish(TTrack *tr)
std::string TDynamicObject::TextureTest(std::string const &name) std::string TDynamicObject::TextureTest(std::string const &name)
{ // Ra 2015-01: sprawdzenie dostępności tekstury o podanej nazwie { // Ra 2015-01: sprawdzenie dostępności tekstury o podanej nazwie
std::string x = name + ".dds"; // na razie prymitywnie std::vector<std::string> extensions = { ".dds", ".tga", ".bmp" };
if (FileExists(x.c_str())) for( auto const &extension : extensions ) {
return x; if( true == FileExists( name + extension ) ) {
else return name + extension;
{
x = name + ".tga"; // w zasadzie to należałoby uwzględnić deklarowaną kolejność
if (FileExists(x.c_str()))
return x;
else
{
x = name + ".bmp";
if (FileExists(x.c_str()))
return x;
} }
} }
return ""; // nie znaleziona return ""; // nie znaleziona

View File

@@ -26,8 +26,9 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
#include "opengl/ARB_Multisample.h" #include "opengl/ARB_Multisample.h"
#include "Globals.h" #include "Globals.h"
#include "Console.h"
#include "Logs.h" #include "Logs.h"
#include "Console.h"
#include "PyInt.h"
#include "World.h" #include "World.h"
#include "Mover.h" #include "Mover.h"
@@ -701,6 +702,8 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
SystemParametersInfo(SPI_SETKEYBOARDSPEED, iOldSpeed, NULL, 0); SystemParametersInfo(SPI_SETKEYBOARDSPEED, iOldSpeed, NULL, 0);
SystemParametersInfo(SPI_SETKEYBOARDDELAY, iOldDelay, NULL, 0); SystemParametersInfo(SPI_SETKEYBOARDDELAY, iOldDelay, NULL, 0);
delete pConsole; // deaktywania sterownika delete pConsole; // deaktywania sterownika
TPythonInterpreter::killInstance();
// shutdown // shutdown
KillGLWindow(); // kill the window KillGLWindow(); // kill the window
return (msg.wParam); // exit the program return (msg.wParam); // exit the program

View File

@@ -72,6 +72,9 @@ TEvent::~TEvent()
delete[] Params[8].asPointer; // zwolniæ obszar delete[] Params[8].asPointer; // zwolniæ obszar
case tp_GetValues: // nic case tp_GetValues: // nic
break; break;
case tp_PutValues: // params[0].astext stores the token
SafeDeleteArray( Params[ 0 ].asText );
break;
} }
evJoined = NULL; // nie usuwaæ podczepionych tutaj evJoined = NULL; // nie usuwaæ podczepionych tutaj
}; };
@@ -87,6 +90,7 @@ void TEvent::Conditions(cParser *parser, string s)
std::string token, str; std::string token, str;
if (!asNodeName.empty()) if (!asNodeName.empty())
{ // podczepienie ³añcucha, jeœli nie jest pusty { // podczepienie ³añcucha, jeœli nie jest pusty
// NOTE: source of a memory leak -- the array never gets deleted. fix the destructor
Params[9].asText = new char[asNodeName.length() + 1]; // usuwane i zamieniane na Params[9].asText = new char[asNodeName.length() + 1]; // usuwane i zamieniane na
// wskaŸnik // wskaŸnik
strcpy(Params[9].asText, asNodeName.c_str()); strcpy(Params[9].asText, asNodeName.c_str());
@@ -457,34 +461,43 @@ void TEvent::Load(cParser *parser, vector3 *org)
{ // obrót wzglêdem osi { // obrót wzglêdem osi
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
Params[9].asText = new char[255]; // nazwa submodelu Params[9].asText = new char[token.size() + 1]; // nazwa submodelu
strcpy(Params[9].asText, token.c_str()); std::strcpy(Params[9].asText, token.c_str());
Params[0].asInt = 1; Params[0].asInt = 1;
parser->getTokens(4); parser->getTokens(4);
*parser >> Params[1].asdouble >> Params[2].asdouble >> Params[3].asdouble >> *parser
Params[4].asdouble; >> Params[1].asdouble
>> Params[2].asdouble
>> Params[3].asdouble
>> Params[4].asdouble;
} }
else if (token.compare("translate") == 0) else if (token.compare("translate") == 0)
{ // przesuw o wektor { // przesuw o wektor
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
Params[9].asText = new char[255]; // nazwa submodelu Params[9].asText = new char[token.size() + 1]; // nazwa submodelu
strcpy(Params[9].asText, token.c_str()); std::strcpy(Params[9].asText, token.c_str());
Params[0].asInt = 2; Params[0].asInt = 2;
parser->getTokens(4); parser->getTokens(4);
*parser >> Params[1].asdouble >> Params[2].asdouble >> Params[3].asdouble >> *parser
Params[4].asdouble; >> Params[1].asdouble
>> Params[2].asdouble
>> Params[3].asdouble
>> Params[4].asdouble;
} }
else if (token.compare("digital") == 0) else if (token.compare("digital") == 0)
{ // licznik cyfrowy { // licznik cyfrowy
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
Params[9].asText = new char[255]; // nazwa submodelu Params[9].asText = new char[token.size() + 1]; // nazwa submodelu
strcpy(Params[9].asText, token.c_str()); std::strcpy(Params[9].asText, token.c_str());
Params[0].asInt = 8; Params[0].asInt = 8;
parser->getTokens(4); // jaki ma byæ sens tych parametrów? parser->getTokens(4); // jaki ma byæ sens tych parametrów?
*parser >> Params[1].asdouble >> Params[2].asdouble >> Params[3].asdouble >> *parser
Params[4].asdouble; >> Params[1].asdouble
>> Params[2].asdouble
>> Params[3].asdouble
>> Params[4].asdouble;
} }
else if (token.substr(token.length() - 4, 4) == ".vmd") // na razie tu, mo¿e bêdzie inaczej else if (token.substr(token.length() - 4, 4) == ".vmd") // na razie tu, mo¿e bêdzie inaczej
{ // animacja z pliku VMD { // animacja z pliku VMD
@@ -499,12 +512,15 @@ void TEvent::Load(cParser *parser, vector3 *org)
} }
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;
Params[9].asText = new char[255]; // nazwa submodelu Params[9].asText = new char[token.size() + 1]; // nazwa submodelu
strcpy(Params[9].asText, token.c_str()); std::strcpy(Params[9].asText, token.c_str());
Params[0].asInt = 4; // rodzaj animacji Params[0].asInt = 4; // rodzaj animacji
parser->getTokens(4); parser->getTokens(4);
*parser >> Params[1].asdouble >> Params[2].asdouble >> Params[3].asdouble >> *parser
Params[4].asdouble; >> Params[1].asdouble
>> Params[2].asdouble
>> Params[3].asdouble
>> Params[4].asdouble;
} }
parser->getTokens(); parser->getTokens();
*parser >> token; *parser >> token;

View File

@@ -117,6 +117,9 @@ TGroundNode::~TGroundNode()
delete Model; delete Model;
Model = NULL; Model = NULL;
break; break;
case TP_SOUND:
SafeDelete(tsStaticSound);
break;
case TP_TERRAIN: case TP_TERRAIN:
{ // pierwsze nNode zawiera model E3D, reszta to trójk¹ty { // pierwsze nNode zawiera model E3D, reszta to trójk¹ty
for (int i = 1; i < iCount; ++i) for (int i = 1; i < iCount; ++i)
@@ -697,6 +700,7 @@ TSubRect::~TSubRect()
if (Global::bManageNodes) // Ra: tu siê coœ sypie if (Global::bManageNodes) // Ra: tu siê coœ sypie
ResourceManager::Unregister(this); // wyrejestrowanie ze sprz¹tacza ResourceManager::Unregister(this); // wyrejestrowanie ze sprz¹tacza
// TODO: usun¹æ obiekty z listy (nRootMesh), bo s¹ one tworzone dla sektora // TODO: usun¹æ obiekty z listy (nRootMesh), bo s¹ one tworzone dla sektora
delete[] tTracks;
} }
void TSubRect::NodeAdd(TGroundNode *Node) void TSubRect::NodeAdd(TGroundNode *Node)
@@ -1767,8 +1771,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
*parser >> token; *parser >> token;
str = token; str = token;
//str = AnsiString(token.c_str()); //str = AnsiString(token.c_str());
tmp->tsStaticSound = new TTextSound(strdup(str.c_str()), sqrt(tmp->fSquareRadius), tmp->pCenter.x, tmp->tsStaticSound = new TTextSound(str, sqrt(tmp->fSquareRadius), tmp->pCenter.x, tmp->pCenter.y, tmp->pCenter.z, false, rmin);
tmp->pCenter.y, tmp->pCenter.z, false, rmin);
if (rmin < 0.0) if (rmin < 0.0)
rmin = rmin =
0.0; // przywrócenie poprawnej wartoœci, jeœli s³u¿y³a do wy³¹czenia efektu Dopplera 0.0; // przywrócenie poprawnej wartoœci, jeœli s³u¿y³a do wy³¹czenia efektu Dopplera
@@ -2320,9 +2323,7 @@ void TGround::FirstInit()
WriteLog("InitLaunchers OK"); WriteLog("InitLaunchers OK");
WriteLog("InitGlobalTime"); WriteLog("InitGlobalTime");
// ABu 160205: juz nie TODO :) // ABu 160205: juz nie TODO :)
GlobalTime = new TMTableTime( GlobalTime = std::make_shared<TMTableTime>( hh, mm, srh, srm, ssh, ssm ); // McZapkie-300302: inicjacja czasu rozkladowego - TODO: czytac z trasy!
hh, mm, srh, srm, ssh,
ssm); // McZapkie-300302: inicjacja czasu rozkladowego - TODO: czytac z trasy!
WriteLog("InitGlobalTime OK"); WriteLog("InitGlobalTime OK");
// jeszcze ustawienie pogody, gdyby nie by³o w scenerii wpisów // jeszcze ustawienie pogody, gdyby nie by³o w scenerii wpisów
glClearColor(Global::AtmoColor[0], Global::AtmoColor[1], Global::AtmoColor[2], glClearColor(Global::AtmoColor[0], Global::AtmoColor[1], Global::AtmoColor[2],

View File

@@ -642,10 +642,11 @@ public:
TBrakeHandle BrakeLocHandle; TBrakeHandle BrakeLocHandle;
double MBPM; /*masa najwiekszego cisnienia*/ double MBPM; /*masa najwiekszego cisnienia*/
TBrake *Hamulec; std::shared_ptr<TBrake> Hamulec;
TDriverHandle *Handle; std::shared_ptr<TDriverHandle> Handle;
TDriverHandle *LocHandle; std::shared_ptr<TDriverHandle> LocHandle;
TReservoir *Pipe; TReservoir *Pipe2; std::shared_ptr<TReservoir> Pipe;
std::shared_ptr<TReservoir> Pipe2;
TLocalBrake LocalBrake; /*rodzaj hamulca indywidualnego*/ TLocalBrake LocalBrake; /*rodzaj hamulca indywidualnego*/
TBrakePressureTable BrakePressureTable; /*wyszczegolnienie cisnien w rurze*/ TBrakePressureTable BrakePressureTable; /*wyszczegolnienie cisnien w rurze*/

View File

@@ -1796,63 +1796,96 @@ int TMoverParameters::ShowCurrent(int AmpN)
bool TMoverParameters::IncMainCtrl(int CtrlSpeed) bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
{ {
// basic fail conditions:
if( ( CabNo == 0 )
|| ( MainCtrlPosNo <= 0 ) ) {
// nie ma sterowania
return false;
}
if( ( TrainType == dt_ET22 ) && ( ScndCtrlPos != 0 ) ) {
// w ET22 nie da się kręcić nastawnikiem przy włączonym boczniku
return false;
}
if( ( TrainType == dt_EZT ) && ( ActiveDir == 0 ) ) {
// w EZT nie da się załączyć pozycji bez ustawienia kierunku
return false;
}
bool OK = false; bool OK = false;
if ((MainCtrlPosNo > 0) && (CabNo != 0))
{
if (MainCtrlPos < MainCtrlPosNo) if (MainCtrlPos < MainCtrlPosNo)
{ {
if ((TrainType != dt_ET22) || switch( EngineType ) {
((TrainType == dt_ET22) &&
(ScndCtrlPos ==
0))) // w ET22 nie da się kręcić nastawnikiem przy włączonym boczniku
switch (EngineType)
{
case None: case None:
case Dumb: case Dumb:
case DieselElectric: case DieselElectric:
case ElectricInductionMotor: case ElectricInductionMotor:
{ {
if (((CtrlSpeed == 1) && (TrainType != dt_EZT)) || if( CtrlSpeed > 1 ) {
((CtrlSpeed == 1) && (TrainType == dt_EZT) && (ActiveDir != 0))) OK = ( IncMainCtrl( 1 )
{ // w EZT nie da się załączyć pozycji bez ustawienia kierunku && IncMainCtrl( CtrlSpeed - 1 ) ); // a fail will propagate up the recursion chain. should this be || instead?
MainCtrlPos++; }
else {
++MainCtrlPos;
OK = true; OK = true;
} }
else if (((CtrlSpeed > 1) && (TrainType != dt_EZT)) ||
((CtrlSpeed > 1) && (TrainType == dt_EZT) && (ActiveDir != 0)))
OK = (IncMainCtrl(1) && IncMainCtrl(CtrlSpeed - 1));
break; break;
} }
case ElectricSeriesMotor: case ElectricSeriesMotor:
{ {
if ((CtrlSpeed == 1) && (ActiveDir != 0)) if( ActiveDir == 0 ) { return false; }
{
MainCtrlPos++; if( CtrlSpeed > 1 ) {
OK = true; // szybkie przejście na bezoporową
if (Imax == ImaxHi) if( TrainType == dt_ET40 ) {
if (RList[MainCtrlPos].Bn > 1) break; // this means ET40 won't react at all to fast acceleration command. should it issue just IncMainCtrl(1) instead?
{
if (TrainType == dt_ET42)
{
MainCtrlPos--;
OK = false;
} }
if (MaxCurrentSwitch(false)) while( ( RList[ MainCtrlPos ].R > 0.0 )
SetFlag( && IncMainCtrl( 1 ) ) {
SoundFlag, // all work is done in the loop header
sound_relay); // wylaczanie wysokiego rozruchu // Q TODO: ;
}
// OK:=true ; {takie chamskie, potem poprawie} <-Ra: kto miał to
// poprawić i po co?
if( ActiveDir == -1 ) {
while( ( RList[ MainCtrlPos ].Bn > 1 )
&& IncMainCtrl( 1 ) ) {
--MainCtrlPos;
}
}
OK = false; // shouldn't this be part of the loop above?
// if (TrainType=dt_ET40) then
// while Abs (Im)>IminHi do
// dec(MainCtrlPos);
// OK:=false ;
}
else { // CtrlSpeed == 1
++MainCtrlPos;
OK = true;
if( Imax == ImaxHi ) {
if( RList[ MainCtrlPos ].Bn > 1 ) {
if( true == MaxCurrentSwitch( false )) {
// wylaczanie wysokiego rozruchu
SetFlag( SoundFlag, sound_relay );
} // Q TODO:
// if (EngineType=ElectricSeriesMotor) and (MainCtrlPos=1) // if (EngineType=ElectricSeriesMotor) and (MainCtrlPos=1)
// then // then
// MainCtrlActualPos:=1; // MainCtrlActualPos:=1;
// //
} if( TrainType == dt_ET42 ) {
if ((CtrlSpeed == 1) && (ActiveDir == -1) && (RList[MainCtrlPos].Bn > 1) && --MainCtrlPos;
(TrainType != dt_PseudoDiesel))
{ // blokada wejścia na równoległą podczas jazdy do tyłu
MainCtrlPos--;
OK = false; OK = false;
} }
}
}
if( ActiveDir == -1 ) {
if( ( TrainType != dt_PseudoDiesel )
&& ( RList[ MainCtrlPos ].Bn > 1 ) ) {
// blokada wejścia na równoległą podczas jazdy do tyłu
--MainCtrlPos;
OK = false;
}
}
// //
// if (TrainType == "et40") // if (TrainType == "et40")
// if (Abs(Im) > IminHi) // if (Abs(Im) > IminHi)
@@ -1861,58 +1894,31 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
// OK = false; // OK = false;
// } // }
//} //}
if (DynamicBrakeFlag)
if (TrainType == dt_ET42)
if (MainCtrlPos > 20)
{
MainCtrlPos--;
OK = false;
} }
}
else if ((CtrlSpeed > 1) && (ActiveDir != 0) && (TrainType != dt_ET40))
{ // szybkie przejście na bezoporową
while ((RList[MainCtrlPos].R > 0) && IncMainCtrl(1)) if( ( TrainType == dt_ET42 ) && ( true == DynamicBrakeFlag ) ) {
; // tutaj ma być pętla na "pusto" if( MainCtrlPos > 20 ) {
// OK:=true ; {takie chamskie, potem poprawie} <-Ra: kto miał to MainCtrlPos = 20;
// poprawić i po co?
if (ActiveDir == -1)
while ((RList[MainCtrlPos].Bn > 1) && IncMainCtrl(1))
MainCtrlPos--;
OK = false;
// if (TrainType=dt_ET40) then
// while Abs (Im)>IminHi do
// dec(MainCtrlPos);
// OK:=false ;
//
if (DynamicBrakeFlag)
if (TrainType == dt_ET42)
while (MainCtrlPos > 20)
MainCtrlPos--;
OK = false; OK = false;
} }
}
// return OK; // return OK;
break; break;
} }
case DieselEngine: case DieselEngine:
{ {
if (CtrlSpeed == 1) if( CtrlSpeed > 1 ) {
{ while( MainCtrlPos < MainCtrlPosNo ) {
MainCtrlPos++;
OK = true;
if (MainCtrlPos > 0)
CompressorAllow = true;
else
CompressorAllow = false;
}
else if (CtrlSpeed > 1)
{
while (MainCtrlPos < MainCtrlPosNo)
IncMainCtrl( 1 ); IncMainCtrl( 1 );
OK = true;
} }
}
else {
++MainCtrlPos;
if( MainCtrlPos > 0 ) { CompressorAllow = true; }
else { CompressorAllow = false; }
}
OK = true;
break; break;
} }
@@ -1921,29 +1927,26 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
OK = AddPulseForce( CtrlSpeed ); OK = AddPulseForce( CtrlSpeed );
break; break;
} }
} // switch EngineType of } // switch EngineType of
} }
else // MainCtrlPos>=MainCtrlPosNo else {// MainCtrlPos>=MainCtrlPosNo
if (CoupledCtrl) // wspólny wał nastawnika jazdy i bocznikowania if( true == CoupledCtrl ) {
{ // wspólny wał nastawnika jazdy i bocznikowania
if (ScndCtrlPos < ScndCtrlPosNo) // 3<3 -> false if( ScndCtrlPos < ScndCtrlPosNo ) { // 3<3 -> false
{ ++ScndCtrlPos;
ScndCtrlPos++;
OK = true; OK = true;
} }
else else {
OK = false; OK = false;
} }
if (OK) }
}
if( true == OK )
{ {
SendCtrlToNext("MainCtrl", MainCtrlPos, CabNo); //??? SendCtrlToNext("MainCtrl", MainCtrlPos, CabNo); //???
SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabNo); SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabNo);
} }
}
else // nie ma sterowania
OK = false;
// if OK then LastRelayTime:=0;
// hunter-101012: poprawka // hunter-101012: poprawka
// poprzedni warunek byl niezbyt dobry, bo przez to przy trzymaniu + // poprzedni warunek byl niezbyt dobry, bo przez to przy trzymaniu +
@@ -5871,16 +5874,16 @@ std::string getkeyval(int rettype, std::string key)
int klen = key.length(); int klen = key.length();
int kpos = Pos(key, xline) - 1; int kpos = Pos(key, xline) - 1;
temp.erase(0, kpos + klen); temp.erase(0, kpos + klen);
if (temp.find(" ") != std::string::npos) if (temp.find(' ') != std::string::npos)
to = temp.find(" "); to = temp.find(' ');
else else
to = 255; to = 255;
kval = temp.substr(0, to); kval = temp.substr(0, to);
if (kval != "") if (kval != "")
kval = TrimSpace(kval); // wyciagnieta wartosc kval = TrimSpace(kval); // wyciagnieta wartosc
sectionname = ExchangeCharInString(sectionname, (char)":", (char)""); sectionname = ExchangeCharInString(sectionname, ':', NULL);
sectionname = ExchangeCharInString(sectionname, (char)".", (char)""); sectionname = ExchangeCharInString(sectionname, '.', NULL);
//--WriteLog(sectionname + "." + keyname + " val= [" + kval + "]"); //--WriteLog(sectionname + "." + keyname + " val= [" + kval + "]");
// if (rettype == 1) vS = kval; // if (rettype == 1) vS = kval;
@@ -6343,7 +6346,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
// appdir = ExtractFilePath(ParamStr(0)); // appdir = ExtractFilePath(ParamStr(0));
std::ifstream in(file.c_str()); std::ifstream in(file);
if (!in.is_open()) if (!in.is_open())
{ {
WriteLog("E8 - FIZ FILE NOT EXIST."); WriteLog("E8 - FIZ FILE NOT EXIST.");
@@ -7400,8 +7403,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
case K: case K:
{ {
WriteLog("XBT W, K"); WriteLog("XBT W, K");
Hamulec = new TWest(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, Hamulec = std::make_shared<TWest>(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
if (MBPM < 2) // jesli przystawka wazaca if (MBPM < 2) // jesli przystawka wazaca
Hamulec->SetLP(0, MaxBrakePress[3], 0); Hamulec->SetLP(0, MaxBrakePress[3], 0);
else else
@@ -7411,8 +7413,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
case KE: case KE:
{ {
WriteLog("XBT WKE"); WriteLog("XBT WKE");
Hamulec = new TKE(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, Hamulec = std::make_shared<TKE>(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
BrakeDelays, BrakeMethod, NAxles, NBpA);
Hamulec->SetRM(RapidMult); Hamulec->SetRM(RapidMult);
if (MBPM < 2) // jesli przystawka wazaca if (MBPM < 2) // jesli przystawka wazaca
Hamulec->SetLP(0, MaxBrakePress[3], 0); Hamulec->SetLP(0, MaxBrakePress[3], 0);
@@ -7426,9 +7427,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
case ESt4: case ESt4:
{ {
WriteLog("XBT NESt3, ESt3, ESt3AL2, ESt4"); WriteLog("XBT NESt3, ESt3, ESt3AL2, ESt4");
Hamulec = new TNESt3(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, Hamulec = std::make_shared<TNESt3>(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA); static_cast<TNESt3 *>(Hamulec.get())->SetSize(BrakeValveSize, BrakeValveParams);
(static_cast<TNESt3 *>(Hamulec))->SetSize(BrakeValveSize, BrakeValveParams);
if (MBPM < 2) // jesli przystawka wazaca if (MBPM < 2) // jesli przystawka wazaca
Hamulec->SetLP(0, MaxBrakePress[3], 0); Hamulec->SetLP(0, MaxBrakePress[3], 0);
else else
@@ -7439,24 +7439,21 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
case LSt: case LSt:
{ {
WriteLog("XBT LSt"); WriteLog("XBT LSt");
Hamulec = new TLSt(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, Hamulec = std::make_shared<TLSt>(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
BrakeDelays, BrakeMethod, NAxles, NBpA);
Hamulec->SetRM(RapidMult); Hamulec->SetRM(RapidMult);
break; break;
} }
case EStED: case EStED:
{ {
WriteLog("XBT EStED"); WriteLog("XBT EStED");
Hamulec = new TEStED(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, Hamulec = std::make_shared<TEStED>(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
Hamulec->SetRM(RapidMult); Hamulec->SetRM(RapidMult);
break; break;
} }
case EP2: case EP2:
{ {
WriteLog("XBT EP2"); WriteLog("XBT EP2");
Hamulec = new TEStEP2(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, Hamulec = std::make_shared<TEStEP2>(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
Hamulec->SetLP(Mass, MBPM, MaxBrakePress[1]); Hamulec->SetLP(Mass, MBPM, MaxBrakePress[1]);
break; break;
} }
@@ -7464,21 +7461,18 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
case CV1: case CV1:
{ {
WriteLog("XBT CV1"); WriteLog("XBT CV1");
Hamulec = new TCV1(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, Hamulec = std::make_shared<TCV1>(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
BrakeDelays, BrakeMethod, NAxles, NBpA);
break; break;
} }
case CV1_L_TR: case CV1_L_TR:
{ {
WriteLog("XBT CV1_L_T"); WriteLog("XBT CV1_L_T");
Hamulec = new TCV1L_TR(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, Hamulec = std::make_shared<TCV1L_TR>(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
break; break;
} }
default: default:
Hamulec = new TBrake(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, Hamulec = std::make_shared<TBrake>(MaxBrakePress[3], BrakeCylRadius, BrakeCylDist, BrakeVVolume, BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
BrakeCylNo, BrakeDelays, BrakeMethod, NAxles, NBpA);
} }
Hamulec->SetASBP(MaxBrakePress[4]); Hamulec->SetASBP(MaxBrakePress[4]);
@@ -7486,49 +7480,48 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
switch (BrakeHandle) switch (BrakeHandle)
{ {
case FV4a: case FV4a:
Handle = new TFV4aM(); Handle = std::make_shared<TFV4aM>();
break; break;
case FVel6: case FVel6:
Handle = new TFVel6(); Handle = std::make_shared<TFVel6>();
break; break;
case testH: case testH:
Handle = new Ttest(); Handle = std::make_shared<Ttest>();
break; break;
case M394: case M394:
Handle = new TM394(); Handle = std::make_shared<TM394>();
break; break;
case Knorr: case Knorr:
Handle = new TH14K1(); Handle = std::make_shared<TH14K1>();
break; break;
case St113: case St113:
Handle = new TSt113(); Handle = std::make_shared<TSt113>();
break; break;
default: default:
Handle = new TDriverHandle(); Handle = std::make_shared<TDriverHandle>();
} }
switch (BrakeLocHandle) switch (BrakeLocHandle)
{ {
case FD1: case FD1:
{ {
LocHandle = new TFD1(); LocHandle = std::make_shared<TFD1>();
LocHandle->Init(MaxBrakePress[0]); LocHandle->Init(MaxBrakePress[0]);
break; break;
} }
case Knorr: case Knorr:
{ {
LocHandle = new TH1405(); LocHandle = std::make_shared<TH1405>();
LocHandle->Init(MaxBrakePress[0]); LocHandle->Init(MaxBrakePress[0]);
break; break;
} }
default: default:
LocHandle = new TDriverHandle(); LocHandle = std::make_shared<TDriverHandle>();
} }
Pipe = new TReservoir(); Pipe = std::make_shared<TReservoir>();
Pipe2 = new TReservoir(); // zabezpieczenie, bo sie PG wywala... :( Pipe->CreateCap( ( Max0R( Dim.L, 14 ) + 0.5 ) * Spg * 1 ); // dlugosc x przekroj x odejscia i takie tam
Pipe->CreateCap((Max0R(Dim.L, 14) + 0.5) * Spg * 1); // dlugosc x przekroj x odejscia i takie Pipe2 = std::make_shared<TReservoir>(); // zabezpieczenie, bo sie PG wywala... :(
// tam
Pipe2->CreateCap( (Max0R(Dim.L, 14) + 0.5) * Spg * 1 ); Pipe2->CreateCap( (Max0R(Dim.L, 14) + 0.5) * Spg * 1 );
if (LightsPosNo > 0) if (LightsPosNo > 0)

View File

@@ -327,21 +327,17 @@ void TNESt3::Init(double PP, double HPP, double LPP, double BP, int BDF)
ValveRes->CreatePress(PP); ValveRes->CreatePress(PP);
BrakeCyl->CreatePress(BP); BrakeCyl->CreatePress(BP);
BrakeRes->CreatePress(PP); BrakeRes->CreatePress(PP);
CntrlRes = new TReservoir(); CntrlRes = std::make_shared<TReservoir>();
CntrlRes->CreateCap(15); CntrlRes->CreateCap(15);
CntrlRes->CreatePress(HPP); CntrlRes->CreatePress(HPP);
BrakeStatus = static_cast<int>(BP > 1.0); BrakeStatus = static_cast<int>(BP > 1.0);
Miedzypoj = new TReservoir(); Miedzypoj = std::make_shared<TReservoir>();
Miedzypoj->CreateCap(5); Miedzypoj->CreateCap(5);
Miedzypoj->CreatePress(PP); Miedzypoj->CreatePress(PP);
BVM = 1.0 / (HPP - 0.05 - LPP) * MaxBP; BVM = 1.0 / (HPP - 0.05 - LPP) * MaxBP;
BrakeDelayFlag = BDF; BrakeDelayFlag = BDF;
RapidStatus = false;
LoadC, LoadM, TareBP, TareM, Podskok, LBP = 0.0;
Zamykajacy, Przys_blok = false;
if (!(typeid(*FM) == typeid(TDisk1) || typeid(*FM) == typeid(TDisk2))) // jesli zeliwo to schodz if (!(typeid(*FM) == typeid(TDisk1) || typeid(*FM) == typeid(TDisk2))) // jesli zeliwo to schodz
RapidStaly = false; RapidStaly = false;
@@ -500,32 +496,31 @@ void TNESt3::SetSize(int size, std::string params) // ustawianie dysz (rozmiaru
if (params.find("ESt3") != std::string::npos) if (params.find("ESt3") != std::string::npos)
{ {
Podskok = 0.7; Podskok = 0.7;
Przekladniki[1] = new TRura(); Przekladniki[1] = std::make_shared<TRura>();
Przekladniki[3] = new TRura(); Przekladniki[3] = std::make_shared<TRura>();
} }
else else
{ {
Podskok = -1; Podskok = -1;
Przekladniki[1] = new TRapid(); Przekladniki[1] = std::make_shared<TRapid>();
if (params.find("-s216") != std::string::npos) if (params.find("-s216") != std::string::npos)
Przekladniki[1]->SetRapidParams(2, 16); Przekladniki[1]->SetRapidParams(2, 16);
else else
Przekladniki[1]->SetRapidParams(2, 0); Przekladniki[1]->SetRapidParams(2, 0);
Przekladniki[3] = new TPrzeciwposlizg(); Przekladniki[3] = std::make_shared<TPrzeciwposlizg>();
if (params.find("-ED") != std::string::npos) if (params.find("-ED") != std::string::npos)
{ {
delete Przekladniki[3]; // tutaj ma byæ destruktor
Przekladniki[1]->SetRapidParams(2, 18); Przekladniki[1]->SetRapidParams(2, 18);
Przekladniki[3] = new TPrzekED(); Przekladniki[3] = std::make_shared<TPrzekED>();
} }
} }
if (params.find("AL2") != std::string::npos) if (params.find("AL2") != std::string::npos)
Przekladniki[2] = new TPrzekCiagly(); Przekladniki[2] = std::make_shared<TPrzekCiagly>();
else if (params.find("PZZ") != std::string::npos) else if (params.find("PZZ") != std::string::npos)
Przekladniki[2] = new TPrzek_PZZ(); Przekladniki[2] = std::make_shared<TPrzek_PZZ>();
else else
Przekladniki[2] = new TRura(); Przekladniki[2] = std::make_shared<TRura>();
if ((params.find("3d") + params.find("4d")) != std::string::npos) if ((params.find("3d") + params.find("4d")) != std::string::npos)
autom = false; autom = false;

View File

@@ -17,10 +17,10 @@ http://mozilla.org/MPL/2.0/.
Copyright (C) 2007-2014 Maciej Cierniak Copyright (C) 2007-2014 Maciej Cierniak
*/ */
#include <memory>
#include "hamulce.h" // Pascal unit #include "hamulce.h" // Pascal unit
#include "friction.h" // Pascal unit #include "friction.h" // Pascal unit
#include "mctools.h" // Pascal unit #include "mctools.h" // Pascal unit
#include <string>
/* /*
(C) youBy (C) youBy
@@ -72,8 +72,8 @@ class TPrzekladnik : public TReservoir // przekladnik (powtarzacz)
{ {
private: private:
public: public:
TReservoir *BrakeRes; std::shared_ptr<TReservoir> BrakeRes;
TReservoir *Next; std::shared_ptr<TReservoir> Next;
TPrzekladnik() : TReservoir() {}; TPrzekladnik() : TReservoir() {};
virtual void Update(double dt); virtual void Update(double dt);
@@ -110,55 +110,51 @@ class TPrzeciwposlizg : public TRura // przy napelnianiu - rura, przy poslizgu -
} }
}; };
class TRapid : public TPrzekladnik // przekladnik dwustopniowy // przekladnik dwustopniowy
class TRapid : public TPrzekladnik {
{
private: private:
bool RapidStatus; // status rapidu bool RapidStatus = false; // status rapidu
double RapidMult; // przelozenie (w dol) double RapidMult = 0.0; // przelozenie (w dol)
// Komora2: real; // Komora2: real;
double DN; double DN = 0.0;
double DL; // srednice dysz napelniania i luzowania double DL = 0.0; // srednice dysz napelniania i luzowania
public: public:
void SetRapidParams(double mult, double size); void SetRapidParams(double mult, double size);
void SetRapidStatus(bool rs); void SetRapidStatus(bool rs);
void Update(double dt) /*override*/; void Update(double dt) /*override*/;
inline TRapid() : TPrzekladnik() inline TRapid() :
{ TPrzekladnik()
RapidStatus = false; {}
RapidMult, DN, DL = 0.0;
}
}; };
class TPrzekCiagly : public TPrzekladnik // AL2 // AL2
class TPrzekCiagly : public TPrzekladnik {
{
private: private:
double mult; double mult = 0.0;
public: public:
void SetMult(double m); void SetMult(double m);
void Update(double dt) /*override*/; void Update(double dt) /*override*/;
inline TPrzekCiagly() : TPrzekladnik() inline TPrzekCiagly() :
{ TPrzekladnik()
mult = 0.0; {}
}
}; };
class TPrzek_PZZ : public TPrzekladnik // podwojny zawor zwrotny // podwojny zawor zwrotny
class TPrzek_PZZ : public TPrzekladnik {
{
private: private:
double LBP; double LBP = 0.0;
public: public:
void SetLBP(double P); void SetLBP(double P);
void Update(double dt) /*override*/; void Update(double dt) /*override*/;
inline TPrzek_PZZ() : TPrzekladnik() inline TPrzek_PZZ() :
{ TPrzekladnik()
LBP = 0.0; {}
}
}; };
class TPrzekZalamany : public TPrzekladnik // Knicksventil class TPrzekZalamany : public TPrzekladnik // Knicksventil
@@ -166,59 +162,55 @@ class TPrzekZalamany : public TPrzekladnik // Knicksventil
{ {
private: private:
public: public:
TPrzekZalamany() : TPrzekladnik() {}; TPrzekZalamany() :
TPrzekladnik()
{}
}; };
class TPrzekED : public TRura // przy napelnianiu - rura, przy hamowaniu - upust // przy napelnianiu - rura, przy hamowaniu - upust
class TPrzekED : public TRura {
{
private: private:
double MaxP; double MaxP = 0.0;
public: public:
void SetP(double P); void SetP(double P);
void Update(double dt) /*override*/; void Update(double dt) /*override*/;
inline TPrzekED() : TRura() inline TPrzekED() :
{ TRura()
MaxP = 0.0; {}
}
}; };
class TNESt3 : public TBrake class TNESt3 : public TBrake {
{
private: private:
std::shared_ptr<TReservoir> CntrlRes; // zbiornik sterujšcy
std::shared_ptr<TReservoir> Miedzypoj; // pojemnosc posrednia (urojona) do napelniania ZP i ZS
std::shared_ptr<TPrzekladnik> Przekladniki[ 4 ];
double Nozzles[ dMAX ]; // dysze double Nozzles[ dMAX ]; // dysze
TReservoir *CntrlRes; // zbiornik sterujšcy double BVM = 0.0; // przelozenie PG-CH
double BVM; // przelozenie PG-CH
// ValveFlag: byte; //polozenie roznych zaworkow // ValveFlag: byte; //polozenie roznych zaworkow
bool Zamykajacy; // pamiec zaworka zamykajacego bool Zamykajacy = false; // pamiec zaworka zamykajacego
// Przys_wlot: boolean; //wlot do komory przyspieszacza // Przys_wlot: boolean; //wlot do komory przyspieszacza
bool Przys_blok; // blokada przyspieszacza bool Przys_blok = false; // blokada przyspieszacza
TReservoir *Miedzypoj; // pojemnosc posrednia (urojona) do napelniania ZP i ZS bool RapidStatus = false;
TPrzekladnik *Przekladniki[4]; bool RapidStaly = false;
bool RapidStatus; double LoadC = 0.0;
bool RapidStaly; double TareM = 0.0; // masa proznego
double LoadC; double LoadM = 0.0; // masa pelnego
double TareM; double TareBP = 0.0; // cisnienie dla proznego
double LoadM; // masa proznego i pelnego double HBG300 = 0.0; // zawor ograniczajacy cisnienie
double TareBP; // cisnienie dla proznego double Podskok = 0.0; // podskok preznosci poczatkowej
double HBG300; // zawor ograniczajacy cisnienie
double Podskok; // podskok preznosci poczatkowej
// HPBR: real; //zasilanie ZP z wysokiego cisnienia // HPBR: real; //zasilanie ZP z wysokiego cisnienia
bool autom; // odluzniacz samoczynny bool autom = false; // odluzniacz samoczynny
double LBP; // cisnienie hamulca pomocniczego double LBP = 0.0; // cisnienie hamulca pomocniczego
public: public:
inline TNESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, inline TNESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa) {}
{
}
void Init(double PP, double HPP, double LPP, double BP, int BDF) /*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF) /*override*/;
virtual double GetPF(double PP, double dt, virtual double GetPF(double PP, double dt, double Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
double Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
void EStParams(double i_crc); // parametry charakterystyczne dla ESt void EStParams(double i_crc); // parametry charakterystyczne dla ESt
virtual double GetCRP() /*override*/; virtual double GetCRP() /*override*/;
void CheckState(double BCP, double &dV1); // glowny przyrzad rozrzadczy void CheckState(double BCP, double &dV1); // glowny przyrzad rozrzadczy

View File

@@ -20,15 +20,15 @@ Copyright (C) 2007-2014 Maciej Cierniak
//---FUNKCJE OGOLNE--- //---FUNKCJE OGOLNE---
static double const DPL = 0.25; static double const DPL = 0.25;
double TFV4aM::pos_table[11] = {-2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0}; double const TFV4aM::pos_table[11] = {-2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0};
double TMHZ_EN57::pos_table[11] = {-2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0}; double const TMHZ_EN57::pos_table[11] = {-2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0};
double TM394::pos_table[11] = {-1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0}; double const TM394::pos_table[11] = {-1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0};
double TH14K1::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}}; double const TH14K1::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}};
double TH14K1::pos_table[11] = {-1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0}; double const TH14K1::pos_table[11] = {-1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0};
double TSt113::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}}; double const TSt113::BPT_K[6][2] = {{10, 0}, {4, 1}, {0, 1}, {4, 0}, {4, -1}, {15, -1}};
double TSt113::BEP_K[7] = {0, -1, 1, 0, 0, 0, 0}; double const TSt113::BEP_K[7] = {0, -1, 1, 0, 0, 0, 0};
double TSt113::pos_table[11] = {-1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1}; double const TSt113::pos_table[11] = {-1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1};
double TFVel6::pos_table[11] = {-1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1}; double const TFVel6::pos_table[11] = {-1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1};
double PR(double P1, double P2) double PR(double P1, double P2)
{ {
@@ -147,14 +147,6 @@ void TReservoir::Flow(double dv)
dVol = dVol + dv; dVol = dVol + dv;
} }
TReservoir::TReservoir()
{
// inherited:: Create;
Cap = 1;
Vol = 0;
dVol = 0;
}
void TReservoir::Act() void TReservoir::Act()
{ {
Vol = Vol + dVol; Vol = Vol + dVol;
@@ -264,9 +256,9 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn
4.2; // objetosc CH w stosunku do cylindra 14" i cisnienia 4.2 atm 4.2; // objetosc CH w stosunku do cylindra 14" i cisnienia 4.2 atm
// BrakeCyl:=TReservoir.Create; // BrakeCyl:=TReservoir.Create;
BrakeCyl = new TBrakeCyl(); BrakeCyl = std::make_shared<TBrakeCyl>();
BrakeRes = new TReservoir(); BrakeRes = std::make_shared<TReservoir>();
ValveRes = new TReservoir(); ValveRes = std::make_shared<TReservoir>();
// tworzenie zbiornikow // tworzenie zbiornikow
BrakeCyl->CreateCap(i_bcd * BCA * 1000); BrakeCyl->CreateCap(i_bcd * BCA * 1000);
@@ -279,34 +271,34 @@ TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn
switch (i_mat) switch (i_mat)
{ {
case bp_P10Bg: case bp_P10Bg:
FM = new TP10Bg(); FM = std::make_shared<TP10Bg>();
break; break;
case bp_P10Bgu: case bp_P10Bgu:
FM = new TP10Bgu(); FM = std::make_shared<TP10Bgu>();
break; break;
case bp_FR513: case bp_FR513:
FM = new TFR513(); FM = std::make_shared<TFR513>();
break; break;
case bp_FR510: case bp_FR510:
FM = new TFR510(); FM = std::make_shared<TFR510>();
break; break;
case bp_Cosid: case bp_Cosid:
FM = new TCosid(); FM = std::make_shared<TCosid>();
break; break;
case bp_P10yBg: case bp_P10yBg:
FM = new TP10yBg(); FM = std::make_shared<TP10yBg>();
break; break;
case bp_P10yBgu: case bp_P10yBgu:
FM = new TP10yBgu(); FM = std::make_shared<TP10yBgu>();
break; break;
case bp_D1: case bp_D1:
FM = new TDisk1(); FM = std::make_shared<TDisk1>();
break; break;
case bp_D2: case bp_D2:
FM = new TDisk2(); FM = std::make_shared<TDisk2>();
break; break;
default: // domyslnie default: // domyslnie
FM = new TP10(); FM = std::make_shared<TP10>();
} }
} }
@@ -2203,10 +2195,7 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TFV4a::Init(double Press) void TFV4a::Init(double Press)
{ {
CP = Press; CP = Press;
TP = 0;
RP = Press; RP = Press;
Time = false;
TimeEP = false;
} }
//---FV4a/M--- nowonapisany kran bez poprawki IC //---FV4a/M--- nowonapisany kran bez poprawki IC
@@ -2342,13 +2331,7 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TFV4aM::Init(double Press) void TFV4aM::Init(double Press)
{ {
CP = Press; CP = Press;
TP = 0.0;
RP = Press; RP = Press;
XP = 0.0;
Time = false;
TimeEP = false;
RedAdj = 0.0;
Fala = false;
} }
void TFV4aM::SetReductor(double nAdj) void TFV4aM::SetReductor(double nAdj)
@@ -2483,12 +2466,6 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep
void TMHZ_EN57::Init(double Press) void TMHZ_EN57::Init(double Press)
{ {
CP = Press; CP = Press;
TP = 0.0;
RP = 0.0;
Time = false;
TimeEP = false;
RedAdj = 0.0;
Fala = false;
} }
void TMHZ_EN57::SetReductor(double nAdj) void TMHZ_EN57::SetReductor(double nAdj)
@@ -2591,9 +2568,7 @@ double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TM394::Init(double Press) void TM394::Init(double Press)
{ {
CP = Press; CP = Press;
RedAdj = 0;
Time = true; Time = true;
TimeEP = false;
} }
void TM394::SetReductor(double nAdj) void TM394::SetReductor(double nAdj)
@@ -2657,7 +2632,6 @@ double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TH14K1::Init(double Press) void TH14K1::Init(double Press)
{ {
CP = Press; CP = Press;
RedAdj = 0;
Time = true; Time = true;
TimeEP = true; TimeEP = true;
} }
@@ -2738,7 +2712,6 @@ void TSt113::Init(double Press)
{ {
Time = true; Time = true;
TimeEP = true; TimeEP = true;
EPS = 0.0;
} }
//--- test --- //--- test ---
@@ -2799,11 +2772,8 @@ double TFD1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TFD1::Init(double Press) void TFD1::Init(double Press)
{ {
BP = 0;
MaxBP = Press; MaxBP = Press;
Time = false; Speed = 1.0;
TimeEP = false;
Speed = 1;
} }
double TFD1::GetCP() double TFD1::GetCP()
@@ -2844,10 +2814,8 @@ double TH1405::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TH1405::Init(double Press) void TH1405::Init(double Press)
{ {
BP = 0;
MaxBP = Press; MaxBP = Press;
Time = true; Time = true;
TimeEP = false;
} }
double TH1405::GetCP() double TH1405::GetCP()
@@ -2919,7 +2887,6 @@ void TFVel6::Init(double Press)
{ {
Time = true; Time = true;
TimeEP = true; TimeEP = true;
EPS = 0.0;
} }
// END // END

View File

@@ -1,6 +1,3 @@
#pragma once
#ifndef INCLUDED_HAMULCE_H
#define INCLUDED_HAMULCE_H
/*fizyka hamulcow dla symulatora*/ /*fizyka hamulcow dla symulatora*/
/* /*
@@ -35,11 +32,10 @@ H14K1 (zasadniczy), H1405 (pomocniczy), St113 (ep)
Knorr/West EP - ¿eby by³ Knorr/West EP - ¿eby by³
*/ */
#pragma once
#include "friction.h" // Pascal unit #include "friction.h" // Pascal unit
#include "mctools.h" // Pascal unit #include "mctools.h" // Pascal unit
//#include <array>
static int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca recznego lub pomocniczego*/ static int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca recznego lub pomocniczego*/
static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/ static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/
@@ -129,8 +125,8 @@ Knorr/West EP -
//7//1.5 //7//1.5
// BPT: array[-2..6] of array [0..1] of real= ((0, 5.0), (14, 5.4), (9, 5.0), (6, 4.6), (9, 4.5), (9, 4.0), (9, 3.5), (9, 2.8), (34, 2.8)); // BPT: array[-2..6] of array [0..1] of real= ((0, 5.0), (14, 5.4), (9, 5.0), (6, 4.6), (9, 4.5), (9, 4.0), (9, 3.5), (9, 2.8), (34, 2.8));
// BPT: array[-2..6] of array [0..1] of real= ((0, 5.0), (7, 5.0), (2.0, 5.0), (4.5, 4.6), (4.5, 4.2), (4.5, 3.8), (4.5, 3.4), (4.5, 2.8), (8, 2.8)); // BPT: array[-2..6] of array [0..1] of real= ((0, 5.0), (7, 5.0), (2.0, 5.0), (4.5, 4.6), (4.5, 4.2), (4.5, 3.8), (4.5, 3.4), (4.5, 2.8), (8, 2.8));
static double BPT[9][2] = { {0 , 5.0} , {7 , 5.0} , {2.0 , 5.0} , {4.5 , 4.6} , {4.5 , 4.2} , {4.5 , 3.8} , {4.5 , 3.4} , {4.5 , 2.8} , {8 , 2.8} }; static double const BPT[9][2] = { {0 , 5.0} , {7 , 5.0} , {2.0 , 5.0} , {4.5 , 4.6} , {4.5 , 4.2} , {4.5 , 3.8} , {4.5 , 3.4} , {4.5 , 2.8} , {8 , 2.8} };
static double BPT_394[7][2] = { {13 , 10.0} , {5 , 5.0} , {0 , -1} , {5 , -1} , {5 , 0.0} , {5 , 0.0} , {18 , 0.0} }; static double const BPT_394[7][2] = { {13 , 10.0} , {5 , 5.0} , {0 , -1} , {5 , -1} , {5 , 0.0} , {5 , 0.0} , {18 , 0.0} };
//double *BPT = zero_based_BPT[2]; //tablica pozycji hamulca dla zakresu -2..6 //double *BPT = zero_based_BPT[2]; //tablica pozycji hamulca dla zakresu -2..6
//double *BPT_394 = zero_based_BPT_394[1]; //tablica pozycji hamulca dla zakresu -1..5 //double *BPT_394 = zero_based_BPT_394[1]; //tablica pozycji hamulca dla zakresu -1..5
// BPT: array[-2..6] of array [0..1] of real= ((0, 5.0), (12, 5.4), (9, 5.0), (9, 4.6), (9, 4.2), (9, 3.8), (9, 3.4), (9, 2.8), (34, 2.8)); // BPT: array[-2..6] of array [0..1] of real= ((0, 5.0), (12, 5.4), (9, 5.0), (9, 4.6), (9, 4.2), (9, 3.8), (9, 3.4), (9, 2.8), (34, 2.8));
@@ -139,17 +135,14 @@ Knorr/West EP -
// static double const pi = 3.141592653589793; //definicja w mctools // static double const pi = 3.141592653589793; //definicja w mctools
//klasa obejmujaca pojedyncze zbiorniki //klasa obejmujaca pojedyncze zbiorniki
class TReservoir {
class TReservoir
{
protected: protected:
double Cap; double Cap = 1.0;
double Vol; double Vol = 0.0;
double dVol; double dVol = 0.0;
public: public:
TReservoir();
void CreateCap(double Capacity); void CreateCap(double Capacity);
void CreatePress(double Press); void CreatePress(double Press);
virtual double pa(); virtual double pa();
@@ -157,54 +150,47 @@ Knorr/West EP -
void Flow(double dv); void Flow(double dv);
void Act(); void Act();
TReservoir() = default;
}; };
typedef TReservoir *PReservoir; typedef TReservoir *PReservoir;
class TBrakeCyl : public TReservoir class TBrakeCyl : public TReservoir {
{
public: public:
virtual double pa()/*override*/; virtual double pa()/*override*/;
virtual double P()/*override*/; virtual double P()/*override*/;
TBrakeCyl() : TReservoir() {}; TBrakeCyl() : TReservoir() {};
}; };
//klasa obejmujaca uklad hamulca zespolonego pojazdu //klasa obejmujaca uklad hamulca zespolonego pojazdu
class TBrake {
class TBrake
{
protected: protected:
TReservoir *BrakeCyl; //silownik std::shared_ptr<TReservoir> BrakeCyl; //silownik
TReservoir *BrakeRes; //ZP std::shared_ptr<TReservoir> BrakeRes; //ZP
TReservoir *ValveRes; //komora wstepna std::shared_ptr<TReservoir> ValveRes; //komora wstepna
int BCN; //ilosc silownikow int BCN = 0; //ilosc silownikow
double BCM; //przekladnia hamulcowa double BCM = 0.0; //przekladnia hamulcowa
double BCA; //laczny przekroj silownikow double BCA = 0.0; //laczny przekroj silownikow
int BrakeDelays; //dostepne opoznienia int BrakeDelays = 0; //dostepne opoznienia
int BrakeDelayFlag; //aktualna nastawa int BrakeDelayFlag = 0; //aktualna nastawa
TFricMat *FM; //material cierny std::shared_ptr<TFricMat> FM; //material cierny
double MaxBP; //najwyzsze cisnienie double MaxBP = 0.0; //najwyzsze cisnienie
int BA; //osie hamowane int BA = 0; //osie hamowane
int NBpA; //klocki na os int NBpA = 0; //klocki na os
double SizeBR; //rozmiar^2 ZP (w stosunku do 14") double SizeBR = 0.0; //rozmiar^2 ZP (w stosunku do 14")
double SizeBC; //rozmiar^2 CH (w stosunku do 14") double SizeBC = 0.0; //rozmiar^2 CH (w stosunku do 14")
bool DCV; //podwojny zawor zwrotny bool DCV = false; //podwojny zawor zwrotny
double ASBP; //cisnienie hamulca pp double ASBP = 0.0; //cisnienie hamulca pp
int BrakeStatus; //flaga stanu
int SoundFlag;
int BrakeStatus = 0; //flaga stanu
int SoundFlag = 0;
public: public:
TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa);
int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa); //maksymalne cisnienie, promien, skok roboczy, pojemnosc ZP, ilosc cylindrow, opoznienia hamulca, material klockow, osie hamowane, klocki na os;
//maksymalne cisnienie, promien, skok roboczy, pojemnosc ZP;
//ilosc cylindrow, opoznienia hamulca, material klockow, osie hamowane, klocki na os;
virtual void Init(double PP, double HPP, double LPP, double BP, int BDF); //inicjalizacja hamulca virtual void Init(double PP, double HPP, double LPP, double BP, int BDF); //inicjalizacja hamulca
double GetFC(double Vel, double N); //wspolczynnik tarcia - hamulec wie lepiej double GetFC(double Vel, double N); //wspolczynnik tarcia - hamulec wie lepiej
@@ -229,23 +215,18 @@ Knorr/West EP -
virtual void ForceEmptiness(); virtual void ForceEmptiness();
int GetSoundFlag(); int GetSoundFlag();
virtual void SetED(double EDstate) {}; //stan hamulca ED do luzowania virtual void SetED(double EDstate) {}; //stan hamulca ED do luzowania
// procedure
}; };
class TWest : public TBrake {
class TWest : public TBrake
{
private: private:
double LBP; //cisnienie hamulca pomocniczego double LBP = 0.0; //cisnienie hamulca pomocniczego
double dVP; //pobor powietrza wysokiego cisnienia double dVP = 0.0; //pobor powietrza wysokiego cisnienia
double EPS; //stan elektropneumatyka double EPS = 0.0; //stan elektropneumatyka
double TareM; double LoadM; //masa proznego i pelnego double TareM = 0.0; //masa proznego
double TareBP; //cisnienie dla proznego double LoadM = 0.0; //i pelnego
double LoadC; //wspolczynnik przystawki wazacej double TareBP = 0.0; //cisnienie dla proznego
double LoadC = 0.0; //wspolczynnik przystawki wazacej
public: public:
void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/;
@@ -256,24 +237,18 @@ Knorr/West EP -
void SetEPS(double nEPS)/*override*/; //stan hamulca EP void SetEPS(double nEPS)/*override*/; //stan hamulca EP
void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej
inline TWest(double i_mbp, double i_bcr, double i_bcd, double i_brc, inline TWest(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa) {}
{
LBP, dVP, EPS, TareM, TareBP, LoadM, LoadC = 0.0;
}
}; };
class TESt : public TBrake {
class TESt : public TBrake
{
private: private:
protected: protected:
TReservoir *CntrlRes; //zbiornik steruj¹cy std::shared_ptr<TReservoir> CntrlRes; //zbiornik steruj¹cy
double BVM; //przelozenie PG-CH double BVM = 0.0; //przelozenie PG-CH
public: public:
void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/;
@@ -285,93 +260,77 @@ Knorr/West EP -
double CVs(double BP); //napelniacz sterujacego double CVs(double BP); //napelniacz sterujacego
double BVs(double BCP); //napelniacz pomocniczego double BVs(double BCP); //napelniacz pomocniczego
inline TESt(double i_mbp, double i_bcr, double i_bcd, double i_brc, inline TESt(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa)
{ {
CntrlRes = new TReservoir(); CntrlRes = std::make_shared<TReservoir>();
} }
}; };
class TESt3 : public TESt {
class TESt3 : public TESt
{
private: private:
//double CylFlowSpeed[2][2]; //zmienna nie uzywana //double CylFlowSpeed[2][2]; //zmienna nie uzywana
public: public:
double GetPF(double PP, double dt, double Vel)/*override*/; //przeplyw miedzy komora wstepna i PG double GetPF(double PP, double dt, double Vel)/*override*/; //przeplyw miedzy komora wstepna i PG
inline TESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, inline TESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TESt( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa) { } {}
}; };
class TESt3AL2 : public TESt3 {
class TESt3AL2 : public TESt3
{
private: private:
double TareM; double LoadM; //masa proznego i pelnego std::shared_ptr<TReservoir> ImplsRes; //komora impulsowa
double TareBP; //cisnienie dla proznego double TareM = 0.0; //masa proznego
double LoadC; double LoadM = 0.0; //i pelnego
double TareBP = 0.0; //cisnienie dla proznego
double LoadC = 0.0;
public: public:
TReservoir *ImplsRes; //komora impulsowa
void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/;
double GetPF(double PP, double dt, double Vel)/*override*/; //przeplyw miedzy komora wstepna i PG double GetPF(double PP, double dt, double Vel)/*override*/; //przeplyw miedzy komora wstepna i PG
void PLC(double mass); //wspolczynnik cisnienia przystawki wazacej void PLC(double mass); //wspolczynnik cisnienia przystawki wazacej
void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej
inline TESt3AL2(double i_mbp, double i_bcr, double i_bcd, double i_brc inline TESt3AL2(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt3(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TESt3( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa)
{ {
TareM, TareBP, LoadM, LoadC = 0.0; ImplsRes = std::make_shared<TReservoir>();
} }
}; };
class TESt4R : public TESt {
class TESt4R : public TESt
{
private: private:
bool RapidStatus; bool RapidStatus = false;
protected: protected:
TReservoir *ImplsRes; //komora impulsowa std::shared_ptr<TReservoir> ImplsRes; //komora impulsowa
double RapidTemp; //aktualne, zmienne przelozenie double RapidTemp = 0.0; //aktualne, zmienne przelozenie
public: public:
void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/;
double GetPF(double PP, double dt, double Vel)/*override*/; //przeplyw miedzy komora wstepna i PG double GetPF(double PP, double dt, double Vel)/*override*/; //przeplyw miedzy komora wstepna i PG
inline TESt4R(double i_mbp, double i_bcr, double i_bcd, double i_brc inline TESt4R(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TESt( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa)
{ {
RapidTemp = 0.0; ImplsRes = std::make_shared<TReservoir>();
ImplsRes = new TReservoir();
} }
}; };
class TLSt : public TESt4R {
class TLSt : public TESt4R
{
private: private:
// double CylFlowSpeed[2][2]; // zmienna nie u¿ywana // double CylFlowSpeed[2][2]; // zmienna nie u¿ywana
protected: protected:
double LBP; //cisnienie hamulca pomocniczego double LBP = 0.0; //cisnienie hamulca pomocniczego
double RM; //przelozenie rapida double RM = 0.0; //przelozenie rapida
double EDFlag; //luzowanie hamulca z powodu zalaczonego ED double EDFlag = 0.0; //luzowanie hamulca z powodu zalaczonego ED
public: public:
void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/;
@@ -382,26 +341,22 @@ Knorr/West EP -
virtual double GetEDBCP(); //cisnienie tylko z hamulca zasadniczego, uzywane do hamulca ED w EP09 virtual double GetEDBCP(); //cisnienie tylko z hamulca zasadniczego, uzywane do hamulca ED w EP09
virtual void SetED(double EDstate); //stan hamulca ED do luzowania virtual void SetED(double EDstate); //stan hamulca ED do luzowania
inline TLSt(double i_mbp, double i_bcr, double i_bcd, double i_brc, inline TLSt(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt4R(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TESt4R( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa) {}
{
}
}; };
class TEStED : public TLSt { //zawor z EP09 - Est4 z oddzielnym przekladnikiem, kontrola rapidu i takie tam
class TEStED : public TLSt //zawor z EP09 - Est4 z oddzielnym przekladnikiem, kontrola rapidu i takie tam
{
private: private:
std::shared_ptr<TReservoir> Miedzypoj; //pojemnosc posrednia (urojona) do napelniania ZP i ZS
double Nozzles[ 11 ]; //dysze double Nozzles[ 11 ]; //dysze
bool Zamykajacy; //pamiec zaworka zamykajacego bool Zamykajacy = false; //pamiec zaworka zamykajacego
bool Przys_blok; //blokada przyspieszacza bool Przys_blok = false; //blokada przyspieszacza
TReservoir *Miedzypoj; //pojemnosc posrednia (urojona) do napelniania ZP i ZS double TareM = 0.0; //masa proznego
double TareM; double LoadM; //masa proznego i pelnego double LoadM = 0.0; //i pelnego
double TareBP; //cisnienie dla proznego double TareBP = 0.0; //cisnienie dla proznego
double LoadC; double LoadC = 0.0;
public: public:
@@ -411,26 +366,21 @@ Knorr/West EP -
void PLC(double mass); //wspolczynnik cisnienia przystawki wazacej void PLC(double mass); //wspolczynnik cisnienia przystawki wazacej
void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej
inline TEStED(double i_mbp, double i_bcr, double i_bcd, double i_brc inline TEStED(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TLSt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TLSt( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa)
{ {
Przys_blok = false; Miedzypoj = std::make_shared<TReservoir>();
TareM, TareBP, LoadM, LoadC = 0.0;
Miedzypoj = new TReservoir();
} }
}; };
class TEStEP2 : public TLSt {
class TEStEP2 : public TLSt
{
private: private:
double TareM; double LoadM; //masa proznego i pelnego double TareM = 0.0; //masa proznego
double TareBP; //cisnienie dla proznego double LoadM = 0.0; //masa pelnego
double LoadC; double TareBP = 0.0; //cisnienie dla proznego
double EPS; double LoadC = 0.0;
double EPS = 0.0;
public: public:
@@ -440,25 +390,18 @@ Knorr/West EP -
void SetEPS(double nEPS)/*override*/; //stan hamulca EP void SetEPS(double nEPS)/*override*/; //stan hamulca EP
void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej
inline TEStEP2(double i_mbp, double i_bcr, double i_bcd, double i_brc inline TEStEP2(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TLSt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TLSt( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa) {}
{
TareM, TareBP, LoadM, LoadC, EPS = 0.0;
}
}; };
class TCV1 : public TBrake {
class TCV1 : public TBrake
{
private: private:
double BVM; //przelozenie PG-CH double BVM = 0.0; //przelozenie PG-CH
protected: protected:
TReservoir *CntrlRes; //zbiornik steruj¹cy std::shared_ptr<TReservoir> CntrlRes; //zbiornik steruj¹cy
public: public:
void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/;
@@ -468,16 +411,13 @@ Knorr/West EP -
double CVs(double BP); double CVs(double BP);
double BVs(double BCP); double BVs(double BCP);
inline TCV1(double i_mbp, double i_bcr, double i_bcd, double i_brc, inline TCV1(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa)
{ {
CntrlRes = new TReservoir(); CntrlRes = std::make_shared<TReservoir>();
} }
}; };
//class TCV1R : public TCV1 //class TCV1R : public TCV1
//{ //{
@@ -495,15 +435,11 @@ Knorr/West EP -
// , i_BD, i_mat, i_ba, i_nbpa, PP, HPP, LPP, BP, BDF) { } // , i_BD, i_mat, i_ba, i_nbpa, PP, HPP, LPP, BP, BDF) { }
//}; //};
class TCV1L_TR : public TCV1 {
class TCV1L_TR : public TCV1
{
private: private:
TReservoir *ImplsRes; //komora impulsowa std::shared_ptr<TReservoir> ImplsRes; //komora impulsowa
double LBP; //cisnienie hamulca pomocniczego double LBP = 0.0; //cisnienie hamulca pomocniczego
public: public:
void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/;
@@ -511,32 +447,27 @@ Knorr/West EP -
void SetLBP(double P); //cisnienie z hamulca pomocniczego void SetLBP(double P); //cisnienie z hamulca pomocniczego
double GetHPFlow(double HP, double dt)/*override*/; //przeplyw - 8 bar double GetHPFlow(double HP, double dt)/*override*/; //przeplyw - 8 bar
inline TCV1L_TR(double i_mbp, double i_bcr, double i_bcd, double i_brc inline TCV1L_TR(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TCV1(i_mbp, i_bcr, i_bcd, i_brc, i_bcn TCV1( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
, i_BD, i_mat, i_ba, i_nbpa)
{ {
LBP = 0.0; ImplsRes = std::make_shared<TReservoir>();
ImplsRes = new TReservoir();
} }
}; };
class TKE : public TBrake { //Knorr Einheitsbauart — jeden do wszystkiego
class TKE : public TBrake //Knorr Einheitsbauart — jeden do wszystkiego
{
private: private:
bool RapidStatus; std::shared_ptr<TReservoir> ImplsRes; //komora impulsowa
TReservoir *ImplsRes; //komora impulsowa std::shared_ptr<TReservoir> CntrlRes; //zbiornik steruj¹cy
TReservoir *CntrlRes; //zbiornik steruj¹cy std::shared_ptr<TReservoir> Brak2Res; //zbiornik pomocniczy 2
TReservoir *Brak2Res; //zbiornik pomocniczy 2 bool RapidStatus = false;
double BVM; //przelozenie PG-CH double BVM = 0.0; //przelozenie PG-CH
double TareM; double LoadM; //masa proznego i pelnego double TareM = 0.0; //masa proznego
double TareBP; //cisnienie dla proznego double LoadM = 0.0; //masa pelnego
double LoadC; //wspolczynnik zaladowania double TareBP = 0.0; //cisnienie dla proznego
double RM; //przelozenie rapida double LoadC = 0.0; //wspolczynnik zaladowania
double LBP; //cisnienie hamulca pomocniczego double RM = 0.0; //przelozenie rapida
double LBP = 0.0; //cisnienie hamulca pomocniczego
public: public:
void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/; void Init(double PP, double HPP, double LPP, double BP, int BDF)/*override*/;
@@ -552,34 +483,26 @@ Knorr/West EP -
void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej void SetLP(double TM, double LM, double TBP); //parametry przystawki wazacej
void SetLBP(double P); //cisnienie z hamulca pomocniczego void SetLBP(double P); //cisnienie z hamulca pomocniczego
inline TKE(double i_mbp, double i_bcr, double i_bcd, double i_brc, int inline TKE(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
i_BD, i_mat, i_ba, i_nbpa)
{ {
RapidStatus = false; ImplsRes = std::make_shared<TReservoir>();
TareM, TareBP, LoadM, LoadC, RM, LBP = 0.0; CntrlRes = std::make_shared<TReservoir>();
ImplsRes = new TReservoir(); Brak2Res = std::make_shared<TReservoir>();
CntrlRes = new TReservoir();
Brak2Res = new TReservoir();
} }
}; };
//klasa obejmujaca krany //klasa obejmujaca krany
class TDriverHandle {
class TDriverHandle
{
private: private:
// BCP: integer; // BCP: integer;
public: public:
bool Time; bool Time = false;
bool TimeEP; bool TimeEP = false;
double Sounds[ 5 ]; //wielkosci przeplywow dla dzwiekow double Sounds[ 5 ]; //wielkosci przeplywow dla dzwiekow
virtual double GetPF(double i_bcp, double PP, double HP, double dt, double ep); virtual double GetPF(double i_bcp, double PP, double HP, double dt, double ep);
virtual void Init(double Press); virtual void Init(double Press);
virtual double GetCP(); virtual double GetCP();
@@ -587,41 +510,39 @@ Knorr/West EP -
virtual double GetSound(int i); virtual double GetSound(int i);
virtual double GetPos(int i); virtual double GetPos(int i);
virtual double GetEP(double pos); virtual double GetEP(double pos);
}; };
class TFV4a : public TDriverHandle {
class TFV4a : public TDriverHandle
{
private: private:
double CP; double TP; double RP; //zbiornik steruj¹cy, czasowy, redukcyjny double CP = 0.0; //zbiornik steruj¹cy
double TP = 0.0; //zbiornik czasowy
double RP = 0.0; //zbiornik redukcyjny
public: public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
void Init(double Press)/*override*/; void Init(double Press)/*override*/;
inline TFV4a(void) : TDriverHandle() { } inline TFV4a() :
TDriverHandle()
{}
}; };
class TFV4aM : public TDriverHandle {
class TFV4aM : public TDriverHandle
{
private: private:
double CP; double TP; double RP; //zbiornik steruj¹cy, czasowy, redukcyjny double CP = 0.0; //zbiornik steruj¹cy
double XP; //komora powietrzna w reduktorze — jest potrzebna do odwzorowania fali double TP = 0.0; //zbiornik czasowy
double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double RP = 0.0; //zbiornik redukcyjny
double XP = 0.0; //komora powietrzna w reduktorze — jest potrzebna do odwzorowania fali
double RedAdj = 0.0; //dostosowanie reduktora cisnienia (krecenie kapturkiem)
// Sounds: array[0..4] of real; //wielkosci przeplywow dla dzwiekow // Sounds: array[0..4] of real; //wielkosci przeplywow dla dzwiekow
bool Fala; bool Fala = false;
//double pos_table[]; static double const pos_table[11]; // = { -2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0 };
// double *pos_table; // = { -2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0 };
static double pos_table[11];
double LPP_RP(double pos); double LPP_RP(double pos);
bool EQ(double pos, double i_pos); bool EQ(double pos, double i_pos);
public: public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
void Init(double Press)/*override*/; void Init(double Press)/*override*/;
@@ -629,20 +550,21 @@ Knorr/West EP -
double GetSound(int i)/*override*/; double GetSound(int i)/*override*/;
double GetPos(int i)/*override*/; double GetPos(int i)/*override*/;
inline TFV4aM(void) : TDriverHandle() { } inline TFV4aM() :
TDriverHandle()
{}
}; };
class TMHZ_EN57 : public TDriverHandle {
class TMHZ_EN57 : public TDriverHandle
{
private: private:
double CP; double TP; double RP; //zbiornik steruj¹cy, czasowy, redukcyjny double CP = 0.0; //zbiornik steruj¹cy
double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double TP = 0.0; //zbiornik czasowy
bool Fala; double RP = 0.0; //zbiornik redukcyjny
// const double pos_table[11] = { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 }; double RedAdj = 0.0; //dostosowanie reduktora cisnienia (krecenie kapturkiem)
static double pos_table[11]; //= { 0, 12, 1, 2, 2, 4, 11, 12, 2, 2, 2 }; bool Fala = false;
static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 };
double LPP_RP(double pos); double LPP_RP(double pos);
bool EQ(double pos, double i_pos); bool EQ(double pos, double i_pos);
@@ -655,11 +577,11 @@ Knorr/West EP -
double GetCP()/*override*/; double GetCP()/*override*/;
double GetEP(double pos); double GetEP(double pos);
inline TMHZ_EN57(void) : TDriverHandle() { } inline TMHZ_EN57(void) :
TDriverHandle()
{}
}; };
/* FBS2= class(TTDriverHandle) /* FBS2= class(TTDriverHandle)
private private
CP, TP, RP: real; //zbiornik steruj¹cy, czasowy, redukcyjny CP, TP, RP: real; //zbiornik steruj¹cy, czasowy, redukcyjny
@@ -690,15 +612,12 @@ Knorr/West EP -
function GetPos(i: int): real; override; function GetPos(i: int): real; override;
end;*/ end;*/
class TM394 : public TDriverHandle {
class TM394 : public TDriverHandle
{
private: private:
double CP; //zbiornik steruj¹cy, czasowy, redukcyjny double CP = 0.0; //zbiornik steruj¹cy, czasowy, redukcyjny
double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double RedAdj = 0.0; //dostosowanie reduktora cisnienia (krecenie kapturkiem)
// double const pos_table[11] = { -1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0 }; static double const pos_table[11]; // = { -1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0 };
static double pos_table[11]; // = { 0, 6, 0, 1, 2, 3, 5, 6, 1, 1, 1 };
public: public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
@@ -707,21 +626,20 @@ Knorr/West EP -
double GetCP()/*override*/; double GetCP()/*override*/;
double GetPos(int i)/*override*/; double GetPos(int i)/*override*/;
inline TM394(void) : TDriverHandle() { } inline TM394(void) :
TDriverHandle()
{}
}; };
class TH14K1 : public TDriverHandle {
class TH14K1 : public TDriverHandle
{
private: private:
double static BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2]; static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2];
// double const table[11] = { -1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0 }; static double const pos_table[11]; // = {-1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0};
double static pos_table[11]; // = { 0, 5, 0, 1, 2, 3, 4, 5, 1, 1, 1 };
protected: protected:
double CP; //zbiornik steruj¹cy, czasowy, redukcyjny double CP = 0.0; //zbiornik steruj¹cy, czasowy, redukcyjny
double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double RedAdj = 0.0; //dostosowanie reduktora cisnienia (krecenie kapturkiem)
public: public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
@@ -730,20 +648,18 @@ Knorr/West EP -
double GetCP()/*override*/; double GetCP()/*override*/;
double GetPos(int i)/*override*/; double GetPos(int i)/*override*/;
inline TH14K1(void) : TDriverHandle() { } inline TH14K1(void) :
TDriverHandle()
{}
}; };
class TSt113 : public TH14K1 {
class TSt113 : public TH14K1
{
private: private:
double EPS; double EPS = 0.0;
double static BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2]; static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2];
double static BEP_K[/*?*/ /*-1..5*/ (5) - (-1) + 1]; static double const BEP_K[/*?*/ /*-1..5*/ (5) - (-1) + 1];
// double const pos_table[11] = { -1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1 }; static double const pos_table[11]; // = {-1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1};
double static pos_table[11]; // = { 0, 6, 0, 1, 3, 4, 5, 6, 1, 1, 2 };
public: public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
@@ -751,52 +667,50 @@ Knorr/West EP -
double GetPos(int i)/*override*/; double GetPos(int i)/*override*/;
void Init(double Press)/*override*/; void Init(double Press)/*override*/;
inline TSt113(void) : TH14K1() { } inline TSt113(void) :
TH14K1()
{}
}; };
class Ttest : public TDriverHandle {
class Ttest : public TDriverHandle
{
private: private:
double CP; double CP = 0.0;
public: public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
void Init(double Press)/*override*/; void Init(double Press)/*override*/;
inline Ttest(void) : TDriverHandle() { } inline Ttest(void) :
TDriverHandle()
{}
}; };
class TFD1 : public TDriverHandle {
class TFD1 : public TDriverHandle
{
private: private:
double MaxBP; //najwyzsze cisnienie double MaxBP = 0.0; //najwyzsze cisnienie
double BP; //aktualne cisnienie double BP = 0.0; //aktualne cisnienie
public: public:
double Speed; //szybkosc dzialania double Speed = 0.0; //szybkosc dzialania
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
void Init(double Press)/*override*/; void Init(double Press)/*override*/;
double GetCP()/*override*/; double GetCP()/*override*/;
void SetSpeed(double nSpeed); void SetSpeed(double nSpeed);
// procedure Init(press: real; MaxBP: real); overload; // procedure Init(press: real; MaxBP: real); overload;
inline TFD1(void) : TDriverHandle() { } inline TFD1(void) :
TDriverHandle()
{}
}; };
class TH1405 : public TDriverHandle {
class TH1405 : public TDriverHandle
{
private: private:
double MaxBP; //najwyzsze cisnienie double MaxBP = 0.0; //najwyzsze cisnienie
double BP; //aktualne cisnienie double BP = 0.0; //aktualne cisnienie
public: public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
@@ -804,19 +718,16 @@ Knorr/West EP -
double GetCP()/*override*/; double GetCP()/*override*/;
// procedure Init(press: real; MaxBP: real); overload; // procedure Init(press: real; MaxBP: real); overload;
inline TH1405(void) : TDriverHandle() { } inline TH1405(void) :
TDriverHandle()
{}
}; };
class TFVel6 : public TDriverHandle {
class TFVel6 : public TDriverHandle
{
private: private:
double EPS; double EPS = 0.0;
// double const table[11] = { -1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1 }; static double const pos_table[ 11 ]; // = {-1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1};
double static pos_table[11]; // = { -1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1 };
public: public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/; double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
@@ -825,7 +736,9 @@ Knorr/West EP -
double GetSound(int i)/*override*/; double GetSound(int i)/*override*/;
void Init(double Press)/*override*/; void Init(double Press)/*override*/;
inline TFVel6(void) : TDriverHandle() { } inline TFVel6(void) :
TDriverHandle()
{}
}; };
@@ -834,8 +747,3 @@ Knorr/West EP -
extern double PFVa(double PH, double PL, double S, double LIM, double DP = 0.1); //zawor napelniajacy z PH do PL, PL do LIM extern double PFVa(double PH, double PL, double S, double LIM, double DP = 0.1); //zawor napelniajacy z PH do PL, PL do LIM
extern double PFVd(double PH, double PL, double S, double LIM, double DP = 0.1); //zawor wypuszczajacy z PH do PL, PH do LIM extern double PFVd(double PH, double PL, double S, double LIM, double DP = 0.1); //zawor wypuszczajacy z PH do PL, PH do LIM
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
#endif
#endif//INCLUDED_HAMULCE_H
//END

View File

@@ -294,20 +294,32 @@ std::string Tab2Sp(std::string const &s) /*Tab to Space sign*/
return s2; return s2;
} }
std::string ExchangeCharInString(std::string s, const char &aim, const char &target) std::string ExchangeCharInString( std::string const &Source, char const &From, char const &To )
{ {
char *tmp = new char[s.length()]; std::string replacement; replacement.reserve( Source.size() );
for (int b = 0; b < s.length(); ++b) std::for_each(Source.cbegin(), Source.cend(), [&](char const idx) {
{ if( idx != From ) { replacement += idx; }
if (s[b] == aim) else {
if (target == (char)"") if( To != NULL ) { replacement += To; } }
b++; } );
else
tmp[b] = target; return replacement;
else /*
tmp[b] = s[b]; int const length = Source.size();
std::string replacement; replacement.reserve( length );
for( int idx = 0; idx < length; ++idx ) {
if( Source[ idx ] != From ) {
replacement += Source[ idx ];
} }
return std::string(tmp); else {
if( To != NULL ) {
replacement += To;
}
}
}
return replacement;
*/
} }
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems) std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems)
@@ -387,25 +399,18 @@ std::string to_string(int _Val, int precision, int width)
return o.str(); return o.str();
}; };
std::string to_string(double _Val, int precision, int width) std::string to_string(double const Value, int const Precision, int const Width)
{ {
std::ostringstream o; std::ostringstream converter;
o.width(width); converter << std::setw( Width ) << std::fixed << std::setprecision(Precision) << Value;
o << std::fixed << std::setprecision(precision); return converter.str();
o << _Val;
return o.str();
}; };
std::string to_hex_str(double _Val, int precision, int width) std::string to_hex_str( int const Value, int const Width )
{ {
std::ostringstream o; std::ostringstream converter;
if (width) converter << "0x" << std::uppercase << std::setfill( '0' ) << std::setw( Width ) << std::hex << Value;
o.width(width); return converter.str();
o << std::fixed << std::hex;
if (precision)
o << std::setprecision(precision);
o << _Val;
return o.str();
}; };
int stol_def(const std::string &str, const int &DefaultValue) int stol_def(const std::string &str, const int &DefaultValue)

View File

@@ -122,7 +122,7 @@ std::string DUE(std::string s); /*Delete Until Equal sign*/
std::string DWE(std::string s); /*Delete While Equal sign*/ std::string DWE(std::string s); /*Delete While Equal sign*/
std::string Ld2Sp(std::string const &s); /*Low dash to Space sign*/ std::string Ld2Sp(std::string const &s); /*Low dash to Space sign*/
std::string Tab2Sp(std::string const &s); /*Tab to Space sign*/ std::string Tab2Sp(std::string const &s); /*Tab to Space sign*/
std::string ExchangeCharInString(std::string s, const char &aim, const char &target); // zamienia jeden znak na drugi std::string ExchangeCharInString(std::string const &s, const char &aim, const char &target); // zamienia jeden znak na drugi
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems); std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems);
std::vector<std::string> Split(const std::string &s, char delim); std::vector<std::string> Split(const std::string &s, char delim);
std::vector<std::string> Split(const std::string &s); std::vector<std::string> Split(const std::string &s);
@@ -134,7 +134,7 @@ std::string to_string(int _Val, int precision, int width);
std::string to_string(double _Val); std::string to_string(double _Val);
std::string to_string(double _Val, int precision); std::string to_string(double _Val, int precision);
std::string to_string(double _Val, int precision, int width); std::string to_string(double _Val, int precision, int width);
std::string to_hex_str(double _Val, int precision = 0, int width = 0); std::string to_hex_str( int const _Val, int const width = 4 );
inline std::string to_string(bool _Val) inline std::string to_string(bool _Val)
{ {
return _Val == true ? "true" : "false"; return _Val == true ? "true" : "false";

View File

@@ -108,6 +108,11 @@ TNames::TNames()
ZeroMemory(rTypes, 20 * sizeof(ItemRecord *)); ZeroMemory(rTypes, 20 * sizeof(ItemRecord *));
}; };
TNames::~TNames() {
delete[] cBuffer;
}
int TNames::Add(int t, const char *n) int TNames::Add(int t, const char *n)
{ // dodanie obiektu typu (t) o nazwie (n) { // dodanie obiektu typu (t) o nazwie (n)
int len = strlen(n) + 1; // ze znacznikiem końca int len = strlen(n) + 1; // ze znacznikiem końca

View File

@@ -49,6 +49,7 @@ class TNames
int iLast; // ostatnio u¿yty rekord int iLast; // ostatnio u¿yty rekord
public: public:
TNames(); TNames();
~TNames();
int Add(int t, const char *n); // dodanie obiektu typu (t) int Add(int t, const char *n); // dodanie obiektu typu (t)
int Add(int t, const char *n, void *d); // dodanie obiektu z wskaŸnikiem int Add(int t, const char *n, void *d); // dodanie obiektu z wskaŸnikiem
int Add(int t, const char *n, int d); // dodanie obiektu z numerem int Add(int t, const char *n, int d); // dodanie obiektu z numerem

View File

@@ -45,13 +45,19 @@ TPythonInterpreter *TPythonInterpreter::getInstance()
return _instance; return _instance;
} }
bool TPythonInterpreter::loadClassFile(const char *lookupPath, const char *className) void
TPythonInterpreter::killInstance() {
delete _instance;
}
bool TPythonInterpreter::loadClassFile( std::string const &lookupPath, std::string const &className )
{ {
std::set<const char *, ltstr>::const_iterator it = _classes.find(className); std::set<std::string const>::const_iterator it = _classes.find(className);
if (it == _classes.end()) if (it == _classes.end())
{ {
FILE *sourceFile = _getFile(lookupPath, className); FILE *sourceFile = _getFile(lookupPath, className);
if (sourceFile != NULL) if (sourceFile != nullptr)
{ {
fseek(sourceFile, 0, SEEK_END); fseek(sourceFile, 0, SEEK_END);
long fsize = ftell(sourceFile); long fsize = ftell(sourceFile);
@@ -72,9 +78,12 @@ bool TPythonInterpreter::loadClassFile(const char *lookupPath, const char *class
handleError(); handleError();
return false; return false;
} }
_classes.insert( className );
/*
char *classNameToRemember = (char *)calloc(strlen(className) + 1, sizeof(char)); char *classNameToRemember = (char *)calloc(strlen(className) + 1, sizeof(char));
strcpy(classNameToRemember, className); strcpy(classNameToRemember, className);
_classes.insert(classNameToRemember); _classes.insert(classNameToRemember);
*/
free(buffer); free(buffer);
return true; return true;
} }
@@ -83,13 +92,28 @@ bool TPythonInterpreter::loadClassFile(const char *lookupPath, const char *class
return true; return true;
} }
PyObject *TPythonInterpreter::newClass(const char *className) PyObject *TPythonInterpreter::newClass( std::string const &className )
{ {
return newClass(className, NULL); return newClass(className, NULL);
} }
FILE *TPythonInterpreter::_getFile(const char *lookupPath, const char *className) FILE *TPythonInterpreter::_getFile( std::string const &lookupPath, std::string const &className )
{ {
if( false == lookupPath.empty() ) {
std::string const sourcefilepath = lookupPath + className + ".py";
FILE *file = fopen( sourcefilepath.c_str(), "r" );
#ifdef _PY_INT_MORE_LOG
WriteLog( sourceFilePath );
#endif // _PY_INT_MORE_LOG
if( nullptr != file ) { return file; }
}
std::string sourcefilepath = "python\\local\\" + className + ".py";
FILE *file = fopen( sourcefilepath.c_str(), "r" );
#ifdef _PY_INT_MORE_LOG
WriteLog( sourceFilePath );
#endif // _PY_INT_MORE_LOG
return file; // either the file, or a nullptr on fail
/*
char *sourceFilePath; char *sourceFilePath;
if (lookupPath != NULL) if (lookupPath != NULL)
{ {
@@ -124,6 +148,7 @@ FILE *TPythonInterpreter::_getFile(const char *lookupPath, const char *className
return file; return file;
} }
return NULL; return NULL;
*/
} }
void TPythonInterpreter::handleError() void TPythonInterpreter::handleError()
@@ -177,14 +202,14 @@ void TPythonInterpreter::handleError()
} }
} }
} }
PyObject *TPythonInterpreter::newClass(const char *className, PyObject *argsTuple) PyObject *TPythonInterpreter::newClass(std::string const &className, PyObject *argsTuple)
{ {
if (_main == NULL) if (_main == NULL)
{ {
WriteLog("main turned into null"); WriteLog("main turned into null");
return NULL; return NULL;
} }
PyObject *classNameObj = PyObject_GetAttrString(_main, className); PyObject *classNameObj = PyObject_GetAttrString(_main, className.c_str());
if (classNameObj == NULL) if (classNameObj == NULL)
{ {
#ifdef _PY_INT_MORE_LOG #ifdef _PY_INT_MORE_LOG
@@ -477,18 +502,12 @@ void TPythonScreens::update()
void TPythonScreens::setLookupPath(std::string const &path) void TPythonScreens::setLookupPath(std::string const &path)
{ {
if (_lookupPath != NULL) _lookupPath = path;
{
free(_lookupPath);
}
_lookupPath = (char *)calloc(path.length() + 1, sizeof(char));
strcpy(_lookupPath, path.c_str());
} }
TPythonScreens::TPythonScreens() TPythonScreens::TPythonScreens()
{ {
_lookupPath = NULL; TPythonInterpreter::getInstance()->loadClassFile("", "abstractscreenrenderer");
TPythonInterpreter::getInstance()->loadClassFile(NULL, "abstractscreenrenderer");
_terminationFlag = false; _terminationFlag = false;
_renderReadyFlag = false; _renderReadyFlag = false;
_cleanupReadyFlag = false; _cleanupReadyFlag = false;
@@ -501,6 +520,7 @@ TPythonScreens::~TPythonScreens()
WriteLog("Called python sceeens destructor"); WriteLog("Called python sceeens destructor");
#endif // _PY_INT_MORE_LOG #endif // _PY_INT_MORE_LOG
reset(NULL); reset(NULL);
/*
if (_lookupPath != NULL) if (_lookupPath != NULL)
{ {
#ifdef _PY_INT_MORE_LOG #ifdef _PY_INT_MORE_LOG
@@ -508,6 +528,7 @@ TPythonScreens::~TPythonScreens()
#endif // _PY_INT_MORE_LOG #endif // _PY_INT_MORE_LOG
free(_lookupPath); free(_lookupPath);
} }
*/
} }
void TPythonScreens::run() void TPythonScreens::run()

18
PyInt.h
View File

@@ -30,21 +30,25 @@ class TPythonInterpreter
{ {
protected: protected:
TPythonInterpreter(); TPythonInterpreter();
~TPythonInterpreter() ~TPythonInterpreter() {}
{
}
static TPythonInterpreter *_instance; static TPythonInterpreter *_instance;
int _screenRendererPriority; int _screenRendererPriority;
std::set<const char *, ltstr> _classes; // std::set<const char *, ltstr> _classes;
std::set<std::string const> _classes;
PyObject *_main; PyObject *_main;
PyObject *_stdErr; PyObject *_stdErr;
FILE *_getFile(const char *lookupPath, const char *className); // FILE *_getFile(const char *lookupPath, const char *className);
FILE *_getFile( std::string const &lookupPath, std::string const &className );
public: public:
static TPythonInterpreter *getInstance(); static TPythonInterpreter *getInstance();
bool loadClassFile(const char *lookupPath, const char *className); static void killInstance();
/* bool loadClassFile(const char *lookupPath, const char *className);
PyObject *newClass(const char *className); PyObject *newClass(const char *className);
PyObject *newClass(const char *className, PyObject *argsTuple); PyObject *newClass(const char *className, PyObject *argsTuple);
*/ bool loadClassFile( std::string const &lookupPath, std::string const &className );
PyObject *newClass( std::string const &className );
PyObject *newClass( std::string const &className, PyObject *argsTuple );
int getScreenRendererPriotity() int getScreenRendererPriotity()
{ {
return _screenRendererPriority; return _screenRendererPriority;
@@ -79,7 +83,7 @@ class TPythonScreens
void *_thread; void *_thread;
unsigned int _threadId; unsigned int _threadId;
std::vector<TPythonScreenRenderer *> _screens; std::vector<TPythonScreenRenderer *> _screens;
char *_lookupPath; std::string _lookupPath;
void *_train; void *_train;
void _cleanup(); void _cleanup();
void _freeTrainState(); void _freeTrainState();

View File

@@ -37,7 +37,7 @@ TRealSound::TRealSound()
bLoopPlay = false; // dźwięk wyłączony bLoopPlay = false; // dźwięk wyłączony
} }
TRealSound::TRealSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, TRealSound::TRealSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
bool freqmod, double rmin) bool freqmod, double rmin)
{ {
Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin); Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
@@ -250,7 +250,7 @@ void TRealSound::ResetPosition()
pSound->SetCurrentPosition(0); pSound->SetCurrentPosition(0);
} }
TTextSound::TTextSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z, TTextSound::TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod, double rmin) bool Dynamic, bool freqmod, double rmin)
: TRealSound(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin) : TRealSound(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin)
{ {

View File

@@ -18,7 +18,7 @@ class TRealSound
{ {
protected: protected:
PSound pSound; PSound pSound;
char *Nazwa; // dla celow odwszawiania // char *Nazwa; // dla celow odwszawiania NOTE: currently not used anywhere
double fDistance, fPreviousDistance; // dla liczenia Dopplera double fDistance, fPreviousDistance; // dla liczenia Dopplera
float fFrequency; // częstotliwość samplowania pliku float fFrequency; // częstotliwość samplowania pliku
int iDoppler; // Ra 2014-07: możliwość wyłączenia efektu Dopplera np. dla śpiewu ptaków int iDoppler; // Ra 2014-07: możliwość wyłączenia efektu Dopplera np. dla śpiewu ptaków
@@ -31,7 +31,7 @@ class TRealSound
double FA; // offset czestotliwosci double FA; // offset czestotliwosci
bool bLoopPlay; // czy zapętlony dźwięk jest odtwarzany bool bLoopPlay; // czy zapętlony dźwięk jest odtwarzany
TRealSound(); TRealSound();
TRealSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, TRealSound( std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
bool freqmod = false, double rmin = 0.0); bool freqmod = false, double rmin = 0.0);
~TRealSound(); ~TRealSound();
void Free(); void Free();
@@ -54,7 +54,7 @@ class TTextSound : public TRealSound
std::string asText; std::string asText;
float fTime; // czas trwania float fTime; // czas trwania
public: public:
TTextSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z, TTextSound(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod = false, double rmin = 0.0); bool Dynamic, bool freqmod = false, double rmin = 0.0);
void Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z, void Init(std::string const &SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod = false, double rmin = 0.0); bool Dynamic, bool freqmod = false, double rmin = 0.0);

View File

@@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/.
#include "Logs.h" #include "Logs.h"
#include "Usefull.h" #include "Usefull.h"
#include "mczapkie/mctools.h" #include "mczapkie/mctools.h"
#include "WavRead.h"
//#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } //#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_RELEASE(p) \ #define SAFE_RELEASE(p) \
{ \ { \

View File

@@ -11,14 +11,7 @@ http://mozilla.org/MPL/2.0/.
#define SoundH #define SoundH
#include <stack> #include <stack>
#undef EOF
#include <objbase.h>
//#include <initguid.h>
//#include <commdlg.h>
#include <mmreg.h>
#include <dsound.h> #include <dsound.h>
//#include "resource.h"
#include "WavRead.h"
typedef LPDIRECTSOUNDBUFFER PSound; typedef LPDIRECTSOUNDBUFFER PSound;

View File

@@ -59,30 +59,26 @@ TSwitchExtension::TSwitchExtension(TTrack *owner, int what)
pOwner = NULL; pOwner = NULL;
pNextAnim = NULL; pNextAnim = NULL;
bMovement = false; // nie potrzeba przeliczać fOffset1 bMovement = false; // nie potrzeba przeliczać fOffset1
Segments[0] = new TSegment(owner); // z punktu 1 do 2 Segments[0] = std::make_shared<TSegment>(owner); // z punktu 1 do 2
Segments[1] = new TSegment( Segments[1] = std::make_shared<TSegment>(owner); // z punktu 3 do 4 (1=3 dla zwrotnic; odwrócony dla skrzyżowań, ewentualnie 1=4)
owner); // z punktu 3 do 4 (1=3 dla zwrotnic; odwrócony dla skrzyżowań, ewentualnie 1=4)
Segments[2] = (what >= 3) ? Segments[2] = (what >= 3) ?
new TSegment(owner) : std::make_shared<TSegment>(owner) :
NULL; // z punktu 2 do 4 skrzyżowanie od góry: wersja "-1": nullptr; // z punktu 2 do 4 skrzyżowanie od góry: wersja "-1":
Segments[3] = Segments[3] = (what >= 4) ?
(what >= 4) ? new TSegment(owner) : NULL; // z punktu 4 do 1 1 1=4 0 0=3 std::make_shared<TSegment>(owner) :
Segments[4] = nullptr; // z punktu 4 do 1 1 1=4 0 0=3
(what >= 5) ? new TSegment(owner) : NULL; // z punktu 1 do 3 4 x 3 3 3 x 2 2 Segments[4] = (what >= 5) ?
Segments[5] = (what >= 6) ? new TSegment(owner) : std::make_shared<TSegment>(owner) :
NULL; // z punktu 3 do 2 2 2 1 1 nullptr; // z punktu 1 do 3 4 x 3 3 3 x 2 2
Segments[5] = (what >= 6) ?
std::make_shared<TSegment>(owner) :
nullptr; // z punktu 3 do 2 2 2 1 1
evPlus = evMinus = NULL; evPlus = evMinus = NULL;
fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem) fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem)
vTrans = vector3(0, 0, 0); // docelowa translacja przesuwnicy vTrans = vector3(0, 0, 0); // docelowa translacja przesuwnicy
} }
TSwitchExtension::~TSwitchExtension() TSwitchExtension::~TSwitchExtension()
{ // nie ma nic do usuwania { // nie ma nic do usuwania
// delete Segments[0];
// delete Segments[1];
delete Segments[2];
delete Segments[3];
delete Segments[4];
delete Segments[5];
} }
TIsolated::TIsolated() TIsolated::TIsolated()
@@ -211,7 +207,11 @@ TTrack::TTrack(TGroundNode *g)
TTrack::~TTrack() TTrack::~TTrack()
{ // likwidacja odcinka { // likwidacja odcinka
if (eType == tt_Normal) if( eType == tt_Cross ) {
delete SwitchExtension->vPoints; // skrzyżowanie może mieć punkty
}
/* if (eType == tt_Normal)
delete Segment; // dla zwrotnic nie usuwać tego (kopiowany) delete Segment; // dla zwrotnic nie usuwać tego (kopiowany)
else else
{ // usuwanie dodatkowych danych dla niezwykłych odcinków { // usuwanie dodatkowych danych dla niezwykłych odcinków
@@ -219,6 +219,7 @@ TTrack::~TTrack()
delete SwitchExtension->vPoints; // skrzyżowanie może mieć punkty delete SwitchExtension->vPoints; // skrzyżowanie może mieć punkty
SafeDelete(SwitchExtension); SafeDelete(SwitchExtension);
} }
*/
} }
void TTrack::Init() void TTrack::Init()
@@ -226,21 +227,21 @@ void TTrack::Init()
switch (eType) switch (eType)
{ {
case tt_Switch: case tt_Switch:
SwitchExtension = new TSwitchExtension(this, 2); // na wprost i na bok SwitchExtension = std::make_shared<TSwitchExtension>( this, 2 ); // na wprost i na bok
break; break;
case tt_Cross: // tylko dla skrzyżowania dróg case tt_Cross: // tylko dla skrzyżowania dróg
SwitchExtension = new TSwitchExtension(this, 6); // 6 połączeń SwitchExtension = std::make_shared<TSwitchExtension>( this, 6 ); // 6 połączeń
SwitchExtension->vPoints = NULL; // brak tablicy punktów SwitchExtension->vPoints = NULL; // brak tablicy punktów
SwitchExtension->iPoints = 0; SwitchExtension->iPoints = 0;
SwitchExtension->bPoints = false; // tablica punktów nie wypełniona SwitchExtension->bPoints = false; // tablica punktów nie wypełniona
SwitchExtension->iRoads = 4; // domyślnie 4 SwitchExtension->iRoads = 4; // domyślnie 4
break; break;
case tt_Normal: case tt_Normal:
Segment = new TSegment(this); Segment = std::make_shared<TSegment>( this );
break; break;
case tt_Table: // oba potrzebne case tt_Table: // oba potrzebne
SwitchExtension = new TSwitchExtension(this, 1); // kopia oryginalnego toru SwitchExtension = std::make_shared<TSwitchExtension>( this, 1 ); // kopia oryginalnego toru
Segment = new TSegment(this); Segment = make_shared<TSegment>(this);
break; break;
} }
} }

View File

@@ -48,7 +48,7 @@ class TSwitchExtension
public: public:
TSwitchExtension(TTrack *owner, int what); TSwitchExtension(TTrack *owner, int what);
~TSwitchExtension(); ~TSwitchExtension();
TSegment *Segments[6]; // dwa tory od punktu 1, pozostałe dwa od 2? Ra 140101: 6 połączeń dla std::shared_ptr<TSegment> Segments[6]; // dwa tory od punktu 1, pozostałe dwa od 2? Ra 140101: 6 połączeń dla
// skrzyżowań // skrzyżowań
// TTrack *trNear[4]; //tory dołączone do punktów 1, 2, 3 i 4 // TTrack *trNear[4]; //tory dołączone do punktów 1, 2, 3 i 4
// dotychczasowe [2]+[2] wskaźniki zamienić na nowe [4] // dotychczasowe [2]+[2] wskaźniki zamienić na nowe [4]
@@ -126,8 +126,8 @@ class TIsolated
class TTrack : public Resource class TTrack : public Resource
{ // trajektoria ruchu - opakowanie { // trajektoria ruchu - opakowanie
private: private:
TSwitchExtension *SwitchExtension; // dodatkowe dane do toru, który jest zwrotnicą std::shared_ptr<TSwitchExtension> SwitchExtension; // dodatkowe dane do toru, który jest zwrotnicą
TSegment *Segment; std::shared_ptr<TSegment> Segment;
TTrack *trNext; // odcinek od strony punktu 2 - to powinno być w segmencie TTrack *trNext; // odcinek od strony punktu 2 - to powinno być w segmencie
TTrack *trPrev; // odcinek od strony punktu 1 TTrack *trPrev; // odcinek od strony punktu 1
// McZapkie-070402: dodalem zmienne opisujace rozmiary tekstur // McZapkie-070402: dodalem zmienne opisujace rozmiary tekstur
@@ -204,7 +204,7 @@ class TTrack : public Resource
{ {
return Segment->GetLength(); return Segment->GetLength();
}; };
inline TSegment * CurrentSegment() inline std::shared_ptr<TSegment> CurrentSegment()
{ {
return Segment; return Segment;
}; };

View File

@@ -316,7 +316,6 @@ PyObject *TTrain::GetTrainState()
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_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_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 ] ) ); 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 i = 0; i<20; i++)
{ {
@@ -329,9 +328,9 @@ PyObject *TTrain::GetTrainState()
PyDict_SetItemString(dict, "dir_brake", PyGetBool(bEP)); PyDict_SetItemString(dict, "dir_brake", PyGetBool(bEP));
if (typeid(mvControlled->Hamulec) == typeid(TLSt) || typeid(mvControlled->Hamulec) == typeid(TEStED)) if (typeid(mvControlled->Hamulec) == typeid(TLSt) || typeid(mvControlled->Hamulec) == typeid(TEStED))
{ {
TBrake* temp_ham = mvControlled->Hamulec; // auto temp_ham = mvControlled->Hamulec;
// TLSt* temp_ham2 = temp_ham; // TLSt* temp_ham2 = temp_ham;
bPN = (static_cast<TLSt*>(temp_ham)->GetEDBCP()>0.2); bPN = ( static_cast<TLSt *>(mvControlled->Hamulec.get())->GetEDBCP() > 0.2 );
} }
else else
bPN = false; bPN = false;

View File

@@ -102,7 +102,7 @@ TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end)
pCurrentTrack->AxleCounter(-1, Owner); // opuszczenie tamtego toru pCurrentTrack->AxleCounter(-1, Owner); // opuszczenie tamtego toru
} }
pCurrentTrack = pTrack; pCurrentTrack = pTrack;
pCurrentSegment = (pCurrentTrack ? pCurrentTrack->CurrentSegment() : NULL); pCurrentSegment = ( pCurrentTrack != nullptr ? pCurrentTrack->CurrentSegment() : nullptr );
if (!pCurrentTrack) if (!pCurrentTrack)
Error(Owner->MoverParameters->Name + " at NULL track"); Error(Owner->MoverParameters->Name + " at NULL track");
return pCurrentTrack; return pCurrentTrack;

View File

@@ -17,7 +17,7 @@ class TTrackFollower
{ // oœ poruszaj¹ca siê po torze { // oœ poruszaj¹ca siê po torze
private: private:
TTrack *pCurrentTrack; // na którym torze siê znajduje TTrack *pCurrentTrack; // na którym torze siê znajduje
TSegment *pCurrentSegment; // zwrotnice mog¹ mieæ dwa segmenty std::shared_ptr<TSegment> pCurrentSegment; // zwrotnice mog¹ mieæ dwa segmenty
double fCurrentDistance; // przesuniêcie wzglêdem Point1 w stronê Point2 double fCurrentDistance; // przesuniêcie wzglêdem Point1 w stronê Point2
double fDirection; // ustawienie wzglêdem toru: -1.0 albo 1.0, mno¿one przez dystans double fDirection; // ustawienie wzglêdem toru: -1.0 albo 1.0, mno¿one przez dystans
bool ComputatePosition(); // przeliczenie pozycji na torze bool ComputatePosition(); // przeliczenie pozycji na torze

View File

@@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "mtable.h" #include "mtable.h"
// using namespace Mtable; // using namespace Mtable;
TMTableTime *Mtable::GlobalTime; std::shared_ptr<TMTableTime> Mtable::GlobalTime;
double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/ double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/
// zwraca ró¿nicê czasu // zwraca ró¿nicê czasu
@@ -529,19 +529,6 @@ void TMTableTime::UpdateMTableTime(double deltaT)
GameTime = GameTime + deltaT; GameTime = GameTime + deltaT;
} }
TMTableTime::TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM)
{
GameTime = 0.0;
dd = 0;
hh = InitH;
mm = InitM;
srh = InitSRH;
srm = InitSRM;
ssh = InitSSH;
ssm = InitSSM;
mr = 0.0;
}
bool TTrainParameters::DirectionChange() bool TTrainParameters::DirectionChange()
// sprawdzenie, czy po zatrzymaniu wykonaæ kolejne komendy // sprawdzenie, czy po zatrzymaniu wykonaæ kolejne komendy
{ {

View File

@@ -86,20 +86,29 @@ class TMTableTime
{ {
public: public:
double GameTime; double GameTime = 0.0;
int dd; int dd = 0;
int hh; int hh = 0;
int mm; int mm = 0;
int srh; int srh = 0;
int srm; /*wschod slonca*/ int srm = 0; /*wschod slonca*/
int ssh; int ssh = 0;
int ssm; /*zachod slonca*/ int ssm = 0; /*zachod slonca*/
double mr; double mr = 0.0;
void UpdateMTableTime(double deltaT); void UpdateMTableTime(double deltaT);
TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM); TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM) :
hh( InitH ),
mm( InitM ),
srh( InitSRH ),
srm( InitSRM ),
ssh( InitSSH ),
ssm( InitSSM )
{}
TMTableTime() = default;
}; };
extern TMTableTime *GlobalTime; extern std::shared_ptr<TMTableTime> GlobalTime;
} }
#if !defined(NO_IMPLICIT_NAMESPACE_USE) #if !defined(NO_IMPLICIT_NAMESPACE_USE)

View File

@@ -191,7 +191,7 @@ bool cParser::trimComments(std::string &String)
return false; return false;
} }
std::string cParser::readComment(const std::string Break) std::string cParser::readComment(std::string const &Break)
{ // pobieranie znaków a¿ do znalezienia znacznika koñca { // pobieranie znaków a¿ do znalezienia znacznika koñca
std::string token = ""; std::string token = "";
while (mStream->peek() != EOF) while (mStream->peek() != EOF)

View File

@@ -57,7 +57,7 @@ class cParser : public std::stringstream
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
readToken(); readToken();
}; };
inline bool expectToken(std::string value) inline bool expectToken(std::string const &value)
{ {
return readToken() == value; return readToken() == value;
}; };
@@ -77,7 +77,7 @@ class cParser : public std::stringstream
protected: protected:
// methods: // methods:
std::string readToken(bool ToLower = true, const char *Break = "\n\t ;"); std::string readToken(bool ToLower = true, const char *Break = "\n\t ;");
std::string readComment(const std::string Break = "\n\t ;"); std::string readComment(std::string const &Break = "\n\t ;");
std::string trtest; std::string trtest;
bool trimComments(std::string &String); bool trimComments(std::string &String);
// members: // members:

View File

@@ -10,6 +10,12 @@
#define _CRTDBG_MAP_ALLOC #define _CRTDBG_MAP_ALLOC
#include <stdlib.h> #include <stdlib.h>
#include <crtdbg.h> #include <crtdbg.h>
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#define new DBG_NEW
#endif
#endif // _DEBUG
#endif #endif
// operating system // operating system
#include "targetver.h" #include "targetver.h"
@@ -19,6 +25,7 @@
#undef NOMINMAX #undef NOMINMAX
// stl // stl
#include <cstdlib> #include <cstdlib>
#include <cassert>
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>

View File

@@ -18,7 +18,6 @@ http://mozilla.org/MPL/2.0/.
#ifndef WAVE_READ_H #ifndef WAVE_READ_H
#define WAVE_READ_H #define WAVE_READ_H
#include <mmreg.h>
#include <mmsystem.h> #include <mmsystem.h>
HRESULT WaveOpenFile(CHAR *strFileName, HMMIO *phmmioIn, WAVEFORMATEX **ppwfxInfo, HRESULT WaveOpenFile(CHAR *strFileName, HMMIO *phmmioIn, WAVEFORMATEX **ppwfxInfo,