void RuleListWidget::ruleContentChanged(int rule) { if(rule != _ruleLayout->count()-1) return; updateRuleList(); }
void RuleListWidget::moveRuleDown(int rule) { if(rule >= _ruleLayout->count()-1) return; swapRules(rule, rule+1); updateRuleList(); }
void RuleListWidget::moveRuleUp(int rule) { if(rule < 1) return; swapRules(rule-1, rule); updateRuleList(); }
void RuleListWidget::clearAll() { while(_ruleLayout->count() != 0) delete _ruleLayout->itemAt(0)->widget(); updateRuleList(); emit numberOfRulesChanged(numberOfRules()-1); }
void RuleListWidget::deleteRule(int rule) { if(rule < 0 || rule >= _ruleLayout->count()) return; delete _ruleLayout->itemAt(rule)->widget(); updateRuleList(); emit numberOfRulesChanged(numberOfRules()-1); }
void RuleListWidget::insertRule(int rulePos) { if(rulePos > _ruleLayout->count()) rulePos = _ruleLayout->count(); _ruleLayout->insertWidget(rulePos, createWidgetAt(rulePos)); updateRuleList(); emit numberOfRulesChanged(numberOfRules()-1); }
bool ruleSmrclgenerator::setExecution(bool run, void *nothing){ //Update the list of generator rules when execution is started. updateRuleList(); //Toggle some stuff, when running is activated/deactivated if (run) { if (running != NULL) running->setValued(1); }else { if (running != NULL) running->setValued(0); } return true; }
RuleListWidget::RuleListWidget(QWidget *parent) : QWidget(parent), _ruleLayout(new QVBoxLayout), _autoDelete(false) { _ruleLayout->setSpacing(10); delete layout(); QVBoxLayout * l = new QVBoxLayout; setLayout(l); l->addLayout(_ruleLayout); l->addStretch(9); setObjectName("listSelector"); setStyleSheet("#listSelector {background-color: black;}"); updateRuleList(); }
/* Function to process the generated smr-cl code and place it into * the robotCommand vector for the current route element. */ bool ruleSmrclgenerator::processCommands(vector<robotCommand> *rCmds, bool waitForNew) { generatorCount++; //Increment counter //Update rules, if the rule list is empty if (!rulesLoaded()) updateRuleList(); //Test if there is still no rules loaded if (!rulesLoaded()) return false; //update iteration counter ruleIterCmds = (int)ruleIter->getValued(); //Wait until the rule-based planner has run another iteration since last //update, if it is required if (ruleIter != NULL) { //only if rule-iter has been loaded from rulebased plug-in while((waitForNew) && (ruleIterCmds == (int)ruleIter->getValued())) { usleep(10000); //Wait 10ms until ruleIter changes } } //Make sure that the size of rCmds is enough if (rCmds->size() != genRules.size()) rCmds->resize(genRules.size()); //Loop through the generator rules for (size_t i = 0; i < genRules.size(); i++) { //Generate the command-set for the current commands if (genRules[i].cmdValid) { //Get the quality (*rCmds)[i].cmdName = genRules[i].cmdName; (*rCmds)[i].quality = genRules[i].quality->getValued(0); (*rCmds)[i].id = genRules[i].id; //Only extract the remaining stuff, if quality is higher than zero if ((*rCmds)[i].quality > 0.0) { //Extract the cmd strings if (genRules[i].command != NULL) (*rCmds)[i].command = ruleStringLoader(genRules[i].command); if (genRules[i].preCommand != NULL) (*rCmds)[i].preCommand = ruleStringLoader(genRules[i].preCommand); if (genRules[i].postCommand != NULL) (*rCmds)[i].postCommand = ruleStringLoader(genRules[i].postCommand); if (genRules[i].failCond != NULL) (*rCmds)[i].failCond = ruleStringLoader(genRules[i].failCond); if (genRules[i].reloadCond != NULL) (*rCmds)[i].reloadCond = ruleStringLoader(genRules[i].reloadCond); if (genRules[i].successCond != NULL) (*rCmds)[i].successCond = ruleStringLoader(genRules[i].successCond); if (genRules[i].initCommand != NULL) (*rCmds)[i].initCommand = ruleStringLoader(genRules[i].initCommand); if (genRules[i].exitCommand != NULL) (*rCmds)[i].exitCommand = ruleStringLoader(genRules[i].exitCommand); if (genRules[i].reload != NULL ) (*rCmds)[i].reload = (bool)genRules[i].reload->getValued(); if (genRules[i].disable != NULL ) (*rCmds)[i].disable = (bool)genRules[i].disable->getValued(); } } } return true; }