当前位置: 首页>>代码示例>>C++>>正文


C++ enter_state函数代码示例

本文整理汇总了C++中enter_state函数的典型用法代码示例。如果您正苦于以下问题:C++ enter_state函数的具体用法?C++ enter_state怎么用?C++ enter_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了enter_state函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process

static void process(void)
{
    int val;
    switch(touch_state)
    {
    case TOUCH_STATE_WAIT:
        /* a touch has happened, check if it's still valid */
        if(imx233_lradc_read_touch_detect())
            enter_state(TOUCH_STATE_MEASURE_X);
        else
        {
            old_touch_detect = false;
            /* clear detect interrupt */
            imx233_lradc_clear_touch_detect_irq();
        }
        break;
    case TOUCH_STATE_MEASURE_X:
        /* read value */
        val = imx233_lradc_read_channel(touch_chan);
        /* if value is too far from average, restart */
        if(nr_samples > 0 && abs(val - touch_x) > DEBOUNCE_THRESHOLD)
            nr_samples = 0;
        touch_x = (touch_x * nr_samples + val) / (nr_samples + 1);
        nr_samples++;
        /* if we have enough samples, measure Y */
        if(nr_samples > SAMPLES_THRESHOLD)
            enter_state(TOUCH_STATE_MEASURE_Y);
        else
            imx233_lradc_kick_delay(touch_delay);
        break;
    case TOUCH_STATE_MEASURE_Y:
        /* read value */
        val = imx233_lradc_read_channel(touch_chan);
        /* if value is too far from average, restart */
        if(nr_samples > 0 && abs(val - touch_y) > DEBOUNCE_THRESHOLD)
            nr_samples = 0;
        touch_y = (touch_y * nr_samples + val) / (nr_samples + 1);
        nr_samples++;
        /* if we have enough samples, verify touch */
        if(nr_samples > SAMPLES_THRESHOLD)
            enter_state(TOUCH_STATE_VERIFY);
        else
            imx233_lradc_kick_delay(touch_delay);
        break;
    case TOUCH_STATE_VERIFY:
        if(imx233_lradc_read_touch_detect())
        {
            old_touch_detect = true;
            old_touch_x = touch_x;
            old_touch_y = touch_y;
            enter_state(TOUCH_STATE_MEASURE_X);
        }
        else
        {
            old_touch_detect = false;
            enter_state(TOUCH_STATE_WAIT);
        }
        break;
    }
}
开发者ID:4nykey,项目名称:rockbox,代码行数:60,代码来源:touchscreen-imx233.c

示例2: state_store

static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
	suspend_state_t state = PM_SUSPEND_ON;
#else
	suspend_state_t state = PM_SUSPEND_STANDBY;
#endif
	const char * const *s;
#endif
	char *p;
	int len;
	int error = -EINVAL;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	/* First, check if we are requested to hibernate */
	if (len == 4 && !strncmp(buf, "disk", len)) {
		error = hibernate();
  goto Exit;
	}
#if defined(CONFIG_MP_MSTAR_STR_BASE)
    // for mstar str, we skip wakelock
    // and earlysuspend/lateresume to speedup suspend
    if (len == 4 && !strncmp(buf, "mstr", len)) {
        state = PM_SUSPEND_MEM;
        pm_is_mstar_str = 1;
        error = enter_state(state);
        pm_is_mstar_str = 0;
        goto Exit;
    }
#endif

#ifdef CONFIG_SUSPEND
	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
			break;
	}
	if (state < PM_SUSPEND_MAX && *s)
#ifdef CONFIG_EARLYSUSPEND
		if (state == PM_SUSPEND_ON || valid_state(state)) {
			error = 0;
			request_suspend_state(state);
		}
#else
		error = enter_state(state);
#endif
#endif

 Exit:
	return error ? error : n;
}
开发者ID:nightcap79,项目名称:kogan-tv-gpl,代码行数:54,代码来源:main.c

示例3: path

static void path(parser_context *context)
{
    enter_state(context, ST_START);
    skip_ws(context);

    absolute_path(context);

    if(ERR_UNEXPECTED_VALUE == context->result.code && '$' == context->result.expected_char)
    {
        enter_state(context, ST_START);
        context->current_step_kind = SINGLE;
        relative_path(context);
    }
}
开发者ID:kazufusa,项目名称:kanabo,代码行数:14,代码来源:core.c

示例4: imx233_touchscreen_enable

void imx233_touchscreen_enable(bool enable)
{
    enter_state(TOUCH_STATE_WAIT);
    imx233_lradc_set_channel_irq_callback(touch_chan, &touch_channel_irq);
    imx233_icoll_enable_interrupt(INT_SRC_LRADC_CHx(touch_chan), enable);
    imx233_icoll_enable_interrupt(INT_SRC_TOUCH_DETECT, enable);
}
开发者ID:4nykey,项目名称:rockbox,代码行数:7,代码来源:touchscreen-imx233.c

