Skip to content

Commit

Permalink
- Added the time stamps to omedit commands log file.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10308 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Nov 7, 2011
1 parent 47b60a1 commit e10a1de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions OMEdit/OMEditGUI/OMCProxy.cpp
Expand Up @@ -163,22 +163,27 @@ QString OMCProxy::getExpression()
}

//! Writes the commands to the omeditcommands.log file.
void OMCProxy::writeCommandLog(QString expression)
//! @param expression the command to write
//! @param commandTime the command start time
void OMCProxy::writeCommandLog(QString expression, QTime* commandTime)
{
if (mCommandsLogFileTextStream.device())
{
mCommandsLogFileTextStream << expression;
mCommandsLogFileTextStream << expression << " " << commandTime->currentTime().toString(tr("hh:mm:ss:zzz"));
mCommandsLogFileTextStream << "\n";
mCommandsLogFileTextStream.flush();
}
}

//! Writes the command response to the omeditcommands.log file.
void OMCProxy::writeCommandResponseLog()
//! @param commandTime the command end time
void OMCProxy::writeCommandResponseLog(QTime* commandTime)
{
if (mCommandsLogFileTextStream.device())
{
mCommandsLogFileTextStream << getResult();
mCommandsLogFileTextStream << getResult() << " " << commandTime->currentTime().toString(tr("hh:mm:ss:zzz"));
mCommandsLogFileTextStream << "\n";
mCommandsLogFileTextStream << "Elapsed Time :: " << QString::number((double)commandTime->elapsed() / 1000).append(" secs");
mCommandsLogFileTextStream << "\n\n";
mCommandsLogFileTextStream.flush();
}
Expand Down Expand Up @@ -335,7 +340,9 @@ void OMCProxy::sendCommand(const QString expression)
return;
}
// write command to the commands log.
writeCommandLog(expression);
QTime commandTime;
commandTime.start();
writeCommandLog(expression, &commandTime);
// Send command to server
try
{
Expand All @@ -347,13 +354,13 @@ void OMCProxy::sendCommand(const QString expression)
while (future.isRunning())
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
future.waitForFinished();
writeCommandResponseLog();
writeCommandResponseLog(&commandTime);
logOMCMessages(expression);
}
else
{
mResult = QString::fromLocal8Bit(mOMC->sendExpression(getExpression().toLocal8Bit()));
writeCommandResponseLog();
writeCommandResponseLog(&commandTime);
logOMCMessages(expression);
}
}
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/OMCProxy.h
Expand Up @@ -74,8 +74,8 @@ class OMCProxy : public QObject
QString getCommandFromMap(QString expression);
void setExpression(QString expression);
QString getExpression();
void writeCommandLog(QString expression);
void writeCommandResponseLog();
void writeCommandLog(QString expression, QTime* commandTime);
void writeCommandResponseLog(QTime* commandTime);

MainWindow *mpParentMainWindow;
enum mModelicaAnnotationVersion {ANNOTATION_VERSION2X, ANNOTATION_VERSION3X};
Expand Down

0 comments on commit e10a1de

Please sign in to comment.