예제 #1
0
// -------------------------------------------------------------------------
void Core::updateScheduler()
{
    std::vector<DbSchedule*> schedules;
    mDbManager->selectAll(schedules);
    mScheduler->clearSchedules();

    for(std::vector<DbSchedule*>::iterator i = schedules.begin()
            ; i != schedules.end(); ++i)
    {
        DbAction* dbAction = (*i)->getAction();
        Action* action = new Action(mDb, new Script(dbAction->getContent()));
        Schedule* schedule = new Schedule(action);
        if((*i)->getMinutes() != "*")
            schedule->setMinute(Util::s2i((*i)->getMinutes()));
        if((*i)->getHours() != "*")
            schedule->setHour(Util::s2i((*i)->getHours()));
        if((*i)->getWeekDays() != "*")
            schedule->setWeekDays(Util::s2i((*i)->getWeekDays()));
        if((*i)->getMonths() != "*")
            schedule->setMonths(Util::s2i((*i)->getMonths()));

        mScheduler->addSchedule(schedule);

        delete *i;
    }

    schedules.clear();
}
예제 #2
0
void XmlReader::parseSchedules() {
	std::string entries = findTag("schedules");

  if(entries.length() > 0) {
    std::vector<std::string> lines = Tools::explode(";", entries);

    for(int l=0; l<lines.size(); l++) {
      if(lines[l].length() > 0) {
        std::vector<std::string> words = Tools::explode(":", lines[l]);
        Schedule s;
        for(int w=0; w<words.size(); w++) {
          if(typeid(words.at(0))==typeid(std::string))  s.setName(words[0]);
          if(typeid(words.at(1))==typeid(std::string))  s.setSocket(words[1]);
          if(typeid(words.at(2))==typeid(std::string))  s.setGpio(words[2]);
          if(typeid(words.at(3))==typeid(std::string))  s.setHour(atoi(words[3].c_str()));
          if(typeid(words.at(4))==typeid(std::string))  s.setMinute(atoi(words[4].c_str()));
          if(typeid(words.at(5))==typeid(std::string))  s.setOnoff(atoi(words[5].c_str()));
          if(typeid(words.at(6))==typeid(std::string))  s.setStatus(atoi(words[6].c_str()));
        }
        schedules.push_back(s);
      }
    }
  }
}