diff --git a/gtk/rtbuf_input_widget.c b/gtk/rtbuf_input_widget.c
index 853ca92..f521272 100644
--- a/gtk/rtbuf_input_widget.c
+++ b/gtk/rtbuf_input_widget.c
@@ -108,11 +108,11 @@ rtbuf_input_widget_set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_RTBUF:
priv->rtbuf = g_value_get_pointer(value);
- rtbuf_input_widget_update(widget);
+ rtbuf_input_widget_update_rtbuf_in(widget);
break;
case PROP_IN:
priv->in = g_value_get_int(value);
- rtbuf_input_widget_update(widget);
+ rtbuf_input_widget_update_rtbuf_in(widget);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@@ -195,8 +195,9 @@ rtbuf_input_widget_get_check (RtbufInputWidget *widget)
}
void
-rtbuf_input_widget_update (RtbufInputWidget *widget)
+rtbuf_input_widget_update_rtbuf_in (RtbufInputWidget *widget)
{
+ static const char *sym_double = NULL;
const RtbufInputWidgetPrivate *priv =
rtbuf_input_widget_get_instance_private(widget);
if (priv && priv->rtbuf && priv->in >= 0) {
@@ -205,6 +206,11 @@ rtbuf_input_widget_update (RtbufInputWidget *widget)
assert((long long) priv->in < (long long) proc->in_n);
label = proc->in[priv->in].name;
gtk_label_set_text(GTK_LABEL(priv->label), label);
+ if (!sym_double)
+ sym_double = symbol_intern("double");
+ if (proc->in[priv->in].type->name == sym_double) {
+ printf("%lf\n", proc->in[priv->in].def);
+ }
}
}
diff --git a/gtk/rtbuf_input_widget.h b/gtk/rtbuf_input_widget.h
index c4342ad..5add3ed 100644
--- a/gtk/rtbuf_input_widget.h
+++ b/gtk/rtbuf_input_widget.h
@@ -58,7 +58,7 @@ RtbufInputWidget * rtbuf_input_widget_new (s_rtbuf *rtbuf,
s_rtbuf * rtbuf_input_widget_get_rtbuf (RtbufInputWidget *widget);
unsigned int rtbuf_input_widget_get_in (RtbufInputWidget *widget);
GtkWidget * rtbuf_input_widget_get_check (RtbufInputWidget *widget);
-void rtbuf_input_widget_update (RtbufInputWidget *widget);
+void rtbuf_input_widget_update_rtbuf_in (RtbufInputWidget *widget);
void rtbuf_input_widget_connect (GtkWidget *input,
gpointer data);
void rtbuf_input_widget_connect_check (GtkWidget *input,
diff --git a/librtbuf/include/rtbuf/proc.h b/librtbuf/include/rtbuf/proc.h
index 076ff63..a5eaadf 100644
--- a/librtbuf/include/rtbuf/proc.h
+++ b/librtbuf/include/rtbuf/proc.h
@@ -26,6 +26,7 @@ struct rtbuf_proc_in {
double def;
double min;
double max;
+ unsigned int offset;
};
struct rtbuf_proc_out {
@@ -44,10 +45,12 @@ struct rtbuf_proc {
f_rtbuf_proc *stop;
s_rtbuf_proc_in in[RTBUF_PROC_IN_MAX]; /* inputs */
unsigned int in_n; /* number of inputs */
+ unsigned int in_bytes; /* size of input data in bytes */
s_rtbuf_proc_out out[RTBUF_PROC_OUT_MAX]; /* outputs */
unsigned int out_n; /* number of outputs */
unsigned int out_bytes; /* size of output data in bytes */
s_rtbuf_lib *lib; /* the library this procedure comes from */
+ unsigned int bytes; /* size of buffer data in bytes */
s_data_type type;
s_data_alloc alloc;
};
diff --git a/librtbuf/include/rtbuf/rtbuf.h b/librtbuf/include/rtbuf/rtbuf.h
index a9e48b1..34b45b4 100644
--- a/librtbuf/include/rtbuf/rtbuf.h
+++ b/librtbuf/include/rtbuf/rtbuf.h
@@ -63,6 +63,7 @@ void rtbuf_bind (unsigned int src, unsigned int out,
int rtbuf_out_find (s_rtbuf *rtb, symbol sym);
int rtbuf_data_set (s_rtbuf *rtb, symbol name, void *value,
unsigned int size);
+void *rtbuf_in_unbound_value (s_rtbuf *rtb, unsigned int in);
void rtbuf_sort ();
int rtbuf_start ();
int rtbuf_run ();
diff --git a/librtbuf/include/rtbuf/type.h b/librtbuf/include/rtbuf/type.h
index 76b4e4e..86b848d 100644
--- a/librtbuf/include/rtbuf/type.h
+++ b/librtbuf/include/rtbuf/type.h
@@ -23,7 +23,6 @@
struct rtbuf_type {
symbol name;
s_data_type t;
- s_data_alloc alloc;
};
#define RTBUF_TYPE_MAX 1024
diff --git a/librtbuf/rtbuf.c b/librtbuf/rtbuf.c
index cbab46c..098f33a 100644
--- a/librtbuf/rtbuf.c
+++ b/librtbuf/rtbuf.c
@@ -55,7 +55,10 @@ int rtbuf_new (s_rtbuf_proc *rp)
int i;
s_rtbuf *rtb;
void *data;
- unsigned int j = 0;
+ unsigned int j;
+ static const char *sym_double = NULL;
+ if (!sym_double)
+ sym_double = symbol_intern("double");
assert(rp);
assert(g_rtbuf);
data = data_new(&rp->alloc);
@@ -69,10 +72,19 @@ int rtbuf_new (s_rtbuf_proc *rp)
rtb->data = data;
rtb->flags = 0;
rtb->proc = rp;
+ j = 0;
while (j < RTBUF_PROC_IN_MAX) {
rtb->in[j].rtb = -1;
j++;
}
+ j = 0;
+ while (j < rp->in_n) {
+ if (rp->in[j].type->name == sym_double) {
+ memcpy(rtbuf_in_unbound_value(rtb, j), &rp->in[j].def,
+ sizeof(double));
+ }
+ j++;
+ }
g_rtbuf_sort = 1;
return i;
}
@@ -584,3 +596,16 @@ int rtbuf_err (const char *msg)
fprintf(stderr, "%s\n", msg);
return -1;
}
+
+void * rtbuf_in_unbound_value (s_rtbuf *rtb, unsigned int in)
+{
+ unsigned int offset;
+ void *p;
+ assert(rtb);
+ assert(rtb->proc);
+ assert(in < rtb->proc->in_n);
+ offset = rtb->proc->in[in].offset;
+ assert(offset < rtb->proc->bytes);
+ p = rtb->data + offset;
+ return p;
+}
diff --git a/librtbuf/rtbuf_lib.c b/librtbuf/rtbuf_lib.c
index 3288b90..644f474 100644
--- a/librtbuf/rtbuf_lib.c
+++ b/librtbuf/rtbuf_lib.c
@@ -180,41 +180,55 @@ s_rtbuf_lib * rtbuf_lib_load (const char *name)
return lib;
}
+unsigned int add_padding (unsigned int offset, unsigned int size)
+{
+ unsigned int align = 1;
+ if (size == 2)
+ align = 2;
+ else if (size == 4)
+ align = 4;
+ else if (size == 8)
+ align = 8;
+ else if (size == 16)
+ align = 16;
+ return (offset + align - 1) / align * align;
+}
+
void rtbuf_lib_proc_in_init_proc (s_rtbuf_proc *proc,
s_rtbuf_lib_proc_in *in)
{
unsigned int i = 0;
bzero(proc->in, sizeof(proc->in));
if (in) {
+ unsigned int offset = proc->out_bytes;
while (in->name && i < RTBUF_PROC_IN_MAX) {
s_rtbuf_proc_in *v = &proc->in[i];
+ unsigned int size;
v->name = symbol_intern(in->name);
v->type = rtbuf_type(in->type);
v->def = in->def;
v->min = in->min;
v->max = in->max;
+ assert(v->type);
+ size = (v->type->t.bits + 7) / 8;
+ offset = add_padding(offset, size);
+ v->offset = offset;
+ offset += size;
in++;
i++;
}
assert(i < RTBUF_PROC_IN_MAX);
+ offset = add_padding(offset, 8);
+ proc->in_bytes = offset - proc->out_bytes;
+ proc->bytes = offset;
+ proc->type.bits = offset * 8;
+ proc->type.type = DATA_TYPE_BITS;
+ data_alloc_init(&proc->alloc, &proc->type, RTBUF_INSTANCE_MAX,
+ NULL, NULL);
}
proc->in_n = i;
}
-unsigned int add_padding (unsigned int offset, unsigned int size)
-{
- unsigned int align = 1;
- if (size == 2)
- align = 2;
- else if (size == 4)
- align = 4;
- else if (size == 8)
- align = 8;
- else if (size == 16)
- align = 16;
- return (offset + align - 1) / align * align;
-}
-
void rtbuf_lib_proc_out_init_proc (s_rtbuf_proc *proc,
s_rtbuf_lib_proc_out *out)
{
@@ -224,7 +238,7 @@ void rtbuf_lib_proc_out_init_proc (s_rtbuf_proc *proc,
unsigned int offset = 0;
while (out->name && i < RTBUF_PROC_OUT_MAX) {
s_rtbuf_proc_out *o = &proc->out[i];
- size_t size;
+ unsigned int size;
o->name = symbol_intern(out->name);
o->type = rtbuf_type(out->type);
assert(o->type);
@@ -238,10 +252,6 @@ void rtbuf_lib_proc_out_init_proc (s_rtbuf_proc *proc,
assert(i < RTBUF_PROC_OUT_MAX);
offset = add_padding(offset, 8);
proc->out_bytes = offset;
- proc->type.bits = offset * 8;
- proc->type.type = DATA_TYPE_BITS;
- data_alloc_init(&proc->alloc, &proc->type, RTBUF_INSTANCE_MAX,
- NULL, NULL);
}
proc->out_n = i;
}
@@ -252,8 +262,8 @@ void rtbuf_lib_proc_init_proc (s_rtbuf_proc *proc, s_rtbuf_lib_proc *x)
proc->f = x->f;
proc->start = x->start;
proc->stop = x->stop;
- rtbuf_lib_proc_in_init_proc(proc, x->in);
rtbuf_lib_proc_out_init_proc(proc, x->out);
+ rtbuf_lib_proc_in_init_proc(proc, x->in);
}
void rtbuf_lib_print (const s_rtbuf_lib *lib)