#include #include #include #include "rti_me_c.h" #include "disc_dpde/disc_dpde_discovery_plugin.h" #include "wh_sm/wh_sm_history.h" #include "rh_sm/rh_sm_history.h" #include "netio/netio_udp.h" #include "TangoNP_DDS.h" #include "TangoNP_DDSSupport.h" #include "TangoNP_DDSPlugin.h" int titi(int argc,char **argv) { printf("RORO HELLO\n"); int retval = -1; DDS_ReturnCode_t retcode; DDS_DomainParticipantFactory *factory = NULL; struct DDS_DomainParticipantFactoryQos dpf_qos = DDS_DomainParticipantFactoryQos_INITIALIZER; struct DDS_DomainParticipantQos dp_qos = DDS_DomainParticipantQos_INITIALIZER; DDS_Boolean success = DDS_BOOLEAN_FALSE; RT_Registry_T *registry = NULL; struct UDP_InterfaceFactoryProperty *udp_property = NULL; struct DPDE_DiscoveryPluginProperty discovery_plugin_properties = DPDE_DiscoveryPluginProperty_INITIALIZER; DDS_DomainParticipant *participant; char type_name[255]; DDS_Entity *entity; factory = DDS_DomainParticipantFactory_get_instance(); registry = DDS_DomainParticipantFactory_get_registry( DDS_DomainParticipantFactory_get_instance()); if (!RT_Registry_register(registry, "wh", WHSM_HistoryFactory_get_interface(), NULL, NULL)) { printf("failed to register wh\n"); goto done; } if (!RT_Registry_register(registry, "rh", RHSM_HistoryFactory_get_interface(), NULL, NULL)) { printf("failed to register rh\n"); goto done; } /* Configure UDP transport's allowed interfaces */ if (!RT_Registry_unregister(registry, "_udp", NULL, NULL)) { printf("failed to unregister udp\n"); goto done; } udp_property = (struct UDP_InterfaceFactoryProperty *) malloc(sizeof(struct UDP_InterfaceFactoryProperty)); *udp_property = UDP_INTERFACE_FACTORY_PROPERTY_DEFAULT; REDA_StringSeq_set_maximum(&udp_property->allow_interface,2); REDA_StringSeq_set_length(&udp_property->allow_interface,2); /* loopback interface */ #if defined(RTI_DARWIN) *REDA_StringSeq_get_reference(&udp_property->allow_interface,0) = DDS_String_dup("lo0"); *REDA_StringSeq_get_reference(&udp_property->allow_interface,1) = DDS_String_dup("en1"); #elif defined (RTI_LINUX) *REDA_StringSeq_get_reference(&udp_property->allow_interface,0) = DDS_String_dup("lo"); *REDA_StringSeq_get_reference(&udp_property->allow_interface,1) = DDS_String_dup("eth0"); #elif defined (RTI_VXWORKS) *REDA_StringSeq_get_reference(&udp_property->allow_interface,0) = DDS_String_dup("lo0"); *REDA_StringSeq_get_reference(&udp_property->allow_interface,1) = DDS_String_dup("geisc0"); #elif defined(RTI_WIN32) *REDA_StringSeq_get_reference(&udp_property->allow_interface,0) = DDS_String_dup("Loopback Pseudo-Interface 1"); *REDA_StringSeq_get_reference(&udp_property->allow_interface,1) = DDS_String_dup("Local Area Connection"); #else REDA_StringSeq_set_length(&udp_property->allow_interface,0); #endif if (!RT_Registry_register(registry, "_udp", UDP_InterfaceFactory_get_interface(), (struct RT_ComponentFactoryProperty*)udp_property, NULL)) { printf("failed to register udp\n"); goto done; } DDS_DomainParticipantFactory_get_qos(factory, &dpf_qos); dpf_qos.entity_factory.autoenable_created_entities = DDS_BOOLEAN_FALSE; DDS_DomainParticipantFactory_set_qos(factory, &dpf_qos); if (!RT_Registry_register(registry, "dpde", DPDE_DiscoveryFactory_get_interface(), &discovery_plugin_properties._parent, NULL)) { printf("failed to register dpde\n"); goto done; } else printf("RORO HELLO DPDE OK\n"); OSAPI_Stdio_snprintf(dp_qos.discovery.discovery.name,8,"dpde"); participant = DDS_DomainParticipantFactory_create_participant(factory, 0, &dp_qos, NULL, DDS_STATUS_MASK_NONE); if (participant == NULL) { printf("failed to create participant\n"); goto done; } else printf("RORO HELLO Part OK\n"); sprintf(type_name, "HelloWorld"); retcode = DDS_DomainParticipant_register_type(participant, type_name, ACT_STTypePlugin_get()); if (retcode != DDS_RETCODE_OK) { printf("failed to register type: %s\n", "test_type"); goto done; } else printf("RORO HELLO REG TYPE OK\n"); entity = DDS_DomainParticipant_as_entity(participant); retcode = DDS_Entity_enable(entity); if (retcode != DDS_RETCODE_OK) { printf("failed to enable entity\n"); goto done; } else printf("RORO HELLO Enable OK\n"); retcode = DDS_DomainParticipant_delete_contained_entities(participant); if (retcode != DDS_RETCODE_OK) { printf("failed to delete conteined entities (retcode=%d)\n",retcode); goto done; } else printf("RORO HELLO Delete Contained OK\n"); if (DDS_DomainParticipant_unregister_type(participant,type_name) != ACT_STTypePlugin_get()) { printf("failed to unregister type: %s\n",type_name); goto done; } else printf("RORO HELLO UNREG TYPE OK\n"); retcode = DDS_DomainParticipantFactory_delete_participant( DDS_DomainParticipantFactory_get_instance(), participant); if (retcode != DDS_RETCODE_OK) { printf("failed to delete participant: %d\n", retcode); goto done; } else printf("RORO HELLO Delete Part OK\n"); registry = DDS_DomainParticipantFactory_get_registry( DDS_DomainParticipantFactory_get_instance()); if (!RT_Registry_unregister(registry, "dpde", NULL, NULL)) { printf("failed to unregister dpde\n"); goto done; } if (!RT_Registry_unregister(registry, "rh", NULL, NULL)) { printf("failed to unregister rh\n"); goto done; } if (!RT_Registry_unregister(registry, "wh", NULL, NULL)) { printf("failed to unregister wh\n"); goto done; } printf("RORO HELLO UNREG ALL OK\n"); DDS_DomainParticipantFactory_finalize_instance(); DPDE_DiscoveryPluginProperty_finalize(&discovery_plugin_properties); UDP_InterfaceFactoryProperty_finalize(udp_property); free(udp_property); retval = 0; done: return retval; }