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

Projekt się buduje, ale ma 3k warningów.

This commit is contained in:
firleju
2016-10-31 07:38:45 +01:00
parent 1491681576
commit cd08fe0b5d
25 changed files with 620 additions and 694 deletions

View File

@@ -26,6 +26,7 @@ http://mozilla.org/MPL/2.0/.
#include "MemCell.h" #include "MemCell.h"
#include "World.h" #include "World.h"
#include "dir.h" #include "dir.h"
#include "mctools.h"
#define LOGVELOCITY 0 #define LOGVELOCITY 0
#define LOGORDERS 0 #define LOGORDERS 0
@@ -87,7 +88,7 @@ const double HardAcceleration = 0.9;
const double PrepareTime = 2.0; //[s] przeb<65>yski <20>wiadomo<6D>ci przy odpalaniu const double PrepareTime = 2.0; //[s] przeb<65>yski <20>wiadomo<6D>ci przy odpalaniu
bool WriteLogFlag = false; bool WriteLogFlag = false;
AnsiString StopReasonTable[] = { string StopReasonTable[] = {
// przyczyny zatrzymania ruchu AI // przyczyny zatrzymania ruchu AI
"", // stopNone, //nie ma powodu - powinien jecha<68> "", // stopNone, //nie ma powodu - powinien jecha<68>
"Off", // stopSleep, //nie zosta<74> odpalony, to nie pojedzie "Off", // stopSleep, //nie zosta<74> odpalony, to nie pojedzie
@@ -244,7 +245,8 @@ bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len)
if (trTrack->iNumDynamics > 0) // a skrzy<7A>owanie zawiera pojazd if (trTrack->iNumDynamics > 0) // a skrzy<7A>owanie zawiera pojazd
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("Tor " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + trTrack->iNumDynamics + "Dist= " + fDist); WriteLog("Tor " + trTrack->NameGet() + " zajety przed pojazdem. Num=" +
to_string(trTrack->iNumDynamics) + "Dist= " + to_string(fDist));
fVelNext = fVelNext =
0.0; // to zabroni<6E> wjazdu (chyba <20>e ten z przodu te<74> jedzie prosto) 0.0; // to zabroni<6E> wjazdu (chyba <20>e ten z przodu te<74> jedzie prosto)
} }
@@ -267,7 +269,8 @@ bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len)
0) // je<6A>li jeszcze nie wjechano na tor, a co<63> na nim jest 0) // je<6A>li jeszcze nie wjechano na tor, a co<63> na nim jest
{ {
if (Global::iWriteLogEnabled & 8) if (Global::iWriteLogEnabled & 8)
WriteLog("Rozjazd " + trTrack->NameGet() + " zajety przed pojazdem. Num=" + trTrack->iNumDynamics + "Dist= "+fDist); WriteLog("Rozjazd " + trTrack->NameGet() + " zajety przed pojazdem. Num=" +
to_string(trTrack->iNumDynamics) + "Dist= "+ to_string(fDist));
//fDist -= 30.0; //fDist -= 30.0;
fVelNext = 0.0; // to niech stanie w zwi<77>kszonej odleg<65>o<EFBFBD>ci fVelNext = 0.0; // to niech stanie w zwi<77>kszonej odleg<65>o<EFBFBD>ci
// else if (fVelNext==0.0) //je<6A>li zosta<74>a wyzerowana // else if (fVelNext==0.0) //je<6A>li zosta<74>a wyzerowana
@@ -810,7 +813,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
{ // o ile dana pozycja tabelki jest istotna { // o ile dana pozycja tabelki jest istotna
if (sSpeedTable[i].iFlags & spPassengerStopPoint) if (sSpeedTable[i].iFlags & spPassengerStopPoint)
{ // je<6A>li przystanek, trzeba obs<62>u<EFBFBD>y<EFBFBD> wg rozk<7A>adu { // je<6A>li przystanek, trzeba obs<62>u<EFBFBD>y<EFBFBD> wg rozk<7A>adu
if (sSpeedTable[i].evEvent->CommandGet() != AnsiString(asNextStop.c_str())) if (sSpeedTable[i].evEvent->CommandGet() != asNextStop)
{ // je<6A>li nazwa nie jest zgodna { // je<6A>li nazwa nie jest zgodna
if (sSpeedTable[i].fDist < -fLength) // je<6A>li zosta<74> przejechany if (sSpeedTable[i].fDist < -fLength) // je<6A>li zosta<74> przejechany
sSpeedTable[i].iFlags = sSpeedTable[i].iFlags =
@@ -830,7 +833,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
#if LOGSTOPS #if LOGSTOPS
WriteLog(pVehicle->asName + " as " + TrainParams->TrainName + ": at " + WriteLog(pVehicle->asName + " as " + TrainParams->TrainName + ": at " +
to_string(GlobalTime->hh) + ":" + to_string(GlobalTime->mm) + to_string(GlobalTime->hh) + ":" + to_string(GlobalTime->mm) +
" skipped " + asNextStop.); // informacja " skipped " + asNextStop); // informacja
#endif #endif
fLastStopExpDist = mvOccupied->DistCounter + 0.250 + fLastStopExpDist = mvOccupied->DistCounter + 0.250 +
0.001 * fLength; // przy jakim dystansie (stanie 0.001 * fLength; // przy jakim dystansie (stanie
@@ -1026,7 +1029,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
else else
{ // je<6A>li dojechali<6C>my do ko<6B>ca rozk<7A>adu { // je<6A>li dojechali<6C>my do ko<6B>ca rozk<7A>adu
#if LOGSTOPS #if LOGSTOPS
WriteLog(pVehicle->asName + " as " + TrainParams->TrainName) + WriteLog(pVehicle->asName + " as " + TrainParams->TrainName +
": at " + to_string(GlobalTime->hh) + ":" + ": at " + to_string(GlobalTime->hh) + ":" +
to_string(GlobalTime->mm) + to_string(GlobalTime->mm) +
" end of route."); // informacja " end of route."); // informacja
@@ -1486,17 +1489,17 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
if (WriteLogFlag) if (WriteLogFlag)
{ {
mkdir("physicslog\\"); mkdir("physicslog\\");
LogFile.open("physicslog\\" + VehicleName.c_str() + ".dat", LogFile.open(string("physicslog\\" + VehicleName + ".dat").c_str(),
std::ios::in | std::ios::out | std::ios::trunc); std::ios::in | std::ios::out | std::ios::trunc);
#if LOGPRESS == 0 #if LOGPRESS == 0
LogFile << AnsiString(" Time [s] Velocity [m/s] Acceleration [m/ss] Coupler.Dist[m] " LogFile << string(" Time [s] Velocity [m/s] Acceleration [m/ss] Coupler.Dist[m] "
"Coupler.Force[N] TractionForce [kN] FrictionForce [kN] " "Coupler.Force[N] TractionForce [kN] FrictionForce [kN] "
"BrakeForce [kN] BrakePress [MPa] PipePress [MPa] " "BrakeForce [kN] BrakePress [MPa] PipePress [MPa] "
"MotorCurrent [A] MCP SCP BCP LBP DmgFlag Command CVal1 CVal2") "MotorCurrent [A] MCP SCP BCP LBP DmgFlag Command CVal1 CVal2")
.c_str() << "\r\n"; .c_str() << "\r\n";
#endif #endif
#if LOGPRESS == 1 #if LOGPRESS == 1
LogFile << AnsiString("t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP").c_str() << "\n"; LogFile << string("t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP").c_str() << "\n";
#endif #endif
LogFile.flush(); LogFile.flush();
} }
@@ -1874,8 +1877,8 @@ bool TController::CheckVehicles(TOrders user)
{ {
if (TrainParams) if (TrainParams)
if (p->asDestination == "none") if (p->asDestination == "none")
p->DestinationSet(AnsiString(TrainParams->Relation2.c_str()), p->DestinationSet(TrainParams->Relation2,
AnsiString(TrainParams->TrainName.c_str())); // relacja docelowa, je<6A>li nie by<62>o TrainParams->TrainName); // relacja docelowa, je<6A>li nie by<62>o
if (AIControllFlag) // je<6A>li prowadzi komputer if (AIControllFlag) // je<6A>li prowadzi komputer
p->RaLightsSet(0, 0); // gasimy <20>wiat<61>a p->RaLightsSet(0, 0); // gasimy <20>wiat<61>a
if (p->MoverParameters->EnginePowerSource.SourceType == CurrentCollector) if (p->MoverParameters->EnginePowerSource.SourceType == CurrentCollector)
@@ -2890,7 +2893,7 @@ void TController::RecognizeCommand()
} }
void TController::PutCommand(std::string NewCommand, double NewValue1, double NewValue2, void TController::PutCommand(std::string NewCommand, double NewValue1, double NewValue2,
const TLocation &NewLocation, TStopReason reason = stopComm) const TLocation &NewLocation, TStopReason reason)
{ // wys<79>anie komendy przez event PutValues, jak pojazd ma obsad<61>, to wysy<73>a tutaj, a nie do pojazdu { // wys<79>anie komendy przez event PutValues, jak pojazd ma obsad<61>, to wysy<73>a tutaj, a nie do pojazdu
// bezpo<70>rednio // bezpo<70>rednio
vector3 sl; vector3 sl;
@@ -2902,7 +2905,7 @@ void TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
} }
bool TController::PutCommand(std::string NewCommand, double NewValue1, double NewValue2, bool TController::PutCommand(std::string NewCommand, double NewValue1, double NewValue2,
const vector3 *NewLocation, TStopReason reason = stopComm) const vector3 *NewLocation, TStopReason reason)
{ // analiza komendy { // analiza komendy
if (NewCommand == "CabSignal") if (NewCommand == "CabSignal")
{ // SHP wyzwalane jest przez cz<63>on z obsad<61>, ale obs<62>ugiwane przez silnikowy { // SHP wyzwalane jest przez cz<63>on z obsad<61>, ale obs<62>ugiwane przez silnikowy
@@ -2926,16 +2929,16 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
mvOccupied->PutCommand("Emergency_brake", 1.0, 1.0, mvOccupied->Loc); mvOccupied->PutCommand("Emergency_brake", 1.0, 1.0, mvOccupied->Loc);
return true; // za<7A>atwione return true; // za<7A>atwione
} }
else if (NewCommand.Pos("Timetable:") == 1) else if (NewCommand.find("Timetable:") == 0)
{ // przypisanie nowego rozk<7A>adu jazdy, r<>wnie<69> prowadzonemu przez u<>ytkownika { // przypisanie nowego rozk<7A>adu jazdy, r<>wnie<69> prowadzonemu przez u<>ytkownika
NewCommand.Delete(1, 10); // zostanie nazwa pliku z rozk<7A>adem NewCommand = NewCommand.erase(0, 10); // zostanie nazwa pliku z rozk<7A>adem
#if LOGSTOPS #if LOGSTOPS
WriteLog("New timetable for " + pVehicle->asName + ": " + NewCommand); // informacja WriteLog("New timetable for " + pVehicle->asName + ": " + NewCommand); // informacja
#endif #endif
if (!TrainParams) if (!TrainParams)
TrainParams = new TTrainParameters(std::string(NewCommand.c_str())); // rozk<7A>ad jazdy TrainParams = new TTrainParameters(NewCommand); // rozk<7A>ad jazdy
else else
TrainParams->NewName(std::string(NewCommand.c_str())); // czy<7A>ci tabelk<6C> przystank<6E>w TrainParams->NewName(NewCommand); // czy<7A>ci tabelk<6C> przystank<6E>w
delete tsGuardSignal; delete tsGuardSignal;
tsGuardSignal = NULL; // wywalenie kierownika tsGuardSignal = NULL; // wywalenie kierownika
if (NewCommand != "none") if (NewCommand != "none")
@@ -2947,7 +2950,7 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
if (ConversionError == -8) if (ConversionError == -8)
ErrorLog("Missed timetable: " + NewCommand); ErrorLog("Missed timetable: " + NewCommand);
WriteLog("Cannot load timetable file " + NewCommand + "\r\nError " + WriteLog("Cannot load timetable file " + NewCommand + "\r\nError " +
ConversionError + " in position " + TrainParams->StationCount); to_string(ConversionError) + " in position " + to_string(TrainParams->StationCount));
NewCommand = ""; // puste, dla wymiennej tekstury NewCommand = ""; // puste, dla wymiennej tekstury
} }
else else
@@ -2959,10 +2962,9 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
asNextStop = TrainParams->NextStop(); asNextStop = TrainParams->NextStop();
iDrivigFlags |= movePrimary; // skoro dosta<74> rozk<7A>ad, to jest teraz g<><67>wnym iDrivigFlags |= movePrimary; // skoro dosta<74> rozk<7A>ad, to jest teraz g<><67>wnym
NewCommand = Global::asCurrentSceneryPath + NewCommand + ".wav"; // na razie jeden NewCommand = Global::asCurrentSceneryPath + NewCommand + ".wav"; // na razie jeden
if (FileExists(NewCommand)) if (fileExists(NewCommand))
{ // wczytanie d<>wi<77>ku odjazdu podawanego bezpo<70>renido { // wczytanie d<>wi<77>ku odjazdu podawanego bezpo<70>renido
tsGuardSignal = new TTextSound(); tsGuardSignal = new TTextSound(NewCommand.c_str(), 30, pVehicle->GetPosition().x,
tsGuardSignal->Init(NewCommand.c_str(), 30, pVehicle->GetPosition().x,
pVehicle->GetPosition().y, pVehicle->GetPosition().z, pVehicle->GetPosition().y, pVehicle->GetPosition().z,
false); false);
// rsGuardSignal->Stop(); // rsGuardSignal->Stop();
@@ -2970,23 +2972,22 @@ bool TController::PutCommand(std::string NewCommand, double NewValue1, double Ne
} }
else else
{ {
NewCommand.Insert("radio", NewCommand.Length() - 3); // wstawienie przed kropk<70> NewCommand = NewCommand.insert(NewCommand.find_last_of("."),"radio"); // wstawienie przed kropk<70>
if (FileExists(NewCommand)) if (fileExists(NewCommand))
{ // wczytanie d<>wi<77>ku odjazdu w wersji radiowej (s<>ycha<68> tylko w kabinie) { // wczytanie d<>wi<77>ku odjazdu w wersji radiowej (s<>ycha<68> tylko w kabinie)
tsGuardSignal = new TTextSound(); tsGuardSignal = new TTextSound(NewCommand.c_str(), -1, pVehicle->GetPosition().x,
tsGuardSignal->Init(NewCommand.c_str(), -1, pVehicle->GetPosition().x,
pVehicle->GetPosition().y, pVehicle->GetPosition().z, pVehicle->GetPosition().y, pVehicle->GetPosition().z,
false); false);
iGuardRadio = iRadioChannel; iGuardRadio = iRadioChannel;
} }
} }
NewCommand = AnsiString(TrainParams->Relation2.c_str()); // relacja docelowa z rozk<7A>adu NewCommand = TrainParams->Relation2; // relacja docelowa z rozk<7A>adu
} }
// jeszcze poustawia<69> tekstury na wy<77>wietlaczach // jeszcze poustawia<69> tekstury na wy<77>wietlaczach
TDynamicObject *p = pVehicles[0]; TDynamicObject *p = pVehicles[0];
while (p) while (p)
{ {
p->DestinationSet(NewCommand, AnsiString(TrainParams->TrainName.c_str())); // relacja docelowa p->DestinationSet(NewCommand, TrainParams->TrainName); // relacja docelowa
p = p->Next(); // pojazd pod<6F><64>czony od ty<74>u (licz<63>c od czo<7A>a) p = p->Next(); // pojazd pod<6F><64>czony od ty<74>u (licz<63>c od czo<7A>a)
} }
} }
@@ -4880,7 +4881,7 @@ void TController::OrdersDump()
WriteLog("Orders for " + pVehicle->asName + ":"); WriteLog("Orders for " + pVehicle->asName + ":");
for (int b = 0; b < maxorders; ++b) for (int b = 0; b < maxorders; ++b)
{ {
WriteLog(AnsiString(b) + ": " + Order2Str(OrderList[b]) + (OrderPos == b ? " <-" : "")); WriteLog(to_string(b) + ": " + Order2Str(OrderList[b]) + (OrderPos == b ? " <-" : ""));
if (b) // z wyj<79>tkiem pierwszej pozycji if (b) // z wyj<79>tkiem pierwszej pozycji
if (OrderList[b] == Wait_for_orders) // je<6A>li ko<6B>cowa komenda if (OrderList[b] == Wait_for_orders) // je<6A>li ko<6B>cowa komenda
break; // dalej nie trzeba break; // dalej nie trzeba
@@ -4988,7 +4989,7 @@ void TController::OrdersInit(double fVel)
// Ale mozna by je zapodac ze scenerii // Ale mozna by je zapodac ze scenerii
}; };
AnsiString TController::StopReasonText() string TController::StopReasonText()
{ // informacja tekstowa o przyczynie zatrzymania { // informacja tekstowa o przyczynie zatrzymania
if (eStopReason != 7) // zawalidroga b<>dzie inaczej if (eStopReason != 7) // zawalidroga b<>dzie inaczej
return StopReasonTable[eStopReason]; return StopReasonTable[eStopReason];
@@ -5300,11 +5301,11 @@ std::string TController::NextStop()
return ""; // tu nie powinno nigdy wej<65><6A> return ""; // tu nie powinno nigdy wej<65><6A>
TMTableLine *t = TrainParams->TimeTable + TrainParams->StationIndex; TMTableLine *t = TrainParams->TimeTable + TrainParams->StationIndex;
if (t->Dh >= 0) // je<6A>li jest godzina odjazdu if (t->Dh >= 0) // je<6A>li jest godzina odjazdu
return asNextStop.substr(19, 30) + " " + Global::to_string(t->Dh) + ":" + return asNextStop.substr(19, 30) + " " + to_string(t->Dh) + ":" +
Global::to_string(t->Dm); // odjazd to_string(t->Dm); // odjazd
else if (t->Ah >= 0) // przyjazd else if (t->Ah >= 0) // przyjazd
return asNextStop.substr(19, 30) + " (" + Global::to_string(t->Ah) + ":" + return asNextStop.substr(19, 30) + " (" + to_string(t->Ah) + ":" +
Global::to_string(t->Am) + ")"; // przyjazd to_string(t->Am) + ")"; // przyjazd
return ""; return "";
}; };
@@ -5477,5 +5478,5 @@ void TController::RouteSwitch(int d)
}; };
std::string TController::OwnerName() std::string TController::OwnerName()
{ {
return pVehicle ? pVehicle->MoverParameters->Name : ("none"); return pVehicle ? pVehicle->MoverParameters->Name : string("none");
}; };

