void createRecursiveActionSet_AllBulbOn() { string actionsetDesc; ActionSet *allBulbOn = new ActionSet(); allBulbOn->type = OIC::ACTIONSET_TYPE::RECURSIVE; allBulbOn->actionsetName = "AllBulbOnRecursiveCall"; allBulbOn->mTime.tm_year = 0; allBulbOn->mTime.tm_mon = 0; allBulbOn->mTime.tm_mday = 0; allBulbOn->mTime.tm_hour = 0; allBulbOn->mTime.tm_min = 0; allBulbOn->mTime.tm_sec = 5; allBulbOn->setDelay(allBulbOn->getSecAbsTime()); for (auto iter = lights.begin(); iter != lights.end(); ++iter) { Action *action = new Action(); action->target = (*iter); Capability *capa = new Capability(); capa->capability = "power"; capa->status = "on"; action->listOfCapability.push_back(capa); allBulbOn->listOfAction.push_back(action); } if (g_resource) { groupMgr->addActionSet(g_resource, allBulbOn, onPut); } delete allBulbOn; }
void createScheduledActionSet_AllBulbOff() { string actionsetDesc; ActionSet *allBulbOff = new ActionSet(); allBulbOff->type = OIC::ACTIONSET_TYPE::SCHEDULED; allBulbOff->actionsetName = "AllBulbOffScheduledCall"; printf("ENTER(YYYY-MM-DD hh:mm:ss) :: "); int res = scanf("%d-%d-%d %d:%d:%d", &allBulbOff->mTime.tm_year, &allBulbOff->mTime.tm_mon, &allBulbOff->mTime.tm_mday, &allBulbOff->mTime.tm_hour, &allBulbOff->mTime.tm_min, &allBulbOff->mTime.tm_sec); if( res < 0 ) { printf("Invalid Input. try again."); delete allBulbOff; return; } allBulbOff->setDelay(allBulbOff->getSecondsFromAbsoluteTime()); printf("DELAY :: %ld\n", allBulbOff->getSecondsFromAbsoluteTime()); for (auto iter = lights.begin(); iter != lights.end(); ++iter) { Action *action = new Action(); action->target = (*iter); Capability *capa = new Capability(); capa->capability = "power"; capa->status = "off"; action->listOfCapability.push_back(capa); allBulbOff->listOfAction.push_back(action); } if (g_resource) { groupMgr->addActionSet(g_resource, allBulbOff, onPut); } delete allBulbOff; }