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 /implementation/service_discovery/src | |
parent | 2eb67a7238f4e3a63e05953628cb93f5f905a2c1 (diff) | |
download | vSomeIP-e57f565e7b50bfc8ec86d3bd8929a3189350bca3.tar.gz |
Signal "registered"/"deregistered" to the application that hosts the
routing manager.
Diffstat (limited to 'implementation/service_discovery/src')
-rw-r--r-- | implementation/service_discovery/src/service_discovery_fsm.cpp | 16 | ||||
-rw-r--r-- | implementation/service_discovery/src/service_discovery_impl.cpp | 14 |
2 files changed, 28 insertions, 2 deletions
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() { |