Ejemplo n.º 1
0
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;
}