示例5: step_predicate_parser

static void step_predicate_parser(parser_context *context)
{
    enter_state(context, ST_PREDICATE);

    skip_ws(context);
    if('[' == get_char(context))
    {
        consume_char(context);
        if(!look_for(context, "]"))
        {
            context->result.code = ERR_UNBALANCED_PRED_DELIM;
            return;
        }
        skip_ws(context);
        if(']' == get_char(context))
        {
            context->result.code = ERR_EMPTY_PREDICATE;
            return;
        }

        try_predicate_parser(wildcard_predicate);
        try_predicate_parser(subscript_predicate);
        try_predicate_parser(slice_predicate);

        if(JSONPATH_SUCCESS != context->result.code && ERR_PARSER_OUT_OF_MEMORY != context->result.code)
        {
            context->result.code = ERR_UNSUPPORTED_PRED_TYPE;
        }
    }
    else
    {
        unexpected_value(context, '[');
    }
}
开发者ID:kazufusa,项目名称:kanabo,代码行数:34,代码来源:core.c

示例6: pm_suspend

/**
 * pm_suspend - Externally visible function for suspending the system.
 * @state: System sleep state to enter.
 *
 * Check if the value of @state represents one of the supported states,
 * execute enter_state() and update system suspend statistics.
 */
int pm_suspend(suspend_state_t state)
{
	int error;
	int s3_state = mid_state_to_sys_state(MID_S3_STATE);

	if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
		return -EINVAL;

	/* time stamp for start of s3 entry */
	if (state == PM_SUSPEND_MEM)
		time_stamp_for_sleep_state_latency(s3_state, true, true);

	pm_suspend_marker("entry");
	error = enter_state(state);
	if (error) {
		suspend_stats.fail++;
		dpm_save_failed_errno(error);
	} else {
		suspend_stats.success++;
		/* time stamp for end of s3 exit */
		if (state == PM_SUSPEND_MEM)
			time_stamp_for_sleep_state_latency(s3_state,
							false, false);
	}
	pm_suspend_marker("exit");
	return error;
}
开发者ID:AirShark,项目名称:android_kernel_lenovo_redhookbay,代码行数:34,代码来源:suspend.c

示例7: step_parser

static void step_parser(parser_context *context)
{
    if(look_for(context, "()"))
    {
        node_type_test(context);
        if(JSONPATH_SUCCESS == context->result.code && has_more_input(context))
        {
            consume_char(context);
            consume_char(context);
        }
    }
    else
    {
        name_test(context);
    }

    if(JSONPATH_SUCCESS == context->result.code && has_more_input(context))
    {
        step_predicate_parser(context);
    }

    if(ERR_UNEXPECTED_VALUE == context->result.code && '[' == context->result.expected_char)
    {
        enter_state(context, ST_STEP);
        context->result.code = JSONPATH_SUCCESS;
    }
}
开发者ID:kazufusa,项目名称:kanabo,代码行数:27,代码来源:core.c

示例8: absolute_path

static void absolute_path(parser_context *context)
{
    enter_state(context, ST_ABSOLUTE_PATH);

    if('$' == get_char(context))
    {
        context->result.code = JSONPATH_SUCCESS;
        context->path->kind = ABSOLUTE_PATH;
        context->current_step_kind = ROOT;
        consume_char(context);

        step *root = make_root_step();
        if(NULL == root)
        {
            context->result.code = ERR_PARSER_OUT_OF_MEMORY;
            return;
        }
        if(!push_step(context, root))
        {
            return;
        }

        if(has_more_input(context))
        {
            qualified_path(context);
        }
    }
    else
    {
        unexpected_value(context, '$');
    }
}
开发者ID:kazufusa,项目名称:kanabo,代码行数:32,代码来源:core.c

示例9: to_state

static int to_state(struct state_t* state,void* input)
{
	int ret;
	do{
		ret=enter_state(state,input);
	}while( state->owner->isrunning && do_transition(state,input) < 0 );

	return exit_state(state,input);
}
开发者ID:wowk,项目名称:wowk-state-machine,代码行数:9,代码来源:state-machine.c

示例10: fn_leave_tag

void
fn_leave_tag(char **args)
{
    if (binding_state != bs_tag) {
	disp_status(DISP_STATUS, "not in <tag> mode");
	return;
    }

    enter_state(leave_tag);
}
开发者ID:robacklin,项目名称:cftp,代码行数:10,代码来源:fn_basic.c

示例11: pm_suspend

/**
 *	pm_suspend - Externally visible function for suspending system.
 *	@state:		Enumerated value of state to enter.
 *
 *	Determine whether or not value is within range, get state
 *	structure, and enter (above).
 */