View File

@@ -13,8 +13,8 @@
ResourceManager.obj VBO.obj mtable.obj TextureDDS.obj ResourceManager.obj VBO.obj mtable.obj TextureDDS.obj
opengl\ARB_Multisample.obj Float3d.obj Classes.obj Driver.obj Names.obj opengl\ARB_Multisample.obj Float3d.obj Classes.obj Driver.obj Names.obj
Console.obj McZapkie\Mover.obj McZapkie\hamulce.obj Console.obj McZapkie\Mover.obj McZapkie\hamulce.obj
McZapkie\Oerlikon_ESt.obj McZapkie\friction.obj Console\PoKeys55.obj McZapkie\Oerlikon_ESt.obj McZapkie\friction.obj McZapkie\mctools.obj
Forth.obj Console\LPT.obj PyInt.obj"/> Console\PoKeys55.obj Forth.obj Console\LPT.obj PyInt.obj"/>
<RESFILES value="EU07.res"/> <RESFILES value="EU07.res"/>
<IDLFILES value=""/> <IDLFILES value=""/>
<IDLGENFILES value=""/> <IDLGENFILES value=""/>

View File

@@ -83,6 +83,7 @@ USEUNIT("McZapkie\Mover.cpp");
USEUNIT("McZapkie\hamulce.cpp"); USEUNIT("McZapkie\hamulce.cpp");
USEUNIT("McZapkie\Oerlikon_ESt.cpp"); USEUNIT("McZapkie\Oerlikon_ESt.cpp");
USEUNIT("McZapkie\friction.cpp"); USEUNIT("McZapkie\friction.cpp");
USEUNIT("McZapkie\mctools.cpp");
USEUNIT("Console\PoKeys55.cpp"); USEUNIT("Console\PoKeys55.cpp");
USEUNIT("Forth.cpp"); USEUNIT("Forth.cpp");
USEUNIT("Console\LPT.cpp"); USEUNIT("Console\LPT.cpp");
@@ -761,3 +762,6 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
KillGLWindow(); // kill the window KillGLWindow(); // kill the window
return (msg.wParam); // exit the program return (msg.wParam); // exit the program
} }

View File

@@ -24,6 +24,7 @@ http://mozilla.org/MPL/2.0/.
#include "MemCell.h" #include "MemCell.h"
#include "Globals.h" #include "Globals.h"
#include "Ground.h" #include "Ground.h"
#include "McZapkie\mctools.h"
#pragma package(smart_init) #pragma package(smart_init)
TEvent::TEvent(string m) TEvent::TEvent(string m)

View File

@@ -927,103 +927,5 @@ double Global::CutValueToRange(double min, double value, double max)
return value; return value;
}; };
std::string to_string(int _Val)
{
std::ostringstream o;
o << _Val;
return o.str();
};
std::string to_string(unsigned int _Val)
{
std::ostringstream o;
o << _Val;
return o.str();
};
std::string to_string(double _Val)
{
std::ostringstream o;
o << _Val;
return o.str();
};
std::string to_string(int _Val, int precision)
{
std::ostringstream o;
o << std::fixed << std::setprecision(precision);
o << _Val;
return o.str();
};
std::string to_string(double _Val, int precision)
{
std::ostringstream o;
o << std::fixed << std::setprecision(precision);
o << _Val;
return o.str();
};
std::string to_string(int _Val, int precision, int width)
{
std::ostringstream o;
o.width(width);
o << std::fixed << std::setprecision(precision);
o << _Val;
return o.str();
};
std::string to_string(double _Val, int precision, int width)
{
std::ostringstream o;
o.width(width);
o << std::fixed << std::setprecision(precision);
o << _Val;
return o.str();
};
std::string to_hex_str(double _Val, int precision, int width)
{
std::ostringstream o;
if (width)
o.width(width);
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)
{
// this function was developed iteratively on Codereview.stackexchange
// with the assistance of @Corbin
std::size_t len = str.size();
while (std::isspace(str[len - 1]))
len--;
if (len == 0)
return DefaultValue;
errno = 0;
char *s = new char[len + 1];
std::strncpy(s, str.c_str(), len);
char *p;
int result = strtol(s, &p, 0);
if ((*p != '\0') || (errno != 0))
{
return DefaultValue;
}
delete s;
return result;
}
std::string ToLower(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), ::tolower);
}
std::string ToUpper(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), ::toupper);
}
#pragma package(smart_init) #pragma package(smart_init)

View File

@@ -326,19 +326,7 @@ class Global
static double CutValueToRange(double min, double value, double max); static double CutValueToRange(double min, double value, double max);
}; };
std::string to_string(int _Val);
std::string to_string(unsigned int _Val);
std::string to_string(int _Val, int precision);
std::string to_string(int _Val, int precision, int width);
std::string to_string(double _Val);
std::string to_string(double _Val, int precision);
std::string to_string(double _Val, int precision, int width);
std::string to_hex_str(int _Val, int precision = 0, int width = 0);
int stol_def(const std::string & str, const int & DefaultValue);
std::string ToLower(std::string text);
std::string ToUpper(std::string text);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#endif #endif

View File

