Skip to content

Commit

Permalink
Merge d6a58c9 into 7c290c5
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrnz committed May 12, 2019
2 parents 7c290c5 + d6a58c9 commit d0d11c0
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 112 deletions.
Expand Up @@ -572,10 +572,6 @@
<source>none</source>
<translation>aucun</translation>
</message>
<message>
<source>the model must have at least one ODE or DAE</source>
<translation>le modèle doit avoir au moins une EDO ou EAD</translation>
</message>
<message>
<source>the model needs both an ODE and an NLA solver, but none are available</source>
<translation>le modèle a besoin à la fois d&apos;un solveur EDO et d&apos;un solveur ALN, mais aucun n&apos;est disponible</translation>
Expand Down
Expand Up @@ -935,152 +935,83 @@ void SimulationExperimentViewSimulationWidget::initialize(bool pReloadingView)
fileManagerInstance->url(simulationFileName):
simulationFileName;
QString information = "<strong>"+QDir::toNativeSeparators(fileName)+"</strong>"+OutputBrLn;
SEDMLSupport::SedmlFileIssues sedmlFileIssues = (mSimulation->sedmlFile() != nullptr)?
mSimulation->sedmlFile()->issues():
SEDMLSupport::SedmlFileIssues();
COMBINESupport::CombineArchiveIssues combineArchiveIssues = (mSimulation->combineArchive() != nullptr)?
mSimulation->combineArchive()->issues():
COMBINESupport::CombineArchiveIssues();
bool atLeastOneBlockingSedmlIssue = false;
bool atLeastOneBlockingCombineIssue = false;

