Exemple #1
0
int pgqtriga_make_sql(PgqTriggerEvent *ev, StringInfo sql)
{
	TriggerData *tg = ev->tgdata;
	TupleDesc tupdesc;
	int i;
	int attcnt;
	int need_event = 1;

	tupdesc = tg->tg_relation->rd_att;

	/*
	 * Count number of active columns
	 */
	for (i = 0, attcnt = 0; i < tupdesc->natts; i++) {
		if (tupdesc->attrs[i]->attisdropped)
			continue;
		attcnt++;
	}

	/*
	 * Determine cmdtype and op_data depending on the command type
	 */
	if (TRIGGER_FIRED_BY_INSERT(tg->tg_event)) {
		process_insert(ev, sql);
	} else if (TRIGGER_FIRED_BY_UPDATE(tg->tg_event)) {
		need_event = process_update(ev, sql);
	} else if (TRIGGER_FIRED_BY_DELETE(tg->tg_event)) {
		process_delete(ev, sql);
	} else
		elog(ERROR, "logtriga fired for unhandled event");

	return need_event;
}
Exemple #2
0
/**
This method sets gpio to operate as pwm
@param gpio - sets pin number according to numbering scheme
@param duty - value from 0 to 255. 0 - output is always 0, 255 - output is always 1, 1-254 - intermediate values
*/
static int start_pwm(const unsigned char gpio, const unsigned char duty){
	int error = 0;
	dbg_print("start_pwm_func con=%d duty=%d\r\n", gpio, duty);
	if ( (error = alloc_gpio(gpio, duty)) != SWPWM_OK ){
		dbg_print("Alloc gpio error %d\r\n", error);
		return -error;
	}
	dbg_print("Start_PWM: Before process update\r\n");
	process_update();
	dbg_print("Start_PWM: After process update\r\n");
	return 0;
}
Exemple #3
0
void core_loop(void) {

    SDL_Event event;
    while (! app.exit) {
        while (SDL_PollEvent(&event)) {
            event_handle(&event);
        }

        if (! timer.paused) {
            process_update();
            view_update();
        }
        view_render();

        timer_step();
    }
}
Exemple #4
0
/**
This method tunes SOFT PWM period
@param period - from 1 to 10000
*/
static int set_period(const unsigned int period){
	swpwm_period = period;
	process_update();
	return 0;
}
Exemple #5
0
/**
This method disables gpio to operate as pwm
@param gpio - sets pin number according to numbering scheme
GPIO is configured as input and all resources, allocated with the device are freed
*/
static int stop_pwm(const unsigned char gpio){
	free_gpio(gpio);
	process_update();
	return 0;
}