@@ -1760,7 +1760,6 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
3.0; 3.0;
break; break;
case TP_SOUND: case TP_SOUND:
tmp->tsStaticSound = new TTextSound;
parser->getTokens(3); parser->getTokens(3);
*parser >> tmp->pCenter.x >> tmp->pCenter.y >> tmp->pCenter.z; *parser >> tmp->pCenter.x >> tmp->pCenter.y >> tmp->pCenter.z;
tmp->pCenter.RotateY(aRotate.y / 180.0 * M_PI); // Ra 2014-11: uwzglêdnienie rotacji tmp->pCenter.RotateY(aRotate.y / 180.0 * M_PI); // Ra 2014-11: uwzglêdnienie rotacji
@@ -1769,7 +1768,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->Init(strdup(str.c_str()), sqrt(tmp->fSquareRadius), tmp->pCenter.x, tmp->tsStaticSound = new TTextSound(strdup(str.c_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 =

2
Logs.h
View File

@@ -24,7 +24,7 @@ void ErrorLog(const std::string &str, bool newline = true);
void WriteLog(const AnsiString &str, bool newline = true); void WriteLog(const AnsiString &str, bool newline = true);
void WriteLog(const std::string &str, bool newline = true); void WriteLog(const std::string &str, bool newline = true);
void CommLog(const char *str); void CommLog(const char *str);
void CommLog(const std::string); void CommLog(const std::string &str);
void CommLog(const AnsiString &str); void CommLog(const AnsiString &str);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#endif #endif

View File

@@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/.
#include "Oerlikon_ESt.h" #include "Oerlikon_ESt.h"
#include "hamulce.h" #include "hamulce.h"
#include <string> #include <string>
#include <mctools.h>
/* /*

View File

@@ -23,7 +23,7 @@ http://mozilla.org/MPL/2.0/.
#include "Mover.h" #include "Mover.h"
#include "../globals.h" #include "../globals.h"
//#include "../qutils.h" //#include "../qutils.h"
#include "mctools.h" #include <mctools.h>
#include "../logs.h" #include "../logs.h"
#include "hamulce.h" #include "hamulce.h"
#include "Oerlikon_ESt.h" #include "Oerlikon_ESt.h"
@@ -3574,17 +3574,17 @@ double TMoverParameters::Adhesive(double staticfriction)
{ {
if (SandDose) if (SandDose)
adhesive = (Max0R(staticfriction * (100.0 + Vel) / ((50.0 + Vel) * 11.0), 0.048)) * adhesive = (Max0R(staticfriction * (100.0 + Vel) / ((50.0 + Vel) * 11.0), 0.048)) *
(11.0 - 2.0 * random(0.0, 1.0)); (11.0 - 2.0 * Random(0.0, 1.0));
else else
adhesive = (staticfriction * (100.0 + Vel) / ((50.0 + Vel) * 10)) * adhesive = (staticfriction * (100.0 + Vel) / ((50.0 + Vel) * 10)) *
(11.0 - 2.0 * random(0.0, 1.0)); (11.0 - 2.0 * Random(0.0, 1.0));
} }
else else
{ {
if (SandDose) if (SandDose)
adhesive = (0.048) * (11 - 2 * random(0.0, 1.0)); adhesive = (0.048) * (11 - 2 * Random(0.0, 1.0));
else else
adhesive = (staticfriction * 0.02) * (11 - 2 * random(0.0, 1.0)); adhesive = (staticfriction * 0.02) * (11 - 2 * Random(0.0, 1.0));
} }
// WriteLog(FloatToStr(adhesive)); // tutaj jest na poziomie 0.2 - 0.3 // WriteLog(FloatToStr(adhesive)); // tutaj jest na poziomie 0.2 - 0.3
return adhesive; return adhesive;
@@ -5409,12 +5409,12 @@ int mSize;
double nMmax, nnMmax, nMnmax, nnmax, nnominalfill, nMstand; double nMmax, nnMmax, nMnmax, nnmax, nnominalfill, nMstand;
int nSize; int nSize;
int ti(std::string val) /*inline int ti(std::string val)
{ {
return atoi(val.c_str()); return atoi(val.c_str());
} }
double td(std::string val) inline double td(std::string val)
{ {
return atof(val.c_str()); return atof(val.c_str());
} }
@@ -5430,14 +5430,15 @@ std::string ts(std::string val)
std::string tS(std::string val) std::string tS(std::string val)
{ {
return ToUpper(val); return ToUpper(val);
} }*/
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160717 // Q: 20160717
// ************************************************************************************************* // *************************************************************************************************
int Pos(std::string find, std::string in) int Pos(std::string str_find, std::string in)
{ {
return (in.Pos(find)); size_t pos = in.find(str_find);
return (pos ? pos : 0);
} }
// ************************************************************************************************* // *************************************************************************************************
@@ -5446,7 +5447,7 @@ int Pos(std::string find, std::string in)
bool issection(std::string name) bool issection(std::string name)
{ {
sectionname = name; sectionname = name;
if (xline.Pos(name) > 0) if (xline.find(name) != string::npos)
{ {
lastsectionname = name; lastsectionname = name;
return true; return true;
@@ -5470,19 +5471,19 @@ std::string getkeyval(int rettype, std::string key)
if (Pos(key, xline) > 0) // jezeli jest klucz w swkcji... if (Pos(key, xline) > 0) // jezeli jest klucz w swkcji...
{ {
int klen = key.Length(); int klen = key.length();
int kpos = Pos(key, xline) - 1; int kpos = Pos(key, xline) - 1;
temp.Delete(1, kpos + klen); temp.erase(0, kpos + klen);
if (temp.Pos(" ") > 0) if (temp.find(" ") != string::npos)
to = temp.Pos(" "); to = temp.find(" ");
else else
to = 255; to = 255;
kval = temp.SubString(1, to); kval = temp.substr(0, to);
if (kval != "") if (kval != "")
kval = kval.Trim(); // wyciagnieta wartosc kval = TrimSpace(kval); // wyciagnieta wartosc
sectionname = StringReplace(sectionname, ":", "", TReplaceFlags() << rfReplaceAll); sectionname = ExchangeCharInString(sectionname, (char)":", (char)"");
sectionname = StringReplace(sectionname, ".", "", TReplaceFlags() << rfReplaceAll); sectionname = ExchangeCharInString(sectionname, (char)".", (char)"");
//--WriteLog(sectionname + "." + keyname + " val= [" + kval + "]"); //--WriteLog(sectionname + "." + keyname + " val= [" + kval + "]");
// if (rettype == 1) vS = kval; // if (rettype == 1) vS = kval;
@@ -5490,8 +5491,9 @@ std::string getkeyval(int rettype, std::string key)
// if (kval != "" && rettype == 3) vD = StrToFloat(kval); // if (kval != "" && rettype == 3) vD = StrToFloat(kval);
} }
else else
kval = "0"; // gdy nie bylo klucza TODO: dodac do funkcji parametr z wartoscia fabryczna kval = ""; // gdy nie bylo klucza TODO: dodac do funkcji parametr z wartoscia fabryczna
// UWAGA! 0 moze powodowac bledy, przemyslec zwracanie wartosci gdy nie ma klucza!!! // UWAGA! 0 moze powodowac bledy, przemyslec zwracanie wartosci gdy nie ma klucza!!!
// zwraca pusty klucz GF 2016-10-26
return kval; return kval;
} }
@@ -5501,6 +5503,32 @@ int MARKERROR(int code, std::string type, std::string msg)
return code; return code;
} }
int s2NPW(string s)
{ // wylicza ilosc osi napednych z opisu ukladu osi
const char A = (char)"A" - (char)1;
int k;
int NPW = 0;
for (k = 0; k < s.length(); k++)
{
if (s[k] >= (char)"A" && s[k] <= (char)"Z")
NPW += s[k] - A;
}
return NPW;
}
int s2NNW(string s)
{ // wylicza ilosc osi nienapedzanych z opisu ukladu osi
const char Zero = (char)"0";
int k;
int NNW = 0;
for (k = 0; k < s.length(); k++)
{
if (s[k] >= (char)"1" && s[k] <= (char)"9")
NNW += s[k] - Zero;
}
return NNW;
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160717 // Q: 20160717
// ************************************************************************************************* // *************************************************************************************************
@@ -5515,27 +5543,27 @@ bool TMoverParameters::readMPT(int ln, std::string xline)
if (ln > 0) // 0 to nazwa sekcji - MotorParamTable0: if (ln > 0) // 0 to nazwa sekcji - MotorParamTable0:
{ {
//--WriteLog("MPT: " + xline); //--WriteLog("MPT: " + xline);
x = split(xline.c_str(), ' '); x = Split(xline, ' ');
p0 = Trim(x[0].c_str()); p0 = TrimSpace(x[0]);
p1 = Trim(x[1].c_str()); p1 = TrimSpace(x[1]);
p2 = Trim(x[2].c_str()); p2 = TrimSpace(x[2]);
p3 = Trim(x[3].c_str()); p3 = TrimSpace(x[3]);
p4 = Trim(x[4].c_str()); p4 = TrimSpace(x[4]);
p5 = Trim(x[5].c_str()); p5 = TrimSpace(x[5]);
p6 = Trim(x[6].c_str()); p6 = TrimSpace(x[6]);
if (AutoRelayType == 0) if (AutoRelayType == 0)
as = false; as = false;
bl = StrToInt(p0); // numer pozycji bl = atoi(p0.c_str()); // numer pozycji
MotorParam[StrToInt(p0)].mfi = StrToFloat(p1); MotorParam[bl].mfi = atof(p1.c_str());
MotorParam[StrToInt(p0)].mIsat = StrToFloat(p2); MotorParam[bl].mIsat = atof(p2.c_str());
MotorParam[StrToInt(p0)].mfi0 = StrToFloat(p3); MotorParam[bl].mfi0 = atof(p3.c_str());
MotorParam[StrToInt(p0)].fi = StrToFloat(p4); MotorParam[bl].fi = atof(p4.c_str());
MotorParam[StrToInt(p0)].Isat = StrToFloat(p5); MotorParam[bl].Isat = atof(p5.c_str());
MotorParam[StrToInt(p0)].fi0 = StrToFloat(p6); MotorParam[bl].fi0 = atof(p6.c_str());
MotorParam[StrToInt(p0)].AutoSwitch = as; MotorParam[bl].AutoSwitch = as;
//--WriteLog(":::: " + p0 + "," + p1 + "," + p2 + "," + p3 + "," + p4 + "," + p5 + "," + //--WriteLog(":::: " + p0 + "," + p1 + "," + p2 + "," + p3 + "," + p4 + "," + p5 + "," +
//p6); //p6);
@@ -5558,29 +5586,29 @@ bool TMoverParameters::readRLIST(int ln, std::string xline)
// WriteLog("RLIST: " + xline); // WriteLog("RLIST: " + xline);
xline = Tab2Sp(xline); // zamieniamy taby na spacje (ile tabow tyle spacji bedzie) xline = Tab2Sp(xline); // zamieniamy taby na spacje (ile tabow tyle spacji bedzie)
xxx = trim_and_reduce_spaces(stdstrtochar(xline.c_str())); // konwertujemy na *char i xxx = TrimAndReduceSpaces(xline.c_str()); // konwertujemy na *char i
// ograniczamy spacje pomiedzy // ograniczamy spacje pomiedzy
// parametrami do jednej // parametrami do jednej
x = split(xxx, ' '); // split je wskaznik na char jak i std::string x = Split(xxx, ' '); // split je wskaznik na char jak i std::string
p0 = Trim(x[0].c_str()); p0 = TrimSpace(x[0]);
p1 = Trim(x[1].c_str()); p1 = TrimSpace(x[1]);
p2 = Trim(x[2].c_str()); p2 = TrimSpace(x[2]);
p3 = Trim(x[3].c_str()); p3 = TrimSpace(x[3]);
p4 = Trim(x[4].c_str()); p4 = TrimSpace(x[4]);
p5 = Trim(x[5].c_str()); p5 = TrimSpace(x[5]);
int k = ln - 1; int k = ln - 1;
RlistSize = s2b(mSize); RlistSize = (mSize);
if (RlistSize > ResArraySize) if (RlistSize > ResArraySize)
ConversionError = -4; ConversionError = -4;
RList[k].Relay = p0.ToInt(); // int RList[k].Relay = atoi(p0.c_str()); // int
RList[k].R = p1.ToDouble(); // double RList[k].R = atof(p1.c_str()); // double
RList[k].Bn = p2.ToInt(); // int RList[k].Bn = atoi(p2.c_str()); // int
RList[k].Mn = p3.ToInt(); // int RList[k].Mn = atoi(p3.c_str()); // int
RList[k].AutoSwitch = false; // p4.ToInt(); RList[k].AutoSwitch = false; // p4.ToInt();
//--WriteLog("RLIST: " + p0 + "," + p1 + "," + p2 + "," + p3 + "," + p4); //--WriteLog("RLIST: " + p0 + "," + p1 + "," + p2 + "," + p3 + "," + p4);
@@ -5603,19 +5631,19 @@ bool TMoverParameters::readBPT(int ln, std::string xline)
{ {
// WriteLog("BPT: " + xline); // WriteLog("BPT: " + xline);
xline = Tab2Sp(xline); xline = Tab2Sp(xline);
xxx = trim_and_reduce_spaces(stdstrtochar(xline.c_str())); xxx = TrimAndReduceSpaces(xline.c_str());
x = split(xxx, ' '); x = Split(xxx, ' ');
p0 = Trim(x[0].c_str()); p0 = TrimSpace(x[0]);
p1 = Trim(x[1].c_str()); p1 = TrimSpace(x[1]);
p2 = Trim(x[2].c_str()); p2 = TrimSpace(x[2]);
p3 = Trim(x[3].c_str()); p3 = TrimSpace(x[3]);
p4 = Trim(x[4].c_str()); p4 = TrimSpace(x[4]);
k = s2iE(p0); k = atoi(p0.c_str());
BrakePressureTable[k].PipePressureVal = p1.ToDouble(); BrakePressureTable[k].PipePressureVal = atof(p1.c_str());
BrakePressureTable[k].BrakePressureVal = p2.ToDouble(); BrakePressureTable[k].BrakePressureVal = atof(p2.c_str());
BrakePressureTable[k].FlowSpeedVal = p3.ToDouble(); BrakePressureTable[k].FlowSpeedVal = atof(p3.c_str());
if (p4 == "Pneumatic") if (p4 == "Pneumatic")
BrakePressureTable[k].BrakeType = Pneumatic; BrakePressureTable[k].BrakeType = Pneumatic;
else if (p4 == "ElectroPneumatic") else if (p4 == "ElectroPneumatic")
@@ -5685,19 +5713,28 @@ void TMoverParameters::BrakeSubsystemDecode()
BrakeSubsystem = ss_None; BrakeSubsystem = ss_None;
switch (BrakeValve) switch (BrakeValve)
{ {
case W, W_Lu_L, W_Lu_VI, W_Lu_XR: case W:
case W_Lu_L:
case W_Lu_VI:
case W_Lu_XR:
BrakeSubsystem = ss_W; BrakeSubsystem = ss_W;
break; break;
case ESt3, ESt3AL2, ESt4, EP2, EP1: case ESt3:
case ESt3AL2:
case ESt4:
case EP2:
case EP1:
BrakeSubsystem = ss_ESt; BrakeSubsystem = ss_ESt;
break; break;
case KE: case KE:
BrakeSubsystem = ss_KE; BrakeSubsystem = ss_KE;
break; break;
case CV1, CV1_L_TR: case CV1:
case CV1_L_TR:
BrakeSubsystem = ss_Dako; BrakeSubsystem = ss_Dako;
break; break;
case LSt, EStED: case LSt:
case EStED:
BrakeSubsystem = ss_LSt; BrakeSubsystem = ss_LSt;
break; break;
} }
@@ -5802,18 +5839,18 @@ void TMoverParameters::PowerParamDecode(std::string lines, std::string prefix,
case CurrentCollector: case CurrentCollector:
{ {
PowerParamDecode.CollectorParameters.CollectorsNo = s2lE(jCollectorsNo); PowerParamDecode.CollectorParameters.CollectorsNo = (jCollectorsNo);
PowerParamDecode.CollectorParameters.MinH = s2rE(jMinH); PowerParamDecode.CollectorParameters.MinH = (jMinH);
PowerParamDecode.CollectorParameters.MaxH = s2rE(jMaxH); PowerParamDecode.CollectorParameters.MaxH = (jMaxH);
PowerParamDecode.CollectorParameters.CSW = s2rE(jCSW); // szerokoœæ czêœci roboczej PowerParamDecode.CollectorParameters.CSW = (jCSW); // szerokoœæ czêœci roboczej
PowerParamDecode.CollectorParameters.MaxV = s2rE(jMaxVoltage); PowerParamDecode.CollectorParameters.MaxV = (jMaxVoltage);
// s:=jMinV; //napiêcie roz³¹czaj¹ce WS // s:=jMinV; //napiêcie roz³¹czaj¹ce WS
if (jMinV == 0) if (jMinV == 0)
PowerParamDecode.CollectorParameters.MinV = PowerParamDecode.CollectorParameters.MinV =
0.5 * PowerParamDecode.CollectorParameters.MaxV; // gdyby parametr nie podany 0.5 * PowerParamDecode.CollectorParameters.MaxV; // gdyby parametr nie podany
else else
PowerParamDecode.CollectorParameters.MinV = s2rE(jMinV); PowerParamDecode.CollectorParameters.MinV = (jMinV);
//-s:=ExtractKeyWord(lines,'InsetV='); //napiêcie wymagane do za³¹czenia WS //-s:=ExtractKeyWord(lines,'InsetV='); //napiêcie wymagane do za³¹czenia WS
//-if s='' then //-if s='' then
@@ -5825,12 +5862,12 @@ void TMoverParameters::PowerParamDecode(std::string lines, std::string prefix,
PowerParamDecode.CollectorParameters.MinPress = 2.0; // domyœlnie 2 bary do za³¹czenia PowerParamDecode.CollectorParameters.MinPress = 2.0; // domyœlnie 2 bary do za³¹czenia
// WS // WS
else else
PowerParamDecode.CollectorParameters.MinPress = s2rE(jMinPress); PowerParamDecode.CollectorParameters.MinPress = (jMinPress);
// s:=ExtractKeyWord(lines,'MaxPress='); //maksymalne ciœnienie za reduktorem // s:=ExtractKeyWord(lines,'MaxPress='); //maksymalne ciœnienie za reduktorem
if (jMaxPress == 0) if (jMaxPress == 0)
PowerParamDecode.CollectorParameters.MaxPress = 5.0 + 0.001 * (random(50) - random(50)); PowerParamDecode.CollectorParameters.MaxPress = 5.0 + 0.001 * (Random(50) - Random(50));
else else
PowerParamDecode.CollectorParameters.MaxPress = s2rE(jMaxPress); PowerParamDecode.CollectorParameters.MaxPress = (jMaxPress);
} }
// case PowerCable: // case PowerCable:
//{ //{
@@ -5862,9 +5899,9 @@ void TMoverParameters::PowerParamDecode(std::string lines, std::string prefix,
// ************************************************************************************************* // *************************************************************************************************
bool TMoverParameters::LoadFIZ(std::string chkpath) bool TMoverParameters::LoadFIZ(std::string chkpath)
{ {
const param_ok = 1; const int param_ok = 1;
const wheels_ok = 2; const int wheels_ok = 2;
const dimensions_ok = 4; const int dimensions_ok = 4;
int ishash; int ishash;
int bl, i, k; int bl, i, k;
@@ -5892,6 +5929,11 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
// appdir = ExtractFilePath(ParamStr(0)); // appdir = ExtractFilePath(ParamStr(0));
ifstream in(file.c_str()); ifstream in(file.c_str());
if (!in.is_open())
{
WriteLog("E8 - FIZ FILE NOT EXIST.");
return false;
}
bool secBPT, secMotorParamTable0, secPower, secEngine, secParam, secLoad, secDimensions, bool secBPT, secMotorParamTable0, secPower, secEngine, secParam, secLoad, secDimensions,
secWheels, secBrake, secBuffCoupl, secCntrl, secSecurity, secLight, secCircuit, secRList, secWheels, secBrake, secBuffCoupl, secCntrl, secSecurity, secLight, secCircuit, secRList,
@@ -5910,7 +5952,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if ((ishash == 0)) if ((ishash == 0))
{ {
if (xline.Length() == 0) if (xline.length() == 0)
startBPT = false; // Tablica parametyrow hamulca nie ma znacznika konca :( startBPT = false; // Tablica parametyrow hamulca nie ma znacznika konca :(
if (issection("END-MPT")) if (issection("END-MPT"))
startMPT = false; startMPT = false;
@@ -5921,207 +5963,207 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
{ {
secParam = true; secParam = true;
SetFlag(OKFlag, param_ok); SetFlag(OKFlag, param_ok);
aCategory = ts(getkeyval(1, "Category")); aCategory = getkeyval(1, "Category");
aType = tS(getkeyval(1, "Type")); aType = ToUpper(getkeyval(1, "Type"));
aMass = td(getkeyval(3, "M")); aMass = atof(getkeyval(3, "M").c_str());
aMred = td(getkeyval(3, "Mred")); aMred = atof(getkeyval(3, "Mred").c_str());
aVmax = td(getkeyval(3, "Vmax")); aVmax = atof(getkeyval(3, "Vmax").c_str());
aPWR = td(getkeyval(3, "PWR")); aPWR = atof(getkeyval(3, "PWR").c_str());
aSandCap = ti(getkeyval(2, "SandCap")); aSandCap = atoi(getkeyval(2, "SandCap").c_str());
aHeatingP = td(getkeyval(3, "HeatingP")); aHeatingP = atof(getkeyval(3, "HeatingP").c_str());
aLightP = td(getkeyval(3, "LightP")); aLightP = atof(getkeyval(3, "LightP").c_str());
} }
if (issection("Load:")) if (issection("Load:"))
{ {
secLoad = true; secLoad = true;
bMaxLoad = ti(getkeyval(2, "MaxLoad")); bMaxLoad = atoi(getkeyval(2, "MaxLoad").c_str());
bLoadQ = ts(getkeyval(1, "LoadQ")); bLoadQ = getkeyval(1, "LoadQ");
bLoadAccepted = ts(getkeyval(1, "LoadAccepted")); bLoadAccepted = getkeyval(1, "LoadAccepted");
bLoadSpeed = td(getkeyval(3, "LoadSpeed")); bLoadSpeed = atof(getkeyval(3, "LoadSpeed").c_str());
bUnLoadSpeed = td(getkeyval(3, "UnLoadSpeed")); bUnLoadSpeed = atof(getkeyval(3, "UnLoadSpeed").c_str());
bOverLoadFactor = td(getkeyval(3, "OverLoadFactor")); bOverLoadFactor = atof(getkeyval(3, "OverLoadFactor").c_str());
} }
if (issection("Dimensions:")) if (issection("Dimensions:"))
{ {
secDimensions = true; secDimensions = true;
SetFlag(OKFlag, dimensions_ok); SetFlag(OKFlag, dimensions_ok);
cL = td(getkeyval(3, "L")); cL = atof(getkeyval(3, "L").c_str());
cH = td(getkeyval(3, "H")); cH = atof(getkeyval(3, "H").c_str());
cW = td(getkeyval(3, "W")); cW = atof(getkeyval(3, "W").c_str());
cCx = td(getkeyval(3, "Cx")); cCx = atof(getkeyval(3, "Cx").c_str());
cFloor = td(getkeyval(3, "Floor")); cFloor = atof(getkeyval(3, "Floor").c_str());
} }
if (issection("Wheels:")) if (issection("Wheels:"))
{ {
secWheels = true; secWheels = true;
dD = td(getkeyval(3, "D")); dD = atof(getkeyval(3, "D").c_str());
dDl = td(getkeyval(3, "Dl")); dDl = atof(getkeyval(3, "Dl").c_str());
dDt = td(getkeyval(3, "Dt")); dDt = atof(getkeyval(3, "Dt").c_str());
dAIM = td(getkeyval(3, "AIM")); dAIM = atof(getkeyval(3, "AIM").c_str());
dTw = td(getkeyval(3, "Tw")); dTw = atof(getkeyval(3, "Tw").c_str());
dAxle = ts(getkeyval(1, "Axle")); dAxle = getkeyval(1, "Axle");
dAd = td(getkeyval(3, "Ad")); dAd = atof(getkeyval(3, "Ad").c_str());
dBd = td(getkeyval(3, "Bd")); dBd = atof(getkeyval(3, "Bd").c_str());
dRmin = td(getkeyval(3, "Rmin")); dRmin = atof(getkeyval(3, "Rmin").c_str());
dBearingType = ts(getkeyval(1, "BearingType")); dBearingType = getkeyval(1, "BearingType");
} }
if (issection("Brake:")) if (issection("Brake:"))
{ {
secBrake = true; secBrake = true;
eBrakeValve = ts(getkeyval(1, "BrakeValve")); eBrakeValve = getkeyval(1, "BrakeValve");
eNBpA = ti(getkeyval(2, "NBpA")); eNBpA = atoi(getkeyval(2, "NBpA").c_str());
eMBF = td(getkeyval(3, "MBF")); eMBF = atof(getkeyval(3, "MBF").c_str());
eTBF = td(getkeyval(3, "TBF")); eTBF = atof(getkeyval(3, "TBF").c_str());
eSize = ti(getkeyval(3, "Size")); eSize = atoi(getkeyval(3, "Size").c_str());
eMaxBP = td(getkeyval(3, "MaxBP")); eMaxBP = atof(getkeyval(3, "MaxBP").c_str());
eMedMaxBP = td(getkeyval(3, "MedMaxBP")); eMedMaxBP = atof(getkeyval(3, "MedMaxBP").c_str());
eTareMaxBP = td(getkeyval(3, "TareMaxBP")); eTareMaxBP = atof(getkeyval(3, "TareMaxBP").c_str());
eMaxLBP = td(getkeyval(3, "MaxLBP")); eMaxLBP = atof(getkeyval(3, "MaxLBP").c_str());
eMaxASBP = td(getkeyval(3, "MaxASBP")); eMaxASBP = atof(getkeyval(3, "MaxASBP").c_str());
eRM = td(getkeyval(3, "RM")); eRM = atof(getkeyval(3, "RM").c_str());
eBCN = ti(getkeyval(2, "BCN")); eBCN = atoi(getkeyval(2, "BCN").c_str());
eBCR = td(getkeyval(3, "BCR")); eBCR = atof(getkeyval(3, "BCR").c_str());
eBCD = td(getkeyval(3, "BCD")); eBCD = atof(getkeyval(3, "BCD").c_str());
eBCM = td(getkeyval(3, "BCM")); eBCM = atof(getkeyval(3, "BCM").c_str());
eBCMlo = td(getkeyval(3, "BCMlo")); eBCMlo = atof(getkeyval(3, "BCMlo").c_str());
eBCMhi = td(getkeyval(3, "BCMhi")); eBCMhi = atof(getkeyval(3, "BCMhi").c_str());
eVv = td(getkeyval(3, "Vv")); eVv = atof(getkeyval(3, "Vv").c_str());
eMinCP = td(getkeyval(3, "MinCP")); eMinCP = atof(getkeyval(3, "MinCP").c_str());
eMaxCP = td(getkeyval(3, "MaxCP")); eMaxCP = atof(getkeyval(3, "MaxCP").c_str());
eBCS = td(getkeyval(3, "BCS")); eBCS = atof(getkeyval(3, "BCS").c_str());
eBSA = td(getkeyval(3, "BSA")); eBSA = atof(getkeyval(3, "BSA").c_str());
eBM = ts(getkeyval(1, "BM")); eBM = atof(getkeyval(1, "BM").c_str());
eBVV = ti(getkeyval(2, "BVV")); eBVV = atoi(getkeyval(2, "BVV").c_str());
eBRE = td(getkeyval(3, "BRE")); eBRE = atof(getkeyval(3, "BRE").c_str());
eHiPP = td(getkeyval(3, "HiPP")); eHiPP = atof(getkeyval(3, "HiPP").c_str());
eLoPP = td(getkeyval(3, "LoPP")); eLoPP = atof(getkeyval(3, "LoPP").c_str());
eCompressorSpeed = td(getkeyval(3, "CompressorSpeed")); eCompressorSpeed = atof(getkeyval(3, "CompressorSpeed").c_str());
eCompressorPower = ts(getkeyval(1, "CompressorPower")); eCompressorPower = atof(getkeyval(1, "CompressorPower").c_str());
} }
if (issection("BuffCoupl.") || issection("BuffCoupl1.")) if (issection("BuffCoupl.") || issection("BuffCoupl1."))
{ {
secBuffCoupl = true; secBuffCoupl = true;
fCType = ts(getkeyval(1, "CType")); fCType = (getkeyval(1, "CType"));
fkB = td(getkeyval(3, "kB")); fkB = atof(getkeyval(3, "kB").c_str());
fDmaxB = td(getkeyval(3, "DmaxB")); fDmaxB = atof(getkeyval(3, "DmaxB").c_str());
fFmaxB = td(getkeyval(3, "FmaxB")); fFmaxB = atof(getkeyval(3, "FmaxB").c_str());
fkC = td(getkeyval(3, "kC")); fkC = atof(getkeyval(3, "kC").c_str());
fDmaxC = td(getkeyval(3, "DmaxC")); fDmaxC = atof(getkeyval(3, "DmaxC").c_str());
fFmaxC = td(getkeyval(3, "FmaxC")); fFmaxC = atof(getkeyval(3, "FmaxC").c_str());
fbeta = td(getkeyval(3, "beta")); fbeta = atof(getkeyval(3, "beta").c_str());
fAllowedFlag = ti(getkeyval(2, "AllowedFlag")); fAllowedFlag = atoi(getkeyval(2, "AllowedFlag").c_str());
} }
if (issection("Cntrl.")) if (issection("Cntrl."))
{ {
secCntrl = true; secCntrl = true;
gBrakeSystem = ts(getkeyval(1, "BrakeSystem")); gBrakeSystem = (getkeyval(1, "BrakeSystem"));
gBCPN = ti(getkeyval(2, "BCPN")); gBCPN = atoi(getkeyval(2, "BCPN").c_str());
gBDelay1 = ti(getkeyval(2, "BDelay1")); gBDelay1 = atoi(getkeyval(2, "BDelay1").c_str());
gBDelay2 = ti(getkeyval(2, "BDelay2")); gBDelay2 = atoi(getkeyval(2, "BDelay2").c_str());
gBDelay3 = ti(getkeyval(2, "BDelay3")); gBDelay3 = atoi(getkeyval(2, "BDelay3").c_str());
gBDelay4 = ti(getkeyval(2, "BDelay4")); gBDelay4 = atoi(getkeyval(2, "BDelay4").c_str());
gASB = ts(getkeyval(1, "ASB")); gASB = (getkeyval(1, "ASB"));
gLocalBrake = ts(getkeyval(1, "LocalBrake")); gLocalBrake = (getkeyval(1, "LocalBrake"));
gDynamicBrake = ts(getkeyval(1, "DynamicBrake")); gDynamicBrake = (getkeyval(1, "DynamicBrake"));
// gManualBrake = ts(getkeyval(1, "ManualBrake")); // gManualBrake = (getkeyval(1, "ManualBrake"));
gFSCircuit = ts(getkeyval(1, "FSCircuit")); gFSCircuit = (getkeyval(1, "FSCircuit").c_str());
gMCPN = ti(getkeyval(2, "MCPN")); gMCPN = atoi(getkeyval(2, "MCPN").c_str());
gSCPN = ti(getkeyval(2, "SCPN")); gSCPN = atoi(getkeyval(2, "SCPN").c_str());
gSCIM = ti(getkeyval(2, "SCIM")); gSCIM = atoi(getkeyval(2, "SCIM").c_str());
gScndS = ts(getkeyval(1, "ScndS")); gScndS = (getkeyval(1, "ScndS"));
gCoupledCtrl = ts(getkeyval(1, "CoupledCtrl")); gCoupledCtrl = (getkeyval(1, "CoupledCtrl"));
gAutoRelay = ts(getkeyval(1, "AutoRelay")); gAutoRelay = (getkeyval(1, "AutoRelay"));
gIniCDelay = td(getkeyval(3, "IniCDelay")); gIniCDelay = atof(getkeyval(3, "IniCDelay").c_str());
gSCDelay = td(getkeyval(3, "SCDelay")); gSCDelay = atof(getkeyval(3, "SCDelay").c_str());
gSCDDelay = td(getkeyval(3, "SCDDelay")); gSCDDelay = atof(getkeyval(3, "SCDDelay").c_str());
gBrakeDelays = ts(getkeyval(1, "BrakeDelays")); gBrakeDelays = (getkeyval(1, "BrakeDelays"));
gBrakeHandle = ts(getkeyval(1, "BrakeHandle")); gBrakeHandle = (getkeyval(1, "BrakeHandle"));
gLocBrakeHandle = ts(getkeyval(1, "LocBrakeHandle")); gLocBrakeHandle = (getkeyval(1, "LocBrakeHandle"));
gMaxBPMass = td(getkeyval(3, "MaxBPMass")); gMaxBPMass = atof(getkeyval(3, "MaxBPMass").c_str());
} }
if (issection("Security:")) if (issection("Security:"))
{ {
secSecurity = true; secSecurity = true;
hAwareSystem = ts(getkeyval(1, "AwareSystem")); hAwareSystem = (getkeyval(1, "AwareSystem"));
hAwareMinSpeed = td(getkeyval(3, "AwareMinSpeed")); hAwareMinSpeed = atof(getkeyval(3, "AwareMinSpeed").c_str());
hAwareDelay = td(getkeyval(3, "AwareDelay")); hAwareDelay = atof(getkeyval(3, "AwareDelay").c_str());
hSoundSignalDelay = td(getkeyval(3, "SoundSignalDelay")); hSoundSignalDelay = atof(getkeyval(3, "SoundSignalDelay").c_str());
hEmergencyBrakeDelay = td(getkeyval(3, "EmergencyBrakeDelay")); hEmergencyBrakeDelay = atof(getkeyval(3, "EmergencyBrakeDelay").c_str());
hRadioStop = ts(getkeyval(1, "RadioStop")); hRadioStop = (getkeyval(1, "RadioStop"));
} }
if (issection("Light:")) if (issection("Light:"))
{ {
secLight = true; secLight = true;
iLight = ts(getkeyval(1, "Light")); iLight = (getkeyval(1, "Light"));
iLGeneratorEngine = ts(getkeyval(1, "LGeneratorEngine")); iLGeneratorEngine = (getkeyval(1, "LGeneratorEngine"));
iLMaxVoltage = td(getkeyval(3, "LMaxVoltage")); iLMaxVoltage = atof(getkeyval(3, "LMaxVoltage").c_str());
iLMaxCurrent = td(getkeyval(3, "LMaxCurrent")); iLMaxCurrent = atof(getkeyval(3, "LMaxCurrent").c_str());
} }
if (issection("Power:")) if (issection("Power:"))
{ {
secPower = true; secPower = true;
jEnginePower = ts(getkeyval(1, "EnginePower")); jEnginePower = (getkeyval(1, "EnginePower"));
jSystemPower = ts(getkeyval(1, "SystemPower")); jSystemPower = (getkeyval(1, "SystemPower"));
jCollectorsNo = ti(getkeyval(2, "CollectorsNo")); jCollectorsNo = atoi(getkeyval(2, "CollectorsNo").c_str());
jMaxVoltage = td(getkeyval(3, "MaxVoltage")); jMaxVoltage = atof(getkeyval(3, "MaxVoltage").c_str());
jMaxCurrent = td(getkeyval(3, "MaxCurrent")); jMaxCurrent = atof(getkeyval(3, "MaxCurrent").c_str());
jIntR = td(getkeyval(3, "IntR")); jIntR = atof(getkeyval(3, "IntR").c_str());
jMinH = td(getkeyval(3, "MinH")); jMinH = atof(getkeyval(3, "MinH").c_str());
jMaxH = td(getkeyval(3, "MaxH")); jMaxH = atof(getkeyval(3, "MaxH").c_str());
jCSW = td(getkeyval(3, "CSW")); jCSW = atof(getkeyval(3, "CSW").c_str());
jMinV = td(getkeyval(3, "MinV")); jMinV = atof(getkeyval(3, "MinV").c_str());
jMinPress = td(getkeyval(3, "MinPress")); jMinPress = atof(getkeyval(3, "MinPress").c_str());
jMaxPress = td(getkeyval(3, "MaxPress")); jMaxPress = atof(getkeyval(3, "MaxPress").c_str());
} }
if (issection("Engine:")) if (issection("Engine:"))
{ {
secEngine = true; secEngine = true;
kEngineType = ts(getkeyval(1, "EngineType")); kEngineType = (getkeyval(1, "EngineType"));
kTrans = ts(getkeyval(1, "Trans")); kTrans = (getkeyval(1, "Trans"));
kVolt = td(getkeyval(3, "Volt")); kVolt = atof(getkeyval(3, "Volt").c_str());
kWindingRes = td(getkeyval(3, "WindingRes")); kWindingRes = atof(getkeyval(3, "WindingRes").c_str());
knmax = td(getkeyval(3, "nmax")); knmax = atof(getkeyval(3, "nmax").c_str());
} }
if (issection("Circuit:")) if (issection("Circuit:"))
{ {
secCircuit = true; secCircuit = true;
lCircuitRes = td(getkeyval(3, "CircuitRes")); lCircuitRes = atof(getkeyval(3, "CircuitRes").c_str());
lImaxLo = ti(getkeyval(2, "ImaxLo")); lImaxLo = atoi(getkeyval(2, "ImaxLo").c_str());
lImaxHi = ti(getkeyval(2, "ImaxHi")); lImaxHi = atoi(getkeyval(2, "ImaxHi").c_str());
lIminLo = ti(getkeyval(2, "IminLo")); lIminLo = atoi(getkeyval(2, "IminLo").c_str());
lIminHi = ti(getkeyval(2, "IminHi")); lIminHi = atoi(getkeyval(2, "IminHi").c_str());
} }
if (issection("RList:")) if (issection("RList:"))
{ {
secRList = true; secRList = true;
mSize = ti(getkeyval(2, "Size")); mSize = atoi(getkeyval(2, "Size").c_str());
mRVent = ts(getkeyval(1, "RVent")); mRVent = (getkeyval(1, "RVent"));
mRVentnmax = td(getkeyval(3, "RVentnmax")); mRVentnmax = atof(getkeyval(3, "RVentnmax").c_str());
mRVentCutOff = td(getkeyval(3, "RVentCutOff")); mRVentCutOff = atof(getkeyval(3, "RVentCutOff").c_str());
} }
if (issection("DList:")) if (issection("DList:"))
{ {
secDList = true; secDList = true;
nMmax = td(getkeyval(3, "Mmax")); nMmax = atof(getkeyval(3, "Mmax").c_str());
nnMmax = td(getkeyval(3, "nMmax")); nnMmax = atof(getkeyval(3, "nMmax").c_str());
nMnmax = td(getkeyval(3, "Mnmax")); nMnmax = atof(getkeyval(3, "Mnmax").c_str());
nnmax = td(getkeyval(3, "nmax")); nnmax = atof(getkeyval(3, "nmax").c_str());
nnominalfill = td(getkeyval(3, "nominalfill")); nnominalfill = atof(getkeyval(3, "nominalfill").c_str());
nMstand = td(getkeyval(3, "Mstand")); nMstand = atof(getkeyval(3, "Mstand").c_str());
nSize = ti(getkeyval(2, "Size")); nSize = atoi(getkeyval(2, "Size").c_str());
} }
if (issection("WWList:")) if (issection("WWList:"))
@@ -6185,7 +6227,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
else if (aCategory == "unimog") else if (aCategory == "unimog")
CategoryFlag = 3; CategoryFlag = 3;
else else
ConversionError = MARKERROR(-7, 1, "Improper vechicle category"); ConversionError = MARKERROR(-7, "1", "Improper vechicle category");
Mass = aMass; Mass = aMass;
Mred = aMred; Mred = aMred;
@@ -6274,7 +6316,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
AxleInertialMoment = 1; AxleInertialMoment = 1;
if (NAxles == 0) if (NAxles == 0)
ConversionError = MARKERROR(-1, 1, "0 axles, hover cat?"); ConversionError = MARKERROR(-1, "1", "0 axles, hover cat?");
if (dBearingType == "Roll") if (dBearingType == "Roll")
BearingType = 1; BearingType = 1;
@@ -6368,7 +6410,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
RapidMult = 1; RapidMult = 1;
} }
else else
ConversionError = MARKERROR(-5, 1, "0 brake cylinder units"); ConversionError = MARKERROR(-5, "1", "0 brake cylinder units");
} }
else else
P2FTrans = 0; P2FTrans = 0;
@@ -6379,7 +6421,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
CntrlPipePress = eHiPP; CntrlPipePress = eHiPP;
else else
CntrlPipePress = CntrlPipePress =
5 + 0.001 * (random(10) - random(10)); // Ra 2014-07: trochê niedok³adnoœci 5 + 0.001 * (Random(10) - Random(10)); // Ra 2014-07: trochê niedok³adnoœci
HighPipePress = CntrlPipePress; HighPipePress = CntrlPipePress;
if (eHiPP != 0) if (eHiPP != 0)
@@ -6705,13 +6747,13 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
{ {
NominalVoltage = kVolt; NominalVoltage = kVolt;
x = split(kTrans.c_str(), ':'); // 18:79 x = Split(kTrans, ':'); // 18:79
p0 = Trim(x[0].c_str()); p0 = TrimSpace(x[0]);
p1 = Trim(x[1].c_str()); p1 = TrimSpace(x[1]);
Transmision.NToothW = s2b(p1); Transmision.NToothW = atoi(p1.c_str());
Transmision.NToothM = s2b(p0); Transmision.NToothM = atoi(p0.c_str());
// ToothW to drugi parametr czyli 79 // ToothW to drugi parametr czyli 79
// ToothM to pierwszy czyli 18 // ToothM to pierwszy czyli 18
@@ -6745,19 +6787,19 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (secCircuit) if (secCircuit)
{ {
// s := DUE(ExtractKeyWord(lines, 'CircuitRes=')); writepaslog('CircuitRes', s); // s := DUE(ExtractKeyWord(lines, 'CircuitRes=')); writepaslog('CircuitRes', s);
CircuitRes = s2r(lCircuitRes); CircuitRes = (lCircuitRes);
// s := DUE(ExtractKeyWord(lines, 'IminLo=')); writepaslog('IminLo', s); // s := DUE(ExtractKeyWord(lines, 'IminLo=')); writepaslog('IminLo', s);
IminLo = s2iE(lIminLo); IminLo = (lIminLo);
// s := DUE(ExtractKeyWord(lines, 'IminHi=')); writepaslog('IminHi', s); // s := DUE(ExtractKeyWord(lines, 'IminHi=')); writepaslog('IminHi', s);
IminHi = s2i(lIminHi); IminHi = (lIminHi);
// s := DUE(ExtractKeyWord(lines, 'ImaxLo=')); writepaslog('ImaxLo', s); // s := DUE(ExtractKeyWord(lines, 'ImaxLo=')); writepaslog('ImaxLo', s);
ImaxLo = s2iE(lImaxLo); ImaxLo = (lImaxLo);
// s := DUE(ExtractKeyWord(lines, 'ImaxHi=')); writepaslog('ImaxHi', s); // s := DUE(ExtractKeyWord(lines, 'ImaxHi=')); writepaslog('ImaxHi', s);
ImaxHi = s2i(lImaxHi); ImaxHi = (lImaxHi);
Imin = IminLo; Imin = IminLo;
Imax = ImaxLo; Imax = ImaxLo;
} }
@@ -6767,7 +6809,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (secRList) if (secRList)
{ {
RlistSize = s2b(mSize); RlistSize = (mSize);
if (mRVent == "Automatic") if (mRVent == "Automatic")
RVentType = 2; RVentType = 2;
@@ -6778,9 +6820,9 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (RVentType > 0) if (RVentType > 0)
{ {
RVentnmax = s2rE(mRVentnmax) / 60.0; RVentnmax = (mRVentnmax) / 60.0;
RVentCutOff = s2r(mRVentCutOff); RVentCutOff = (mRVentCutOff);
} }
} }
@@ -6791,9 +6833,9 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
// WriteLog(""); // WriteLog("");
// WriteLog("----------------------------------------------------------------------------------------"); // WriteLog("----------------------------------------------------------------------------------------");
WriteLog("CERROR: " + IntToStr(ConversionError) + ", SUCCES: " + AS(BoolToYN(OK))); WriteLog("CERROR: " + to_string(ConversionError) + ", SUCCES: " + to_string(OK));
// WriteLogSS(); // WriteLogSS();
WriteLog(""); //WriteLog("");
return OK; return OK;
} // LoadFIZ() } // LoadFIZ()
@@ -6940,7 +6982,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
Handle = new TSt113(); Handle = new TSt113();
break; break;
default: default:
Handle = new TBHandle(); Handle = new TDriverHandle();
} }
switch (BrakeLocHandle) switch (BrakeLocHandle)
@@ -6958,7 +7000,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
break; break;
} }
default: default:
LocHandle = new TBHandle(); LocHandle = new TDriverHandle();
} }
// ustalanie srednicy przewodu glownego (lokomotywa lub napêdowy // ustalanie srednicy przewodu glownego (lokomotywa lub napêdowy
@@ -7070,7 +7112,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
// Hamulec->Init(PipePress, HighPipePress, LowPipePress, BrakePress, BrakeDelayFlag); // Hamulec->Init(PipePress, HighPipePress, LowPipePress, BrakePress, BrakeDelayFlag);
// ScndPipePress = Compressor; // ScndPipePress = Compressor;
WriteLogSS("OK=", BoolTo10(OK)); WriteLog("OK=" + to_string(OK));
return OK; return OK;
} }
@@ -7228,7 +7270,7 @@ bool TMoverParameters::CreateBrakeSys()
Handle = new TSt113(); Handle = new TSt113();
break; break;
default: default:
Handle = new TBHandle(); Handle = new TDriverHandle();
} }
switch (BrakeLocHandle) switch (BrakeLocHandle)
@@ -7246,7 +7288,7 @@ bool TMoverParameters::CreateBrakeSys()
break; break;
} }
default: default:
LocHandle = new TBHandle(); LocHandle = new TDriverHandle();
} }
Pipe = new TReservoir(); Pipe = new TReservoir();
@@ -7336,7 +7378,7 @@ bool TMoverParameters::CreateBrakeSys()
ScndPipePress = Compressor; ScndPipePress = Compressor;
// WriteLogSS("OK=", BoolTo10(OK)); // WriteLogSS("OK=", BoolTo10(OK));
WriteLog(""); //WriteLog("");
return OK; return OK;
} }

