fastrtps: clean up and fix template for client/agent code

This commit is contained in:
TSC21
2018-06-11 19:15:51 +01:00
committed by Lorenz Meier
parent 3399ec9e73
commit 518daa4a8d
6 changed files with 40 additions and 38 deletions
+14 -14
View File
@@ -48,7 +48,7 @@ topic = spec.short_name
*
****************************************************************************/
/*!
/*!
* @@file @(topic)_Publisher.cpp
* This file contains the implementation of the publisher functions.
*
@@ -74,26 +74,26 @@ topic = spec.short_name
bool @(topic)_Publisher::init()
{
// Create RTPSParticipant
ParticipantAttributes PParam;
PParam.rtps.builtin.domainId = 0;
PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
PParam.rtps.setName("Participant_publisher"); //You can put here the name you want
PParam.rtps.setName("@(topic)_publisher"); //You can put here the name you want
mp_participant = Domain::createParticipant(PParam);
if(mp_participant == nullptr)
return false;
//Register the type
Domain::registerType(mp_participant,(TopicDataType*) &myType);
Domain::registerType(mp_participant, (TopicDataType*) &myType);
// Create Publisher
PublisherAttributes Wparam;
Wparam.topic.topicKind = NO_KEY;
Wparam.topic.topicDataType = myType.getName(); //This type MUST be registered
Wparam.topic.topicName = "@(topic)_PubSubTopic";
mp_publisher = Domain::createPublisher(mp_participant,Wparam,(PublisherListener*)&m_listener);
Wparam.topic.topicName = "@(topic)";
mp_publisher = Domain::createPublisher(mp_participant, Wparam, (PublisherListener*) &m_listener);
if(mp_publisher == nullptr)
return false;
//std::cout << "Publisher created, waiting for Subscribers." << std::endl;
@@ -120,13 +120,13 @@ void @(topic)_Publisher::run()
{
eClock::my_sleep(250); // Sleep 250 ms
}
// Publication code
@(topic)_ st;
/* Initialize your structure here */
int msgsent = 0;
char ch = 'y';
do