(root)/src/abe/actsalvage.cpp - Rev 906
Rev 905 |
Rev 907 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include "amie_global.h"
#include "actsalvage.h"
#include "fmstp.h"
#include "fmstand.h"
#include "fomescript.h"
#include "scheduler.h"
#include "tree.h"
#include "expression.h"
#include "expressionwrapper.h"
namespace AMIE {
ActSalvage::ActSalvage(FMSTP *parent)
{
mCondition = 0;
mMaxPreponeActivity = 0;
mBaseActivity.setEnabled(false); // avoid active scheduling...
mBaseActivity.setIsSalvage(true);
mBaseActivity.setIsRepeating(true);
mBaseActivity.setExecuteImmediate(true);
}
ActSalvage::~ActSalvage()
{
if (mCondition)
delete mCondition;
}
void ActSalvage::setup(QJSValue value)
{
Activity::setup(value); // setup base events
QString condition = FMSTP::valueFromJs(value, "disturbanceCondition").toString();
if (!condition.isEmpty() && condition!="undefined") {
mCondition = new Expression(condition);
}
mMaxPreponeActivity = FMSTP::valueFromJs(value, "maxPrepone", "0").toInt();
}
bool ActSalvage::execute(FMStand *stand)
{
// the salvaged timber is already accounted for - so nothing needs to be done here.
// however, we check if there is a planned activity for the stand which could be executed sooner
// than planned.
stand->unit()->scheduler()->
}
QStringList ActSalvage::info()
{
QStringList lines = Activity::info();
lines << QString("condition: %1").arg(mCondition?mCondition->expression(), "-");
lines << QString("maxPrepone: %1").arg(mMaxPreponeActivity);
return lines;
}
bool ActSalvage::testRemove(Tree *tree) const
{
if (!mCondition)
return true; // default: remove all trees
TreeWrapper tw(tree);
bool result = mCondition->execute(0, &tw);
return result;
}
} // namespace