Commit 12e8f67f authored by Emmanuel Promayon's avatar Emmanuel Promayon

FIXED time computation in xsl presentation of XML asm output log

parent c75e7eea
......@@ -32,8 +32,9 @@
// -- Qt stuff
#include <QPushButton>
#include <QMainWindow>
#include <QMetaProperty>
#include <Log.h>
using namespace camitk;
......@@ -43,7 +44,7 @@ ActionState::ActionState(QState* parent, QString name, QString description, QTex
this->name = name;
this->description = description;
this->logStream = logStream;
this->myAction = NULL;
this->myAction = nullptr;
this->myStateWidget = new ActionStateWidget(this);
}
......@@ -76,10 +77,10 @@ ActionStateWidget* ActionState::getWidget() {
}
// ------------- addActionTransition -----------------
ActionTransition* ActionState::addActionTransition(QString buttonText, QAbstractState* nextState, bool applyAction, QVector<Action::ApplyStatus> disableConditions) {
ActionTransition* ActionState::addActionTransition(QString transitionName, QAbstractState* nextState, bool applyAction, QVector<Action::ApplyStatus> disableConditions) {
QPushButton* button = myStateWidget->addTransitionButton(buttonText);
ActionTransition* transition = new ActionTransition(button, SIGNAL(clicked()), this, buttonText, applyAction, logStream);
QPushButton* button = myStateWidget->addTransitionButton(transitionName);
ActionTransition* transition = new ActionTransition(button, SIGNAL(clicked()), this, applyAction, logStream);
transition->setTargetState(nextState);
for (QVector<Action::ApplyStatus>::const_iterator it = disableConditions.begin();
......@@ -105,6 +106,10 @@ Action::ApplyStatus ActionState::applyAction() {
Action::ApplyStatus status(Action::TRIGGERED);
if (myAction != NULL) {
if (logStream != NULL) {
(*logStream) << "\t\t<applyAction>" << endl;
}
// apply the action
status = myAction->applyInPipeline();
......@@ -182,19 +187,23 @@ void ActionState::setPreviousActionStatus(camitk::Action::ApplyStatus status) {
}
}
// ------------- autoNextEntry -----------------
void ActionState::autoNextEntry() {
onEntry(new QEvent(QEvent::ApplicationStateChange));
}
// ------------- onEntry -----------------
void ActionState::onEntry ( QEvent* event ) {
if (logStream == NULL) {
return;
}
//-- log the start
startTime = new QTime();
startTime->start();
if (logStream != NULL) {
//-- log the start
startTime = new QTime();
startTime->start();
(*logStream) << "\t<state>" << endl;
(*logStream) << "\t\t<name>" << this->name << "</name>" << endl;
(*logStream) << "\t\t<startTime>" << startTime->toString("hh:mm:ss:zzz") << "</startTime>" << endl;
(*logStream) << "\t<state>" << endl;
(*logStream) << "\t\t<name>" << this->name << "</name>" << endl;
(*logStream) << "\t\t<startTime>" << startTime->toString("hh:mm:ss:zzz") << "</startTime>" << endl;
}
//-- set the parameters default values
if (myAction != NULL) {
......@@ -203,7 +212,6 @@ void ActionState::onEntry ( QEvent* event ) {
}
// log the parameters
(*logStream) << "\t\t<applyAction>" << endl;
(*logStream) << "\t\t\t<name>" << myAction->getName() << "</name>" << endl;
// Properties
int nbStaticProps = myAction->metaObject()->propertyCount();
......@@ -279,24 +287,20 @@ void ActionState::onEntry ( QEvent* event ) {
}
}
// ------------- autoNextExit -----------------
void ActionState::autoNextExit() {
onExit(new QEvent(QEvent::ApplicationStateChange));
}
// -------------onExit -----------------
void ActionState::onExit(QEvent* event) {
if (logStream == NULL) {
return;
if (logStream != NULL) {
QTime endTime = QTime::currentTime();
(*logStream) << "\t\t<!-- exiting " << this->name << " -->" << endl;
(*logStream) << "\t\t<endTime>" << endTime.toString("hh:mm:ss:zzz") << "</endTime>" << endl;
(*logStream) << "\t\t<timeEnlapsed unit='ms'>" << (startTime->elapsed()) << "</timeEnlapsed>" << endl;
(*logStream) << "\t</state>" << endl;
}
QTime endTime = QTime::currentTime();
(*logStream) << "\t\t<endTime>" << endTime.toString("hh:mm:ss:zzz") << "</endTime>" << endl;
(*logStream) << "\t\t<timeEnlapsed unit='ms'>" << (startTime->elapsed()) << "</timeEnlapsed>" << endl;
(*logStream) << "\t</state>" << endl;
}
// ------------- trigger -----------------
void ActionState::trigger() {
onEntry(nullptr);
applyAction();
onExit(nullptr);
}
// ------------- getInputComponents -----------------
......
......@@ -137,34 +137,37 @@ td.simple {
</style>
</head>
<body>
<div class="mainFrame">
<xsl:variable name="duration" select="/log:application/log:timeEnlapsed"/>
<!--
int milisec = (startTime->elapsed());
int mili = milisec % 1000;
int seconds = ((milisec % (3600000)) % (60000)) / 1000;
int minutes = (milisec % (3600000)) / (60000);
int hours = milisec / (3600000);
-->
<div class="mainFrame">
<div class="stateFrame">
<h1><xsl:value-of select="/log:application/log:name"/></h1>
<h2>Log file</h2>
<h3> Runned the <xsl:value-of select="/log:application/log:startDate"/></h3>
<h3> Start: <xsl:value-of select="/log:application/log:startTime"/> Stop: <xsl:value-of select="/log:application/log:endTime"/> </h3>
<h2> duration: <xsl:value-of select="floor($duration div 3600000)"/> h <xsl:value-of select="floor(($duration mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($duration mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($duration mod 1000)"/> ms</h2>
<h3>Input xml file name: <xsl:value-of select="/log:application/log:inputXmlFile"/></h3>
<h2> duration: <xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="/log:application/log:timeEnlapsed"/>
</xsl:call-template>
</h2>
<h3>Input xml file name: <xsl:value-of select="/log:application/log:inputXmlFile"/></h3>
</div>
<div class="stateFrame">
<xsl:variable name="timeStateTotal" select="sum(log:application/log:state/log:timeEnlapsed)"/>
<xsl:variable name="timeActionTotal" select="sum(log:application/log:transition/log:timeEnlapsed)"/>
<h3>Total time within states:
<span class="stateColor"><xsl:value-of select="floor($timeStateTotal div 3600000)"/> h <xsl:value-of select="floor(($timeStateTotal mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($timeStateTotal mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($timeStateTotal mod 1000)"/> (i.e. <xsl:value-of select="$timeStateTotal"/> ms)</span>
<h3>Total time within states (action triggering):
<span class="stateColor">
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="sum(log:application/log:state/log:timeEnlapsed)"/>
</xsl:call-template>
(i.e., <xsl:value-of select="sum(log:application/log:state/log:timeEnlapsed)"/> ms)</span>
</h3>
<h3>Total time on action application:
<span class="actionColor"><xsl:value-of select="floor($timeActionTotal div 3600000)"/> h <xsl:value-of select="floor(($timeActionTotal mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($timeActionTotal mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($timeActionTotal mod 1000)"/> (i.e. <xsl:value-of select="$timeActionTotal"/> ms)</span>
<span class="actionColor">
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="sum(log:application/log:transition/log:timeEnlapsed)"/>
</xsl:call-template>
(i.e., <xsl:value-of select="sum(log:application/log:transition/log:timeEnlapsed)"/> ms)</span>
</h3>
<table>
<tr>
......@@ -191,9 +194,10 @@ td.simple {
</div></span>
</td>
<td>
<xsl:variable name="stateD" select="log:timeEnlapsed"/>
<span class="stateColor">
<xsl:value-of select="floor(($stateD mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($stateD mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($stateD mod 1000)"/> ms
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="log:timeEnlapsed"/>
</xsl:call-template>
</span>
</td>
</tr>
......@@ -225,34 +229,36 @@ td.simple {
</table>
</td>
<td>
<xsl:variable name="transD" select="../log:timeEnlapsed"/>
<span class="actionColor">
<xsl:value-of select="floor(($transD mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($transD mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($transD mod 1000)"/> ms
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="../log:timeEnlapsed"/>
</xsl:call-template>
</span>
</td>
</tr>
</xsl:template>
<xsl:template match="log:closing">
<xsl:template match="log:closing">
<tr>
<td colspan="2">
<span class="actionColor"><span class="enhanced">Closing:</span></span>
<span class="actionColor"><span class="enhanced">Closing:</span></span>
</td>
</tr>
<tr>
<td>
<table class="simple">
<xsl:apply-templates select="log:component"/>
</table>
</td>
<td>
<xsl:variable name="transD" select="../log:timeEnlapsed"/>
<tr>
<td>
<table class="simple">
<xsl:apply-templates select="log:component"/>
</table>
</td>
<td>
<span class="actionColor">
<xsl:value-of select="floor(($transD mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($transD mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($transD mod 1000)"/> ms
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="../log:timeEnlapsed"/>
</xsl:call-template>
</span>
</td>
</tr>
</xsl:template>
</td>
</tr>
</xsl:template>
<xsl:template match="log:parameters">
<table class="simple">
......@@ -316,4 +322,22 @@ td.simple {
</td>
</tr>
</xsl:template>
<xsl:template name="formatTime">
<xsl:param name="timeElapsed" select="/log:application/log:timeEnlapsed"/>
<!--
int milisec = (startTime->elapsed());
int mili = milisec % 1000;
int seconds = ((milisec % (3600000)) % (60000)) / 1000;
int minutes = (milisec % (3600000)) / (60000);
int hours = milisec / (3600000);
-->
<xsl:variable name="hours" select="floor($timeElapsed div 3600000)"/>
<xsl:variable name="minutes" select="floor(($timeElapsed - $hours * 3600000) div 60000)"/>
<xsl:variable name="secondes" select="floor(($timeElapsed - $hours * 3600000 - $minutes * 60000) div 1000)"/>
<xsl:variable name="msec" select="floor($timeElapsed - $hours * 3600000 - $minutes * 60000 -$secondes * 1000)"/> <xsl:if test="$hours > 0"><xsl:value-of select="$hours"/> h </xsl:if>
<xsl:if test="$minutes > 0"><xsl:value-of select="$minutes"/> min </xsl:if>
<xsl:if test="$secondes > 0"><xsl:value-of select="$secondes"/> s </xsl:if>
<xsl:if test="$msec > 0"><xsl:value-of select="$msec"/> ms</xsl:if>
</xsl:template>
</xsl:stylesheet>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment