dol: initial dol commit
[jump.git] / dol / examples / examplewindowedfifo / src / consumer.c
diff --git a/dol/examples/examplewindowedfifo/src/consumer.c b/dol/examples/examplewindowedfifo/src/consumer.c
new file mode 100644 (file)
index 0000000..cf6902a
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+#include "consumer.h"
+
+void consumer_init(DOLProcess *p) {
+    sprintf(p->local->name, "consumer");
+    p->local->index = 0;
+    p->local->len = LENGTH;
+}
+
+int consumer_fire(DOLProcess *p) {
+    float *c;
+    if (p->local->index < p->local->len) {
+        DOL_capture((void*)PORT_IN, &c, sizeof(float), p);
+        printf("%s: %f\n", p->local->name, *c);
+        DOL_consume((void*)PORT_IN, p);
+        p->local->index++;
+    }
+
+    if (p->local->index >= p->local->len) {
+        DOL_detach(p);
+        return -1;
+    }
+
+    return 0;
+}
+