summaryrefslogtreecommitdiff
path: root/code/core/tracepoints.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'code/core/tracepoints.cpp')
-rw-r--r--code/core/tracepoints.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/code/core/tracepoints.cpp b/code/core/tracepoints.cpp
new file mode 100644
index 0000000..7243f1c
--- /dev/null
+++ b/code/core/tracepoints.cpp
@@ -0,0 +1,57 @@
+#include "event.h"
+#include "regex.h"
+
+#include "simulate.h"
+
+/* input event streams */
+
+template<class T>
+static void FileInputEvent<T>::CreateInputStream(InputInterface<T> *iface) {
+ double time = iface->peekNextTime();
+ if (time == INFINITY) {
+ delete iface;
+ return;
+ }
+ if (time < s.currentTime) {
+ DIE("tried to include a file with events of the past");
+ }
+ s.addEvent(new FileInputEvent(iface, time));
+}
+
+template<class T>
+void FileInputEvent<T>::vexecute() {
+ iface->readFileUntil(time);
+ CreateInputStream(iface);
+}
+
+/* command loop */
+
+bool executeTracepoints() {
+ // the main loop of the program
+ char *str = NULL;
+ size_t _foo;
+
+ // loop over trace commands
+ while (getline(&str, &_foo, stdin) > 0) {
+ // parse request
+ if (!regex::parseRequest(str))
+ DIE("Invalid tracepoint format");
+
+ // proceed time if a run command was given
+ if (regex::targetTimeOffset != 0.0) {
+ if (!s.proceedTime(s.currentTime + tracepoints::targetTimeOffset))
+ fprintf(stderr, "Warning: network is dead\n");
+ // reset target time
+ targetTimeOffset = 0.0;
+ // reset spike output list
+ BOOST_FOREARCH(SpikeMUX *i, s.spikeOIfList) { delete i; }
+ s.spikeOIfList.empty();
+ }
+
+
+ free(str);
+ str = NULL;
+ }
+
+ return true;
+}
contact: Jan Huwald // Impressum