View File

@@ -330,7 +330,7 @@ void TNESt3::Init(double PP, double HPP, double LPP, double BP, unsigned char BD
CntrlRes = new TReservoir(); CntrlRes = new TReservoir();
CntrlRes->CreateCap(15); CntrlRes->CreateCap(15);
CntrlRes->CreatePress(1 * HPP); CntrlRes->CreatePress(1 * HPP);
BrakeStatus = Byte(BP > 1) * 1; BrakeStatus = int(BP > 1) * 1;
Miedzypoj = new TReservoir(); Miedzypoj = new TReservoir();
Miedzypoj->CreateCap(5); Miedzypoj->CreateCap(5);
Miedzypoj->CreatePress(PP); Miedzypoj->CreatePress(PP);
@@ -457,7 +457,7 @@ void TNESt3::PLC(double mass)
{ {
LoadC = LoadC =
1 + 1 +
Byte(mass < LoadM) * double(mass < LoadM) *
((TareBP + (MaxBP - TareBP) * (mass - TareM) * 1.0 / (LoadM - TareM)) * 1.0 / MaxBP - ((TareBP + (MaxBP - TareBP) * (mass - TareM) * 1.0 / (LoadM - TareM)) * 1.0 / MaxBP -
1); 1);
} }

View File

@@ -185,6 +185,9 @@ class TNESt3 : public TBrake
double LBP; // cisnienie hamulca pomocniczego double LBP; // cisnienie hamulca pomocniczego
public: public:
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) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn
, i_BD, i_mat, i_ba, i_nbpa) { }
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

