Fawkes API  Fawkes Development Version
HardwareModelsInterface.h
1 
2 /***************************************************************************
3  * HardwareModelsInterface.h - Fawkes BlackBoard Interface - HardwareModelsInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2019 Daniel Habering
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. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _INTERFACES_HARDWAREMODELSINTERFACE_H_
25 #define _INTERFACES_HARDWAREMODELSINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(HardwareModelsInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  private:
42  /** Internal data storage, do NOT modify! */
43  typedef struct {
44  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
45  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
46  char error[1024]; /**< Error state of the plugin */
47  bool busy; /**< Busy flag */
48  } HardwareModelsInterface_data_t;
49 
50  HardwareModelsInterface_data_t *data;
51 
52  public:
53  /* messages */
54  class StateChangeMessage : public Message
55  {
56  private:
57  /** Internal data storage, do NOT modify! */
58  typedef struct {
59  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
60  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
61  char component[1024]; /**< The component that changed its state */
62  char transition[1024]; /**< The transition executed by the component */
63  } StateChangeMessage_data_t;
64 
65  StateChangeMessage_data_t *data;
66 
67  public:
68  StateChangeMessage(const char * ini_component, const char * ini_transition);
71 
72  explicit StateChangeMessage(const StateChangeMessage *m);
73  /* Methods */
74  char * component() const;
75  void set_component(const char * new_component);
76  size_t maxlenof_component() const;
77  char * transition() const;
78  void set_transition(const char * new_transition);
79  size_t maxlenof_transition() const;
80  virtual Message * clone() const;
81  };
82 
83  virtual bool message_valid(const Message *message) const;
84  private:
87 
88  public:
89  /* Methods */
90  char * error() const;
91  void set_error(const char * new_error);
92  size_t maxlenof_error() const;
93  bool is_busy() const;
94  void set_busy(const bool new_busy);
95  size_t maxlenof_busy() const;
96  virtual Message * create_message(const char *type) const;
97 
98  virtual void copy_values(const Interface *other);
99  virtual const char * enum_tostring(const char *enumtype, int val) const;
100 
101 };
102 
103 } // end namespace fawkes
104 
105 #endif
fawkes::HardwareModelsInterface::StateChangeMessage::StateChangeMessage
StateChangeMessage()
Constructor.
Definition: HardwareModelsInterface.cpp:186
fawkes::HardwareModelsInterface::StateChangeMessage::~StateChangeMessage
~StateChangeMessage()
Destructor.
Definition: HardwareModelsInterface.cpp:198
fawkes::HardwareModelsInterface::StateChangeMessage::transition
char * transition() const
Get transition value.
Definition: HardwareModelsInterface.cpp:251
fawkes::HardwareModelsInterface::StateChangeMessage::maxlenof_transition
size_t maxlenof_transition() const
Get maximum length of transition value.
Definition: HardwareModelsInterface.cpp:261
fawkes::Message
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:45
fawkes::HardwareModelsInterface::is_busy
bool is_busy() const
Get busy value.
Definition: HardwareModelsInterface.cpp:101
fawkes::HardwareModelsInterface::enum_tostring
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
Definition: HardwareModelsInterface.cpp:154
fawkes::HardwareModelsInterface::StateChangeMessage::component
char * component() const
Get component value.
Definition: HardwareModelsInterface.cpp:221
fawkes::Interface::type
const char * type() const
Get type of interface.
Definition: interface.cpp:643
fawkes::HardwareModelsInterface::set_error
void set_error(const char *new_error)
Set error value.
Definition: HardwareModelsInterface.cpp:91
fawkes::HardwareModelsInterface::message_valid
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Definition: HardwareModelsInterface.cpp:291
fawkes::HardwareModelsInterface::StateChangeMessage::maxlenof_component
size_t maxlenof_component() const
Get maximum length of component value.
Definition: HardwareModelsInterface.cpp:231
fawkes
Fawkes library namespace.
fawkes::HardwareModelsInterface::maxlenof_error
size_t maxlenof_error() const
Get maximum length of error value.
Definition: HardwareModelsInterface.cpp:81
fawkes::HardwareModelsInterface
HardwareModelsInterface Fawkes BlackBoard Interface.
Definition: HardwareModelsInterface.h:34
fawkes::HardwareModelsInterface::StateChangeMessage::set_component
void set_component(const char *new_component)
Set component value.
Definition: HardwareModelsInterface.cpp:241
fawkes::Interface
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
fawkes::HardwareModelsInterface::create_message
virtual Message * create_message(const char *type) const
Create message based on type name.
Definition: HardwareModelsInterface.cpp:128
fawkes::HardwareModelsInterface::StateChangeMessage::clone
virtual Message * clone() const
Clone this message.
Definition: HardwareModelsInterface.cpp:282
fawkes::HardwareModelsInterface::maxlenof_busy
size_t maxlenof_busy() const
Get maximum length of busy value.
Definition: HardwareModelsInterface.cpp:111
fawkes::HardwareModelsInterface::StateChangeMessage::set_transition
void set_transition(const char *new_transition)
Set transition value.
Definition: HardwareModelsInterface.cpp:271
fawkes::HardwareModelsInterface::error
char * error() const
Get error value.
Definition: HardwareModelsInterface.cpp:71
fawkes::HardwareModelsInterface::set_busy
void set_busy(const bool new_busy)
Set busy value.
Definition: HardwareModelsInterface.cpp:121
fawkes::HardwareModelsInterface::StateChangeMessage
StateChangeMessage Fawkes BlackBoard Interface Message.
Definition: HardwareModelsInterface.h:55
fawkes::HardwareModelsInterface::copy_values
virtual void copy_values(const Interface *other)
Copy values from other interface.
Definition: HardwareModelsInterface.cpp:143