var_t oesr_var_param_create_remote(void *context, int module_idx, char *name, int size) { oesr_context_t *ctx = context; OESR_ASSERT_PARAM_P(name); sdebug("remote_idx=%d name=%s, size=%d\n",module_idx,name,size); OESR_ASSERT_PARAM_P(module_idx); OESR_ASSERT_PARAM_P(size>=0); nod_module_t *my_module = ctx->module; nod_waveform_t *waveform = (nod_waveform_t*) my_module->parent.waveform; nod_module_t *his_module = (nod_module_t*) &waveform->modules[module_idx]; return (var_t) nod_module_variable_create(his_module, name, size); }
/** * Initializes a counter object. This function is called by the oesr_counter_create(). * It calls nod_module_variable_create() to create a new module variable, which is associated to the * counter. Then uses nod_variable_init() to allocate the memory. */ int oesr_counter_init(void *context, oesr_counter_t *counter, string name) { sdebug("context=0x%x, counter_id=%d, name=%s\n",context,counter->id,name); oesr_context_t *ctx = context; nod_module_t *module = ctx->module; OESR_ASSERT_PARAM(counter); OESR_ASSERT_PARAM(name); variable_t *variable = nod_module_variable_create(module, name,0); if (!variable) { return -1; } variable->size = sizeof(int); variable->cur_value = &counter->count[0].tv_usec; sdebug("variable_id=%d, addr=0x%x\n",variable->id,variable->cur_value); counter->variable = variable; counter->context = ctx; return 0; }
/** * Creates a new public variable with a given name. After this call size bytes of the buffer ptr may be * accessible by other modules or ALOE (through the OESR Manager API) for either read or write. * * \param context OESR context pointer * \param name Name of the variable. This name will be used by other modules or the OESR Manager API to * view/modify the variable value * \param ptr Pointer to the user memory where the variable is located * \param size Size of the variable * \return On success, oesr_var_create() returns a non-null handler which is passed as a first parameter * to oesr_var_close() to close the public variable. * */ var_t oesr_var_create(void *context, char *name, void *ptr, int size) { oesr_context_t *ctx = context; nod_module_t *module = ctx->module; OESR_ASSERT_PARAM_P(name); sdebug("name=%s, size=%d, ptr=0x%x\n",name,size,ptr); OESR_ASSERT_PARAM_P(module); OESR_ASSERT_PARAM_P(size>0); OESR_ASSERT_PARAM_P(ptr); variable_t *variable; variable = nod_module_variable_get(module, name); if (!variable) { variable = nod_module_variable_create(module, name,0); if (!variable) { return NULL; } } variable->size = size; variable->cur_value = ptr; return 0; }