if (!combineArchiveIssues.isEmpty()) {
// There is one or several issues with our COMBINE archive, so list
// it/them

for (const auto &combineArchiveIssue : combineArchiveIssues) {
QString issueType;
CellMLSupport::CellmlFileRuntime *runtime = mSimulation->runtime();
bool validRuntime = (runtime != nullptr) && runtime->isValid();

switch (combineArchiveIssue.type()) {
case COMBINESupport::CombineArchiveIssue::Type::Information:
issueType = tr("Information:");
CellMLSupport::CellmlFileRuntimeParameter *voi = validRuntime?runtime->voi():nullptr;

break;
case COMBINESupport::CombineArchiveIssue::Type::Error:
issueType = tr("Error:");
bool atLeastOneBlockingIssue = mSimulation->checkForIssues();

atLeastOneBlockingCombineIssue = true;
if (!atLeastOneBlockingIssue) {
information += QString()+OutputTab+"<strong>"+tr("Runtime:")+"</strong> ";

break;
case COMBINESupport::CombineArchiveIssue::Type::Warning:
issueType = tr("Warning:");
if (voi != nullptr) {
// A VOI could be retrieved for our CellML file, so we can also
// output the model type

break;
case COMBINESupport::CombineArchiveIssue::Type::Fatal:
issueType = tr("Fatal:");
information += QString()+"<span"+OutputGood+">"+tr("valid")+"</span>."+OutputBrLn
+QString(QString()+OutputTab+"<strong>"+tr("Model type:")+"</strong> <span"+OutputInfo+">%1</span>."+OutputBrLn).arg(runtime->needNlaSolver()?tr("DAE"):tr("ODE"));
} else {
// We couldn't retrieve a VOI, which means that we either don't
// have a runtime or we have one, but it's not valid or it's
// valid but we really don't have a VOI
// Note: in the case of a valid runtime and no VOI, we really
// shouldn't consider the runtime to be valid, hence we
// handle this case here...

atLeastOneBlockingCombineIssue = true;
mError = Error::InvalidCellmlFile;

break;
}
updateInvalidModelMessageWidget();

information += QString(QString()+OutputTab+"<span"+OutputBad+"><strong>%1</strong> %2.</span>"+OutputBrLn).arg(issueType)
.arg(Core::formatMessage(combineArchiveIssue.message()));
information += QString()+"<span"+OutputBad+">"+((runtime != nullptr)?tr("invalid"):tr("none"))+"</span>."+OutputBrLn;
}
}

if (!sedmlFileIssues.isEmpty()) {
// There is one or several issues with our SED-ML file, so list
auto simulationIssues = mSimulation->issues();

if (!simulationIssues.isEmpty()) {
// There is one or several issues with our Simulation, so list
// it/them

for (const auto &sedmlFileIssue : sedmlFileIssues) {
for (const auto &simulationIssue : simulationIssues) {
QString issueType;

switch (sedmlFileIssue.type()) {
case SEDMLSupport::SedmlFileIssue::Type::Unknown:
switch (simulationIssue.type()) {
case SimulationSupport::SimulationIssue::Type::Unknown:
// We should never come here...

#ifdef QT_DEBUG
qFatal("FATAL ERROR | %s:%d: a SED-ML file issue cannot be of unknown type.", __FILE__, __LINE__);
qFatal("FATAL ERROR | %s:%d: a simulation issue cannot be of unknown type.", __FILE__, __LINE__);
#else
break;
#endif
case SEDMLSupport::SedmlFileIssue::Type::Information:
case SimulationSupport::SimulationIssue::Type::Information:
issueType = tr("Information:");

break;
case SEDMLSupport::SedmlFileIssue::Type::Error:
case SimulationSupport::SimulationIssue::Type::Error:
issueType = tr("Error:");

atLeastOneBlockingSedmlIssue = true;

break;
case SEDMLSupport::SedmlFileIssue::Type::Warning:
case SimulationSupport::SimulationIssue::Type::Warning:
issueType = tr("Warning:");

break;
case SEDMLSupport::SedmlFileIssue::Type::Fatal:
case SimulationSupport::SimulationIssue::Type::Fatal:
issueType = tr("Fatal:");

atLeastOneBlockingSedmlIssue = true;

break;
}

if ((sedmlFileIssue.line() != 0) && (sedmlFileIssue.column() != 0)) {
information += QString(QString()+OutputTab+"<span"+OutputBad+"><strong>[%1:%2] %3</strong> %4.</span>"+OutputBrLn).arg(sedmlFileIssue.line())
.arg(sedmlFileIssue.column())
if ((simulationIssue.line() != 0) && (simulationIssue.column() != 0)) {
information += QString(QString()+OutputTab+"<span"+OutputBad+"><strong>[%1:%2] %3</strong> %4.</span>"+OutputBrLn).arg(simulationIssue.line())
.arg(simulationIssue.column())
.arg(issueType)
.arg(Core::formatMessage(sedmlFileIssue.message().toHtmlEscaped()));
.arg(Core::formatMessage(simulationIssue.message().toHtmlEscaped()));
} else {
information += QString(QString()+OutputTab+"<span"+OutputBad+"><strong>%1</strong> %2.</span>"+OutputBrLn).arg(issueType)
.arg(Core::formatMessage(sedmlFileIssue.message().toHtmlEscaped()));
}
}
}

CellMLSupport::CellmlFileRuntime *runtime = mSimulation->runtime();
bool validRuntime = (runtime != nullptr) && runtime->isValid();

CellMLSupport::CellmlFileRuntimeParameter *voi = validRuntime?runtime->voi():nullptr;

if (!atLeastOneBlockingSedmlIssue && !atLeastOneBlockingCombineIssue) {
information += QString()+OutputTab+"<strong>"+tr("Runtime:")+"</strong> ";

if (voi != nullptr) {
// A VOI could be retrieved for our CellML file, so we can also
// output the model type

information += QString()+"<span"+OutputGood+">"+tr("valid")+"</span>."+OutputBrLn
+QString(QString()+OutputTab+"<strong>"+tr("Model type:")+"</strong> <span"+OutputInfo+">%1</span>."+OutputBrLn).arg(runtime->needNlaSolver()?tr("DAE"):tr("ODE"));
} else {
// We couldn't retrieve a VOI, which means that we either don't
// have a runtime or we have one, but it's not valid or it's
// valid but we really don't have a VOI
// Note: in the case of a valid runtime and no VOI, we really
// shouldn't consider the runtime to be valid, hence we
// handle this case here...

mError = Error::InvalidCellmlFile;

updateInvalidModelMessageWidget();

information += QString()+"<span"+OutputBad+">"+((runtime != nullptr)?tr("invalid"):tr("none"))+"</span>."+OutputBrLn;

if (validRuntime) {
// We have a valid runtime, but no VOI, which means that the
// model doesn't contain any ODE or DAE

information += QString()+OutputTab+"<span"+OutputBad+"><strong>"+tr("Error:")+"</strong> "+tr("the model must have at least one ODE or DAE")+".</span>"+OutputBrLn;
} else {
// We don't have a valid runtime, so either there are some
// problems with the CellML file, its runtime, or even the
// parent SED-ML file and/or COMBINE archive
// Note: in the case of problems with the SED-ML file and/or
// COMBINE archive, we will already have listed the
// problems, so no need to do anything more in those
// cases...

if (sedmlFileIssues.isEmpty() && combineArchiveIssues.isEmpty()) {
for (const auto &issue : (runtime != nullptr)?
runtime->issues():
(mSimulation->cellmlFile() != nullptr)?
mSimulation->cellmlFile()->issues():
CellMLSupport::CellmlFileIssues()) {
information += QString(QString()+OutputTab+"<span"+OutputBad+"><strong>%1</strong> %2.</span>"+OutputBrLn).arg((issue.type() == CellMLSupport::CellmlFileIssue::Type::Error)?tr("Error:"):tr("Warning:"))
.arg(issue.message());
}
}
.arg(Core::formatMessage(simulationIssue.message().toHtmlEscaped()));
}
}
}
Expand All @@ -1094,7 +1025,7 @@ void SimulationExperimentViewSimulationWidget::initialize(bool pReloadingView)

mValidSimulationEnvironment = false;

if (!atLeastOneBlockingSedmlIssue && !atLeastOneBlockingCombineIssue) {
if (!atLeastOneBlockingIssue) {
// Enable/disable our run/pause action depending on whether we have
// a VOI

Expand Down
Expand Up @@ -11,5 +11,9 @@
<source>the starting point cannot be greater than the ending point</source>
<translation>le point de départ ne peut pas être plus grand que le point d&apos;arrivée</translation>
</message>
<message>
<source>the model must have at least one ODE or DAE</source>
<translation>le modèle doit avoir au moins une EDO ou EAD</translation>
</message>
</context>
</TS>

0 comments on commit d0d11c0

Please sign in to comment.