diff options
| author | Manuel Traut <manut@mecka.net> | 2012-06-08 03:47:25 +0200 |
|---|---|---|
| committer | Manuel Traut <manut@mecka.net> | 2012-06-08 03:47:25 +0200 |
| commit | bdf4c406cd80fe0e25df68ef98a8b626093290c4 (patch) | |
| tree | 923352000f983b16c861d1298fa67825cd24045b | |
| parent | bc732c7ab1932fcad66001363bfc999f985470fe (diff) | |
generic_gpio: add io simulator
- used for testing of callbacks to get events without real hw
Signed-off-by: Manuel Traut <manut@mecka.net>
| -rw-r--r-- | io/bin/generic_gpio/generic_gpio.cpp | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/io/bin/generic_gpio/generic_gpio.cpp b/io/bin/generic_gpio/generic_gpio.cpp index 2100e40..35986ea 100644 --- a/io/bin/generic_gpio/generic_gpio.cpp +++ b/io/bin/generic_gpio/generic_gpio.cpp @@ -7,40 +7,54 @@ #include <iostream> -class Io_manager : public ACE_Task < ACE_MT_SYNCH > { - public: - Io_manager () { } - ~Io_manager () { } - - private: - int svc (void) { - while (1) { - /** TODO: implement some cyclic gpio stuff */ - sleep (1); - } - } -}; - class My_digital : public Distrio_Digital_i { public: My_digital (std::string io_name) : Distrio_Digital_i (io_name) { } ::Distrio::Error *set () { + update_timestamp (); + val = 1; std::cout << "set" << std::endl; return distrio_success (); } ::Distrio::Error *reset () { + update_timestamp (); + val = 0; std::cout << "reset" << std::endl; return distrio_success (); } + + ::Distrio::Error *get (::CORBA::Long_out value) { + value = val; + std::cout << "get" << std::endl; + return distrio_success (); + } +}; + +class Io_simulator : public ACE_Task < ACE_MT_SYNCH > { + public: + Io_simulator (My_digital *_io) { io = _io; } + ~Io_simulator () { } + + private: + My_digital *io; + + int svc (void) { + while (1) { + io->raise (); + sleep (3); + io->fall (); + sleep (5); + } + } }; ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int ret = 0; My_digital *digital; - /* Io_manager manager; */ + Io_simulator *sim; if (init_corba (argc, argv)) return -EINVAL; @@ -55,13 +69,11 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) goto out; } - std::cout << "registered id: " << digital->id () << std::endl; + sim = new Io_simulator (digital); - /* TODO: activate if cyclic stuff is needed - manager.activate (); - manager.wait (); - */ + std::cout << "registered id: " << digital->id () << std::endl; + sim->activate (); join_orb (); out: |
