// TestRTIEventCUD.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include "TrackCUDEvents.h" std::string GetExeDirectory() { #ifdef WIN32 char directory[512] = {0}; GetModuleFileName(NULL, directory, 512); std::string dir = directory; std::string::size_type index = dir.find_last_of('\\'); return dir.substr(0, index+1); #else return ""; #endif } bool LoadQOSFile() { bool bResult = false; std::string csFullQOSFileName; DDS::DomainParticipantFactoryQos factoryQos; DDS::DomainParticipantFactory::get_instance()->get_qos(factoryQos); std::string csSegPathDefault = GetExeDirectory(); std::string csQOSFileNameDefault = "JTCWDDS_QOS.xml"; csFullQOSFileName = csSegPathDefault + "\\" + csQOSFileNameDefault; factoryQos.profile.url_profile.ensure_length(1, 1); char * writable = new char[csFullQOSFileName.size() + 1]; std::copy(csFullQOSFileName.begin(), csFullQOSFileName.end(), writable); writable[csFullQOSFileName.size()] = '\0'; const char* szSet1 = writable; factoryQos.profile.url_profile.set_at(0, szSet1); factoryQos.profile.ignore_environment_profile = true; factoryQos.profile.ignore_resource_profile = true; factoryQos.profile.ignore_user_profile = true; DDS_ReturnCode_t ret = DDS::DomainParticipantFactory::get_instance()->set_qos(factoryQos); if(ret == DDS::RETCODE_OK) { bResult = true; } else { //mb->Show(); std::string strExceptionMsg = "LoadDDSQOSXmlFile Exception: :"; bResult = false; } return(bResult); } int _tmain(int argc, _TCHAR* argv[]) { if(LoadQOSFile() == true) { std::string strError; UnManagedC2PCC::TrackCUDEventsController controller; controller.Init(5, strError); DDS::Duration_t receive_period = {4,0}; /* Main loop */ while(true) { printf("TrackCUDEEvent subscriber sleeping for %d sec...\n", receive_period.sec); NDDSUtility::sleep(receive_period); } controller.shutdown(); } return 0; }