source: finroc_plugins_runtime_construction/tAdministrationService.h @ 94:20a1183cbd09

17.03
Last change on this file since 94:20a1183cbd09 was 94:20a1183cbd09, checked in by Max Reichardt <mreichardt@…>, 6 years ago

Adds GetRegisterUpdates function to AdministrationService

File size: 10.8 KB
Line 
1//
2// You received this file as part of Finroc
3// A framework for intelligent robot control
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this program; if not, write to the Free Software Foundation, Inc.,
19// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20//
21//----------------------------------------------------------------------
22/*!\file    plugins/runtime_construction/tAdministrationService.h
23 *
24 * \author  Max Reichardt
25 *
26 * \date    2012-12-02
27 *
28 * \brief   Contains tAdministrationService
29 *
30 * \b tAdministrationService
31 *
32 * Service for administration.
33 * It provides functions to create, modify and delete Finroc elements such
34 * as groups, modules, ports and port connections at application runtime.
35 * One port needs to be created to be able to edit application
36 * structure using finstruct (currently done in dynamic_loading.cpp)
37 *
38 */
39//----------------------------------------------------------------------
40#ifndef __plugins__runtime_construction__tAdministrationService_h__
41#define __plugins__runtime_construction__tAdministrationService_h__
42
43//----------------------------------------------------------------------
44// External includes (system with <>, local with "")
45//----------------------------------------------------------------------
46#include "rrlib/serialization/tRegisterUpdate.h"
47#include "plugins/rpc_ports/tServerPort.h"
48
49//----------------------------------------------------------------------
50// Internal includes with ""
51//----------------------------------------------------------------------
52
53//----------------------------------------------------------------------
54// Namespace declaration
55//----------------------------------------------------------------------
56namespace finroc
57{
58namespace runtime_construction
59{
60
61//----------------------------------------------------------------------
62// Forward declarations / typedefs / enums
63//----------------------------------------------------------------------
64
65//----------------------------------------------------------------------
66// Class declaration
67//----------------------------------------------------------------------
68//! Service for administration
69/*!
70 * Service for administration.
71 * It provides functions to create, modify and delete Finroc elements such
72 * as groups, modules, ports and port connections at application runtime.
73 * One port needs to be created to be able to edit application
74 * structure using finstruct (currently done in dynamic_loading.cpp)
75 */
76class tAdministrationService : public rpc_ports::tRPCInterface
77{
78
79//----------------------------------------------------------------------
80// Public methods and typedefs
81//----------------------------------------------------------------------
82public:
83
84  /*!
85   * Return values for IsExecuting
86   */
87  enum class tExecutionStatus
88  {
89    NONE,
90    PAUSED,
91    RUNNING,
92    BOTH
93  };
94
95
96  tAdministrationService();
97
98  ~tAdministrationService();
99
100
101  /*!
102   * (superseded by ConnectPorts)
103   * Connect source port to destination port
104   *
105   * \param source_port_handle Handle of source port
106   * \param destination_port_handle Handle of destination port
107   */
108  void Connect(int source_port_handle, int destination_port_handle);
109
110  /*!
111   * Connect source port to destination port with connect options
112   * (new connect method)
113   *
114   * \param source_port_handle Handle of source port
115   * \param destination_port_handle Handle of destination port
116   * \param connect_options Connect options
117   * \return Returns error message if connecting failed. On success an empty string is returned.
118   */
119  std::string ConnectPorts(int source_port_handle, int destination_port_handle, const core::tConnectOptions& connect_options);
120
121  /*!
122   * Instantiates port for administration
123   */
124  static void CreateAdministrationPort();
125
126  /*!
127   * Created module
128   *
129   * \param create_action_index Index of create action
130   * \param module_name Name to give new module
131   * \param parent_handle Handle of parent element
132   * \param serialized_creation_parameters Serialized constructor parameters in case the module requires such - otherwise empty
133   * \return Empty string if it worked - otherwise error message
134   */
135  std::string CreateModule(uint32_t create_action_index, const std::string& module_name, int parent_handle, const rrlib::serialization::tMemoryBuffer& serialized_creation_parameters);
136
137  /*!
138   * Create URI connector connecting local port using one of the supported URI schemes (provided e.g. by network transports).
139   *
140   * \param local_port_handle Handle of local owner port
141   * \param uri URI of partner port
142   * \param connect_options Connect options
143   * \return Returns error message if connecting failed. On success an empty string is returned.
144   */
145  std::string CreateUriConnector(int local_port_handle, const rrlib::uri::tURI& uri, const core::tUriConnectOptions& connect_options);
146
147  /*!
148   * Deletes specified framework element
149   *
150   * \param element_handle Handle of framework element
151   */
152  void DeleteElement(int element_handle);
153
154  /*!
155   * Delete URI connector
156   *
157   * \param local_port_handle Handle of local owner port
158   * \param index Index of URI connector in owner port's list
159   * \return Whether any connector was deleted
160   */
161  bool DeleteUriConnector(int local_port_handle, uint index);
162
163  /*!
164   * Disconnect the two ports
165   *
166   * \param source_port_handle Handle of source port
167   * \param destination_port_handle Handle of destination port
168   */
169  void Disconnect(int source_port_handle, int destination_port_handle);
170
171  /*!
172   * Disconnect all ports from port with specified handle
173   *
174   * \param port_handle Port handle
175   */
176  void DisconnectAll(int port_handle);
177
178  /*!
179   * Retrieve annotation from specified framework element
180   *
181   * \param element_handle Handle of framework element
182   * \param annotation_type_name Name of annotation type
183   * \return Serialized annotation
184   */
185  rrlib::serialization::tMemoryBuffer GetAnnotation(int element_handle, const std::string& annotation_type_name);
186
187  /*!
188   * (superseded by GetRegisterUpdates)
189   *
190   * \return All actions for creating framework element currently registered in this runtime environment - serialized
191   */
192  rrlib::serialization::tMemoryBuffer GetCreateModuleActions();
193
194  /*!
195   * \return Available module libraries (.so files) that have not been loaded yet - serialized
196   */
197  rrlib::serialization::tMemoryBuffer GetModuleLibraries();
198
199  /*!
200   * \param root_element_handle Handle of root element to get parameter info below of
201   * \return Serialized parameter info
202   */
203  rrlib::serialization::tMemoryBuffer GetParameterInfo(int root_element_handle);
204
205  /*!
206   * Gets all updates on specified register and all registers to be updated on change.
207   * After calling this method, the client's data on these remote registers is up to date.
208   *
209   * \param register_uid Uid of register to obtain updates for
210   * \return Updates (object does not need to be processed - does its work during deserialization)
211   */
212  rrlib::serialization::tRegisterUpdate GetRegisterUpdates(int register_uid);
213
214  /*!
215   * \param element_handle Handle of framework element
216   * \return Is specified framework element currently executing?
217   */
218  tExecutionStatus IsExecuting(int element_handle);
219
220  /*!
221   * Dynamically loads specified module library (.so file)
222   *
223   * \param library_name File name of library to load
224   * \return Empty memory buffer (used to be buffer with all actions for creating framework element currently registered in this runtime environment - serialized)
225   */
226  rrlib::serialization::tMemoryBuffer LoadModuleLibrary(const std::string& library_name);
227
228  /*!
229   * (superseded by CreateUriConnector)
230   *
231   * Connect local port to port in remote runtime environment using one of the
232   * available network transport plugins.
233   *
234   * \param local_port_handle Handle of local port
235   * \param preferred_transport ID of preferred network transport to be used (e.g. "tcp"). If specified, it will be attempted to create the connection using this transport first.
236   * \param remote_runtime_uuid UUID of remote runtime
237   * \param remote_port_handle Handle of remote port
238   * \param remote_port_link Link of port in remote runtime environment
239   * \param disconnect If 'false' the ports are connected - if 'true' the ports are disconnected
240   * \return Returns error message if connecting failed. On success an empty string is returned.
241   */
242  std::string NetworkConnect(int local_port_handle, const std::string& preferred_transport, const std::string& remote_runtime_uuid,
243                             int remote_port_handle, const std::string& remote_port_link, bool disconnect);
244
245  /*!
246   * Pauses execution of tasks in specified framework element
247   * (possibly its parent thread container - if there is no such, then all children)
248   *
249   * \param element_handle Handle of framework element
250   */
251  void PauseExecution(int element_handle);
252
253  /*!
254   * Saves all finstructable files in this runtime environment
255   */
256  void SaveAllFinstructableFiles();
257
258  /*!
259   * Save contents finstructable group to xml file
260   *
261   * \param group_handle Handle of group to save
262   */
263  void SaveFinstructableGroup(int group_handle);
264
265  /*!
266   * Set/change annotation of specified framework element
267   *
268   * \param element_handle Handle of framework element
269   * \param serialized_annotation Serialized annotation (including type of annotation)
270   */
271  void SetAnnotation(int element_handle, const rrlib::serialization::tMemoryBuffer& serialized_annotation);
272
273  /*!
274   * Set value of port
275   *
276   * \param port_handle Port handle
277   * \param serialized_new_value New value - serialized
278   * \return Empty string if it worked - otherwise error message
279   */
280  std::string SetPortValue(int port_handle, const rrlib::serialization::tMemoryBuffer& serialized_new_value);
281
282  /*!
283   * Starts executing tasks in specified framework element
284   * (possibly its parent thread container - if there is no such, then all children)
285   *
286   * \param element_handle Handle of framework element
287   */
288  void StartExecution(int element_handle);
289
290//----------------------------------------------------------------------
291// Private fields and methods
292//----------------------------------------------------------------------
293private:
294
295};
296
297//----------------------------------------------------------------------
298// End of namespace declaration
299//----------------------------------------------------------------------
300}
301}
302
303
304#endif
Note: See TracBrowser for help on using the repository browser.