-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIWARE Context Broker integration (#124)
* Add FiwareNode implementation and tests Signed-off-by: Irene Bandera <irenebandera@eprosima.com> * Fix python linter Signed-off-by: Irene Bandera <irenebandera@eprosima.com> * Add Flask dependency to project_dependencies action.yml Signed-off-by: Irene Bandera <irenebandera@eprosima.com> * Add requests dependency to project_dependencies action.yml Signed-off-by: Irene Bandera <irenebandera@eprosima.com> * Add configuration params for FiwareNode Signed-off-by: Irene Bandera <irenebandera@eprosima.com> * Add FiwareNode c++ implementation Signed-off-by: Irene Bandera <irenebandera@eprosima.com> * Add documentation Signed-off-by: Irene Bandera <irenebandera@eprosima.com> * Add run(), post_data() and get_inference() methods Signed-off-by: Irene Bandera <irenebandera@eprosima.com> * Update docs Signed-off-by: Irene Bandera <irenebandera@eprosima.com> * Add review changes Signed-off-by: Denisa <denisa@eprosima.com> * Fix returning errors in Fiware Context Broker Signed-off-by: Denisa <denisa@eprosima.com> * Use BooleanWaitHandler for handling inference data Signed-off-by: Denisa <denisa@eprosima.com> --------- Signed-off-by: Irene Bandera <irenebandera@eprosima.com> Signed-off-by: Denisa <denisa@eprosima.com> Co-authored-by: Denisa <denisa@eprosima.com>
- Loading branch information
Showing
14 changed files
with
790 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/** | ||
* @file FiwareNode.hpp | ||
*/ | ||
|
||
#ifndef AMLIPCPP__SRC_CPP_NODE_FIWARENODE_HPP | ||
#define AMLIPCPP__SRC_CPP_NODE_FIWARENODE_HPP | ||
|
||
#include <functional> | ||
|
||
#include <amlip_cpp/node/ParentNode.hpp> | ||
|
||
namespace eprosima { | ||
namespace amlip { | ||
namespace node { | ||
|
||
/** | ||
* | ||
* @brief This is a specialization of AML-IP Node that interacts with FIWARE Context Broker and handles inference data. | ||
* | ||
* Fiware Nodes are the ones in charge of reading data from a context broker entity data, requesting inference from an Inference Node and sending the inferred solution to the context broker entity. | ||
* | ||
*/ | ||
class FiwareNode : public ParentNode | ||
{ | ||
public: | ||
|
||
/** | ||
* @brief Construct a new Fiware Node object. | ||
* | ||
* @param name name of the Node (it is advisable to use a unique, or at least a representative name). | ||
*/ | ||
AMLIP_CPP_DllAPI FiwareNode( | ||
const char* name, | ||
uint32_t domain_id); | ||
|
||
AMLIP_CPP_DllAPI FiwareNode( | ||
const char* name); | ||
|
||
//! Same as previous ctor but with a string argument. | ||
AMLIP_CPP_DllAPI FiwareNode( | ||
const std::string& name); | ||
|
||
/** | ||
* @brief Destroy the Fiware Node object and its internal DDS entities. | ||
* | ||
*/ | ||
AMLIP_CPP_DllAPI ~FiwareNode(); | ||
}; | ||
|
||
} /* namespace node */ | ||
} /* namespace amlip */ | ||
} /* namespace eprosima */ | ||
|
||
#endif /* AMLIPCPP__SRC_CPP_NODE_FIWARENODE_HPP */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/** | ||
* @file FiwareNode.cpp | ||
*/ | ||
|
||
#include <cpp_utils/Log.hpp> | ||
|
||
#include <amlip_cpp/node/FiwareNode.hpp> | ||
|
||
#include <dds/Participant.hpp> | ||
#include <dds/network_utils/topic.hpp> | ||
|
||
namespace eprosima { | ||
namespace amlip { | ||
namespace node { | ||
|
||
FiwareNode::FiwareNode( | ||
const char* name, | ||
uint32_t domain_id) | ||
: ParentNode(name, types::NodeKind::fiware, types::StateKind::running, domain_id) | ||
{ | ||
logInfo(AMLIPCPP_NODE_FIWARE, "Created new Fiware Node: " << *this << "."); | ||
} | ||
|
||
FiwareNode::FiwareNode( | ||
const char* name) | ||
: FiwareNode(name, dds::Participant::default_domain_id()) | ||
{ | ||
} | ||
|
||
FiwareNode::FiwareNode( | ||
const std::string& name) | ||
: FiwareNode(name.c_str(), dds::Participant::default_domain_id()) | ||
{ | ||
} | ||
|
||
FiwareNode::~FiwareNode() | ||
{ | ||
change_status_(types::StateKind::stopped); | ||
logDebug(AMLIPCPP_NODE_FIWARE, "Destroying Fiware Node: " << *this << "."); | ||
} | ||
|
||
std::ostream& operator <<( | ||
std::ostream& os, | ||
const FiwareNode& node) | ||
{ | ||
os << "FIWARE_NODE{" << node.id() << "}"; | ||
return os; | ||
} | ||
|
||
} /* namespace node */ | ||
} /* namespace amlip */ | ||
} /* namespace eprosima */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,9 @@ url | |
Vulcanexus | ||
wget | ||
yaml | ||
detections | ||
namespacing | ||
Dev | ||
Utils | ||
Foonathan | ||
Fiware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.. include:: ../../exports/alias.include | ||
|
||
.. _user_manual_nodes_fiware: | ||
|
||
########### | ||
Fiware Node | ||
########### | ||
|
||
This kind of node interacts with the `FIWARE context broker <https://fiware-orion.readthedocs.io/en/master/>`__ in order to handle inference data. | ||
It provides mechanisms to read data from a context broker entity, request inference from an :ref:`user_manual_nodes_inference`, and send the inference to the context broker entity. | ||
To facilitate the inference requests, the Fiware Node includes an :ref:`user_manual_nodes_edge`. | ||
|
||
Steps | ||
----- | ||
|
||
* Create a new :code:`FiwareNode` object with at least a :code:`name`, a :code:`server_ip` and a :code:`server_port`. | ||
* Start the Flask server. | ||
|
||
.. tabs:: | ||
|
||
.. tab:: Python | ||
|
||
.. code-block:: python | ||
server_ip = '192.168.1.1' | ||
server_port = 1028 | ||
# Create a new Fiware Node | ||
node = FiwareNode(name='My_Fiware_Node', | ||
server_ip=server_ip, | ||
server_port=server_port, | ||
context_broker_ip='localhost', | ||
context_broker_port=1026, | ||
entity_id='ID_entity', | ||
entity_data='data', | ||
entity_solution='inference', | ||
domain=0, | ||
logger=CustomLogger(logger_name='FiwareNode', log_level=logging.WARNING)) | ||
# Start the Flask server | ||
fiware_node.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.