View File

@@ -1,232 +0,0 @@
// Borland C++ Builder
// Copyright (c) 1995, 1999 by Borland International
// All rights reserved
// (DO NOT EDIT: machine generated header) 'friction.pas' rev: 5.00
#ifndef frictionHPP
#define frictionHPP
#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <SysUtils.hpp> // Pascal unit
#include <mctools.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Physics
{
//-- type declarations -------------------------------------------------------
class DELPHICLASS TFricMat;
class PASCALIMPLEMENTATION TFricMat : public System::TObject
{
typedef System::TObject inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TFricMat(void) : System::TObject() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TFricMat(void) { }
#pragma option pop
};
class DELPHICLASS TP10Bg;
class PASCALIMPLEMENTATION TP10Bg : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TP10Bg(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TP10Bg(void) { }
#pragma option pop
};
class DELPHICLASS TP10Bgu;
class PASCALIMPLEMENTATION TP10Bgu : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TP10Bgu(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TP10Bgu(void) { }
#pragma option pop
};
class DELPHICLASS TP10yBg;
class PASCALIMPLEMENTATION TP10yBg : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TP10yBg(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TP10yBg(void) { }
#pragma option pop
};
class DELPHICLASS TP10yBgu;
class PASCALIMPLEMENTATION TP10yBgu : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TP10yBgu(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TP10yBgu(void) { }
#pragma option pop
};
class DELPHICLASS TP10;
class PASCALIMPLEMENTATION TP10 : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TP10(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TP10(void) { }
#pragma option pop
};
class DELPHICLASS TFR513;
class PASCALIMPLEMENTATION TFR513 : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TFR513(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TFR513(void) { }
#pragma option pop
};
class DELPHICLASS TFR510;
class PASCALIMPLEMENTATION TFR510 : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TFR510(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TFR510(void) { }
#pragma option pop
};
class DELPHICLASS TCosid;
class PASCALIMPLEMENTATION TCosid : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TCosid(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TCosid(void) { }
#pragma option pop
};
class DELPHICLASS TDisk1;
class PASCALIMPLEMENTATION TDisk1 : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TDisk1(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TDisk1(void) { }
#pragma option pop
};
class DELPHICLASS TDisk2;
class PASCALIMPLEMENTATION TDisk2 : public TFricMat
{
typedef TFricMat inherited;
public:
virtual double __fastcall GetFC(double N, double Vel);
public:
#pragma option push -w-inl
/* TObject.Create */ inline __fastcall TDisk2(void) : TFricMat() { }
#pragma option pop
#pragma option push -w-inl
/* TObject.Destroy */ inline __fastcall virtual ~TDisk2(void) { }
#pragma option pop
};
//-- var, const, procedure ---------------------------------------------------
} /* namespace Friction */
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace Friction;
#endif
#pragma option pop // -w-
#pragma option pop // -Vx
#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // friction

