return get_item(sensors, addr).state;
}
+float ArduControl::get_telemetry_value(const string &name) const
+{
+ throw key_error(name);
+}
+
void ArduControl::tick()
{
Tag tag;
virtual void set_sensor(unsigned, bool) { }
virtual bool get_sensor(unsigned) const;
+ virtual const TelemetryInfo *enumerate_telemetry(unsigned) const { return 0; }
+ virtual float get_telemetry_value(const std::string &) const;
+
virtual void tick();
virtual void flush();
private:
#include <algorithm>
+#include <msp/core/maputils.h>
#include <msp/core/refptr.h>
#include <msp/io/print.h>
#include <msp/net/resolve.h>
return false;
}
+float CentralStation::get_telemetry_value(const string &name) const
+{
+ throw key_error(name);
+}
+
void CentralStation::tick()
{
while(Message msg = receive())
virtual void set_sensor(unsigned, bool) { }
virtual bool get_sensor(unsigned) const;
+ virtual const TelemetryInfo *enumerate_telemetry(unsigned) const { return 0; }
+ virtual float get_telemetry_value(const std::string &) const;
+
virtual void tick();
virtual void flush();
std::string name;
};
+ struct TelemetryInfo
+ {
+ const char *name;
+ const char *label;
+ const char *unit;
+ unsigned precision;
+ };
+
sigc::signal<void, bool> signal_power;
sigc::signal<void, bool> signal_halt;
sigc::signal<void, const DetectedLocomotive &> signal_locomotive_detected;
virtual void set_sensor(unsigned, bool) = 0;
virtual bool get_sensor(unsigned) const = 0;
+ virtual const TelemetryInfo *enumerate_telemetry(unsigned) const = 0;
+ virtual float get_telemetry_value(const std::string &) const = 0;
+
virtual void tick() = 0;
virtual void flush() = 0;
#include <cstdlib>
+#include <msp/core/maputils.h>
#include <msp/strings/utils.h>
#include <msp/time/utils.h>
#include "dummy.h"
return false;
}
+float Dummy::get_telemetry_value(const string &name) const
+{
+ throw key_error(name);
+}
+
void Dummy::tick()
{
Time::TimeStamp t = Time::now();
virtual void set_sensor(unsigned, bool);
virtual bool get_sensor(unsigned) const;
+ virtual const TelemetryInfo *enumerate_telemetry(unsigned) const { return 0; }
+ virtual float get_telemetry_value(const std::string &) const;
+
virtual void tick();
virtual void flush() { }
};
#include <fcntl.h>
#include <termios.h>
#include <sys/poll.h>
+#include <msp/core/maputils.h>
#include <msp/io/print.h>
#include <msp/time/units.h>
#include <msp/time/utils.h>
return false;
}
+float Intellibox::get_telemetry_value(const string &name) const
+{
+ throw key_error(name);
+}
+
void Intellibox::tick()
{
const Time::TimeStamp t = Time::now();
virtual void set_sensor(unsigned, bool) { }
virtual bool get_sensor(unsigned) const;
+ virtual const TelemetryInfo *enumerate_telemetry(unsigned) const { return 0; }
+ virtual float get_telemetry_value(const std::string &) const;
+
virtual void tick();
virtual void flush();