Skip to content

Commit

Permalink
Clear the generated files before each new tlm co-simulation.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Sep 20, 2016
1 parent 37a0f72 commit b2c63fa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions OMEdit/OMEditGUI/TLM/TLMCoSimulationThread.cpp
Expand Up @@ -46,10 +46,37 @@ TLMCoSimulationThread::TLMCoSimulationThread(TLMCoSimulationOutputWidget *pTLMCo

void TLMCoSimulationThread::run()
{
removeGeneratedFiles();
runManager();
exec();
}

/*!
* \brief TLMCoSimulationThread::removeGeneratedFiles
* Removes the files that TLMPlugin generates during co-simulation.
*/
void TLMCoSimulationThread::removeGeneratedFiles()
{
TLMCoSimulationOptions tlmCoSimulationOptions = mpTLMCoSimulationOutputWidget->getTLMCoSimulationOptions();
QFileInfo fileInfo(tlmCoSimulationOptions.getFileName());
// remove result file
if (QFile::exists(QString("%1/%2.csv").arg(fileInfo.absoluteDir().absolutePath()).arg(fileInfo.completeBaseName()))) {
QFile::remove(QString("%1/%2.csv").arg(fileInfo.absoluteDir().absolutePath()).arg(fileInfo.completeBaseName()));
}
// remove run file
if (QFile::exists(QString("%1/%2.run").arg(fileInfo.absoluteDir().absolutePath()).arg(fileInfo.completeBaseName()))) {
QFile::remove(QString("%1/%2.run").arg(fileInfo.absoluteDir().absolutePath()).arg(fileInfo.completeBaseName()));
}
// remove TLM log file
if (QFile::exists(QString("%1/TLMlogfile.log").arg(fileInfo.absoluteDir().absolutePath()))) {
QFile::remove(QString("%1/TLMlogfile.log").arg(fileInfo.absoluteDir().absolutePath()));
}
// remove monitor log file
if (QFile::exists(QString("%1/monitor.log").arg(fileInfo.absoluteDir().absolutePath()))) {
QFile::remove(QString("%1/monitor.log").arg(fileInfo.absoluteDir().absolutePath()));
}
}

void TLMCoSimulationThread::runManager()
{
mpManagerProcess = new QProcess;
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/TLM/TLMCoSimulationThread.h
Expand Up @@ -62,6 +62,7 @@ class TLMCoSimulationThread : public QThread
QFile mProgressFile;
QTimer *mpProgressFileTimer;

void removeGeneratedFiles();
void runManager();
void runMonitor();
private slots:
Expand Down

0 comments on commit b2c63fa

Please sign in to comment.