Beispiel #1
0
/**
 * Starts the counter clock.
 *
 * \param counter Value returned by the oesr_counter_create() function
 * \returns 0 on success or -1 on error.
 */
int oesr_counter_start(counter_t counter) {
	oesr_counter_t *cnt = (oesr_counter_t*) counter;
	oesr_context_t *ctx = cnt->context;
	OESR_ASSERT_PARAM(counter);
	rtdal_time_get(&cnt->count[1]);
	sdebug("context=0x%x, counter_id=%d, start=%d:%d\n",ctx,cnt->id,
			cnt->count[1].tv_sec,cnt->count[1].tv_usec);
	return -1;
}
Beispiel #2
0
inline static void pipeline_run_thread_print_time(pipeline_t *obj) {
#ifdef PRINT_TIME
	time_t tdata;
	rtdal_time_get(&tdata);
	if (!(obj->ts_counter%10000))
		printf("Pipeline %d running %d modules at TS=%d\t Start: %d:%d\n",obj->id, obj->nof_processes,
				rtdal_time_slot(),
				(int) tdata.tv_sec, (int) tdata.tv_usec);
#endif

}
Beispiel #3
0
/**
 *  Stops the counter clock and sets the elapsed time.
 *
 * \param counter Value returned by the oesr_counter_create() function
 * \returns 0 on success or -1 on error.
 */
int oesr_counter_stop(counter_t counter) {
	oesr_counter_t *cnt = (oesr_counter_t*) counter;
	oesr_context_t *ctx = cnt->context;
	OESR_ASSERT_PARAM(counter);
	variable_t *variable = cnt->variable;

	rtdal_time_get(&cnt->count[2]);
	rtdal_time_interval(cnt->count);
	sdebug("context=0x%x, counter_id=%d, finish=%d:%d, count=%d, value=0x%x\n",ctx,cnt->id,
			cnt->count[2].tv_sec,cnt->count[2].tv_usec,cnt->count[0].tv_usec,
			variable->cur_value);
	return 0;
}
Beispiel #4
0
void pipeline_run_from_timer(void *arg, struct timespec *time) {
	pipeline_t *obj = (pipeline_t*) arg;
	time_t realtime;
#ifdef KERNEL_DEB_TIME
	rtdal_time_get(&realtime);
	hdebug("now is %d:%d\n",realtime.tv_sec,realtime.tv_usec);
#else
	hdebug("now is %d:%d\n",time->tv_sec,time->tv_nsec);
#endif

	if (!timer_first_cycle && time) {
		rtdal_time_reset_realtime(time);
		timer_first_cycle = 1;
	}

	if (!is_first_in_cycle()) {
		kernel_tslot_run();
	}

	pipeline_run_time_slot(obj);
}
Beispiel #5
0
int _run_cycle(void* context) {
	int i;
	oesr_context_t *ctx = (oesr_context_t*) context;
	nod_module_t *module = (nod_module_t*) ctx->module;
	nod_waveform_t *waveform = (nod_waveform_t*) module->parent.waveform;
	sdebug("context=0x%x, module_id=%d, changing_status=%d, cur_status=%d waveform_status=%d\n",context,
			module->parent.id, module->changing_status, module->parent.status, waveform->status.cur_status);

	if (waveform->status.cur_status == LOADED && module->parent.status == PARSED) {
		/* ack we have successfully been loaded */
		module->parent.status = LOADED;
		/* register init and stop functions */
		module->init = _call_init;
		module->stop = _call_stop;
	}

	/* Change only if finished previous status change */
	if (!module->changing_status && module->parent.status != waveform->status.cur_status) {
		sdebug("next_tslot=%d, cur_tslot=%d\n",waveform->status.next_timeslot, rtdal_time_slot());
		/* is it time to change? */
		if (rtdal_time_slot() >= waveform->status.next_timeslot) {
			switch(waveform->status.cur_status) {
			case INIT:
			case STOP:
			break;
			case STEP:
				if (module->parent.status == RUN) {
					module->parent.status = waveform->status.cur_status;
				} else {
					module->parent.status = RUN;
				}
				break;
			case PAUSE:
			case RUN:
				/* These status does not need confirmation */
				module->parent.status = waveform->status.cur_status;
			break;
			default:
				break;
			}
		}
	}

	if (!module->changing_status && module->parent.status == RUN) {
#ifdef OESR_API_GETTIME
		/* save start time */
		rtdal_time_get(&module->parent.execinfo.t_exec[1]);
#endif

		/* run aloe cycle */
		for (i=0;i<waveform->tslot_multiplicity;i++) {
			if (Run(context)) {
				sdebug("RUNERROR: module_id=%d\n",module->parent.id);

				/* set run-time error code */
				if (rtdal_process_seterror(module->process,RUNERROR)) {
					aerror("rtdal_process_seterror");
				}
			}
		}
		ctx->tstamp++;

		/* save end time */
#ifdef OESR_API_GETTIME
		rtdal_time_get(&module->parent.execinfo.t_exec[2]);
		rtdal_time_interval(module->parent.execinfo.t_exec);
		nod_module_execinfo_add_sample(&module->parent.execinfo);
		if (DEBUG_TIMEMOD_ID == module->parent.id || DEBUG_TIMEMOD_ID == -1) {
			tmdebug("%d,%d\n",module->parent.id,
				module->parent.execinfo.t_exec[0].tv_usec);
		}
#endif

		/* compute execution time, exponential average, max, etc. and save data to mymodule.execinfo */
#ifdef kk
		/* stat reports */
		for (i=0;i<nof_reporting_vars;i++) {
			module.reporting_variables[i].period_cnt++;
			/* save the first window samples only */
			if (module.reporting_variables[i].period_cnt++<module.reporting_variables[i].window)
				module.reporting_variables[i].serialize(module.reporting_variables[i].report_packet);
			}
			/* send report every period */
			if (module.reporting_variables[i].periodCnt++<module.reporting_variables[i].period) {
				rtdal.newTask(report_variable,&reporting_variables[i]);
			}
		}

		/* write logs */
		for (i=0;i<nof_logs;i++) {
			if (logs[i].w_ptr) {
				rtdal.new_task(oesr_log._writelog,logs[i]);
			}
		}
#endif
	}