Rev 1633 | Rev 1644 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1633 | Rev 1642 | ||
|---|---|---|---|
| Line 16... | Line 16... | ||
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
18 | * |
| 19 | */ |
19 | */ |
| 20 | 20 | ||
| 21 | #ifndef |
21 | #ifndef CONTROL_MANAGER_H |
| 22 | #define |
22 | #define CONTROL_MANAGER_H |
| 23 | 23 | ||
| 24 | #include <map> |
24 | #include <map> |
| 25 | #include <string> |
25 | #include <string> |
| 26 | 26 | ||
| 27 | #include <boost/shared_ptr.hpp> |
27 | #include <boost/shared_ptr.hpp> |
| Line 29... | Line 29... | ||
| 29 | 29 | ||
| 30 | #include "logging/Logger.h" |
30 | #include "logging/Logger.h" |
| 31 | #include "broker/Subscriber.h" |
31 | #include "broker/Subscriber.h" |
| 32 | 32 | ||
| 33 | #include "timer/Subscriber.h" |
33 | #include "timer/Subscriber.h" |
| 34 | #include " |
34 | #include "common/common.h" |
| 35 | 35 | ||
| 36 | #include "Node.h" |
36 | #include "Node.h" |
| 37 | #include "Module.h" |
37 | #include "Module.h" |
| 38 | #include "Message.h" |
38 | #include "can/Message.h" |
| 39 | 39 | ||
| 40 | namespace atom { |
40 | namespace atom { |
| 41 | namespace |
41 | namespace control { |
| 42 | 42 | ||
| 43 | class Manager : public broker::Subscriber, public timer::Subscriber |
43 | class Manager : public broker::Subscriber, public timer::Subscriber |
| 44 | { |
44 | { |
| 45 | public: |
45 | public: |
| 46 | typedef boost::shared_ptr<Manager> Pointer; |
46 | typedef boost::shared_ptr<Manager> Pointer; |
| 47 | typedef std::map<Node::Id, Node::Pointer> NodeList; |
47 | typedef std::map<Node::Id, Node::Pointer> NodeList; |
| 48 | typedef std::map<Module::FullId, Module::Pointer> ModuleList; |
48 | typedef std::map<Module::FullId, Module::Pointer> ModuleList; |
| 49 | typedef boost::signals2::signal<void(unsigned int node_id, bool available)> SignalOnNodeChange; |
49 | typedef boost::signals2::signal<void(unsigned int node_id, bool available)> SignalOnNodeChange; |
| 50 | typedef boost::signals2::signal<void(std::string full_id, bool available)> SignalOnModuleChange; |
50 | typedef boost::signals2::signal<void(std::string full_id, bool available)> SignalOnModuleChange; |
| 51 | typedef boost::signals2::signal<void(std::string full_id, std::string command, |
51 | typedef boost::signals2::signal<void(std::string full_id, std::string command, common::StringMap variables)> SignalOnModuleMessage; |
| 52 | 52 | ||
| 53 | virtual ~Manager(); |
53 | virtual ~Manager(); |
| 54 | 54 | ||
| 55 | static Pointer Instance(); |
55 | static Pointer Instance(); |
| 56 | static void Create(); |
56 | static void Create(); |
| 57 | static void Delete(); |
57 | static void Delete(); |
| 58 | 58 | ||
| 59 | void ConnectSlots(const SignalOnNodeChange::slot_type& signal_on_node_change_, const SignalOnModuleChange::slot_type& slot_on_module_change, const SignalOnModuleMessage::slot_type& slot_on_module_message); |
59 | void ConnectSlots(const SignalOnNodeChange::slot_type& signal_on_node_change_, const SignalOnModuleChange::slot_type& slot_on_module_change, const SignalOnModuleMessage::slot_type& slot_on_module_message); |
| 60 | 60 | ||
| 61 | void SendMessage(std::string full_id, std::string command, |
61 | void SendMessage(std::string full_id, std::string command, common::StringMap variables); |
| 62 | bool IsModuleAvailable(std::string full_id); |
62 | bool IsModuleAvailable(std::string full_id); |
| - | 63 | bool ProgramNode(Node::Id node_id, bool is_bios, std::string filename); |
|
| 63 | 64 | ||
| 64 | private: |
65 | private: |
| 65 | static Pointer instance_; |
66 | static Pointer instance_; |
| 66 | 67 | ||
| 67 | timer::TimerId timer_id_; |
68 | timer::TimerId timer_id_; |
| Line 78... | Line 79... | ||
| 78 | 79 | ||
| 79 | void SlotOnMessageHandler(broker::Message::Pointer message); |
80 | void SlotOnMessageHandler(broker::Message::Pointer message); |
| 80 | void SlotOnTimeoutHandler(timer::TimerId timer_id, bool repeat); |
81 | void SlotOnTimeoutHandler(timer::TimerId timer_id, bool repeat); |
| 81 | void SlotOnNewState(Node::Id node_id, Node::State current_state, Node::State target_state); |
82 | void SlotOnNewState(Node::Id node_id, Node::State current_state, Node::State target_state); |
| 82 | 83 | ||
| 83 | void SendMessageHandler(std::string full_id, std::string command, |
84 | void SendMessageHandler(std::string full_id, std::string command, common::StringMap variables); |
| 84 | 85 | ||
| 85 | Node::Pointer GetNode(Node::Id node_id); |
86 | Node::Pointer GetNode(Node::Id node_id); |
| 86 | Module::Pointer GetModule(Module::Id module_id, std::string module_name, std::string class_name); |
87 | Module::Pointer GetModule(Module::Id module_id, std::string module_name, std::string class_name); |
| 87 | void RemoveModules(Node::Id node_id); |
88 | void RemoveModules(Node::Id node_id); |
| 88 | unsigned int GetNumberOfModules(Node::Id node_id); |
89 | unsigned int GetNumberOfModules(Node::Id node_id); |
| 89 | 90 | ||
| 90 | logging::Logger LOG; |
91 | logging::Logger LOG; |
| 91 | }; |
92 | }; |
| 92 | 93 | ||
| 93 | }; // namespace |
94 | }; // namespace control |
| 94 | }; // namespace atom |
95 | }; // namespace atom |
| 95 | 96 | ||
| 96 | #endif // |
97 | #endif // CONTROL_MANAGER_H |