int pm_suspend(suspend_state_t state)
{
	int error;

	if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
		return -EINVAL;

	pm_suspend_marker("entry");
	error = enter_state(state);
	pm_suspend_marker("exit");

	return error;
}
开发者ID:Abioy,项目名称:meizu-mx-kernel,代码行数:20,代码来源:suspend.c

示例12: TRACE

	void DispatcherPrivate::task_main_imp(volatile PROCESS_ENTRY_STATE* process)
	{
		const PROCESS_ENTRY_DATA* pdata = process->data;
		PROCESS_ENTRY* pcb = process->process;

		TRACE(("[%s] task_main_imp(): starting\r\n", process->data->name));
		process->thread->mutex.lock();
		if (pcb->process_start != NULL)
			pcb->process_start(pcb);

		STATE_ENTRY* state = pdata->initstate;
		enter_state(process, state);
		process->state = ProcessRunning;
		process->thread->mutex.unlock();
		osSignalSet(_dispid, SIGNAL_CHANGED);

		for (;;)
		{
			//TRACE(("[%s] task_main_imp(): waiting for signal.\r\n", process->data->name));
			process->state = ProcessWaiting;
			DelayedThread::signal_wait(SIGNAL_RUN_TASKS);
			process->state = ProcessRunning;
			//TRACE(("[%s] task_main_imp(): woken up.\r\n", process->data->name));

			process->thread->mutex.lock();
			//TRACE(("DispatcherPrivate::run_tasks(): locked\r\n"));

			do
			{
				//TRACE(("[%s:%s] task_main_imp(): current state type is %i.\r\n", process->data->name, process->current->data->name, process->current->data->mode));
				TRANSITION_ENTRY* transition = find_valid_transition(process);
				if (transition != NULL)
				{
					take_transition(process, transition);
				}
				else
				{
					process->stepped = false;
					//TRACE(("[%s:%s] task_main_imp(): no transitions found.\r\n", process->data->name, process->current->data->name));
					break;
				}

			} while (process->current->data->mode == StateCommited);

			//TRACE(("DispatcherPrivate::run_tasks(): unlocking\r\n"));
			process->thread->mutex.unlock();
			osSignalSet(_dispid, SIGNAL_CHANGED);
		}

	}
开发者ID:arieleiz,项目名称:VerifiedPacemaker,代码行数:50,代码来源:ModelImpl.cpp

示例13: state_store

static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
	suspend_state_t state = PM_SUSPEND_ON;
#else
	suspend_state_t state = PM_SUSPEND_STANDBY;
#endif
	const char * const *s;
#endif
	char *p;
	int len;
	int error = -EINVAL;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	/* First, check if we are requested to hibernate */
	if (len == 4 && !strncmp(buf, "disk", len)) {
		printk(KERN_ERR "entering hibernate");
		error = hibernate();
  goto Exit;
	}

#ifdef CONFIG_SUSPEND
	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
			break;
	}
	printk(KERN_ERR "entering sleep state = %d\n", state);

	if (state < PM_SUSPEND_MAX && *s)
	{
#ifdef CONFIG_EARLYSUSPEND
		if (state == PM_SUSPEND_ON || valid_state(state)) {
			error = 0;
			request_suspend_state(state);
		} else {
			printk(KERN_ERR "not valid state with state = %d", state);
		}
#else
		error = enter_state(state);
#endif
	}
#endif

 Exit:
	return error ? error : n;
}
开发者ID:faizauthar12,项目名称:Hyper_kernel,代码行数:50,代码来源:main.c

示例14: pm_suspend

/**
 *	pm_suspend - Externally visible function for suspending system.
 *	@state:		Enumerated value of state to enter.
 *
 *	Determine whether or not value is within range, get state
 *	structure, and enter (above).
 */
int pm_suspend(suspend_state_t state)
{
	int ret;
	if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX) {
		ret = enter_state(state);
		if (ret) {
			suspend_stats.fail++;
			dpm_save_failed_errno(ret);
		} else
			suspend_stats.success++;
		return ret;
	}
	return -EINVAL;
}
开发者ID:OneOfMany07,项目名称:fjord-kernel,代码行数:21,代码来源:suspend.c

示例15: wildcard_name

static void wildcard_name(parser_context *context)
{
    enter_state(context, ST_WILDCARD_NAME_TEST);

    step *current = make_step(context->current_step_kind, WILDCARD_TEST);
    if(NULL == current)
    {
        context->result.code = ERR_PARSER_OUT_OF_MEMORY;
        return;
    }
    push_step(context, current);

    consume_char(context);
    context->result.code = JSONPATH_SUCCESS;
}
开发者ID:kazufusa,项目名称:kanabo,代码行数:15,代码来源:core.c


注:本文中的enter_state函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。