Esempio n. 1
0
int
evsignal_add(struct event *ev)
{
	int evsignal;
	struct event_base *base = ev->ev_base;
	struct evsignal_info *sig = &ev->ev_base->sig;

	if (ev->ev_events & (EV_READ|EV_WRITE))
		event_errx(1, "%s: EV_SIGNAL incompatible use", __func__);
	evsignal = EVENT_SIGNAL(ev);
	assert(evsignal >= 0 && evsignal < NSIG);
	if (TAILQ_EMPTY(&sig->evsigevents[evsignal])) {
		event_debug(("%s: %p: changing signal handler", __func__, ev));
		if (_evsignal_set_handler(
			    base, evsignal, evsignal_handler) == -1)
			return (-1);

		/* catch signals if they happen quickly */
		evsignal_base = base;

		if (!sig->ev_signal_added) {
			if (event_add(&sig->ev_signal, NULL))
				return (-1);
			sig->ev_signal_added = 1;
		}
	}

	/* multiple events may listen to the same signal */
	TAILQ_INSERT_TAIL(&sig->evsigevents[evsignal], ev, ev_signal_next);

	return (0);
}
Esempio n. 2
0
static void manual_key_release (void *p_arg)
{
	uint32_t *key_pressed = p_arg;
	mn_screen_event_t touch;
	if (*key_pressed == KEY_ENTER)
	{

		widgetClick(page->p_widget[page->wt_selected], NT_RELEASE);
		touch.event = EVENT_SIGNAL(page->p_widget[page->wt_selected]->id,EVENT_CLICK);
		xQueueSend( menu.qEvent, &touch, 0 );
	}
	else if (*key_pressed == KEY_ESC)
	{
		widgetClick(&btn_voltar, NT_RELEASE);
		touch.event = EVENT_SIGNAL(btn_voltar.id, EVENT_CLICK);
		xQueueSend( menu.qEvent, &touch, 0 );
	}
}
Esempio n. 3
0
int
evsignal_del(struct event *ev)
{
	struct event_base *base = ev->ev_base;
	struct evsignal_info *sig = &base->sig;
	int evsignal = EVENT_SIGNAL(ev);

	assert(evsignal >= 0 && evsignal < NSIG);

	/* multiple events may listen to the same signal */
	TAILQ_REMOVE(&sig->evsigevents[evsignal], ev, ev_signal_next);

	if (!TAILQ_EMPTY(&sig->evsigevents[evsignal]))
		return (0);

	event_debug(("%s: %p: restoring signal handler", __func__, ev));

	return (_evsignal_restore_handler(ev->ev_base, EVENT_SIGNAL(ev)));
}
Esempio n. 4
0
void page_handler (void *p_arg)
{
	static uint8_t progress_val;
	mn_screen_event_t *p_page_hdl = p_arg;
	mn_load_t *p_load_arg = p_page_hdl->p_arg;
	char str[20];

	if (p_page_hdl->event == EVENT_SHOW)
	{
		if (p_load_arg->type == MEM_FORMAT)
		{
			widgetVisible(&btn_sim, NT_HIDE);
			widgetVisible(&btn_nao, NT_HIDE);
			widgetVisible(&txt_info, NT_HIDE);
			widgetVisible(&load_bar, NT_SHOW);
			snprintf(str,sizeof(str), "Formatando mem ext");
		    xTaskCreate( (pdTASK_CODE)format_mem_task,     "format_mem_task    ",  256, NULL, 1, NULL); /* keyboard_task      */
		}
		if (p_load_arg->type == FILE_LOAD)
		{
			widgetVisible(&btn_sim, NT_HIDE);
			widgetVisible(&btn_nao, NT_HIDE);
			widgetVisible(&txt_info, NT_HIDE);
			widgetVisible(&load_bar, NT_SHOW);
			snprintf(str,sizeof(str), "Carregando arquivo");
		    xTaskCreate( (pdTASK_CODE)copy_file_task,     "format_mem_task    ",  512, p_file_path, 1, &xHdlTaskFilecopy);
		}
		changeTxt(&txt_version,str);
		mn_screen_create_timer(&timer0,200);
		mn_screen_start_timer(&timer0);
	}
	else if (p_page_hdl->event == EVENT_SIGNAL(timer0.id,EVENT_TIMER))
	{
		if(progress_val <= 10)
		{
			widgetProgressBar(&load_bar,(progress_val*100)/10);
			progress_val++;
		}
		else
		{
			progress_val = 0;
		}
	}
	else if (p_page_hdl->event == FILE_LOAD_EVENT)
	{
		mn_screen_change(&main_page,EVENT_SHOW);
	}
	else if (p_page_hdl->event == EMERGENCIA_SIGNAL_EVENT)
	{
		emergencia_args.p_ret_page = page;
		emergencia_page.p_args = &emergencia_args;
		mn_screen_change(&emergencia_page,EVENT_SHOW);
	}
}
Esempio n. 5
0
static void
signal_cb(evutil_socket_t fd, short event, void *arg)
{
	struct event *signal = arg;

	printf("%s: got signal %d\n", __func__, EVENT_SIGNAL(signal));

	if (called >= 2)
		event_del(signal);

	called++;
}
Esempio n. 6
0
int
kq_del(void *arg, struct event *ev)
{
	struct kqop *kqop = arg;
	struct kevent kev;

	if (!(ev->ev_flags & EVLIST_X_KQINKERNEL))
		return (0);

	if (ev->ev_events & EV_SIGNAL) {
		int nsignal = EVENT_SIGNAL(ev);

 		memset(&kev, 0, sizeof(kev));
		kev.ident = nsignal;
		kev.filter = EVFILT_SIGNAL;
		kev.flags = EV_DELETE;
		
		if (kq_insert(kqop, &kev) == -1)
			return (-1);

		if (signal(nsignal, SIG_DFL) == SIG_ERR)
			return (-1);

		ev->ev_flags &= ~EVLIST_X_KQINKERNEL;
		return (0);
	}

	if (ev->ev_events & EV_READ) {
 		memset(&kev, 0, sizeof(kev));
		kev.ident = ev->ev_fd;
		kev.filter = EVFILT_READ;
		kev.flags = EV_DELETE;
		
		if (kq_insert(kqop, &kev) == -1)
			return (-1);

		ev->ev_flags &= ~EVLIST_X_KQINKERNEL;
	}

	if (ev->ev_events & EV_WRITE) {
 		memset(&kev, 0, sizeof(kev));
		kev.ident = ev->ev_fd;
		kev.filter = EVFILT_WRITE;
		kev.flags = EV_DELETE;
		
		if (kq_insert(kqop, &kev) == -1)
			return (-1);

		ev->ev_flags &= ~EVLIST_X_KQINKERNEL;
	}

	return (0);
}
Esempio n. 7
0
void page_handler (void *p_arg)
{
	mn_screen_event_t *p_page_hdl = p_arg;
	if (p_page_hdl->event == EVENT_SHOW)
	{
		page->wt_selected = mn_screen_select_widget(page,&btn_manual);

	}
	else if (p_page_hdl->event == EVENT_SIGNAL(btn_manual.id,EVENT_CLICK))
	{
		mn_screen_change(&jog_page,EVENT_SHOW);
	}
	else if (p_page_hdl->event == EVENT_SIGNAL(btn_vel_manual.id,EVENT_CLICK))
	{
		vel_keypad_args.p_var = &configVarJog[JOG_RAPIDO];
		vel_keypad_args.step = 1;
		vel_keypad_args.min = 10;
		vel_keypad_args.max = 10000;
		vel_keypad_args.p_ret_page = page;
		vel_keypad_args.p_next_page = page;
		keypad_page.p_args = &vel_keypad_args;
		mn_screen_change(&keypad_page,EVENT_SHOW);
	}
	else if (p_page_hdl->event == EVENT_SIGNAL(btn_deslocar.id,EVENT_CLICK))
	{
		if (zeromaq_flag == true)
		{
			xio_close(cs.primary_src);
			warn_args.buttonUseInit = BTN_ASK;
			warn_args.img_txt[0] = IMG_CONTINUAR;
			warn_args.msg_count = 1;
			warn_args.func_callback = warning_desloca_callback;
			warning_page.p_args = &warn_args;
			mn_screen_change(&warning_page,EVENT_SHOW);
		}
		else
		{
			warning_case = 0;
			warning_page.p_args = &warn_semzeromaquina_args;
			mn_screen_change(&warning_page,EVENT_SHOW);
		}
	}
	else if (p_page_hdl->event == EVENT_SIGNAL(btn_zerar_maq.id,EVENT_CLICK))
	{
		warning_page.p_args = &warn_zerarmaquina_args;
		mn_screen_change(&warning_page,EVENT_SHOW);
	}
	else if (p_page_hdl->event == EVENT_SIGNAL(btn_zerar_peca.id,EVENT_CLICK))
	{
		if (zeromaq_flag == true)
		{
			warning_page.p_args = &warn_zerarpeca_args;
			mn_screen_change(&warning_page,EVENT_SHOW);
		}
		else
		{
			warning_case = 1;
			warning_page.p_args = &warn_semzeromaquina_args;
			mn_screen_change(&warning_page,EVENT_SHOW);
		}
	}
	else if (p_page_hdl->event == EVENT_SIGNAL(btn_voltar.id,EVENT_CLICK))
	{
		mn_screen_change(&main_page,EVENT_SHOW);
	}
	else if (p_page_hdl->event == EMERGENCIA_SIGNAL_EVENT)
	{
		emergencia_args.p_ret_page = page;
		emergencia_page.p_args = &emergencia_args;
		mn_screen_change(&emergencia_page,EVENT_SHOW);
	}
}
Esempio n. 8
0
int
kq_add(void *arg, struct event *ev)
{
	struct kqop *kqop = arg;
	struct kevent kev;

	if (ev->ev_events & EV_SIGNAL) {
		int nsignal = EVENT_SIGNAL(ev);

 		memset(&kev, 0, sizeof(kev));
		kev.ident = nsignal;
		kev.filter = EVFILT_SIGNAL;
		kev.flags = EV_ADD;
		if (!(ev->ev_events & EV_PERSIST))
			kev.flags |= EV_ONESHOT;
		kev.udata = INTPTR(ev);
		
		if (kq_insert(kqop, &kev) == -1)
			return (-1);

		if (signal(nsignal, kq_sighandler) == SIG_ERR)
			return (-1);

		ev->ev_flags |= EVLIST_X_KQINKERNEL;
		return (0);
	}

	if (ev->ev_events & EV_READ) {
 		memset(&kev, 0, sizeof(kev));
		kev.ident = ev->ev_fd;
		kev.filter = EVFILT_READ;
#ifdef NOTE_EOF
		/* Make it behave like select() and poll() */
		kev.fflags = NOTE_EOF;
#endif
		kev.flags = EV_ADD;
		if (!(ev->ev_events & EV_PERSIST))
			kev.flags |= EV_ONESHOT;
		kev.udata = INTPTR(ev);
		
		if (kq_insert(kqop, &kev) == -1)
			return (-1);

		ev->ev_flags |= EVLIST_X_KQINKERNEL;
	}

	if (ev->ev_events & EV_WRITE) {
 		memset(&kev, 0, sizeof(kev));
		kev.ident = ev->ev_fd;
		kev.filter = EVFILT_WRITE;
		kev.flags = EV_ADD;
		if (!(ev->ev_events & EV_PERSIST))
			kev.flags |= EV_ONESHOT;
		kev.udata = INTPTR(ev);
		
		if (kq_insert(kqop, &kev) == -1)
			return (-1);

		ev->ev_flags |= EVLIST_X_KQINKERNEL;
	}

	return (0);
}
Esempio n. 9
0
static void signal_cb(evutil_socket_t fd, short event, void *arg) {
    struct event *signal = (struct event *)arg;
    sleep(10);
    printf("%s: got signal %d\n", __func__, EVENT_SIGNAL(signal));
}