Fawkes API  Fawkes Development Version
clock_adapter.h
1 
2 /***************************************************************************
3  * clock_adapter.h - PLEXIL adapter for Fawkes' clock
4  *
5  * Created: Mon Aug 13 15:13:59 2018
6  * Copyright 2006-2018 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_PLEXIL_CLOCK_ADAPTER_H_
24 #define __PLUGINS_PLEXIL_CLOCK_ADAPTER_H_
25 
26 #include "timer_thread.h"
27 
28 #include <utils/time/clock.h>
29 
30 #include <TimeAdapter.hh>
31 
32 /**
33  * @brief An interface adapter using standard POSIX time facilities
34  * to implement LookupNow and LookupOnChange.
35  */
36 class ClockPlexilTimeAdapter : public PLEXIL::TimeAdapter,
38 {
39 public:
40  ClockPlexilTimeAdapter(PLEXIL::AdapterExecInterface &execInterface);
41  ClockPlexilTimeAdapter(PLEXIL::AdapterExecInterface &execInterface, pugi::xml_node const xml);
42 
43  /// @cond DELETED
44  ClockPlexilTimeAdapter() = delete;
46  ClockPlexilTimeAdapter &operator=(const ClockPlexilTimeAdapter &) = delete;
47  /// @endcond
48 
49  virtual ~ClockPlexilTimeAdapter();
50 
51  double getCurrentTime() throw(PLEXIL::InterfaceError);
52 
53  virtual bool initialize();
54  virtual bool start();
55  virtual bool stop();
56  virtual bool reset();
57  virtual bool shutdown();
58 
59  virtual void lookupNow(PLEXIL::State const &state, PLEXIL::StateCacheEntry &cacheEntry);
60  virtual void subscribe(const PLEXIL::State &state);
61  virtual void unsubscribe(const PLEXIL::State &state);
62  virtual void setThresholds(const PLEXIL::State &state, double hi, double lo);
63  virtual void setThresholds(const PLEXIL::State &state, int32_t hi, int32_t lo);
64 
65  virtual void timer_event();
66 
67 private:
68  fawkes::Clock * clock_;
69  PlexilTimerThread *timer_;
70 };
71 
72 extern "C" {
73 void initFawkesTimeAdapter();
74 }
75 
76 #endif
ClockPlexilTimeAdapter::ClockPlexilTimeAdapter
ClockPlexilTimeAdapter(PLEXIL::AdapterExecInterface &execInterface)
Constructor.
Definition: clock_adapter.cpp:39
ClockPlexilTimeAdapter::~ClockPlexilTimeAdapter
virtual ~ClockPlexilTimeAdapter()
Destructor.
Definition: clock_adapter.cpp:56
ClockPlexilTimeAdapter::lookupNow
virtual void lookupNow(PLEXIL::State const &state, PLEXIL::StateCacheEntry &cacheEntry)
Immediate lookup of value.
Definition: clock_adapter.cpp:122
ClockPlexilTimeAdapter::stop
virtual bool stop()
Stop adapter.
Definition: clock_adapter.cpp:89
ClockPlexilTimeAdapter::timer_event
virtual void timer_event()
Called for timer events.
Definition: clock_adapter.cpp:185
ClockPlexilTimeAdapter::setThresholds
virtual void setThresholds(const PLEXIL::State &state, double hi, double lo)
Set thresholds for subscription.
Definition: clock_adapter.cpp:157
ClockPlexilTimeAdapter::reset
virtual bool reset()
Reset adapter.
Definition: clock_adapter.cpp:103
ClockPlexilTimeAdapter::shutdown
virtual bool shutdown()
Shut adapter down.
Definition: clock_adapter.cpp:112
ClockPlexilTimeAdapter::unsubscribe
virtual void unsubscribe(const PLEXIL::State &state)
Unsubscribe from updates.
Definition: clock_adapter.cpp:146
PlexilTimerThread::CallbackListener
Callback listener pure virtual class.
Definition: timer_thread.h:40
PlexilTimerThread
Definition: timer_thread.h:27
ClockPlexilTimeAdapter::initialize
virtual bool initialize()
Initialize adapter.
Definition: clock_adapter.cpp:64
ClockPlexilTimeAdapter::subscribe
virtual void subscribe(const PLEXIL::State &state)
Subscribe to updates for given state.
Definition: clock_adapter.cpp:137
ClockPlexilTimeAdapter::getCurrentTime
double getCurrentTime()
Get the current time from the operating system.
Definition: clock_adapter.cpp:194
fawkes::Clock
Definition: clock.h:39
ClockPlexilTimeAdapter
An interface adapter using standard POSIX time facilities to implement LookupNow and LookupOnChange.
Definition: clock_adapter.h:35
ClockPlexilTimeAdapter::start
virtual bool start()
Start adapter.
Definition: clock_adapter.cpp:75