diff options
author | Lutz Bichler <Lutz.Bichler@bmw.de> | 2014-07-07 15:03:32 +0200 |
---|---|---|
committer | Lutz Bichler <Lutz.Bichler@bmw.de> | 2014-07-07 15:03:32 +0200 |
commit | e57f565e7b50bfc8ec86d3bd8929a3189350bca3 (patch) | |
tree | 8f229c032f533d705475bc77d7e4c11b77c281c1 | |
parent | 2eb67a7238f4e3a63e05953628cb93f5f905a2c1 (diff) | |
download | vSomeIP-e57f565e7b50bfc8ec86d3bd8929a3189350bca3.tar.gz |
Signal "registered"/"deregistered" to the application that hosts the
routing manager.
10 files changed, 45 insertions, 12 deletions
diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index d5fb3dc..fde5f0b 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -47,6 +47,7 @@ public: std::string get_group(service_t _service, instance_t _instance) const; + std::set< std::string > get_servicegroups() const; uint32_t get_min_initial_delay(const std::string &_name) const; uint32_t get_max_initial_delay(const std::string &_name) const; uint32_t get_repetition_base_delay(const std::string &_name) const; diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 41c412d..3230c1f 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -430,6 +430,12 @@ boost::log::trivial::severity_level configuration_impl::get_loglevel() const { return loglevel_; } +std::set< std::string > configuration_impl::get_servicegroups() const { + std::set< std::string > its_keys; + for (auto i : servicegroups_) its_keys.insert(i.first); + return its_keys; +} + uint32_t configuration_impl::get_min_initial_delay(const std::string &_name) const { uint32_t its_delay = 0; diff --git a/implementation/routing/include/routing_manager_proxy.hpp b/implementation/routing/include/routing_manager_proxy.hpp index f2d25ba..75335a4 100644 --- a/implementation/routing/include/routing_manager_proxy.hpp +++ b/implementation/routing/include/routing_manager_proxy.hpp @@ -83,8 +83,6 @@ public: service_t _service, instance_t _instance, event_t _event, const std::vector< byte_t > &_value); - void on_register_application(client_t _client); - void on_deregister_application(client_t _client); void on_message(const byte_t *_data, length_t _length, endpoint *_receiver); void on_routing_info(const byte_t *_data, uint32_t _size); diff --git a/implementation/routing/src/routing_manager_impl.cpp b/implementation/routing/src/routing_manager_impl.cpp index 253efd3..b43cb7c 100644 --- a/implementation/routing/src/routing_manager_impl.cpp +++ b/implementation/routing/src/routing_manager_impl.cpp @@ -86,9 +86,13 @@ void routing_manager_impl::init() { void routing_manager_impl::start() { stub_->start(); if (discovery_) discovery_->start(); + + host_->on_event(event_type_e::REGISTERED); } void routing_manager_impl::stop() { + host_->on_event(event_type_e::DEREGISTERED); + if (discovery_) discovery_->stop(); stub_->stop(); } diff --git a/implementation/routing/src/routing_manager_proxy.cpp b/implementation/routing/src/routing_manager_proxy.cpp index 3359fde..febdfbc 100644 --- a/implementation/routing/src/routing_manager_proxy.cpp +++ b/implementation/routing/src/routing_manager_proxy.cpp @@ -260,12 +260,6 @@ void routing_manager_proxy::set(client_t _client, event_t _event, const std::vector< byte_t > &_value) { } -void routing_manager_proxy::on_register_application(client_t _client) { -} - -void routing_manager_proxy::on_deregister_application(client_t _client) { -} - void routing_manager_proxy::on_message( const byte_t *_data, length_t _size, endpoint *_receiver) { #if 0 diff --git a/implementation/service_discovery/include/service_discovery_fsm.hpp b/implementation/service_discovery/include/service_discovery_fsm.hpp index 9776cb7..f5d3109 100644 --- a/implementation/service_discovery/include/service_discovery_fsm.hpp +++ b/implementation/service_discovery/include/service_discovery_fsm.hpp @@ -47,6 +47,8 @@ struct fsm: uint32_t repetition_base_delay_; uint8_t repetition_max_; uint32_t cyclic_offer_delay_; + + bool is_up_; }; struct inactive: diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp index 4332430..918e92b 100644 --- a/implementation/service_discovery/include/service_discovery_impl.hpp +++ b/implementation/service_discovery/include/service_discovery_impl.hpp @@ -7,6 +7,7 @@ #ifndef VSOMEIP_SERVICE_DISCOVERY_IMPL #define VSOMEIP_SERVICE_DISCOVERY_IMPL +#include <map> #include <memory> #include <set> @@ -50,8 +51,8 @@ private: boost::asio::io_service &io_; service_discovery_host *host_; - std::unique_ptr< service_discovery_fsm > default_; - std::set< std::unique_ptr< service_discovery_fsm > > additional_; // one fsm represents one service group + std::shared_ptr< service_discovery_fsm > default_; + std::map< std::string, std::shared_ptr< service_discovery_fsm > > additional_; // one fsm represents one service group std::shared_ptr< endpoint > endpoint_; }; diff --git a/implementation/service_discovery/src/service_discovery_fsm.cpp b/implementation/service_discovery/src/service_discovery_fsm.cpp index 1cd9b76..c89af28 100644 --- a/implementation/service_discovery/src/service_discovery_fsm.cpp +++ b/implementation/service_discovery/src/service_discovery_fsm.cpp @@ -42,10 +42,19 @@ inactive::inactive(my_context context): sc::state< inactive, fsm >(context) { } sc::result inactive::react(const ev_none &_event) { + if (outermost_context().is_up_) { + return transit< active >(); + } + return discard_event(); } sc::result inactive::react(const ev_status_change &_event) { + outermost_context().is_up_ = _event.is_up_; + if (outermost_context().is_up_) { + return transit< active >(); + } + return discard_event(); } @@ -60,6 +69,10 @@ active::~active() { } sc::result active::react(const ev_status_change &_event) { + outermost_context().is_up_ = _event.is_up_; + if (!outermost_context().is_up_) + return transit< inactive >(); + return discard_event(); } @@ -68,10 +81,11 @@ sc::result active::react(const ev_status_change &_event) { /////////////////////////////////////////////////////////////////////////////// initial::initial(my_context _context): sc::state< initial, active >(_context) { VSOMEIP_DEBUG << "sd::inactive.initial"; + outermost_context().start_timer(outermost_context().initial_delay_); } sc::result initial::react(const ev_timeout &_event) { - return discard_event(); + return transit< repeat >(); } /////////////////////////////////////////////////////////////////////////////// diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 6ca44c6..d3cef62 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -4,6 +4,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include <vsomeip/configuration.hpp> #include <vsomeip/logger.hpp> #include "../include/service_discovery_fsm.hpp" @@ -17,7 +18,7 @@ namespace sd { service_discovery_impl::service_discovery_impl(service_discovery_host *_host) : host_(_host), io_(_host->get_io()), - default_(new service_discovery_fsm("default", this)) { + default_(std::make_shared< service_discovery_fsm >("default", this)) { } service_discovery_impl::~service_discovery_impl() { @@ -32,6 +33,17 @@ boost::asio::io_service & service_discovery_impl::get_io() { } void service_discovery_impl::init() { + std::shared_ptr< configuration > its_configuration = host_->get_configuration(); + if (its_configuration) { + std::set< std::string > its_servicegroups = its_configuration->get_servicegroups(); + for (auto its_group : its_servicegroups) { + if (its_group != "default") { + additional_[its_group] = std::make_shared< service_discovery_fsm >(its_group, this); + } + } + } else { + VSOMEIP_ERROR << "SD: no configuration found!"; + } } void service_discovery_impl::start() { diff --git a/interface/vsomeip/configuration.hpp b/interface/vsomeip/configuration.hpp index b1217a5..d165d69 100644 --- a/interface/vsomeip/configuration.hpp +++ b/interface/vsomeip/configuration.hpp @@ -44,6 +44,7 @@ public: virtual std::string get_group(service_t _service, instance_t _instance) const = 0; virtual std::string get_address(service_t _service, instance_t _instance) const = 0; + virtual std::set< std::string > get_servicegroups() const = 0; virtual uint32_t get_min_initial_delay(const std::string &_name) const = 0; virtual uint32_t get_max_initial_delay(const std::string &_name) const = 0; virtual uint32_t get_repetition_base_delay(const std::string &_name) const = 0; |