Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First features for safety critical systems #486

Merged
merged 27 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dbc32c2
Fixed size strings [4216] (#361)
MiguelCompany Dec 26, 2018
598c37b
New Allocation test [4259] (#364)
JuanCarlos-Arce Jan 16, 2019
cd29fc1
Fixed size bitmaps [4320] (#370)
MiguelCompany Jan 16, 2019
a029bae
Merge branch 'develop' into feature/safety-critical-systems
MiguelCompany Jan 17, 2019
430f352
Remove ParameterList_t [4370] (#379)
MiguelCompany Jan 22, 2019
25a5dd1
Merge branch 'develop' into feature/safety-critical-systems
MiguelCompany Jan 23, 2019
660f601
Merge branch 'develop' into feature/safety-critical-systems
MiguelCompany Jan 30, 2019
3ff2d32
Refs #4370. Fixing errors compiling on Debug.
MiguelCompany Jan 30, 2019
181b507
Mutex wrapper with testing properties [4405] (#383)
richiware Feb 4, 2019
a730633
Resource limited vector [4421] (#386)
MiguelCompany Feb 11, 2019
95b4fa3
Merge branch 'develop' into feature/safety-critical-systems
MiguelCompany Feb 11, 2019
2bf0a7f
Writers: Resource limits on the number of matched readers [4570] (#406)
MiguelCompany Feb 13, 2019
c5f89a4
Merge branch 'develop' into feature/safety-critical-systems
MiguelCompany Feb 15, 2019
15bea84
Refs #4704. Using matchedSubscribersAllocation on allocations test. (…
MiguelCompany Feb 20, 2019
20d6d6e
Merge branch 'develop' into feature/safety-critical-systems
MiguelCompany Feb 20, 2019
99764dd
Merge branch 'develop' into feature/safety-critical-systems
MiguelCompany Feb 26, 2019
de9e382
Merge remote-tracking branch 'origin/develop' into feature/safety-cri…
richiware Mar 5, 2019
fb301dc
Merge branch 'develop' into feature/safety-critical-systems
MiguelCompany Mar 12, 2019
edd523e
Merge remote-tracking branch 'origin/develop' into feature/safety-cri…
richiware Mar 15, 2019
3af1e02
Merge remote-tracking branch 'origin/develop' into feature/safety-cri…
richiware Mar 27, 2019
74e6ab1
Merge branch 'develop' into feature/safety-critical-systems
MiguelCompany Apr 1, 2019
c592937
WIP: Sync write converted to non-blocking call (#426)
richiware Apr 10, 2019
30d4d25
Refs #5094 Added ReaderProxyTests (find_change related tests).
Apr 10, 2019
9d0c4c6
Refs #5094 Fixed find_change related bug.
Apr 10, 2019
2e5762c
Refs #5107. Fixing windows compile error.
richiware Apr 11, 2019
52e28a9
Fixing non deterministic tests.
richiware Apr 11, 2019
072cfca
Fixed a warning on windows.
richiware Apr 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 35 additions & 16 deletions cmake/common/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,28 @@ macro(check_gmock)
endif()
endmacro()

macro(add_gtest test)
macro(add_gtest)
# Parse arguments
set(multiValueArgs SOURCES ENVIRONMENTS DEPENDENCIES)
cmake_parse_arguments(GTEST "" "" "${multiValueArgs}" ${ARGN})
if("${ARGV0}" STREQUAL "NAME")
set(uniValueArgs NAME COMMAND)
unset(test)
unset(command)
else()
set(test "${ARGV0}")
set(command "${test}")
endif()
set(multiValueArgs SOURCES ENVIRONMENTS DEPENDENCIES LABELS)
cmake_parse_arguments(GTEST "" "${uniValueArgs}" "${multiValueArgs}" ${ARGN})

if(GTEST_NAME)
set(test ${GTEST_NAME})
set(command ${GTEST_COMMAND})
endif()

if(GTEST_INDIVIDUAL)
if(WIN32)
set(WIN_PATH "$ENV{PATH}")
get_target_property(LINK_LIBRARIES_ ${test} LINK_LIBRARIES)
get_target_property(LINK_LIBRARIES_ ${command} LINK_LIBRARIES)
if(NOT "${LINK_LIBRARIES_}" STREQUAL "LINK_LIBRARIES_-NOTFOUND")
foreach(LIBRARY_LINKED ${LINK_LIBRARIES_})
if(TARGET ${LIBRARY_LINKED})
Expand All @@ -97,32 +110,35 @@ macro(add_gtest test)
endif()

foreach(GTEST_SOURCE_FILE ${GTEST_SOURCES})
file(STRINGS ${GTEST_SOURCE_FILE} GTEST_NAMES REGEX ^TEST)
foreach(GTEST_NAME ${GTEST_NAMES})
string(REGEX REPLACE ["\) \(,"] ";" GTEST_NAME ${GTEST_NAME})
list(GET GTEST_NAME 1 GTEST_GROUP_NAME)
list(GET GTEST_NAME 3 GTEST_NAME)
add_test(NAME ${GTEST_GROUP_NAME}.${GTEST_NAME}
COMMAND ${test}
--gtest_filter=${GTEST_GROUP_NAME}.${GTEST_NAME})
file(STRINGS ${GTEST_SOURCE_FILE} GTEST_TEST_NAMES REGEX ^TEST)
foreach(GTEST_TEST_NAME ${GTEST_TEST_NAMES})
string(REGEX REPLACE ["\) \(,"] ";" GTEST_TEST_NAME ${GTEST_TEST_NAME})
list(GET GTEST_TEST_NAME 1 GTEST_GROUP_NAME)
list(GET GTEST_TEST_NAME 3 GTEST_TEST_NAME)
add_test(NAME ${GTEST_GROUP_NAME}.${GTEST_TEST_NAME}
COMMAND ${command} --gtest_filter=${GTEST_GROUP_NAME}.${GTEST_TEST_NAME})

# Add environment
if(WIN32)
set_property(TEST ${GTEST_GROUP_NAME}.${GTEST_NAME} APPEND PROPERTY ENVIRONMENT "PATH=${WIN_PATH}")
set_property(TEST ${GTEST_GROUP_NAME}.${GTEST_TEST_NAME} APPEND PROPERTY ENVIRONMENT "PATH=${WIN_PATH}")
endif()

foreach(property ${GTEST_ENVIRONMENTS})
set_property(TEST ${GTEST_GROUP_NAME}.${GTEST_NAME} APPEND PROPERTY ENVIRONMENT "${property}")
set_property(TEST ${GTEST_GROUP_NAME}.${GTEST_TEST_NAME} APPEND PROPERTY ENVIRONMENT "${property}")
endforeach()

# Add labels
set_property(TEST ${GTEST_GROUP_NAME}.${GTEST_TEST_NAME} PROPERTY LABELS "${GTEST_LABELS}")

endforeach()
endforeach()
else()
add_test(NAME ${test} COMMAND ${test})
add_test(NAME ${test} COMMAND ${command})

# Add environment
if(WIN32)
set(WIN_PATH "$ENV{PATH}")
get_target_property(LINK_LIBRARIES_ ${test} LINK_LIBRARIES)
get_target_property(LINK_LIBRARIES_ ${command} LINK_LIBRARIES)
if(NOT "${LINK_LIBRARIES_}" STREQUAL "LINK_LIBRARIES_-NOTFOUND")
foreach(LIBRARY_LINKED ${LINK_LIBRARIES_})
if(TARGET ${LIBRARY_LINKED})
Expand All @@ -140,5 +156,8 @@ macro(add_gtest test)
foreach(property ${GTEST_ENVIRONMENTS})
set_property(TEST ${test} APPEND PROPERTY ENVIRONMENT "${property}")
endforeach()

# Add labels
set_property(TEST ${test} PROPERTY LABELS "${GTEST_LABELS}")
endif()
endmacro()
1 change: 1 addition & 0 deletions include/fastrtps/attributes/PublisherAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class PublisherAttributes
//!Underlying History memory policy
rtps::MemoryManagementPolicy_t historyMemoryPolicy;
rtps::PropertyPolicy properties;
ResourceLimitedContainerConfig matched_subscriber_allocation;

/**
* Get the user defined ID
Expand Down
12 changes: 6 additions & 6 deletions include/fastrtps/attributes/TopicAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class TopicAttributes
{
topicKind = tKind;
topicDiscoveryKind = tDiscovery;
topicName = std::string(name);
topicDataType = std::string(dataType);
topicName = name;
topicDataType = dataType;
}

virtual ~TopicAttributes() {}
Expand All @@ -70,7 +70,7 @@ class TopicAttributes
* Get the topic data type
* @return Topic data type
*/
const std::string& getTopicDataType() const {
const string_255& getTopicDataType() const {
return topicDataType;
}

Expand All @@ -95,7 +95,7 @@ class TopicAttributes
* Get the topic name
* @return Topic name
*/
const std::string& getTopicName() const {
const string_255& getTopicName() const {
return topicName;
}

Expand All @@ -104,9 +104,9 @@ class TopicAttributes
//! Topic discovery kind, default value NO_CHECK.
rtps::TopicDiscoveryKind_t topicDiscoveryKind;
//! Topic Name.
std::string topicName;
string_255 topicName;
//!Topic Data Type.
std::string topicDataType;
string_255 topicDataType;
//!QOS Regarding the History to be saved.
HistoryQosPolicy historyQos;
//!QOS Regarding the resources to allocate.
Expand Down
7 changes: 5 additions & 2 deletions include/fastrtps/publisher/PublisherHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ class PublisherHistory:public rtps::WriterHistory
* @param wparams
* @return True if added.
*/
bool add_pub_change(rtps::CacheChange_t* change, rtps::WriteParams &wparams,
std::unique_lock<std::recursive_mutex>& lock);
bool add_pub_change(
rtps::CacheChange_t* change,
rtps::WriteParams &wparams,
std::unique_lock<std::recursive_timed_mutex>& lock,
std::chrono::time_point<std::chrono::steady_clock> max_blocking_time);

/**
* Remove all change from the associated history.
Expand Down
61 changes: 22 additions & 39 deletions include/fastrtps/qos/ParameterList.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,13 @@
#include "../rtps/messages/CDRMessage.h"
#include "../rtps/common/CacheChange.h"

#include <functional>

namespace eprosima {
namespace fastrtps {

/**
* ParameterList_t class, used to store multiple parameters as a vector of pointers to the base class.
* @ingroup PARAMETER_MODULE
*/
class ParameterList_t
{
public:

ParameterList_t() {}

ParameterList_t(ParameterList_t&& plist) : m_parameters(std::move(plist.m_parameters)) {}

virtual ~ParameterList_t()
{
for(std::vector<Parameter_t*>::iterator it = m_parameters.begin();
it!=m_parameters.end();++it)
delete(*it);
m_parameters.clear();
}

//! Vector of the pointers to the parameters.
std::vector<Parameter_t*> m_parameters;

private:

ParameterList_t(const ParameterList_t& plist) = delete;
};

/**
* ParameterList class has static methods to update or read a ParameterList_t
* ParameterList class has static methods to update or read a list of Parameter_t
* @ingroup PARAMETER_MODULE
*/

Expand All @@ -66,22 +40,31 @@ class ParameterList
public:

/**
* Update the CDRMessage of a parameterList.
* Write parameterList encapsulation to the CDRMessage.
* @param msg Pointer to the message (the pos should be correct, otherwise the behaviour is undefined).
* @param plist Pointer to the parameterList.
* @return True if correct.
*/
static bool writeParameterListToCDRMsg(rtps::CDRMessage_t* msg, ParameterList_t* plist, bool use_encapsulation);
static bool writeEncapsulationToCDRMsg(rtps::CDRMessage_t* msg);

/**
* Read a parameterList from a CDRMessage
* Update the information of a cache change parsing the inline qos from a CDRMessage
* @param[inout] change Reference to the cache change to be updated.
* @param[in] msg Pointer to the message (the pos should be correct, otherwise the behaviour is undefined).
* @param[out] plist Pointer to the parameter list.
* @param[out] change Pointer to the cache change.
* @return Number of bytes of the parameter list.
* @param[out] qos_size Number of bytes processed.
* @return true if parsing was correct, false otherwise.
*/
static bool updateCacheChangeFromInlineQos(rtps::CacheChange_t& change, rtps::CDRMessage_t* msg, uint32_t& qos_size);

/**
* Read a parameterList from a CDRMessage
* @param[in] msg Reference to the message (the pos should be correct, otherwise the behaviour is undefined).
* @param[in] processor Function to process each of the parameters in the list.
* @param[in] use_encapsulation Wether encapsulation field should be read.
* @param[out] qos_size Number of bytes processed.
* @return true if parsing was correct, false otherwise.
*/
static int32_t readParameterListfromCDRMsg(rtps::CDRMessage_t* msg, ParameterList_t* plist, rtps::CacheChange_t* change,
bool encapsulation);
static bool readParameterListfromCDRMsg(rtps::CDRMessage_t& msg, std::function<bool(const Parameter_t*)> processor,
bool use_encapsulation, uint32_t& qos_size);

/**
* Read change instanceHandle from the KEY_HASH or another specific PID parameter of a CDRMessage
Expand All @@ -92,7 +75,7 @@ class ParameterList
static bool readInstanceHandleFromCDRMsg(rtps::CacheChange_t* change, const uint16_t pid);
};

} /* namespace */
} /* namespace fastrtps */
} /* namespace eprosima */
#endif
#endif /* PARAMLISTT_H_ */
38 changes: 34 additions & 4 deletions include/fastrtps/qos/ParameterTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "../rtps/common/all_common.h"
#include "../rtps/common/Token.h"

#include "../utils/fixed_size_string.hpp"

#if HAVE_SECURITY
#include "../rtps/security/accesscontrol/ParticipantSecurityAttributes.h"
#include "../rtps/security/accesscontrol/EndpointSecurityAttributes.h"
Expand Down Expand Up @@ -207,7 +209,8 @@ class ParameterLocator_t: public Parameter_t {
/**
*
*/
class ParameterString_t: public Parameter_t {
class ParameterString_t: public Parameter_t
{
public:
ParameterString_t(){};
/**
Expand All @@ -216,17 +219,18 @@ class ParameterString_t: public Parameter_t {
* @param in_length Its associated length
*/
ParameterString_t(ParameterId_t pid,uint16_t in_length):Parameter_t(pid,in_length){};
ParameterString_t(ParameterId_t pid,uint16_t in_length,std::string& strin):Parameter_t(pid,in_length),m_string(strin){}
ParameterString_t(ParameterId_t pid,uint16_t in_length,const string_255& strin):Parameter_t(pid,in_length),m_string(strin){}

/**
* Add the parameter to a CDRMessage_t message.
* @param[in,out] msg Pointer to the message where the parameter should be added.
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(rtps::CDRMessage_t* msg) override;
inline const char* getName()const { return m_string.c_str(); };
inline void setName(const char* name){ m_string = std::string(name); };
inline void setName(const char* name){ m_string = name; };
private:
std::string m_string;
string_255 m_string;
};

/**
Expand Down Expand Up @@ -383,6 +387,32 @@ class ParameterBool_t:public Parameter_t{

#define PARAMETER_BOOL_LENGTH 4

/**
*
*/
class ParameterStatusInfo_t :public Parameter_t
{
public:
uint8_t status;
ParameterStatusInfo_t() :status(0) {}

/**
* Constructor using a parameter PID and the parameter length
* @param pid Pid of the parameter
* @param in_length Its associated length
*/
ParameterStatusInfo_t(ParameterId_t pid, uint16_t in_length) :Parameter_t(pid, in_length), status(0) {}
ParameterStatusInfo_t(ParameterId_t pid, uint16_t in_length, uint8_t instatus) :Parameter_t(pid, in_length), status(instatus) {}
/**
* Add the parameter to a CDRMessage_t message.
* @param[in,out] msg Pointer to the message where the parameter should be added.
* @return True if the parameter was correctly added.
*/
bool addToCDRMessage(rtps::CDRMessage_t* msg) override;
};

#define PARAMETER_STATUS_INFO_LENGTH 4

/**
*
*/
Expand Down
Loading