View File

@@ -20,6 +20,18 @@ 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] = { 0, 8, 1, 2, 0, 3, 6, 8, 2, 2, 2 };
double TMHZ_EN57::pos_table[11] = { 0, 12, 1, 2, 2, 4, 11, 12, 2, 2, 2 };
double TM394::pos_table[11] = { 0, 6, 0, 1, 2, 3, 5, 6, 1, 1, 1 };
double TH14K1::BPT_K[6][2] =
{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) };
double TH14K1::pos_table[11] = { 0, 5, 0, 1, 2, 3, 4, 5, 1, 1, 1 };
double 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 TSt113::pos_table[11] = { 0, 6, 0, 1, 3, 4, 5, 6, 1, 1, 2 };
double 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)
{ {
@@ -40,7 +52,7 @@ double PF_old(double P1, double P2, double S)
return (PH + 1) * 222 * S * (P2 - P1) * 1.0 / (1.13 * PH - PL); return (PH + 1) * 222 * S * (P2 - P1) * 1.0 / (1.13 * PH - PL);
} }
double PF(double P1, double P2, double S, double DP = 0.25) double PF(double P1, double P2, double S, double DP)
{ {
double PH = Max0R(P1, P2) + 1; // wyzsze cisnienie absolutne double PH = Max0R(P1, P2) + 1; // wyzsze cisnienie absolutne
double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne
@@ -79,7 +91,7 @@ long lround(double value)
} }
double PFVa(double PH, double PL, double S, double LIM, double PFVa(double PH, double PL, double S, double LIM,
double DP = 0.1) // zawor napelniajacy z PH do PL, PL do LIM double DP) // zawor napelniajacy z PH do PL, PL do LIM
{ {
if (LIM > PL) if (LIM > PL)
{ {
@@ -104,7 +116,7 @@ double PFVa(double PH, double PL, double S, double LIM,
} }
double PFVd(double PH, double PL, double S, double LIM, double PFVd(double PH, double PL, double S, double LIM,
double DP = 0.1) // zawor wypuszczajacy z PH do PL, PH do LIM double DP) // zawor wypuszczajacy z PH do PL, PH do LIM
{ {
if (LIM < PH) if (LIM < PH)
{ {
@@ -2347,9 +2359,7 @@ double TFV4aM::GetSound(int i)
double TFV4aM::GetPos(int i) double TFV4aM::GetPos(int i)
{ {
static double const table[11] = { -2, 6, -1, 0, -2, 1, 4, 6, 0, 0, 0 }; return pos_table[i];
return table[i];
} }
double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji;
@@ -2481,9 +2491,7 @@ double TMHZ_EN57::GetSound(int i)
double TMHZ_EN57::GetPos(int i) double TMHZ_EN57::GetPos(int i)
{ {
static double const table[11] = { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 }; return pos_table[i];
return table[i];
} }
double TMHZ_EN57::GetCP() double TMHZ_EN57::GetCP()
@@ -2585,9 +2593,7 @@ double TM394::GetCP()
double TM394::GetPos(int i) double TM394::GetPos(int i)
{ {
static double const table[11] = { -1, 5, -1, 0, 1, 2, 4, 5, 0, 0, 0 }; return pos_table[i];
return table[i];
} }
//---H14K1-- Knorr //---H14K1-- Knorr
@@ -2595,8 +2601,8 @@ double TM394::GetPos(int i)
double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep) double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{ {
static int const LBDelay = 100; // szybkosc + zasilanie sterujacego static int const LBDelay = 100; // szybkosc + zasilanie sterujacego
static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2] = // static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2] =
{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) }; //{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) };
static double const NomPress = 5.0; static double const NomPress = 5.0;
double LimPP; double LimPP;
@@ -2653,9 +2659,7 @@ double TH14K1::GetCP()
double TH14K1::GetPos(int i) double TH14K1::GetPos(int i)
{ {
static double const table[11] = { -1, 4, -1, 0, 1, 2, 3, 4, 0, 0, 0 }; return pos_table[i];
return table[i];
} }
//---St113-- Knorr EP //---St113-- Knorr EP
@@ -2663,9 +2667,6 @@ double TH14K1::GetPos(int i)
double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep) double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
{ {
static int const LBDelay = 100; // szybkosc + zasilanie sterujacego static int const LBDelay = 100; // szybkosc + zasilanie sterujacego
static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2] =
{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) };
static double const BEP_K[/*?*/ /*-1..5*/ (5) - (-1) + 1] = { 0, -1, 1, 0, 0, 0, 0 };
static double const NomPress = 5.0; static double const NomPress = 5.0;
double LimPP; double LimPP;
@@ -2715,9 +2716,7 @@ double TSt113::GetCP()
double TSt113::GetPos(int i) double TSt113::GetPos(int i)
{ {
static double const table[11] = { -1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1 }; return pos_table[i];
return table[i];
} }
void TSt113::Init(double Press) void TSt113::Init(double Press)
@@ -2890,9 +2889,7 @@ double TFVel6::GetCP()
double TFVel6::GetPos(int i) double TFVel6::GetPos(int i)
{ {
static double const table[11] = { -1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1 }; return pos_table[i];
return table[i];
} }
double TFVel6::GetSound(int i) double TFVel6::GetSound(int i)

View File

@@ -129,10 +129,10 @@ 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 zero_based_BPT[ /*?*//*-2..6*/ (6) - (-2) + 1][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[ /*?*//*-2..6*/ (6) - (-2) + 1][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 zero_based_BPT_394[ /*?*//*-1..5*/ (5) - (-1) + 1][2] = { (13 , 10.0) , (5 , 5.0) , (0 , -1) , (5 , -1) , (5 , 0.0) , (5 , 0.0) , (18 , 0.0) }; static double BPT_394[ /*?*//*-1..5*/ (5) - (-1) + 1][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));
// BPT: array[-2..6] of array [0..1] of real= ((0, 0),(0, 0),(0, 0),(0, 0),(0, 0),(0, 0),(0, 0),(0, 0),(0, 0)); // BPT: array[-2..6] of array [0..1] of real= ((0, 0),(0, 0),(0, 0),(0, 0),(0, 0),(0, 0),(0, 0),(0, 0),(0, 0));
static int const i_bcpno = 6; static int const i_bcpno = 6;
@@ -559,6 +559,8 @@ Knorr/West EP -
double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double RedAdj; //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;
// const double pos_table[11] = { -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:
@@ -580,6 +582,8 @@ Knorr/West EP -
double CP; double TP; double RP; //zbiornik steruj¹cy, czasowy, redukcyjny double CP; double TP; double RP; //zbiornik steruj¹cy, czasowy, redukcyjny
double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem)
bool Fala; bool Fala;
// const double pos_table[11] = { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 };
static double pos_table[11]; //= { 0, 12, 1, 2, 2, 4, 11, 12, 2, 2, 2 };
double LPP_RP(double pos); double LPP_RP(double pos);
bool EQ(double pos, double i_pos); bool EQ(double pos, double i_pos);
@@ -634,6 +638,8 @@ Knorr/West EP -
private: private:
double CP; //zbiornik steruj¹cy, czasowy, redukcyjny double CP; //zbiornik steruj¹cy, czasowy, redukcyjny
double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem)
// 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*/;
@@ -650,6 +656,10 @@ Knorr/West EP -
class TH14K1 : public TDriverHandle class TH14K1 : public TDriverHandle
{ {
private:
double static BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2];
// double const 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; //zbiornik steruj¹cy, czasowy, redukcyjny
double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double RedAdj; //dostosowanie reduktora cisnienia (krecenie kapturkiem)
@@ -671,6 +681,10 @@ Knorr/West EP -
{ {
private: private:
double EPS; double EPS;
double static BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2];
double static BEP_K[/*?*/ /*-1..5*/ (5) - (-1) + 1];
// 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*/;
@@ -742,6 +756,8 @@ Knorr/West EP -
{ {
private: private:
double EPS; double EPS;
// double const 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*/;

View File

@@ -14,6 +14,10 @@ Copyright (C) 2007-2014 Maciej Cierniak
#include "mctools.h" #include "mctools.h"
#include <cmath> #include <cmath>
#include <fstream> #include <fstream>
#include <cctype>
#include <ostream>
#include <iomanip>
#include <algorithm>
using namespace std; using namespace std;
/*================================================*/ /*================================================*/
@@ -139,7 +143,7 @@ std::string ReadWord(std::ifstream& infile)
return s; return s;
} }
std::string Cut_Space(std::string s, int Just) std::string TrimSpace(std::string s, int Just)
{ {
int ii; int ii;
@@ -148,26 +152,45 @@ std::string Cut_Space(std::string s, int Just)
case CutLeft: case CutLeft:
{ {
ii = 0; ii = 0;
while ((ii < s.length()) && (s[ii + 1] == _SPACE)) while ((ii < s.length()) && (s[ii + 1] == (char)" "))
++ii; ++ii;
s = s.substr(ii + 1, s.length() - ii); s = s.substr(ii + 1, s.length() - ii);
} }
case CutRight: case CutRight:
{ {
ii = s.length(); ii = s.length();
while ((ii > 0) && (s[ii] == _SPACE)) while ((ii > 0) && (s[ii] == (char)" "))
--ii; --ii;
s = s.substr(0, ii); s = s.substr(0, ii);
} }
case CutBoth: case CutBoth:
{ {
s = Cut_Space(s, CutLeft); s = TrimSpace(s, CutLeft);
s = Cut_Space(s, CutRight); s = TrimSpace(s, CutRight);
} }
} }
return s; return s;
} }
/*Cut_Space*/
char* TrimAndReduceSpaces(const char* s)
{ // redukuje spacje pomiedzy znakami do jednej
char* tmp;
if (s)
{
strcpy(tmp, s);
char* from = tmp + strspn(tmp, " ");
char* to = tmp;
do if ((*to = *from++) == ' ')
from += strspn(from, " ");
while (*to++);
while (*--to == ' ')
*to = '\0';
}
return tmp;
}
std::string ExtractKeyWord(std::string InS, std::string KeyWord) std::string ExtractKeyWord(std::string InS, std::string KeyWord)
{ {
@@ -186,13 +209,13 @@ std::string ExtractKeyWord(std::string InS, std::string KeyWord)
return s; return s;
} }
std::string DUE(std::string s) /*Delete Until Equal sign*/ std::string DUE(std::string s) /*Delete Before Equal sign*/
{ {
//DUE = Copy(s, Pos("=", s) + 1, length(s)); //DUE = Copy(s, Pos("=", s) + 1, length(s));
return s.substr(s.find("=") + 1, s.length()); return s.substr(s.find("=") + 1, s.length());
} }
std::string DWE(std::string s) /*Delete While Equal sign*/ std::string DWE(std::string s) /*Delete After Equal sign*/
{ {
size_t ep = s.find("="); size_t ep = s.find("=");
if (ep != string::npos) if (ep != string::npos)
@@ -237,6 +260,141 @@ std::string Tab2Sp(std::string s) /*Tab to Space sign*/
//return s2; //return s2;
} }
std::string ExchangeCharInString(string s, const char &aim, const char &target)
{
char *tmp = new char[s.length()];
for (int b = 0; b < s.length(); ++b)
{
if (s[b] == aim)
if (target == (char)"")
b++;
else
tmp[b] = target;
else
tmp[b] = s[b];
}
return string(tmp);
}
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems)
{ // dzieli tekst na wektor tekstow
std::stringstream ss(s);
std::string item;
while (std::getline(ss, item, delim))
{
elems.push_back(item);
}
return elems;
}
std::vector<std::string> Split(const std::string &s, char delim)
{ // dzieli tekst na wektor tekstow
std::vector<std::string> elems;
Split(s, delim, elems);
return elems;
}
std::string to_string(int _Val)
{
std::ostringstream o;
o << _Val;
return o.str();
};
std::string to_string(unsigned int _Val)
{
std::ostringstream o;
o << _Val;
return o.str();
};
std::string to_string(double _Val)
{
std::ostringstream o;
o << _Val;
return o.str();
};
std::string to_string(int _Val, int precision)
{
std::ostringstream o;
o << std::fixed << std::setprecision(precision);
o << _Val;
return o.str();
};
std::string to_string(double _Val, int precision)
{
std::ostringstream o;
o << std::fixed << std::setprecision(precision);
o << _Val;
return o.str();
};
std::string to_string(int _Val, int precision, int width)
{
std::ostringstream o;
o.width(width);
o << std::fixed << std::setprecision(precision);
o << _Val;
return o.str();
};
std::string to_string(double _Val, int precision, int width)
{
std::ostringstream o;
o.width(width);
o << std::fixed << std::setprecision(precision);
o << _Val;
return o.str();
};
std::string to_hex_str(double _Val, int precision, int width)
{
std::ostringstream o;
if (width)
o.width(width);
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)
{
// this function was developed iteratively on Codereview.stackexchange
// with the assistance of @Corbin
std::size_t len = str.size();
while (std::isspace(str[len - 1]))
len--;
if (len == 0)
return DefaultValue;
errno = 0;
char *s = new char[len + 1];
std::strncpy(s, str.c_str(), len);
char *p;
int result = strtol(s, &p, 0);
if ((*p != '\0') || (errno != 0))
{
return DefaultValue;
}
delete s;
return result;
}
std::string ToLower(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), ::tolower);
return text;
}
std::string ToUpper(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), ::toupper);
return text;
}
void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL,
double &phi, double &Xout, double &Yout) double &phi, double &Xout, double &Yout)
/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/ /*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/

View File

@@ -19,6 +19,8 @@ http://mozilla.org/MPL/2.0/.
#include <fstream> #include <fstream>
#include <time.h> #include <time.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <vector>
#include <sstream>
using namespace std; using namespace std;
@@ -35,18 +37,18 @@ static char _EOL[2] = { (char)13, (char)10 };
//static char const _SPACE = " "; //static char const _SPACE = " ";
static char _Spacesigns[4] = { (char)" ",(char)9, (char)13, (char)10}; static char _Spacesigns[4] = { (char)" ",(char)9, (char)13, (char)10};
static string _spacesigns = " " + (char)9 + (char)13 + (char)10; static string _spacesigns = " " + (char)9 + (char)13 + (char)10;
static int const CutLeft = -1; static int const CutLeft = -1;
static int const CutRight = 1; static int const CutRight = 1;
static int const CutBoth = 0; /*Cut_Space*/ static int const CutBoth = 0; /*Cut_Space*/
static double const pi = 3.141592653589793; static double const pi = 3.141592653589793;
int ConversionError = 0; int ConversionError = 0;
int LineCount = 0; int LineCount = 0;
bool DebugModeFlag = false; bool DebugModeFlag = false;
bool FreeFlyModeFlag = false; bool FreeFlyModeFlag = false;
typedef unsigned long/*?*//*set of: char */ TableChar; /*MCTUTIL*/ typedef unsigned long/*?*//*set of: char */ TableChar; /*MCTUTIL*/
/*konwersje*/ /*konwersje*/
@@ -70,12 +72,17 @@ inline int Random()
return rand(); return rand();
} }
inline float random(float a, float b) inline double Random(double a, double b)
{ {
srand(time(NULL)); srand(time(NULL));
return a + rand() / (float)RAND_MAX * (b - a); return a + rand() / (float)RAND_MAX * (b - a);
} }
inline double Random(double b)
{
return Random(0.0, b);
}
inline double BorlandTime() inline double BorlandTime()
{ {
std::tm epoch; std::tm epoch;
@@ -91,9 +98,9 @@ inline double BorlandTime()
} }
/*funkcje logiczne*/ /*funkcje logiczne*/
bool TestFlag(int Flag, int Value); extern bool TestFlag(int Flag, int Value);
bool SetFlag( int & Flag, int Value); extern bool SetFlag( int & Flag, int Value);
bool iSetFlag( int & Flag, int Value); extern bool iSetFlag( int & Flag, int Value);
bool FuzzyLogic(double Test, double Threshold, double Probability); bool FuzzyLogic(double Test, double Threshold, double Probability);
/*jesli Test>Threshold to losowanie*/ /*jesli Test>Threshold to losowanie*/
@@ -103,19 +110,41 @@ bool FuzzyLogicAI(double Test, double Threshold, double Probability);
/*operacje na stringach*/ /*operacje na stringach*/
std::string ReadWord( std::ifstream& infile); /*czyta slowo z wiersza pliku tekstowego*/ std::string ReadWord( std::ifstream& infile); /*czyta slowo z wiersza pliku tekstowego*/
//std::string Ups(std::string s); //std::string Ups(std::string s);
std::string Cut_Space(std::string s, int Just); std::string TrimSpace(std::string s, int Just = CutBoth);
char* TrimAndReduceSpaces(const char* s);
std::string ExtractKeyWord(std::string InS, std::string KeyWord); /*wyciaga slowo kluczowe i lancuch do pierwszej spacji*/ std::string ExtractKeyWord(std::string InS, std::string KeyWord); /*wyciaga slowo kluczowe i lancuch do pierwszej spacji*/
std::string DUE(std::string s); /*Delete Until Equal sign*/ 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 s); /*Low dash to Space sign*/ std::string Ld2Sp(std::string s); /*Low dash to Space sign*/
std::string Tab2Sp(std::string s); /*Tab to Space sign*/ std::string Tab2Sp(std::string s); /*Tab to Space sign*/
std::string ExchangeCharInString(string 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::string to_string(int _Val);
std::string to_string(unsigned int _Val);
std::string to_string(int _Val, int precision);
std::string to_string(int _Val, int precision, int width);
std::string to_string(double _Val);
std::string to_string(double _Val, int precision);
std::string to_string(double _Val, int precision, int width);
std::string to_hex_str(double _Val, int precision = 0, int width = 0);
inline std::string to_string(bool _Val)
{
to_string((int)_Val);
}
int stol_def(const std::string & str, const int & DefaultValue);
std::string ToLower(std::string text);
std::string ToUpper(std::string text);
/*procedury, zmienne i funkcje graficzne*/ /*procedury, zmienne i funkcje graficzne*/
void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, double & phi, double & Xout, double & Yout); void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, double & phi, double & Xout, double & Yout);
/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/ /*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/
void ComputeALine(double X0, double Y0, double Xn, double Yn, double L, double R, double & Xout, double & Yout); void ComputeALine(double X0, double Y0, double Xn, double Yn, double L, double R, double & Xout, double & Yout);
inline bool fileExist(const std::string &name) inline bool fileExists(const std::string &name)
{ {
struct stat buffer; struct stat buffer;
return (stat(name.c_str(), &buffer) == 0); return (stat(name.c_str(), &buffer) == 0);

View File

@@ -40,6 +40,12 @@ 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,
bool freqmod, double rmin)
{
Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
}
TRealSound::~TRealSound() TRealSound::~TRealSound()
{ {
// if (this) if (pSound) pSound->Stop(); // if (this) if (pSound) pSound->Stop();
@@ -49,7 +55,7 @@ void TRealSound::Free()
{ {
} }
void TRealSound::Init(char *SoundName, double DistanceAttenuation, double X, double Y, double Z, void TRealSound::Init(const char *SoundName, double DistanceAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod, double rmin) bool Dynamic, bool freqmod, double rmin)
{ {
// Nazwa=SoundName; //to tak raczej nie zadziała, (SoundName) jest tymczasowe // Nazwa=SoundName; //to tak raczej nie zadziała, (SoundName) jest tymczasowe
@@ -247,10 +253,17 @@ void TRealSound::ResetPosition()
pSound->SetCurrentPosition(0); pSound->SetCurrentPosition(0);
} }
void TTextSound::Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z, TTextSound::TTextSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod, double rmin)
: TRealSound(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin)
{
Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
}
void TTextSound::Init(const char *SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod, double rmin) bool Dynamic, bool freqmod, double rmin)
{ // dodatkowo doczytuje plik tekstowy { // dodatkowo doczytuje plik tekstowy
TRealSound::Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin); //TRealSound::Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
fTime = GetWaveTime(); fTime = GetWaveTime();
AnsiString txt = AnsiString(SoundName); AnsiString txt = AnsiString(SoundName);
txt.Delete(txt.Length() - 3, 4); // obcięcie rozszerzenia txt.Delete(txt.Length() - 3, 4); // obcięcie rozszerzenia

View File

@@ -33,10 +33,12 @@ class TRealSound
double FM; // mnoznik czestotliwosci double FM; // mnoznik czestotliwosci
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,
bool freqmod = false, double rmin = 0.0);
~TRealSound(); ~TRealSound();
void Free(); void Free();
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, void Init(const char *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);
double ListenerDistance(vector3 ListenerPosition); double ListenerDistance(vector3 ListenerPosition);
void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition); void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition);
@@ -55,8 +57,10 @@ class TTextSound : public TRealSound
AnsiString asText; AnsiString asText;
float fTime; // czas trwania float fTime; // czas trwania
public: public:
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic, TTextSound(const char *SoundName, double SoundAttenuation, double X, double Y, double Z,
bool freqmod = false, double rmin = 0.0); bool Dynamic, bool freqmod = false, double rmin = 0.0);
void Init(const char *SoundName, double SoundAttenuation, double X, double Y, double Z,
bool Dynamic, bool freqmod = false, double rmin = 0.0);
void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition); void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition);
}; };

View File

@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
#include "Usefull.h" #include "Usefull.h"
#include "Globals.h" #include "Globals.h"
#include "Track.h" #include "Track.h"
#include <mctools.h>
//#define Precision 10000 //#define Precision 10000

View File

@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "Sound.h" #include "Sound.h"
#include "Usefull.h" #include "Usefull.h"
#include "Globals.h" #include "Globals.h"
#include <mctools.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) \
{ \ { \
@@ -33,7 +34,7 @@ LPDIRECTSOUNDNOTIFY TSoundsManager::pDSNotify;
int TSoundsManager::Count = 0; int TSoundsManager::Count = 0;
TSoundContainer *TSoundsManager::First = NULL; TSoundContainer *TSoundsManager::First = NULL;
TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, char *Directory, char *strFileName, TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const char *strFileName,
int NConcurrent) int NConcurrent)
{ // wczytanie pliku dŸwiêkowego { // wczytanie pliku dŸwiêkowego
int hr = 111; int hr = 111;
@@ -54,7 +55,7 @@ TSoundContainer::TSoundContainer(LPDIRECTSOUND pDS, char *Directory, char *strFi
// Load the wave file // Load the wave file
if (FAILED(pWaveSoundRead->Open(Name))) if (FAILED(pWaveSoundRead->Open(Name)))
if (FAILED(pWaveSoundRead->Open(strFileName))) if (FAILED(pWaveSoundRead->Open(strdup(strFileName))))
{ {
// SetFileUI( hDlg, TEXT("Bad wave file.") ); // SetFileUI( hDlg, TEXT("Bad wave file.") );
return; return;
@@ -182,7 +183,7 @@ void TSoundsManager::Free()
SAFE_RELEASE(pDS); SAFE_RELEASE(pDS);
}; };
TSoundContainer * TSoundsManager::LoadFromFile(char *Dir, char *Name, int Concurrent) TSoundContainer * TSoundsManager::LoadFromFile(const char *Dir, const char *Name, int Concurrent)
{ {
TSoundContainer *Tmp = First; TSoundContainer *Tmp = First;
First = new TSoundContainer(pDS, Dir, Name, Concurrent); First = new TSoundContainer(pDS, Dir, Name, Concurrent);
@@ -203,7 +204,7 @@ void TSoundsManager::LoadSounds(char *Directory)
FindClose(handle); FindClose(handle);
}; };
LPDIRECTSOUNDBUFFER TSoundsManager::GetFromName(char *Name, bool Dynamic, float *fSamplingRate) LPDIRECTSOUNDBUFFER TSoundsManager::GetFromName(const char *Name, bool Dynamic, float *fSamplingRate)
{ // wyszukanie dŸwiêku w pamiêci albo wczytanie z pliku { // wyszukanie dŸwiêku w pamiêci albo wczytanie z pliku
AnsiString file; AnsiString file;
if (Dynamic) if (Dynamic)

View File

@@ -39,7 +39,7 @@ class TSoundContainer
TSoundContainer *Next; TSoundContainer *Next;
std::stack<LPDIRECTSOUNDBUFFER> DSBuffers; std::stack<LPDIRECTSOUNDBUFFER> DSBuffers;
LPDIRECTSOUNDBUFFER GetUnique(LPDIRECTSOUND pDS); LPDIRECTSOUNDBUFFER GetUnique(LPDIRECTSOUND pDS);
TSoundContainer(LPDIRECTSOUND pDS, char *Directory, char *strFileName, int NConcurrent); TSoundContainer(LPDIRECTSOUND pDS, const char *Directory, const char *strFileName, int NConcurrent);
~TSoundContainer(); ~TSoundContainer();
}; };
@@ -51,7 +51,7 @@ class TSoundsManager
// static char Directory[80]; // static char Directory[80];
static int Count; static int Count;
static TSoundContainer *First; static TSoundContainer *First;
static TSoundContainer * LoadFromFile(char *Dir, char *Name, int Concurrent); static TSoundContainer * LoadFromFile(const char *Dir, const char *Name, int Concurrent);
public: public:
// TSoundsManager(HWND hWnd); // TSoundsManager(HWND hWnd);
@@ -61,7 +61,7 @@ class TSoundsManager
static void Free(); static void Free();
static void Init(char *Name, int Concurrent); static void Init(char *Name, int Concurrent);
static void LoadSounds(char *Directory); static void LoadSounds(char *Directory);
static LPDIRECTSOUNDBUFFER GetFromName(char *Name, bool Dynamic, float *fSamplingRate = NULL); static LPDIRECTSOUNDBUFFER GetFromName(const char *Name, bool Dynamic, float *fSamplingRate = NULL);
static void RestoreAll(); static void RestoreAll();
}; };

View File

@@ -111,11 +111,11 @@ bool TTractionPowerSource::Update(double dt)
{ {
SlowFuse = true; SlowFuse = true;
ErrorLog("Power overload: \"" + gMyNode->asName + "\" disabled for " + ErrorLog("Power overload: \"" + gMyNode->asName + "\" disabled for " +
AnsiString(SlowFuseTimeOut) + "s"); to_string(SlowFuseTimeOut) + "s");
} }
else else
ErrorLog("Power overload: \"" + gMyNode->asName + "\" disabled for " + ErrorLog("Power overload: \"" + gMyNode->asName + "\" disabled for " +
AnsiString(FastFuseTimeOut) + "s"); to_string(FastFuseTimeOut) + "s");
FuseTimer = 0; FuseTimer = 0;
} }
if (FastFuse || SlowFuse) if (FastFuse || SlowFuse)

View File

@@ -167,7 +167,7 @@ std::string cParser::readToken(bool ToLower, const char *Break)
// if (trtest2.find("tr/")!=0) // if (trtest2.find("tr/")!=0)
mIncludeParser = new cParser(includefile, buffer_FILE, mPath, LoadTraction); mIncludeParser = new cParser(includefile, buffer_FILE, mPath, LoadTraction);
if (mIncludeParser->mSize <= 0) if (mIncludeParser->mSize <= 0)
ErrorLog("Missed include: " + AnsiString(includefile.c_str())); ErrorLog("Missed include: " + includefile);
} }
else else
while (token.compare("end") != 0) while (token.compare("end") != 0)

View File

@@ -25,11 +25,9 @@ void TSky::Init()
{ {
WriteLog(Global::asSky.c_str()); WriteLog(Global::asSky.c_str());
WriteLog("init"); WriteLog("init");
AnsiString asModel; if ((Global::asSky != "1") && (Global::asSky != "0"))
asModel = Global::asSky;
if ((asModel != "1") && (asModel != "0"))
// { // {
mdCloud = TModelsManager::GetModel(asModel.c_str()); mdCloud = TModelsManager::GetModel(Global::asSky.c_str());
// } // }
}; };