diff options
| author | Manuel Traut <manut@mecka.net> | 2013-01-14 10:38:45 +0100 |
|---|---|---|
| committer | Manuel Traut <manut@mecka.net> | 2013-01-14 10:38:45 +0100 |
| commit | f8b3b3b854ad05329c73d5b98fa24916a270de65 (patch) | |
| tree | 2e0b7927770f3be7ec27d90f77d788f93994aca7 | |
| parent | 78da4fbc47c296a5f7b04865677398c672fd6895 (diff) | |
add direction attribute to IOs
is quiet useful to get an idea via IDL if it's an input or output
Signed-off-by: Manuel Traut <manut@mecka.net>
| -rw-r--r-- | interfaces/distrio_io.idl | 9 | ||||
| -rw-r--r-- | io/lib/distrio_io.cpp | 20 | ||||
| -rw-r--r-- | io/lib/distrio_io.h | 14 |
3 files changed, 39 insertions, 4 deletions
diff --git a/interfaces/distrio_io.idl b/interfaces/distrio_io.idl index 42da67d..67e6d9c 100644 --- a/interfaces/distrio_io.idl +++ b/interfaces/distrio_io.idl @@ -22,6 +22,11 @@ module Distrio { TRIGGER_FALLING_EDGE }; + enum Direction { + INPUT, + OUTPUT + }; + /** a digital input or output pin */ interface Digital { /** get the name of the hardware which is connected to this pin */ @@ -34,6 +39,8 @@ module Distrio { Distrio::Error get (out long value); /** register a callback that is called if the state of the pin changes */ Distrio::Error register_callback (in Device dev, in Digital_trigger trigger); + /** returns direction of digital IO */ + Distrio::Direction direction (); /** stores a timestamp of the last update of the referenced value */ attribute Distrio::Timestamp last_update; /** the id is given by Distrio::Manager during registration */ @@ -64,6 +71,8 @@ module Distrio { Distrio::Error get (out long value); /** register a callback that is called if the trigger matches */ Distrio::Error register_callback (in Device dev, in Analog_trigger trigger); + /** returns direction of analog IO */ + Distrio::Direction direction (); /** stores a timestamp of the last update of the referenced value */ attribute Distrio::Timestamp last_update; /** the id is given by Distrio::Manager during registration */ diff --git a/io/lib/distrio_io.cpp b/io/lib/distrio_io.cpp index ecf703a..fee698b 100644 --- a/io/lib/distrio_io.cpp +++ b/io/lib/distrio_io.cpp @@ -32,9 +32,11 @@ #include <distrio_error.h> -Distrio_Digital_i::Distrio_Digital_i (std::string _name) +Distrio_Digital_i::Distrio_Digital_i (std::string _name, + ::Distrio::Direction _dir) { io_name = _name; + dir = _dir; val = -1; } @@ -125,6 +127,12 @@ void Distrio_Digital_i::update_timestamp () { ts.nanoseconds = _ts.tv_nsec; } +::Distrio::Direction Distrio_Digital_i::direction ( + void) +{ + return dir; +} + ::Distrio::Timestamp Distrio_Digital_i::last_update ( void) { @@ -149,10 +157,12 @@ void Distrio_Digital_i::id ( io_id = _id; } -Distrio_Analog_i::Distrio_Analog_i (std::string _name) +Distrio_Analog_i::Distrio_Analog_i (std::string _name, Distrio::Direction _dir) { + dir = _dir; io_name = _name; } + // Implementation skeleton constructor Distrio_Analog_i::Distrio_Analog_i (void) { @@ -222,6 +232,12 @@ void Distrio_Analog_i::last_update ( // Add your implementation here } +::Distrio::Direction Distrio_Analog_i::direction ( + void) +{ + return dir; +} + ::CORBA::Long Distrio_Analog_i::id ( void) { diff --git a/io/lib/distrio_io.h b/io/lib/distrio_io.h index c989508..997e305 100644 --- a/io/lib/distrio_io.h +++ b/io/lib/distrio_io.h @@ -44,7 +44,7 @@ class Distrio_Digital_i { public: // Constructor - Distrio_Digital_i (std::string _name); + Distrio_Digital_i (std::string _name, ::Distrio::Direction _dir); Distrio_Digital_i (void); // Destructor @@ -72,6 +72,10 @@ public: ::Distrio::Digital_trigger trigger); virtual + ::Distrio::Direction direction ( + void); + + virtual ::Distrio::Timestamp last_update ( void); @@ -102,6 +106,7 @@ private: std::list<Distrio::Device_ptr> cb_list_rise; std::list<Distrio::Device_ptr> cb_list_fall; ::Distrio::Timestamp ts; + ::Distrio::Direction dir; }; class Distrio_Analog_i @@ -109,7 +114,7 @@ class Distrio_Analog_i { public: // Constructor - Distrio_Analog_i (std::string _name); + Distrio_Analog_i (std::string _name, ::Distrio::Direction _dir); Distrio_Analog_i (void); // Destructor @@ -141,6 +146,10 @@ public: const ::Distrio::Analog_trigger & trigger); virtual + ::Distrio::Direction direction ( + void); + + virtual ::Distrio::Timestamp last_update ( void); @@ -157,6 +166,7 @@ public: ::CORBA::Long id); private: std::string io_name; + ::Distrio::Direction dir; ::CORBA::Long io_id; }; |
