示例#1
0
文件: oesr_var.c 项目: alring/aloe
/**
 * Returns a handler for the parameter with name "name".
 * This handler is then used by the functions oesr_var_param_value() and oesr_var_param_type()
 *
 * \param context OESR context pointer
 * \param name Name of the parameter, as it appears in the waveform .app file
 * \return On success, returns a non-null handler. On error returns null.
 */
var_t oesr_var_param_get(void *context, char *name) {
	cast_p(ctx,context);
	OESR_ASSERT_PARAM_P(name);
	sdebug("name=%s\n",name);

	nod_module_t *module = (nod_module_t*) ctx->module;
	variable_t *variable = nod_module_variable_get(module,name);
	if (!variable) {
		OESR_SETERROR(OESR_ERROR_NOTFOUND);
		return NULL;
	}
	return (var_t) variable;
}
示例#2
0
/**
 * It creates a new log for the module. The returned handler (if non-null)
 * is then passed as the first parameter to the functions oesr_log_write() or oesr_log_printf().
 * \param context OESR context pointer
 * \param name Name of the log to create
 * \returns NULL on error or non-null on success.
 */
log_t oesr_log_create(void *context, char *name) {
	sdebug("context=0x%x, name=%s\n",context,name);
	cast_p(ctx,context);
	OESR_ASSERT_PARAM_P(name);
	int i;

	i=0;
	while(i<MAX(oesr_log) && ctx->logs[i].id)
		i++;
	if (i==MAX(oesr_log)) {
		OESR_SETERROR(OESR_ERROR_NOSPACE);
		return NULL;
	}
	if (oesr_log_init(ctx, &ctx->logs[i], name)) {
		return NULL;
	}
	ctx->logs[i].id = i+1;
	return (log_t) &ctx->logs[i];

}
示例#3
0
/**
 *
 * oesr_counter_create() creates a new counter. It returns a handler that is then used by the
 * counter functions to manage it.
 *
 * \param context OESR context pointer
 * \param name Name associated to the public variable
 * \returns On success, returns a non-null counter_t object. On error returns null.
 */
counter_t oesr_counter_create(void *context, char *name) {
	sdebug("context=0x%x, name=%s\n",context,name);
	cast_p(ctx,context);
	OESR_ASSERT_PARAM_P(name);
	int i;

	i=0;
	while(i<MAX(oesr_counter) && ctx->counters[i].id)
		i++;
	if (i==MAX(oesr_counter)) {
		OESR_SETERROR(OESR_ERROR_NOSPACE);
		return NULL;
	}
	sdebug("counter_pos=%d\n",i);
	if (oesr_counter_init(ctx, &ctx->counters[i],name)) {
		return NULL;
	} else {
		ctx->counters[i].id = i+1;
		return (counter_t) &ctx->counters[i];
	}
}
示例#4
0
/**  Returns a pointer to the oesr name string.
 */
char *oesr_module_name(void *context) {
	cast_p(ctx,context);
	nod_module_t *module = (nod_module_t*) ctx->module;
	return module->parent.name;
}