/* * ParticipantWrapper.cpp * * Created on: Nov 11, 2015 * Author: sune */ #include "ParticipantWrapper.h" #include namespace cobraid { void ParticipantWrapper::CreateCustomFlowController() { DDS_FlowControllerProperty_t customFlowController; domainParticipant->get_default_flowcontroller_property( customFlowController); customFlowController.scheduling_policy = DDS_RR_FLOW_CONTROLLER_SCHED_POLICY; customFlowController.token_bucket.period.sec = 0; customFlowController.token_bucket.period.nanosec = 10000000; customFlowController.token_bucket.max_tokens = 100; customFlowController.token_bucket.tokens_added_per_period = 40; customFlowController.token_bucket.tokens_leaked_per_period = 0; customFlowController.token_bucket.bytes_per_token = 66000; const char* flowControllerName = "MyFlowController"; DDSFlowController* flowController = NULL; flowController = domainParticipant->create_flowcontroller( DDS_String_dup(flowControllerName), customFlowController); } void ParticipantWrapper::setUDPProperty() { struct NDDS_Transport_UDPv4_Property_t udpProperty = NDDS_TRANSPORT_UDPV4_PROPERTY_DEFAULT; NDDSTransportSupport::get_builtin_transport_property(domainParticipant, DDS_TRANSPORTBUILTIN_UDPv4, (struct NDDS_Transport_Property_t&) (udpProperty)); udpProperty.parent.message_size_max = 65536; udpProperty.send_socket_buffer_size = 1000000; udpProperty.recv_socket_buffer_size = 1000000; } void ParticipantWrapper::setShmemProperty() { struct NDDS_Transport_Shmem_Property_t shmemProperty = NDDS_TRANSPORT_SHMEM_PROPERTY_DEFAULT; NDDSTransportSupport::get_builtin_transport_property(domainParticipant, DDS_TRANSPORTBUILTIN_SHMEM, (struct NDDS_Transport_Property_t&) (shmemProperty)); shmemProperty.receive_buffer_size = 1048576; shmemProperty.received_message_count_max = 1024; } ParticipantWrapper::ParticipantWrapper(Settings settings) { DDS_DomainParticipantFactoryQos qosFactory; DDSTheParticipantFactory->get_qos(qosFactory); qosFactory.entity_factory.autoenable_created_entities = false; DDSTheParticipantFactory->set_qos(qosFactory); DDS_DomainParticipantQos qos; DDSTheParticipantFactory->get_default_participant_qos(qos); char* participantNameCstr = new char[settings.participantName.length() + 1]; char* domainNameCstr = new char[settings.domainName.length() + 1]; strcpy(participantNameCstr, settings.participantName.c_str()); strcpy(domainNameCstr, settings.domainName.c_str()); qos.participant_name.name = participantNameCstr; qos.participant_name.role_name = domainNameCstr; qos.receiver_pool.buffer_size = 65507; qos.transport_builtin.mask = DDS_TRANSPORTBUILTIN_UDPv4; DDSTheParticipantFactory->set_default_participant_qos(qos); domainParticipant = DDSTheParticipantFactory->create_participant(1, DDS_PARTICIPANT_QOS_DEFAULT, NULL, DDS_STATUS_MASK_NONE); CreateCustomFlowController(); setUDPProperty(); setShmemProperty(); } ParticipantWrapper::~ParticipantWrapper() { //shutDownParticipant(); } void ParticipantWrapper::enableDomainParticipant() { domainParticipant->enable(); } DDSDomainParticipant* ParticipantWrapper::getDomainParticipant() const { return domainParticipant; } void ParticipantWrapper::shutDownParticipant() { if (domainParticipant != NULL) { domainParticipant->delete_contained_entities(); DDSTheParticipantFactory->delete_participant(domainParticipant); } } }