コード例 #1
0
ファイル: PNPActionServer.cpp プロジェクト: mircolosi/HRI_LAS
bool PNPActionServer::EvalConditionWrapper(pnp_msgs::PNPCondition::Request  &req,
         pnp_msgs::PNPCondition::Response &res)  {

    //cout << "EvalConditionWrapper started " << endl;

	int r0 = -1;
	// This is necessary because multiple calls to the same condition can happen
	if (ConditionCache.find(req.cond) != ConditionCache.end()) {
		r0 = ConditionCache[req.cond];
	}

    int r1 = evalCondition(req.cond);
    int r2 = check_for_event(req.cond);

	//cout << "EvalConditionWrapper  " << req.cond << " : cache / eval / check " << r0 << " " << r1 << " " << r2 ;

    int result=-1;
    if (r0!=-1) result=r0;
	else if (r1!=-1) result=r1; 
	else result=r2;
 
    //TODO implement unknown value of a condition in PNP
    if (result==-1) result=0;

	//cout << " RESULT = " << result << endl;
	
	ConditionCache[req.cond] = result;
    res.truth_value = result;

    return true;
}
コード例 #2
0
ファイル: waitset.c プロジェクト: Karamax/arrakis
/**
 * \brief check and dispatch next event on given waitset
 *
 * Check if there is any pending activity on some channel, or deferred
 * call, and then call the corresponding closure.
 *
 * Do not wait!  In case of no pending events, return err LIB_ERR_NO_EVENT.
 *
 * \param ws Waitset
 */
errval_t event_dispatch_non_block(struct waitset *ws)
{
    struct event_closure closure;
    errval_t err = check_for_event(ws, &closure);

    if (err_is_fail(err)) {
        return err;
    }

    assert(closure.handler != NULL);
    closure.handler(closure.arg);
    return SYS_ERR_OK;
}
コード例 #3
0
ファイル: master.c プロジェクト: huiweics/arrakis
static void
master_process_reqs(void)
{
    /* process slave requests */
    for (;;) {
        struct event_closure closure;
        errval_t ret;
        ret = check_for_event(get_default_waitset(), &closure);
        if (ret == LIB_ERR_NO_EVENT)
            break;
        assert(err_is_ok(ret));
        assert(closure.handler != NULL);
        //printf(RED("-------- GOT A MASTER EVENT handler=%p arg=%p"), closure.handler, closure.arg);
        closure.handler(closure.arg);
    }
}