copied everything over from 2012 and removed all of the actual robot code except the drivetrain stuff
git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4078 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/aos/common/input/SensorInput-tmpl.h b/aos/common/input/SensorInput-tmpl.h
new file mode 100644
index 0000000..e92a923
--- /dev/null
+++ b/aos/common/input/SensorInput-tmpl.h
@@ -0,0 +1,41 @@
+#include "aos/common/input/SensorInput.h"
+#ifndef __VXWORKS__
+#include "aos/common/network/ReceiveSocket.h"
+#include "aos/common/Configuration.h"
+#endif
+
+namespace aos {
+
+#ifdef __VXWORKS__
+template<class Values> SEM_ID SensorInput<Values>::lock_ = semBCreate(SEM_Q_PRIORITY, SEM_FULL);
+template<class Values> std::vector<SensorInput<Values> *> SensorInput<Values>::running_;
+#endif
+template<class Values> void SensorInput<Values>::Run() {
+#ifndef __VXWORKS__
+ ReceiveSocket sock(NetworkPort::kSensors);
+ Values values;
+ while (true) {
+ if (sock.Recv(&values, sizeof(values)) == -1) {
+ LOG(WARNING, "socket receive failed\n");
+ continue;
+ }
+ RunIteration(values);
+ }
+#else
+ semTake(lock_, WAIT_FOREVER);
+ running_.push_back(this);
+ semGive(lock_);
+#endif
+}
+
+#ifdef __VXWORKS__
+template<class Values> void SensorInput<Values>::RunIterationAll(Values &vals) {
+ semTake(lock_, WAIT_FOREVER);
+ for (auto it = running_.begin(); it != running_.end(); ++it) {
+ (*it)->RunIteration(vals);
+ }
+ semGive(lock_);
+}
+#endif
+
+} // namespace aos