Changes have been pushed for the repository "fawkesrobotics/fawkes".
Clone: https://github.com/fawkesrobotics/fawkes.git Gitweb: https://github.com/fawkesrobotics/fawkes The branch, thofmann/interface-uuids has been created at dbe572b1cf2ec2b6047ecca482aa7704f316c5c2 (commit) https://github.com/fawkesrobotics/fawkes/tree/thofmann/interface-uuids - *Log* --------------------------------------------------------------- commit 3e502810568ae14bed4c4701e9156047b9c0425b Author: Till Hofmann <[email protected]> AuthorDate: Tue Nov 17 16:11:27 2020 +0100 Commit: Till Hofmann <[email protected]> CommitDate: Tue Nov 17 16:11:27 2020 +0100 utils: add Uuid, a thin wrapper to uuid_t This utility class can be used to conveniently create UUID objects, using libuuid. https://github.com/fawkesrobotics/fawkes/commit/3e5028105 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit b9f63ca6061a7fbe8edb8fd03856d8b09f3839b4 Author: Till Hofmann <[email protected]> AuthorDate: Tue Nov 17 16:15:30 2020 +0100 Commit: Till Hofmann <[email protected]> CommitDate: Tue Nov 17 16:15:30 2020 +0100 interface: make the interface serial a UUID This allows us to use the same serial across multiple fawkes instances, e.g., if they are connected via the network. https://github.com/fawkesrobotics/fawkes/commit/b9f63ca60 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit 8bcb345fbe7a04d85084d227bdbc5458226facac Author: Till Hofmann <[email protected]> AuthorDate: Tue Nov 17 16:16:20 2020 +0100 Commit: Till Hofmann <[email protected]> CommitDate: Tue Nov 17 16:16:20 2020 +0100 blackboard: adapt to the interface serial being a uuid https://github.com/fawkesrobotics/fawkes/commit/8bcb345fb - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit 25099f94bf8d528fd4c35dd4489310e6fb0c06ad Author: Till Hofmann <[email protected]> AuthorDate: Tue Nov 17 16:21:50 2020 +0100 Commit: Till Hofmann <[email protected]> CommitDate: Tue Nov 17 16:22:26 2020 +0100 interfaces: adapt to the interface serial being a uuid https://github.com/fawkesrobotics/fawkes/commit/25099f94b - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit 7f0fa6b22e8bf157b02f5f20cf52717110cbc3ba Author: Till Hofmann <[email protected]> AuthorDate: Tue Nov 17 16:22:44 2020 +0100 Commit: Till Hofmann <[email protected]> CommitDate: Tue Nov 17 16:22:44 2020 +0100 clips: adapt to the interface serial being a uuid https://github.com/fawkesrobotics/fawkes/commit/7f0fa6b22 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit 81027528253336eb287e3ee133c3f958c6fa762d Author: Till Hofmann <[email protected]> AuthorDate: Tue Nov 17 16:23:01 2020 +0100 Commit: Till Hofmann <[email protected]> CommitDate: Tue Nov 17 16:23:01 2020 +0100 eclipse-clp: adapt to the interface serial being a uuid https://github.com/fawkesrobotics/fawkes/commit/810275282 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit d73780d6d67595b6c6e12a93d640852f1bb1cca8 Author: Till Hofmann <[email protected]> AuthorDate: Tue Nov 17 17:11:24 2020 +0100 Commit: Till Hofmann <[email protected]> CommitDate: Tue Nov 17 17:11:24 2020 +0100 skiller-simulator: adapt to the interface serial being a uuid https://github.com/fawkesrobotics/fawkes/commit/d73780d6d - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - commit dbe572b1cf2ec2b6047ecca482aa7704f316c5c2 Author: Till Hofmann <[email protected]> AuthorDate: Tue Nov 17 17:12:17 2020 +0100 Commit: Till Hofmann <[email protected]> CommitDate: Tue Nov 17 17:12:17 2020 +0100 skiller: adapt to the interface serial being a uuid https://github.com/fawkesrobotics/fawkes/commit/dbe572b1c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *Summary* ----------------------------------------------------------- etc/buildsys/interface.mk | 4 +-- src/libs/Makefile | 2 +- src/libs/blackboard/interface_listener.cpp | 16 +++++----- src/libs/blackboard/interface_listener.h | 12 +++----- src/libs/blackboard/internal/interface_manager.cpp | 16 +--------- src/libs/blackboard/internal/interface_manager.h | 3 +- src/libs/blackboard/internal/notifier.cpp | 8 ++--- src/libs/blackboard/internal/notifier.h | 13 ++++----- src/libs/blackboard/net/handler.cpp | 18 ++++++------ src/libs/blackboard/net/handler.h | 11 +++---- src/libs/blackboard/net/interface_listener.cpp | 30 +++++++++---------- src/libs/blackboard/net/interface_listener.h | 14 ++++----- src/libs/blackboard/net/interface_proxy.cpp | 34 +++++++++++----------- src/libs/blackboard/net/interface_proxy.h | 21 +++++++------ src/libs/blackboard/net/messages.h | 12 ++++---- src/libs/blackboard/remote.cpp | 24 +++++++-------- src/libs/blackboard/remote.h | 21 ++++++------- src/libs/interface/Makefile | 2 +- src/libs/interface/interface.cpp | 6 ++-- src/libs/interface/interface.h | 13 +++++---- src/libs/interface/interface.tolua | 2 +- src/libs/interface/message.cpp | 3 +- src/libs/interface/message.h | 15 +++++----- src/libs/interface/message.tolua | 2 +- src/libs/interfaces/SkillerInterface.xml | 2 +- src/libs/interfaces/generator/tolua_generator.cpp | 4 +-- src/plugins/clips/clips/blackboard.clp | 2 +- src/plugins/clips/feature_blackboard.cpp | 8 ++--- src/plugins/eclipse-clp/externals/blackboard.cpp | 2 +- src/plugins/skiller-simulator/exec_thread.cpp | 8 ++--- src/plugins/skiller/rest-api/api.yaml | 3 +- src/plugins/skiller/rest-api/model/Skill.cpp | 6 ++-- src/plugins/skiller/rest-api/model/Skill.h | 8 ++--- 33 files changed, 161 insertions(+), 184 deletions(-) - *Diffs* ------------------------------------------------------------- - *commit* 3e502810568ae14bed4c4701e9156047b9c0425b - - - - - - - - - - Author: Till Hofmann <[email protected]> Date: Tue Nov 17 16:11:27 2020 +0100 Subject: utils: add Uuid, a thin wrapper to uuid_t src/libs/utils/Makefile | 4 +- .../tests}/Makefile | 39 ++++----- .../utils/tests/catch2_main.cpp} | 14 ++-- src/libs/utils/tests/test_uuid.cpp | 77 +++++++++++++++++ src/libs/utils/uuid.cpp | 98 ++++++++++++++++++++++ .../{syncpoint/syncpoint_call.h => utils/uuid.h} | 39 +++++---- 6 files changed, 216 insertions(+), 55 deletions(-) _Diff for modified files_: diff --git a/src/libs/utils/Makefile b/src/libs/utils/Makefile index 0538ac783..01adfaa2f 100644 --- a/src/libs/utils/Makefile +++ b/src/libs/utils/Makefile @@ -18,7 +18,7 @@ include $(BASEDIR)/etc/buildsys/config.mk include $(BUILDSYSDIR)/lua.mk include $(BASEDIR)/etc/buildsys/boost.mk -FILTER_OUT=%_tolua.o +FILTER_OUT=%_tolua.o tests/% REQ_BOOST_LIBS = asio system HAVE_BOOST_LIBS = $(call boost-have-libs,$(REQ_BOOST_LIBS)) @@ -31,7 +31,7 @@ else WARN_TARGETS += warning_libmagic endif -LIBS_libfawkesutils = stdc++ m rt fawkescore fawkeslogging $(LIBS_LIBMAGIC) $(if $(filter-out Darwin,$(OS)),rt) $(if $(filter Linux,$(OS)),dl pthread) +LIBS_libfawkesutils = stdc++ m rt fawkescore fawkeslogging $(LIBS_LIBMAGIC) $(if $(filter-out Darwin,$(OS)),rt) $(if $(filter Linux,$(OS)),dl pthread) uuid OBJS_libfawkesutils = $(filter-out $(FILTER_OUT),$(patsubst %.cpp,%.o,$(patsubst qa/%,,$(subst $(SRCDIR)/,,$(realpath $(wildcard $(SRCDIR)/*.cpp $(SRCDIR)/*/*.cpp $(SRCDIR)/*/*/*.cpp)))))) HDRS_libfawkesutils = $(subst $(SRCDIR)/,,$(filter-out $(patsubst %.o,%.h,$(FILTER_OUT)),$(wildcard $(SRCDIR)/*.h $(SRCDIR)/*/*.h))) - *commit* b9f63ca6061a7fbe8edb8fd03856d8b09f3839b4 - - - - - - - - - - Author: Till Hofmann <[email protected]> Date: Tue Nov 17 16:15:30 2020 +0100 Subject: interface: make the interface serial a UUID src/libs/interface/Makefile | 2 +- src/libs/interface/interface.cpp | 6 +++--- src/libs/interface/interface.h | 13 ++++++++----- src/libs/interface/interface.tolua | 2 +- src/libs/interface/message.cpp | 3 +-- src/libs/interface/message.h | 15 ++++++++------- src/libs/interface/message.tolua | 2 +- 7 files changed, 23 insertions(+), 20 deletions(-) _Diff for modified files_: diff --git a/src/libs/interface/Makefile b/src/libs/interface/Makefile index 83dfa0a33..75bede047 100644 --- a/src/libs/interface/Makefile +++ b/src/libs/interface/Makefile @@ -25,7 +25,7 @@ HDRS_libfawkesinterface = $(subst $(SRCDIR)/,,$(wildcard $(SRCDIR)/*.h)) CFLAGS_fawkesinterface_tolua = -Wno-unused-function $(CFLAGS_LUA) TOLUA_fawkesinterface = $(wildcard $(SRCDIR)/*.tolua) LDFLAGS_lua_fawkesinterface = $(LDFLAGS_LUA) -LIBS_lua_fawkesinterface = fawkescore fawkesinterface $(TOLUA_LIBS) +LIBS_lua_fawkesinterface = fawkescore fawkesinterface fawkesutils $(TOLUA_LIBS) OBJS_lua_fawkesinterface = fawkesinterface_tolua.o OBJS_all = $(OBJS_libfawkesinterface) $(OBJS_lua_fawkesinterface) $(SRCDIR)/interface_tolua.cpp diff --git a/src/libs/interface/interface.cpp b/src/libs/interface/interface.cpp index 39906a2b1..b0b032a5e 100644 --- a/src/libs/interface/interface.cpp +++ b/src/libs/interface/interface.cpp @@ -110,7 +110,7 @@ InterfaceInvalidMessageException::InterfaceInvalidMessageException(const Interfa InterfaceInvalidException::InterfaceInvalidException(const Interface *interface, const char *method) : Exception("The interface %s (instance serial %u) is invalid. You cannot call %s anymore.", interface->uid(), - interface->serial(), + interface->serial().get_string().c_str(), method) { } @@ -555,7 +555,7 @@ Interface::set_type_id(const char *type, const char *id) * @param instance_serial instance serial */ void -Interface::set_instance_serial(unsigned short instance_serial) +Interface::set_instance_serial(const Uuid &instance_serial) { instance_serial_ = instance_serial; } @@ -682,7 +682,7 @@ Interface::uid() const /** Get instance serial of interface. * @return instance serial of the interface. */ -unsigned short +Uuid Interface::serial() const { return instance_serial_; diff --git a/src/libs/interface/interface.h b/src/libs/interface/interface.h index 31e70f9f4..af89d0759 100644 --- a/src/libs/interface/interface.h +++ b/src/libs/interface/interface.h @@ -26,6 +26,7 @@ #include <core/exception.h> #include <interface/message.h> #include <interface/message_queue.h> +#include <utils/uuid.h> #include <cstddef> #include <list> @@ -91,7 +92,7 @@ public: const char * type() const; const char * id() const; const char * uid() const; - unsigned short serial() const; + Uuid serial() const; unsigned int mem_serial() const; bool operator==(Interface &comp) const; const unsigned char *hash() const; @@ -229,7 +230,7 @@ protected: private: void set_type_id(const char *type, const char *id); - void set_instance_serial(unsigned short instance_serial); + void set_instance_serial(const Uuid &serial); void set_mediators(InterfaceMediator *iface_mediator, MessageMediator *msg_mediator); void set_memory(unsigned int serial, void *real_ptr, void *data_ptr); void set_readwrite(bool write_access, RefCountRWLock *rwlock); @@ -238,7 +239,9 @@ private: inline unsigned int next_msg_id() { - return (instance_serial_ << 16) | ++next_message_id_; + // TODO use instance_serial_ + //return (instance_serial_ << 16) | ++next_message_id_; + return ++next_message_id_; } char type_[INTERFACE_TYPE_SIZE_ + 1]; @@ -248,8 +251,8 @@ private: char hash_printable_[INTERFACE_HASH_SIZE_ * 2 + 1]; char * owner_; - unsigned short instance_serial_; - bool valid_; + Uuid instance_serial_; + bool valid_; void * mem_data_ptr_; void * mem_real_ptr_; diff --git a/src/libs/interface/interface.tolua b/src/libs/interface/interface.tolua index 1e9ab519d..659ac7360 100644 --- a/src/libs/interface/interface.tolua +++ b/src/libs/interface/interface.tolua @@ -36,7 +36,7 @@ class Interface const char * type() const; const char * id() const; const char * uid() const; - unsigned int serial() const; + fawkes::Uuid serial() const; unsigned int mem_serial() const; bool operator== (Interface &comp) const; const unsigned char * hash() const; diff --git a/src/libs/interface/message.cpp b/src/libs/interface/message.cpp index 72066ed23..5b7fc4693 100644 --- a/src/libs/interface/message.cpp +++ b/src/libs/interface/message.cpp @@ -69,7 +69,6 @@ Message::Message(const char *type) num_fields_ = 0; data_ptr = NULL; data_ts = NULL; - _sender_id = 0; _type = strdup(type); time_enqueued_ = new Time(); @@ -312,7 +311,7 @@ Message::sender_thread_name() const /** Get ID of sender. * @return name of sending thread. */ -unsigned int +Uuid Message::sender_id() const { return _sender_id; diff --git a/src/libs/interface/message.h b/src/libs/interface/message.h index 9897645bc..163422153 100644 --- a/src/libs/interface/message.h +++ b/src/libs/interface/message.h @@ -28,6 +28,7 @@ #include <core/utils/refcount.h> #include <interface/field_iterator.h> #include <interface/types.h> +#include <utils/uuid.h> #include <cstring> #include <type_traits> @@ -59,10 +60,10 @@ public: bool enqueued() const; const Time * time_enqueued() const; - unsigned int sender_id() const; - const char * sender_thread_name() const; - Interface * interface() const; - const char * type() const; + Uuid sender_id() const; + const char *sender_thread_name() const; + Interface * interface() const; + const char *type() const; InterfaceFieldIterator fields(); InterfaceFieldIterator fields_end(); @@ -104,9 +105,9 @@ private: // fields unsigned int recipient_interface_mem_serial; unsigned int sender_interface_instance_serial; - char * _type; - char * _sender_thread_name; - unsigned int _sender_id; + char *_type; + char *_sender_thread_name; + Uuid _sender_id; Interface *_transmit_via_iface; diff --git a/src/libs/interface/message.tolua b/src/libs/interface/message.tolua index 70fc6e3cc..9d5b6179f 100644 --- a/src/libs/interface/message.tolua +++ b/src/libs/interface/message.tolua @@ -35,7 +35,7 @@ class Message : public RefCount unsigned int id() const; - unsigned int sender_id() const; + fawkes::Uuid sender_id() const; const char * sender_thread_name() const; Interface * interface() const; const char * type() const; - *commit* 8bcb345fbe7a04d85084d227bdbc5458226facac - - - - - - - - - - Author: Till Hofmann <[email protected]> Date: Tue Nov 17 16:16:20 2020 +0100 Subject: blackboard: adapt to the interface serial being a uuid src/libs/blackboard/interface_listener.cpp | 16 +++++----- src/libs/blackboard/interface_listener.h | 12 +++----- src/libs/blackboard/internal/interface_manager.cpp | 16 +--------- src/libs/blackboard/internal/interface_manager.h | 3 +- src/libs/blackboard/internal/notifier.cpp | 8 ++--- src/libs/blackboard/internal/notifier.h | 13 ++++----- src/libs/blackboard/net/handler.cpp | 18 ++++++------ src/libs/blackboard/net/handler.h | 11 +++---- src/libs/blackboard/net/interface_listener.cpp | 30 +++++++++---------- src/libs/blackboard/net/interface_listener.h | 14 ++++----- src/libs/blackboard/net/interface_proxy.cpp | 34 +++++++++++----------- src/libs/blackboard/net/interface_proxy.h | 21 +++++++------ src/libs/blackboard/net/messages.h | 12 ++++---- src/libs/blackboard/remote.cpp | 24 +++++++-------- src/libs/blackboard/remote.h | 21 ++++++------- 15 files changed, 114 insertions(+), 139 deletions(-) _Diff for modified files_: diff --git a/src/libs/blackboard/interface_listener.cpp b/src/libs/blackboard/interface_listener.cpp index e1100b60b..f57e1bdcc 100644 --- a/src/libs/blackboard/interface_listener.cpp +++ b/src/libs/blackboard/interface_listener.cpp @@ -156,8 +156,8 @@ BlackBoardInterfaceListener::bb_interface_message_received(Interface *interface, * added. */ void -BlackBoardInterfaceListener::bb_interface_reader_added(Interface * interface, - unsigned int instance_serial) throw() +BlackBoardInterfaceListener::bb_interface_reader_added(Interface *interface, + Uuid instance_serial) throw() { } @@ -169,8 +169,8 @@ BlackBoardInterfaceListener::bb_interface_reader_added(Interface * interface, * removed. */ void -BlackBoardInterfaceListener::bb_interface_reader_removed(Interface * interface, - unsigned int instance_serial) throw() +BlackBoardInterfaceListener::bb_interface_reader_removed(Interface *interface, + Uuid instance_serial) throw() { } @@ -182,8 +182,8 @@ BlackBoardInterfaceListener::bb_interface_reader_removed(Interface * interface, * added. */ void -BlackBoardInterfaceListener::bb_interface_writer_added(Interface * interface, - unsigned int instance_serial) throw() +BlackBoardInterfaceListener::bb_interface_writer_added(Interface *interface, + Uuid instance_serial) throw() { } @@ -195,8 +195,8 @@ BlackBoardInterfaceListener::bb_interface_writer_added(Interface * interface, * removed. */ void -BlackBoardInterfaceListener::bb_interface_writer_removed(Interface * interface, - unsigned int instance_serial) throw() +BlackBoardInterfaceListener::bb_interface_writer_removed(Interface *interface, + Uuid instance_serial) throw() { } diff --git a/src/libs/blackboard/interface_listener.h b/src/libs/blackboard/interface_listener.h index 1080b2514..78ca5800b 100644 --- a/src/libs/blackboard/interface_listener.h +++ b/src/libs/blackboard/interface_listener.h @@ -81,14 +81,10 @@ public: virtual void bb_interface_data_changed(Interface *interface) throw(); virtual bool bb_interface_message_received(Interface *interface, Message *message) throw(); - virtual void bb_interface_writer_added(Interface * interface, - unsigned int instance_serial) throw(); - virtual void bb_interface_writer_removed(Interface * interface, - unsigned int instance_serial) throw(); - virtual void bb_interface_reader_added(Interface * interface, - unsigned int instance_serial) throw(); - virtual void bb_interface_reader_removed(Interface * interface, - unsigned int instance_serial) throw(); + virtual void bb_interface_writer_added(Interface *interface, Uuid instance_serial) throw(); + virtual void bb_interface_writer_removed(Interface *interface, Uuid instance_serial) throw(); + virtual void bb_interface_reader_added(Interface *interface, Uuid instance_serial) throw(); + virtual void bb_interface_reader_removed(Interface *interface, Uuid instance_serial) throw(); protected: void bbil_add_data_interface(Interface *interface); diff --git a/src/libs/blackboard/internal/interface_manager.cpp b/src/libs/blackboard/internal/interface_manager.cpp index 651b425c1..8b3aa8b22 100644 --- a/src/libs/blackboard/internal/interface_manager.cpp +++ b/src/libs/blackboard/internal/interface_manager.cpp @@ -100,7 +100,7 @@ BlackBoardInterfaceManager::new_interface_instance(const char *type, { Interface *iface = instance_factory->new_interface_instance(type, identifier); - iface->set_instance_serial(next_instance_serial()); + //iface->set_instance_serial(next_instance_serial()); iface->set_mediators(this, msgmgr); if (owner) iface->set_owner(owner); @@ -171,20 +171,6 @@ BlackBoardInterfaceManager::next_mem_serial() return serial; } -/** Get next instance serial. - * @return next unique instance serial - */ -unsigned int -BlackBoardInterfaceManager::next_instance_serial() -{ - if (memmgr->is_master()) { - // simple, just increment value and return it - return instance_serial++; - } else { - throw BBNotMasterException("Instance serial can only be requested by BB Master"); - } -} - /** Create an interface instance. * This will create a new interface instance. Storage in the shared memory * is allocated to hold the interface data. diff --git a/src/libs/blackboard/internal/interface_manager.h b/src/libs/blackboard/internal/interface_manager.h index 175cc49bb..95bca940a 100644 --- a/src/libs/blackboard/internal/interface_manager.h +++ b/src/libs/blackboard/internal/interface_manager.h @@ -56,7 +56,7 @@ public: Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner = NULL); Interface * - open_for_writing(const char *interface_type, const char *identifier, const char *owner = NULL); + open_for_writing(const char *interface_type, const char *identifier, const char *owner = NULL); void close(Interface *interface); InterfaceInfoList *list_all() const; @@ -84,7 +84,6 @@ private: void * find_interface_in_memory(const char *type, const char *identifier); unsigned int next_mem_serial(); - unsigned int next_instance_serial(); void create_interface(const char *type, const char *identifier, const char *owner, diff --git a/src/libs/blackboard/internal/notifier.cpp b/src/libs/blackboard/internal/notifier.cpp index f542976a1..da595a9a0 100644 --- a/src/libs/blackboard/internal/notifier.cpp +++ b/src/libs/blackboard/internal/notifier.cpp @@ -493,7 +493,7 @@ BlackBoardNotifier::process_bbio_queue() */ void BlackBoardNotifier::notify_of_writer_added(const Interface *interface, - unsigned int event_instance_serial) throw() + Uuid event_instance_serial) throw() { bbil_writer_mutex_->lock(); bbil_writer_events_ += 1; @@ -530,7 +530,7 @@ BlackBoardNotifier::notify_of_writer_added(const Interface *interface, */ void BlackBoardNotifier::notify_of_writer_removed(const Interface *interface, - unsigned int event_instance_serial) throw() + Uuid event_instance_serial) throw() { bbil_writer_mutex_->lock(); bbil_writer_events_ += 1; @@ -587,7 +587,7 @@ BlackBoardNotifier::process_writer_queue() */ void BlackBoardNotifier::notify_of_reader_added(const Interface *interface, - unsigned int event_instance_serial) throw() + Uuid event_instance_serial) throw() { bbil_reader_mutex_->lock(); bbil_reader_events_ += 1; @@ -624,7 +624,7 @@ BlackBoardNotifier::notify_of_reader_added(const Interface *interface, */ void BlackBoardNotifier::notify_of_reader_removed(const Interface *interface, - unsigned int event_instance_serial) throw() + Uuid event_instance_serial) throw() { bbil_reader_mutex_->lock(); bbil_reader_events_ += 1; diff --git a/src/libs/blackboard/internal/notifier.h b/src/libs/blackboard/internal/notifier.h index 77b5341d9..ea7bacafb 100644 --- a/src/libs/blackboard/internal/notifier.h +++ b/src/libs/blackboard/internal/notifier.h @@ -28,6 +28,7 @@ #include <blackboard/interface_listener.h> #include <blackboard/interface_observer.h> #include <core/utils/rwlock_map.h> +#include <utils/uuid.h> #include <list> #include <string> @@ -58,14 +59,10 @@ public: bool notify_of_message_received(const Interface *interface, Message *message); void notify_of_interface_created(const char *type, const char *id) throw(); void notify_of_interface_destroyed(const char *type, const char *id) throw(); - void notify_of_writer_added(const Interface *interface, - unsigned int event_instance_serial) throw(); - void notify_of_writer_removed(const Interface *interface, - unsigned int event_instance_serial) throw(); - void notify_of_reader_added(const Interface *interface, - unsigned int event_instance_serial) throw(); - void notify_of_reader_removed(const Interface *interface, - unsigned int event_instance_serial) throw(); + void notify_of_writer_added(const Interface *interface, Uuid event_instance_serial) throw(); + void notify_of_writer_removed(const Interface *interface, Uuid event_instance_serial) throw(); + void notify_of_reader_added(const Interface *interface, Uuid event_instance_serial) throw(); + void notify_of_reader_removed(const Interface *interface, Uuid event_instance_serial) throw(); private: /// @cond INTERNALS diff --git a/src/libs/blackboard/net/handler.cpp b/src/libs/blackboard/net/handler.cpp index 5daa4ee4f..c66a1a9ad 100644 --- a/src/libs/blackboard/net/handler.cpp +++ b/src/libs/blackboard/net/handler.cpp @@ -204,7 +204,7 @@ BlackBoardNetworkHandler::loop() case MSG_BB_CLOSE: { bb_iserial_msg_t *sm = msg->msg<bb_iserial_msg_t>(); - unsigned int sm_serial = ntohl(sm->serial); + Uuid sm_serial = sm->serial; if (interfaces_.find(sm_serial) != interfaces_.end()) { bool close = false; client_interfaces_.lock(); @@ -241,14 +241,14 @@ BlackBoardNetworkHandler::loop() "Client %u tried to close " "interface with serial %u, but opened by other client", clid, - sm_serial); + sm_serial.get_string().c_str()); } } else { LibLogger::log_warn("BlackBoardNetworkHandler", "Client %u tried to close " "interface with serial %u which has not been opened", clid, - sm_serial); + sm_serial.get_string().c_str()); } //LibLogger::log_debug("BBNH", "C: interfaces: %zu s2c: %zu ci: %zu", @@ -259,7 +259,7 @@ BlackBoardNetworkHandler::loop() case MSG_BB_DATA_CHANGED: { void * payload = msg->payload(); bb_idata_msg_t *dm = (bb_idata_msg_t *)payload; - unsigned int dm_serial = ntohl(dm->serial); + Uuid dm_serial = dm->serial; if (interfaces_.find(dm_serial) != interfaces_.end()) { if (ntohl(dm->data_size) != interfaces_[dm_serial]->datasize()) { LibLogger::log_error("BlackBoardNetworkHandler", @@ -275,14 +275,14 @@ BlackBoardNetworkHandler::loop() LibLogger::log_error("BlackBoardNetworkHandler", "DATA_CHANGED: Interface with " "serial %u not found, ignoring.", - dm_serial); + dm_serial.get_string().c_str()); } } break; case MSG_BB_INTERFACE_MESSAGE: { void * payload = msg->payload(); bb_imessage_msg_t *mm = (bb_imessage_msg_t *)payload; - unsigned int mm_serial = ntohl(mm->serial); + Uuid mm_serial = mm->serial; if (interfaces_.find(mm_serial) != interfaces_.end()) { if (!interfaces_[mm_serial]->is_writer()) { try { @@ -316,7 +316,7 @@ BlackBoardNetworkHandler::loop() LibLogger::log_error("BlackBoardNetworkHandler", "DATA_CHANGED: Interface with " "serial %u not found, ignoring.", - mm_serial); + mm_serial.get_string().c_str()); } } break; @@ -338,7 +338,7 @@ BlackBoardNetworkHandler::send_opensuccess(unsigned int clid, Interface *interfa { void * payload = calloc(1, sizeof(bb_iopensucc_msg_t) + interface->datasize()); bb_iopensucc_msg_t *osm = (bb_iopensucc_msg_t *)payload; - osm->serial = htonl(interface->serial()); + osm->serial = interface->serial(); osm->writer_readers = htonl(interface->num_readers()); if (interface->has_writer()) { osm->writer_readers |= htonl(0x80000000); @@ -431,7 +431,7 @@ BlackBoardNetworkHandler::client_disconnected(unsigned int clid) (*ciit_)->id(), clid); - unsigned int serial = (*ciit_)->serial(); + Uuid serial = (*ciit_)->serial(); serial_to_clid_.erase(serial); interfaces_.erase_locked(serial); delete listeners_[serial]; diff --git a/src/libs/blackboard/net/handler.h b/src/libs/blackboard/net/handler.h index fcfa58418..09f33a667 100644 --- a/src/libs/blackboard/net/handler.h +++ b/src/libs/blackboard/net/handler.h @@ -28,6 +28,7 @@ #include <core/utils/lock_map.h> #include <core/utils/lock_queue.h> #include <netcomm/fawkes/handler.h> +#include <utils/uuid.h> #include <list> @@ -67,16 +68,16 @@ private: LockQueue<FawkesNetworkMessage *> inbound_queue_; // All interfaces, key is the instance serial, value the interface - LockMap<unsigned int, Interface *> interfaces_; - LockMap<unsigned int, Interface *>::iterator iit_; + LockMap<Uuid, Interface *> interfaces_; + LockMap<Uuid, Interface *>::iterator iit_; - std::map<unsigned int, BlackBoardNetHandlerInterfaceListener *> listeners_; - std::map<unsigned int, BlackBoardNetHandlerInterfaceListener *>::iterator lit_; + std::map<Uuid, BlackBoardNetHandlerInterfaceListener *> listeners_; + std::map<Uuid, BlackBoardNetHandlerInterfaceListener *>::iterator lit_; BlackBoardNetHandlerInterfaceObserver *observer_; // Map from instance serial to clid - LockMap<unsigned int, unsigned int> serial_to_clid_; + LockMap<Uuid, unsigned int> serial_to_clid_; // Interfaces per client, key is the client ID, value a list of interfaces opened by client LockMap<unsigned int, std::list<Interface *>> client_interfaces_; diff --git a/src/libs/blackboard/net/interface_listener.cpp b/src/libs/blackboard/net/interface_listener.cpp index 6ab0d18e8..99badfc2d 100644 --- a/src/libs/blackboard/net/interface_listener.cpp +++ b/src/libs/blackboard/net/interface_listener.cpp @@ -86,7 +86,7 @@ BlackBoardNetHandlerInterfaceListener::bb_interface_data_changed(Interface *inte size_t payload_size = sizeof(bb_idata_msg_t) + interface->datasize(); void * payload = malloc(payload_size); bb_idata_msg_t *dm = (bb_idata_msg_t *)payload; - dm->serial = htonl(interface->serial()); + dm->serial = interface->serial(); dm->data_size = htonl(interface->datasize()); memcpy((char *)payload + sizeof(bb_idata_msg_t), interface->datachunk(), interface->datasize()); @@ -106,7 +106,7 @@ BlackBoardNetHandlerInterfaceListener::bb_interface_message_received(Interface * size_t payload_size = sizeof(bb_imessage_msg_t) + message->datasize(); void * payload = calloc(1, payload_size); bb_imessage_msg_t *dm = (bb_imessage_msg_t *)payload; - dm->serial = htonl(interface->serial()); + dm->serial = interface->serial(); strncpy(dm->msg_type, message->type(), INTERFACE_MESSAGE_TYPE_SIZE_ - 1); dm->data_size = htonl(message->datasize()); dm->msgid = htonl(message->id()); @@ -127,11 +127,11 @@ BlackBoardNetHandlerInterfaceListener::bb_interface_message_received(Interface * void BlackBoardNetHandlerInterfaceListener::send_event_serial(Interface * interface, unsigned int msg_id, - unsigned int event_serial) + Uuid event_serial) { bb_ieventserial_msg_t *esm = (bb_ieventserial_msg_t *)malloc(sizeof(bb_ieventserial_msg_t)); - esm->serial = htonl(interface->serial()); - esm->event_serial = htonl(event_serial); + esm->serial = interface->serial(); + esm->event_serial = event_serial; try { fnh_->send(clid_, FAWKES_CID_BLACKBOARD, msg_id, esm, sizeof(bb_ieventserial_msg_t)); @@ -142,33 +142,29 @@ BlackBoardNetHandlerInterfaceListener::send_event_serial(Interface * interface, } void -BlackBoardNetHandlerInterfaceListener::bb_interface_writer_added( - Interface * interface, - unsigned int instance_serial) throw() +BlackBoardNetHandlerInterfaceListener::bb_interface_writer_added(Interface *interface, + Uuid instance_serial) throw() { send_event_serial(interface, MSG_BB_WRITER_ADDED, instance_serial); } void -BlackBoardNetHandlerInterfaceListener::bb_interface_writer_removed( - Interface * interface, - unsigned int instance_serial) throw() +BlackBoardNetHandlerInterfaceListener::bb_interface_writer_removed(Interface *interface, + Uuid instance_serial) throw() { send_event_serial(interface, MSG_BB_WRITER_REMOVED, instance_serial); } void -BlackBoardNetHandlerInterfaceListener::bb_interface_reader_added( - Interface * interface, - unsigned int instance_serial) throw() +BlackBoardNetHandlerInterfaceListener::bb_interface_reader_added(Interface *interface, + Uuid instance_serial) throw() { send_event_serial(interface, MSG_BB_READER_ADDED, instance_serial); } void -BlackBoardNetHandlerInterfaceListener::bb_interface_reader_removed( - Interface * interface, - unsigned int instance_serial) throw() +BlackBoardNetHandlerInterfaceListener::bb_interface_reader_removed(Interface *interface, + Uuid instance_serial) throw() { send_event_serial(interface, MSG_BB_READER_REMOVED, instance_serial); } diff --git a/src/libs/blackboard/net/interface_listener.h b/src/libs/blackboard/net/interface_listener.h index b15c010a7..6992f80d4 100644 --- a/src/libs/blackboard/net/interface_listener.h +++ b/src/libs/blackboard/net/interface_listener.h @@ -42,17 +42,13 @@ public: virtual void bb_interface_data_changed(Interface *interface) throw(); virtual bool bb_interface_message_received(Interface *interface, Message *message) throw(); - virtual void bb_interface_writer_added(Interface * interface, - unsigned int instance_serial) throw(); - virtual void bb_interface_writer_removed(Interface * interface, - unsigned int instance_serial) throw(); - virtual void bb_interface_reader_added(Interface * interface, - unsigned int instance_serial) throw(); - virtual void bb_interface_reader_removed(Interface * interface, - unsigned int instance_serial) throw(); + virtual void bb_interface_writer_added(Interface *interface, Uuid instance_serial) throw(); + virtual void bb_interface_writer_removed(Interface *interface, Uuid instance_serial) throw(); + virtual void bb_interface_reader_added(Interface *interface, Uuid instance_serial) throw(); + virtual void bb_interface_reader_removed(Interface *interface, Uuid instance_serial) throw(); private: - void send_event_serial(Interface *interface, unsigned int msg_id, unsigned int event_serial); + void send_event_serial(Interface *interface, unsigned int msg_id, Uuid event_serial); BlackBoard * blackboard_; Interface * interface_; diff --git a/src/libs/blackboard/net/interface_proxy.cpp b/src/libs/blackboard/net/interface_proxy.cpp index 36cab91e7..5c9221f31 100644 --- a/src/libs/blackboard/net/interface_proxy.cpp +++ b/src/libs/blackboard/net/interface_proxy.cpp @@ -68,7 +68,7 @@ BlackBoardInterfaceProxy::BlackBoardInterfaceProxy(FawkesNetworkClient * client, notifier_ = notifier; interface_ = interface; - instance_serial_ = ntohl(osm->serial); + instance_serial_ = osm->serial; has_writer_ = osm->writer_readers & htonl(0x80000000); num_readers_ = ntohl(osm->writer_readers & htonl(0x7FFFFFFF)); data_size_ = ntohl(osm->data_size); @@ -123,12 +123,12 @@ BlackBoardInterfaceProxy::process_data_changed(FawkesNetworkMessage *msg) void * payload = msg->payload(); bb_idata_msg_t *dm = (bb_idata_msg_t *)payload; - if (ntohl(dm->serial) != instance_serial_) { + if (dm->serial != instance_serial_) { LibLogger::log_error("BlackBoardInterfaceProxy", "Serial mismatch, expected %u, " "but got %u, ignoring.", - instance_serial_, - ntohl(dm->serial)); + instance_serial_.get_string().c_str(), + dm->serial.get_string().c_str()); return; } @@ -162,12 +162,12 @@ BlackBoardInterfaceProxy::process_interface_message(FawkesNetworkMessage *msg) void * payload = msg->payload(); bb_imessage_msg_t *mm = (bb_imessage_msg_t *)payload; - if (ntohl(mm->serial) != instance_serial_) { + if (mm->serial != instance_serial_) { LibLogger::log_error("BlackBoardInterfaceProxy", - "Serial mismatch (msg), expected %u, " - "but got %u, ignoring.", - instance_serial_, - ntohl(mm->serial)); + "Serial mismatch (msg), expected %s, " + "but got %s, ignoring.", + instance_serial_.get_string().c_str(), + mm->serial.get_string().c_str()); return; } @@ -219,7 +219,7 @@ BlackBoardInterfaceProxy::process_interface_message(FawkesNetworkMessage *msg) * @param event_serial instance serial of the interface that caused the event */ void -BlackBoardInterfaceProxy::reader_added(unsigned int event_serial) +BlackBoardInterfaceProxy::reader_added(Uuid event_serial) { ++num_readers_; notifier_->notify_of_reader_added(interface_, event_serial); @@ -229,7 +229,7 @@ BlackBoardInterfaceProxy::reader_added(unsigned int event_serial) * @param event_serial instance serial of the interface that caused the event */ void -BlackBoardInterfaceProxy::reader_removed(unsigned int event_serial) +BlackBoardInterfaceProxy::reader_removed(Uuid event_serial) { if (num_readers_ > 0) { --num_readers_; @@ -241,7 +241,7 @@ BlackBoardInterfaceProxy::reader_removed(unsigned int event_serial) * @param event_serial instance serial of the interface that caused the event */ void -BlackBoardInterfaceProxy::writer_added(unsigned int event_serial) +BlackBoardInterfaceProxy::writer_added(Uuid event_serial) { has_writer_ = true; notifier_->notify_of_writer_added(interface_, event_serial); @@ -251,7 +251,7 @@ BlackBoardInterfaceProxy::writer_added(unsigned int event_serial) * @param event_serial instance serial of the interface that caused the event */ void -BlackBoardInterfaceProxy::writer_removed(unsigned int event_serial) +BlackBoardInterfaceProxy::writer_removed(Uuid event_serial) { has_writer_ = false; notifier_->notify_of_writer_removed(interface_, event_serial); @@ -260,7 +260,7 @@ BlackBoardInterfaceProxy::writer_removed(unsigned int event_serial) /** Get instance serial of interface. * @return instance serial */ -unsigned int +Uuid BlackBoardInterfaceProxy::serial() const { return instance_serial_; @@ -269,7 +269,7 @@ BlackBoardInterfaceProxy::serial() const /** Get client ID of assigned client. * @return client ID */ -unsigned int +Uuid BlackBoardInterfaceProxy::clid() const { return instance_serial_; @@ -316,7 +316,7 @@ BlackBoardInterfaceProxy::notify_of_data_change(const Interface *interface) size_t payload_size = sizeof(bb_idata_msg_t) + interface->datasize(); void * payload = malloc(payload_size); bb_idata_msg_t *dm = (bb_idata_msg_t *)payload; - dm->serial = htonl(interface->serial()); + dm->serial = interface->serial(); dm->data_size = htonl(interface->datasize()); memcpy((char *)payload + sizeof(bb_idata_msg_t), interface->datachunk(), interface->datasize()); @@ -333,7 +333,7 @@ BlackBoardInterfaceProxy::transmit(Message *message) size_t payload_size = sizeof(bb_imessage_msg_t) + message->datasize(); void * payload = calloc(1, payload_size); bb_imessage_msg_t *dm = (bb_imessage_msg_t *)payload; - dm->serial = htonl(interface_->serial()); + dm->serial = interface_->serial(); unsigned int msgid = next_msg_id(); dm->msgid = htonl(msgid); dm->hops = htonl(message->hops()); diff --git a/src/libs/blackboard/net/interface_proxy.h b/src/libs/blackboard/net/interface_proxy.h index 4cbb13d92..dbc40e4f0 100644 --- a/src/libs/blackboard/net/interface_proxy.h +++ b/src/libs/blackboard/net/interface_proxy.h @@ -26,6 +26,7 @@ #include <interface/mediators/interface_mediator.h> #include <interface/mediators/message_mediator.h> +#include <utils/uuid.h> #include <cstdlib> @@ -49,14 +50,14 @@ public: void process_data_changed(FawkesNetworkMessage *msg); void process_interface_message(FawkesNetworkMessage *msg); - void reader_added(unsigned int event_serial); - void reader_removed(unsigned int event_serial); - void writer_added(unsigned int event_serial); - void writer_removed(unsigned int event_serial); + void reader_added(Uuid event_serial); + void reader_removed(Uuid event_serial); + void writer_added(Uuid event_serial); + void writer_removed(Uuid event_serial); - unsigned int serial() const; - unsigned int clid() const; - Interface * interface() const; + Uuid serial() const; + Uuid clid() const; + Interface *interface() const; /* InterfaceMediator */ virtual bool exists_writer(const Interface *interface) const; @@ -72,7 +73,9 @@ private: inline unsigned int next_msg_id() { - return ((instance_serial_ << 16) | next_msg_id_++); + // TODO use instance_serial_ + //return ((instance_serial_ << 16) | next_msg_id_++); + return next_msg_id_++; } private: @@ -86,7 +89,7 @@ private: void * data_chunk_; size_t data_size_; - unsigned short instance_serial_; + Uuid instance_serial_; unsigned short next_msg_id_; unsigned int num_readers_; bool has_writer_; diff --git a/src/libs/blackboard/net/messages.h b/src/libs/blackboard/net/messages.h index 58d4cf5ac..9e99f9867 100644 --- a/src/libs/blackboard/net/messages.h +++ b/src/libs/blackboard/net/messages.h @@ -117,7 +117,7 @@ typedef struct */ typedef struct { - uint32_t serial; /**< instance serial to unique identify this instance */ + Uuid serial; /**< instance serial to unique identify this instance */ } bb_iserial_msg_t; /** Message to identify an two interface instances. @@ -126,8 +126,8 @@ typedef struct */ typedef struct { - uint32_t serial; /**< instance serial to unique identify own instance */ - uint32_t event_serial; /**< instance serial to unique identify instance that + Uuid serial; /**< instance serial to unique identify own instance */ + Uuid event_serial; /**< instance serial to unique identify instance that * caused the event. */ } bb_ieventserial_msg_t; @@ -139,7 +139,7 @@ typedef struct */ typedef struct { - uint32_t serial; /**< instance serial to unique identify this instance */ + Uuid serial; /**< instance serial to unique identify this instance */ uint32_t writer_readers; /**< combined writer reader information. First * bit (any endian) is 1 if writer exists, 0 otherwise. * The remaining 31 bits encode the number of readers @@ -162,7 +162,7 @@ typedef struct */ typedef struct { - uint32_t serial; /**< instance serial to unique identify this instance */ + Uuid serial; /**< instance serial to unique identify this instance */ uint32_t data_size; /**< size in bytes of the following data. */ } bb_idata_msg_t; @@ -172,7 +172,7 @@ typedef struct */ typedef struct { - uint32_t serial; /**< interface instance serial */ + Uuid serial; /**< interface instance serial */ char msg_type[INTERFACE_MESSAGE_TYPE_SIZE_]; /**< message type */ uint32_t msgid; /**< message ID */ uint32_t hops; /**< number of hops this message already passed */ diff --git a/src/libs/blackboard/remote.cpp b/src/libs/blackboard/remote.cpp index 0cb760250..aaf3266c2 100644 --- a/src/libs/blackboard/remote.cpp +++ b/src/libs/blackboard/remote.cpp @@ -321,7 +321,7 @@ RemoteBlackBoard::close(Interface *interface) if (interface == NULL) return; - unsigned int serial = interface->serial(); + Uuid serial = interface->serial(); if (proxies_.find(serial) != proxies_.end()) { delete proxies_[serial]; @@ -331,7 +331,7 @@ RemoteBlackBoard::close(Interface *interface) if (fnc_->connected()) { // We cannot "officially" close it, if we are disconnected it cannot be used anyway bb_iserial_msg_t *sm = (bb_iserial_msg_t *)calloc(1, sizeof(bb_iserial_msg_t)); - sm->serial = htonl(interface->serial()); + sm->serial = interface->serial(); FawkesNetworkMessage *omsg = new FawkesNetworkMessage(FAWKES_CID_BLACKBOARD, MSG_BB_CLOSE, sm, sizeof(bb_iserial_msg_t)); @@ -459,34 +459,34 @@ RemoteBlackBoard::inbound_received(FawkesNetworkMessage *m, unsigned int id) thr unsigned int msgid = m->msgid(); try { if (msgid == MSG_BB_DATA_CHANGED) { - unsigned int serial = ntohl(((unsigned int *)m->payload())[0]); + Uuid serial = ((Uuid *)m->payload())[0]; if (proxies_.find(serial) != proxies_.end()) { proxies_[serial]->process_data_changed(m); } } else if (msgid == MSG_BB_INTERFACE_MESSAGE) { - unsigned int serial = ntohl(((unsigned int *)m->payload())[0]); + Uuid serial = ((Uuid *)m->payload())[0]; if (proxies_.find(serial) != proxies_.end()) { proxies_[serial]->process_interface_message(m); } } else if (msgid == MSG_BB_READER_ADDED) { bb_ieventserial_msg_t *esm = m->msg<bb_ieventserial_msg_t>(); - if (proxies_.find(ntohl(esm->serial)) != proxies_.end()) { - proxies_[ntohl(esm->serial)]->reader_added(ntohl(esm->event_serial)); + if (proxies_.find(esm->serial) != proxies_.end()) { + proxies_[esm->serial]->reader_added(esm->event_serial); } } else if (msgid == MSG_BB_READER_REMOVED) { bb_ieventserial_msg_t *esm = m->msg<bb_ieventserial_msg_t>(); - if (proxies_.find(ntohl(esm->serial)) != proxies_.end()) { - proxies_[ntohl(esm->serial)]->reader_removed(ntohl(esm->event_serial)); + if (proxies_.find(esm->serial) != proxies_.end()) { + proxies_[esm->serial]->reader_removed(esm->event_serial); } } else if (msgid == MSG_BB_WRITER_ADDED) { bb_ieventserial_msg_t *esm = m->msg<bb_ieventserial_msg_t>(); - if (proxies_.find(ntohl(esm->serial)) != proxies_.end()) { - proxies_[ntohl(esm->serial)]->writer_added(ntohl(esm->event_serial)); + if (proxies_.find(esm->serial) != proxies_.end()) { + proxies_[esm->serial]->writer_added(esm->event_serial); } } else if (msgid == MSG_BB_WRITER_REMOVED) { bb_ieventserial_msg_t *esm = m->msg<bb_ieventserial_msg_t>(); - if (proxies_.find(ntohl(esm->serial)) != proxies_.end()) { - proxies_[ntohl(esm->serial)]->writer_removed(ntohl(esm->event_serial)); + if (proxies_.find(esm->serial) != proxies_.end()) { + proxies_[esm->serial]->writer_removed(esm->event_serial); } } else if (msgid == MSG_BB_INTERFACE_CREATED) { bb_ievent_msg_t *em = m->msg<bb_ievent_msg_t>(); diff --git a/src/libs/blackboard/remote.h b/src/libs/blackboard/remote.h index efdee1a39..7a28d6be9 100644 --- a/src/libs/blackboard/remote.h +++ b/src/libs/blackboard/remote.h @@ -27,6 +27,7 @@ #include <core/exceptions/software.h> #include <core/utils/lock_map.h> #include <netcomm/fawkes/client_handler.h> +#include <utils/uuid.h> #include <list> @@ -55,7 +56,7 @@ public: virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner = NULL); virtual Interface * - open_for_writing(const char *interface_type, const char *identifier, const char *owner = NULL); + open_for_writing(const char *interface_type, const char *identifier, const char *owner = NULL); virtual void close(Interface *interface); virtual InterfaceInfoList *list_all(); @@ -86,15 +87,15 @@ private: /* methods */ void reopen_interfaces(); private: /* members */ - Mutex * mutex_; - FawkesNetworkClient * fnc_; - bool fnc_owner_; - FawkesNetworkMessage * m_; - BlackBoardInstanceFactory * instance_factory_; - LockMap<unsigned int, BlackBoardInterfaceProxy *> proxies_; - LockMap<unsigned int, BlackBoardInterfaceProxy *>::iterator pit_; - std::list<BlackBoardInterfaceProxy *> invalid_proxies_; - std::list<BlackBoardInterfaceProxy *>::iterator ipit_; + Mutex * mutex_; + FawkesNetworkClient * fnc_; + bool fnc_owner_; + FawkesNetworkMessage * m_; + BlackBoardInstanceFactory * instance_factory_; + LockMap<Uuid, BlackBoardInterfaceProxy *> proxies_; + LockMap<Uuid, BlackBoardInterfaceProxy *>::iterator pit_; + std::list<BlackBoardInterfaceProxy *> invalid_proxies_; + std::list<BlackBoardInterfaceProxy *>::iterator ipit_; Mutex * wait_mutex_; WaitCondition *wait_cond_; - *commit* 25099f94bf8d528fd4c35dd4489310e6fb0c06ad - - - - - - - - - - Author: Till Hofmann <[email protected]> Date: Tue Nov 17 16:21:50 2020 +0100 Subject: interfaces: adapt to the interface serial being a uuid etc/buildsys/interface.mk | 4 ++-- src/libs/Makefile | 2 +- src/libs/interfaces/SkillerInterface.xml | 2 +- src/libs/interfaces/generator/tolua_generator.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) _Diff for modified files_: diff --git a/etc/buildsys/interface.mk b/etc/buildsys/interface.mk index 54537e12c..e4d400312 100644 --- a/etc/buildsys/interface.mk +++ b/etc/buildsys/interface.mk @@ -49,8 +49,8 @@ else INTERFACE_GENERATOR_ERROR = ($(call merge, and ,$(INTERFACE_GENERATOR_MISSING_PACKAGE)) not installed) endif -_LIBS_INTERFACE = fawkescore fawkesinterface -_LIBS_TOLUA = fawkescore fawkesinterface $(TOLUA_LIBS) +_LIBS_INTERFACE = fawkescore fawkesinterface fawkesutils +_LIBS_TOLUA = fawkescore fawkesinterface fawkesutils $(TOLUA_LIBS) _CFLAGS_TOLUA = -Wno-unused-function $(CFLAGS_LUA) _LDFLAGS_TOLUA = $(LDFLAGS_LUA) diff --git a/src/libs/Makefile b/src/libs/Makefile index e851e155a..7573cd3d6 100644 --- a/src/libs/Makefile +++ b/src/libs/Makefile @@ -45,7 +45,7 @@ interface: core utils blackboard: core utils interface netcomm logging netcomm: core utils navgraph: core utils aspect -interfaces: core interface +interfaces: core interface utils config: core netcomm utils logging plugin: core netcomm utils config logging aspect: core utils blackboard netcomm config plugin webview logging tf pcl_utils syncpoint diff --git a/src/libs/interfaces/SkillerInterface.xml b/src/libs/interfaces/SkillerInterface.xml index e54c7b2dc..3546e3c9e 100644 --- a/src/libs/interfaces/SkillerInterface.xml +++ b/src/libs/interfaces/SkillerInterface.xml @@ -26,7 +26,7 @@ <field type="string" length="128" name="error"> String describing the error. Can be set by a skill when it fails. </field> - <field type="uint32" name="exclusive_controller"> + <field type="string" length="37" name="exclusive_controller"> Instance serial of the exclusive controller of the skiller. If this does not carry your instance serial your exec messages will be ignored. Aquire control with the AquireControlMessage. Make sure you release control before exiting. diff --git a/src/libs/interfaces/generator/tolua_generator.cpp b/src/libs/interfaces/generator/tolua_generator.cpp index f49dc0c3b..bbb2c33bd 100644 --- a/src/libs/interfaces/generator/tolua_generator.cpp +++ b/src/libs/interfaces/generator/tolua_generator.cpp @@ -323,7 +323,7 @@ ToLuaInterfaceGenerator::write_superclass_h(FILE *f) " const char * type() const;\n" " const char * id() const;\n" " const char * uid() const;\n" - " unsigned int serial() const;\n" + " fawkes::Uuid serial() const;\n" " unsigned int mem_serial() const;\n" " bool operator== (Interface &comp) const;\n" " const unsigned char * hash() const;\n" @@ -371,7 +371,7 @@ ToLuaInterfaceGenerator::write_message_superclass_h(FILE *f) fprintf(f, " unsigned int id() const;\n" "\n" - " unsigned int sender_id() const;\n" + " fawkes::Uuid sender_id() const;\n" " const char * sender_thread_name() const;\n" " Interface * interface() const;\n" " const char * type() const;\n" - *commit* 7f0fa6b22e8bf157b02f5f20cf52717110cbc3ba - - - - - - - - - - Author: Till Hofmann <[email protected]> Date: Tue Nov 17 16:22:44 2020 +0100 Subject: clips: adapt to the interface serial being a uuid src/plugins/clips/clips/blackboard.clp | 2 +- src/plugins/clips/feature_blackboard.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) _Diff for modified files_: diff --git a/src/plugins/clips/clips/blackboard.clp b/src/plugins/clips/clips/blackboard.clp index a9d9b16ee..2790d29e6 100644 --- a/src/plugins/clips/clips/blackboard.clp +++ b/src/plugins/clips/clips/blackboard.clp @@ -12,7 +12,7 @@ (slot type (type STRING)) (slot uid (type STRING)) (slot hash (type STRING)) - (slot serial (type INTEGER)) + (slot serial (type STRING)) (slot writing (type SYMBOL) (allowed-values FALSE TRUE)) ) diff --git a/src/plugins/clips/feature_blackboard.cpp b/src/plugins/clips/feature_blackboard.cpp index 5b41c52f9..9d3ac3f8e 100644 --- a/src/plugins/clips/feature_blackboard.cpp +++ b/src/plugins/clips/feature_blackboard.cpp @@ -375,12 +375,12 @@ BlackboardCLIPSFeature::clips_blackboard_open_interface(const std::string &env_n iface_map.insert(std::make_pair(type, std::list<fawkes::Interface *>(1, iface))); fawkes::MutexLocker lock(clips.objmutex_ptr()); clips->assert_fact_f("(blackboard-interface (id \"%s\") (type \"%s\") (uid \"%s\") " - " (hash \"%s\") (serial %u) (writing %s))", + " (hash \"%s\") (serial \"%s\") (writing %s))", iface->id(), iface->type(), iface->uid(), iface->hash_printable(), - iface->serial(), + iface->serial().get_string().c_str(), writing ? "TRUE" : "FALSE"); } } else { @@ -403,12 +403,12 @@ BlackboardCLIPSFeature::clips_blackboard_open_interface(const std::string &env_n iface->is_writer() ? "writing" : "reading"); fawkes::MutexLocker lock(clips.objmutex_ptr()); clips->assert_fact_f("(blackboard-interface (id \"%s\") (type \"%s\") (uid \"%s\") " - " (hash \"%s\") (serial %u) (writing %s))", + " (hash \"%s\") (serial \"%s\") (writing %s))", iface->id(), iface->type(), iface->uid(), iface->hash_printable(), - iface->serial(), + iface->serial().get_string().c_str(), writing ? "TRUE" : "FALSE"); } catch (Exception &e) { logger_->log_warn(name.c_str(), - *commit* 81027528253336eb287e3ee133c3f958c6fa762d - - - - - - - - - - Author: Till Hofmann <[email protected]> Date: Tue Nov 17 16:23:01 2020 +0100 Subject: eclipse-clp: adapt to the interface serial being a uuid src/plugins/eclipse-clp/externals/blackboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) _Diff for modified files_: diff --git a/src/plugins/eclipse-clp/externals/blackboard.cpp b/src/plugins/eclipse-clp/externals/blackboard.cpp index 3ddc8682a..3bd2607c6 100644 --- a/src/plugins/eclipse-clp/externals/blackboard.cpp +++ b/src/plugins/eclipse-clp/externals/blackboard.cpp @@ -213,7 +213,7 @@ p_bb_instance_serial() std::map<std::string, Interface *> &interfaces = EclExternalBlackBoard::instance()->interfaces(); if (interfaces.find(uid) != interfaces.end()) { - if (EC_succeed != EC_arg(2).unify(interfaces[uid]->serial())) { + if (EC_succeed != EC_arg(2).unify(interfaces[uid]->serial().get_string().c_str())) { fprintf(stderr, "p_bb_instance_serial(): could not bind return value\n"); return EC_fail; } else { - *commit* d73780d6d67595b6c6e12a93d640852f1bb1cca8 - - - - - - - - - - Author: Till Hofmann <[email protected]> Date: Tue Nov 17 17:11:24 2020 +0100 Subject: skiller-simulator: adapt to the interface serial being a uuid src/plugins/skiller-simulator/exec_thread.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) _Diff for modified files_: diff --git a/src/plugins/skiller-simulator/exec_thread.cpp b/src/plugins/skiller-simulator/exec_thread.cpp index 590ba533d..7d68d2048 100644 --- a/src/plugins/skiller-simulator/exec_thread.cpp +++ b/src/plugins/skiller-simulator/exec_thread.cpp @@ -56,14 +56,14 @@ SkillerSimulatorExecutionThread::loop() skiller_if_->msgq_first<SkillerInterface::AcquireControlMessage>(); if (skiller_if_->exclusive_controller() == 0) { logger->log_debug(name(), - "%s is new exclusive controller (ID %u)", + "%s is new exclusive controller (ID %s)", m->sender_thread_name(), - m->sender_id()); - skiller_if_->set_exclusive_controller(m->sender_id()); + m->sender_id().get_string().c_str()); + skiller_if_->set_exclusive_controller(m->sender_id().get_string().c_str()); write_interface = true; } else if (m->is_steal_control()) { logger->log_warn(name(), "%s steals exclusive control", m->sender_thread_name()); - skiller_if_->set_exclusive_controller(m->sender_id()); + skiller_if_->set_exclusive_controller(m->sender_id().get_string().c_str()); skiller_if_->set_msgid(m->id()); write_interface = true; } else { - *commit* dbe572b1cf2ec2b6047ecca482aa7704f316c5c2 - - - - - - - - - - Author: Till Hofmann <[email protected]> Date: Tue Nov 17 17:12:17 2020 +0100 Subject: skiller: adapt to the interface serial being a uuid src/plugins/skiller/rest-api/api.yaml | 3 +-- src/plugins/skiller/rest-api/model/Skill.cpp | 6 +++--- src/plugins/skiller/rest-api/model/Skill.h | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) _Diff for modified files_: diff --git a/src/plugins/skiller/rest-api/api.yaml b/src/plugins/skiller/rest-api/api.yaml index f070b78b0..53b828cb8 100644 --- a/src/plugins/skiller/rest-api/api.yaml +++ b/src/plugins/skiller/rest-api/api.yaml @@ -183,8 +183,7 @@ components: type: integer format: int64 exclusive_controller: - type: integer - format: int64 + type: string status: type: string enum: ["INACTIVE", "FINAL", "RUNNING", "FAILED"] diff --git a/src/plugins/skiller/rest-api/model/Skill.cpp b/src/plugins/skiller/rest-api/model/Skill.cpp index c5e441256..b3cb9b0d8 100644 --- a/src/plugins/skiller/rest-api/model/Skill.cpp +++ b/src/plugins/skiller/rest-api/model/Skill.cpp @@ -103,7 +103,7 @@ Skill::to_json_value(rapidjson::Document &d, rapidjson::Value &v) const } if (exclusive_controller_) { rapidjson::Value v_exclusive_controller; - v_exclusive_controller.SetInt64(*exclusive_controller_); + v_exclusive_controller.SetString(*exclusive_controller_, allocator); v.AddMember("exclusive_controller", v_exclusive_controller, allocator); } if (status_) { @@ -147,7 +147,7 @@ Skill::from_json_value(const rapidjson::Value &d) msg_id_ = d["msg_id"].GetInt64(); } if (d.HasMember("exclusive_controller") && d["exclusive_controller"].IsInt64()) { - exclusive_controller_ = d["exclusive_controller"].GetInt64(); + exclusive_controller_ = d["exclusive_controller"].GetString(); } if (d.HasMember("status") && d["status"].IsString()) { status_ = d["status"].GetString(); @@ -180,4 +180,4 @@ Skill::validate(bool subcall) const throw std::runtime_error(s.str()); } } -} \ No newline at end of file +} diff --git a/src/plugins/skiller/rest-api/model/Skill.h b/src/plugins/skiller/rest-api/model/Skill.h index c17336291..d87a07205 100644 --- a/src/plugins/skiller/rest-api/model/Skill.h +++ b/src/plugins/skiller/rest-api/model/Skill.h @@ -210,7 +210,7 @@ public: /** Get exclusive_controller value. * @return exclusive_controller value */ - std::optional<int64_t> + std::optional<std::string> exclusive_controller() const { return exclusive_controller_; @@ -220,7 +220,7 @@ public: * @param exclusive_controller new value */ void - set_exclusive_controller(const int64_t &exclusive_controller) + set_exclusive_controller(const std::string &exclusive_controller) { exclusive_controller_ = exclusive_controller; } @@ -250,6 +250,6 @@ private: std::optional<std::string> skill_string_; std::optional<std::string> error_; std::optional<int64_t> msg_id_; - std::optional<int64_t> exclusive_controller_; + std::optional<std::string> exclusive_controller_; std::optional<std::string> status_; -}; \ No newline at end of file +}; _______________________________________________ fawkes-commits mailing list [email protected] https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits
