From f8b3b3b854ad05329c73d5b98fa24916a270de65 Mon Sep 17 00:00:00 2001 From: Manuel Traut Date: Mon, 14 Jan 2013 10:38:45 +0100 Subject: 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 --- interfaces/distrio_io.idl | 9 +++++++++ io/lib/distrio_io.cpp | 20 ++++++++++++++++++-- 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_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 @@ -71,6 +71,10 @@ public: ::Distrio::Device_ptr dev, ::Distrio::Digital_trigger trigger); + virtual + ::Distrio::Direction direction ( + void); + virtual ::Distrio::Timestamp last_update ( void); @@ -102,6 +106,7 @@ private: std::list cb_list_rise; std::list 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 @@ -140,6 +145,10 @@ public: ::Distrio::Device_ptr dev, 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; }; -- cgit v1.2.3