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 */
36class ClockPlexilTimeAdapter : public PLEXIL::TimeAdapter,
38{
39public:
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
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
67private:
68 fawkes::Clock * clock_;
69 PlexilTimerThread *timer_;
70};
71
72extern "C" {
73void initFawkesTimeAdapter();
74}
75
76#endif
An interface adapter using standard POSIX time facilities to implement LookupNow and LookupOnChange.
Definition: clock_adapter.h:38
virtual bool reset()
Reset adapter.
virtual void subscribe(const PLEXIL::State &state)
Subscribe to updates for given state.
virtual bool initialize()
Initialize adapter.
virtual bool shutdown()
Shut adapter down.
virtual bool start()
Start adapter.
virtual void setThresholds(const PLEXIL::State &state, double hi, double lo)
Set thresholds for subscription.
virtual void lookupNow(PLEXIL::State const &state, PLEXIL::StateCacheEntry &cacheEntry)
Immediate lookup of value.
virtual bool stop()
Stop adapter.
virtual ~ClockPlexilTimeAdapter()
Destructor.
virtual void timer_event()
Called for timer events.
double getCurrentTime()
Get the current time from the operating system.
ClockPlexilTimeAdapter(PLEXIL::AdapterExecInterface &execInterface)
Constructor.
virtual void unsubscribe(const PLEXIL::State &state)
Unsubscribe from updates.
Callback listener pure virtual class.
Definition: timer_thread.h:38
Timer support class.
Definition: timer_thread.h:29
This is supposed to be the central clock in Fawkes.
Definition: clock.h:35