Example #1
0
int ::mycomp::run(int argc, char* argv[])
{
#ifdef USE_QTGUI
    QApplication a(argc, argv);  // GUI application
#else
    QCoreApplication a(argc, argv);  // NON-GUI application
#endif
    int status=EXIT_SUCCESS;

    ControllerPrx controller_proxy;
    DifferentialRobotPrx differentialrobot_proxy;
    LaserPrx laser_proxy;

    string proxy, tmp;
    initialize();


    try
    {
        if (not GenericMonitor::configGetString(communicator(), prefix, "ControllerProxy", proxy, ""))
        {
            cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy ControllerProxy\n";
        }
        controller_proxy = ControllerPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
    }
    catch(const Ice::Exception& ex)
    {
        cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
        return EXIT_FAILURE;
    }
    rInfo("ControllerProxy initialized Ok!");
    mprx["ControllerProxy"] = (::IceProxy::Ice::Object*)(&controller_proxy);//Remote server proxy creation example


    try
    {
        if (not GenericMonitor::configGetString(communicator(), prefix, "DifferentialRobotProxy", proxy, ""))
        {
            cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy DifferentialRobotProxy\n";
        }
        differentialrobot_proxy = DifferentialRobotPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
    }
    catch(const Ice::Exception& ex)
    {
        cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
        return EXIT_FAILURE;
    }
    rInfo("DifferentialRobotProxy initialized Ok!");
    mprx["DifferentialRobotProxy"] = (::IceProxy::Ice::Object*)(&differentialrobot_proxy);//Remote server proxy creation example


    try
    {
        if (not GenericMonitor::configGetString(communicator(), prefix, "LaserProxy", proxy, ""))
        {
            cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy LaserProxy\n";
        }
        laser_proxy = LaserPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
    }
    catch(const Ice::Exception& ex)
    {
        cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
        return EXIT_FAILURE;
    }
    rInfo("LaserProxy initialized Ok!");
    mprx["LaserProxy"] = (::IceProxy::Ice::Object*)(&laser_proxy);//Remote server proxy creation example

    IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));


    SpecificWorker *worker = new SpecificWorker(mprx);
    //Monitor thread
    SpecificMonitor *monitor = new SpecificMonitor(worker,communicator());
    QObject::connect(monitor, SIGNAL(kill()), &a, SLOT(quit()));
    QObject::connect(worker, SIGNAL(kill()), &a, SLOT(quit()));
    monitor->start();

    if ( !monitor->isRunning() )
        return status;

    while (!monitor->ready)
    {
        usleep(10000);
    }

    try
    {
        // Server adapter creation and publication
        if (not GenericMonitor::configGetString(communicator(), prefix, "CommonBehavior.Endpoints", tmp, ""))
        {
            cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CommonBehavior\n";
        }
        Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapterWithEndpoints("commonbehavior", tmp);
        CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
        adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
        adapterCommonBehavior->activate();






        // Server adapter creation and publication
        if (not GenericMonitor::configGetString(communicator(), prefix, "AprilTagsTopic.Endpoints", tmp, ""))
        {
            cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy AprilTagsProxy";
        }
        Ice::ObjectAdapterPtr AprilTags_adapter = communicator()->createObjectAdapterWithEndpoints("apriltags", tmp);
        AprilTagsPtr apriltagsI_ = new AprilTagsI(worker);
        Ice::ObjectPrx apriltags = AprilTags_adapter->addWithUUID(apriltagsI_)->ice_oneway();
        IceStorm::TopicPrx apriltags_topic;
        if(!apriltags_topic) {
            try {
                apriltags_topic = topicManager->create("AprilTags");
            }
            catch (const IceStorm::TopicExists&) {
                //Another client created the topic
                try {
                    apriltags_topic = topicManager->retrieve("AprilTags");
                }
                catch(const IceStorm::NoSuchTopic&)
                {
                    //Error. Topic does not exist
                }
            }
            IceStorm::QoS qos;
            apriltags_topic->subscribeAndGetPublisher(qos, apriltags);
        }
        AprilTags_adapter->activate();

        // Server adapter creation and publication
        cout << SERVER_FULL_NAME " started" << endl;

        // User defined QtGui elements ( main window, dialogs, etc )

#ifdef USE_QTGUI
        //ignoreInterrupt(); // Uncomment if you want the component to ignore console SIGINT signal (ctrl+c).
        a.setQuitOnLastWindowClosed( true );
#endif
        // Run QT Application Event Loop
        a.exec();
        status = EXIT_SUCCESS;
    }
    catch(const Ice::Exception& ex)
    {
        status = EXIT_FAILURE;

        cout << "[" << PROGRAM_NAME << "]: Exception raised on main thread: " << endl;
        cout << ex;

#ifdef USE_QTGUI
        a.quit();
#endif
        monitor->exit(0);
    }

    return status;
}
Example #2
0
int ::controller::run(int argc, char* argv[])
{
#ifdef USE_QTGUI
	QApplication a(argc, argv);  // GUI application
#else
	QCoreApplication a(argc, argv);  // NON-GUI application
#endif
	int status=EXIT_SUCCESS;

	DifferentialRobotPrx differentialrobot_proxy;
	LaserPrx laser_proxy;

	string proxy, tmp;
	initialize();


	try
	{
		if (not GenericMonitor::configGetString(communicator(), prefix, "DifferentialRobotProxy", proxy, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy DifferentialRobotProxy\n";
		}
		differentialrobot_proxy = DifferentialRobotPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
	}
	catch(const Ice::Exception& ex)
	{
		cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
		return EXIT_FAILURE;
	}
	rInfo("DifferentialRobotProxy initialized Ok!");
	mprx["DifferentialRobotProxy"] = (::IceProxy::Ice::Object*)(&differentialrobot_proxy);//Remote server proxy creation example


	try
	{
		if (not GenericMonitor::configGetString(communicator(), prefix, "LaserProxy", proxy, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy LaserProxy\n";
		}
		laser_proxy = LaserPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
	}
	catch(const Ice::Exception& ex)
	{
		cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
		return EXIT_FAILURE;
	}
	rInfo("LaserProxy initialized Ok!");
	mprx["LaserProxy"] = (::IceProxy::Ice::Object*)(&laser_proxy);//Remote server proxy creation example



	SpecificWorker *worker = new SpecificWorker(mprx);
	//Monitor thread
	SpecificMonitor *monitor = new SpecificMonitor(worker,communicator());
	QObject::connect(monitor, SIGNAL(kill()), &a, SLOT(quit()));
	QObject::connect(worker, SIGNAL(kill()), &a, SLOT(quit()));
	monitor->start();

	if ( !monitor->isRunning() )
		return status;
	
	while (!monitor->ready)
	{
		usleep(10000);
	}
	
	try
	{
		// Server adapter creation and publication
		if (not GenericMonitor::configGetString(communicator(), prefix, "CommonBehavior.Endpoints", tmp, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CommonBehavior\n";
		}
		Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapterWithEndpoints("commonbehavior", tmp);
		CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
		adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
		adapterCommonBehavior->activate();






		// Server adapter creation and publication
		cout << SERVER_FULL_NAME " started" << endl;

		// User defined QtGui elements ( main window, dialogs, etc )

#ifdef USE_QTGUI
		//ignoreInterrupt(); // Uncomment if you want the component to ignore console SIGINT signal (ctrl+c).
		a.setQuitOnLastWindowClosed( true );
#endif
		// Run QT Application Event Loop
		a.exec();
		status = EXIT_SUCCESS;
	}
	catch(const Ice::Exception& ex)
	{
		status = EXIT_FAILURE;

		cout << "[" << PROGRAM_NAME << "]: Exception raised on main thread: " << endl;
		cout << ex;

#ifdef USE_QTGUI
		a.quit();
#endif
		monitor->exit(0);
}

	return status;
}
Example #3
0
int ::speech::run(int argc, char* argv[])
{
#ifdef USE_QTGUI
    QApplication a(argc, argv);  // GUI application
#else
    QCoreApplication a(argc, argv);  // NON-GUI application
#endif
    int status=EXIT_SUCCESS;

    SpeechInformPrx speechinform_proxy;

    string proxy, tmp;
    initialize();

    IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));

    IceStorm::TopicPrx speechinform_topic;
    while (!speechinform_topic)
    {
        try
        {
            speechinform_topic = topicManager->retrieve("SpeechInform");
        }
        catch (const IceStorm::NoSuchTopic&)
        {
            try
            {
                speechinform_topic = topicManager->create("SpeechInform");
            }
            catch (const IceStorm::TopicExists&) {
                // Another client created the topic.
            }
        }
    }
    Ice::ObjectPrx speechinform_pub = speechinform_topic->getPublisher()->ice_oneway();
    SpeechInformPrx speechinform = SpeechInformPrx::uncheckedCast(speechinform_pub);
    mprx["SpeechInformPub"] = (::IceProxy::Ice::Object*)(&speechinform);



    SpecificWorker *worker = new SpecificWorker(mprx);
    //Monitor thread
    SpecificMonitor *monitor = new SpecificMonitor(worker,communicator());
    QObject::connect(monitor, SIGNAL(kill()), &a, SLOT(quit()));
    QObject::connect(worker, SIGNAL(kill()), &a, SLOT(quit()));
    monitor->start();

    if ( !monitor->isRunning() )
        return status;

    while (!monitor->ready)
    {
        usleep(10000);
    }

    try
    {
        // Server adapter creation and publication
        if (not GenericMonitor::configGetString(communicator(), prefix, "CommonBehavior.Endpoints", tmp, ""))
        {
            cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CommonBehavior\n";
        }
        Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapterWithEndpoints("commonbehavior", tmp);
        CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
        adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
        adapterCommonBehavior->activate();







        // Server adapter creation and publication
        if (not GenericMonitor::configGetString(communicator(), prefix, "SpeechSIMDTopic.Endpoints", tmp, ""))
        {
            cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy SpeechSIMDProxy";
        }
        Ice::ObjectAdapterPtr SpeechSIMD_adapter = communicator()->createObjectAdapterWithEndpoints("speechsimd", tmp);
        SpeechSIMDPtr speechsimdI_ = new SpeechSIMDI(worker);
        Ice::ObjectPrx speechsimd = SpeechSIMD_adapter->addWithUUID(speechsimdI_)->ice_oneway();
        IceStorm::TopicPrx speechsimd_topic;
        if(!speechsimd_topic) {
            try {
                speechsimd_topic = topicManager->create("SpeechSIMD");
            }
            catch (const IceStorm::TopicExists&) {
                //Another client created the topic
                try {
                    speechsimd_topic = topicManager->retrieve("SpeechSIMD");
                }
                catch(const IceStorm::NoSuchTopic&)
                {
                    //Error. Topic does not exist
                }
            }
            IceStorm::QoS qos;
            speechsimd_topic->subscribeAndGetPublisher(qos, speechsimd);
        }
        SpeechSIMD_adapter->activate();

        // Server adapter creation and publication
        cout << SERVER_FULL_NAME " started" << endl;

        // User defined QtGui elements ( main window, dialogs, etc )

#ifdef USE_QTGUI
        //ignoreInterrupt(); // Uncomment if you want the component to ignore console SIGINT signal (ctrl+c).
        a.setQuitOnLastWindowClosed( true );
#endif
        // Run QT Application Event Loop
        a.exec();
        status = EXIT_SUCCESS;
    }
    catch(const Ice::Exception& ex)
    {
        status = EXIT_FAILURE;

        cout << "[" << PROGRAM_NAME << "]: Exception raised on main thread: " << endl;
        cout << ex;

#ifdef USE_QTGUI
        a.quit();
#endif
        monitor->exit(0);
    }

    return status;
}
Example #4
0
int ::dialogagent::run(int argc, char* argv[])
{
#ifdef USE_QTGUI
	QApplication a(argc, argv);  // GUI application
#else
	QCoreApplication a(argc, argv);  // NON-GUI application
#endif


	sigset_t sigs;
	sigemptyset(&sigs);
	sigaddset(&sigs, SIGHUP);
	sigaddset(&sigs, SIGINT);
	sigaddset(&sigs, SIGTERM);
	sigprocmask(SIG_UNBLOCK, &sigs, 0);



	int status=EXIT_SUCCESS;

	SpeechPrx speech_proxy;
	AGMExecutivePrx agmexecutive_proxy;

	string proxy, tmp;
	initialize();


	try
	{
		if (not GenericMonitor::configGetString(communicator(), prefix, "SpeechProxy", proxy, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy SpeechProxy\n";
		}
		speech_proxy = SpeechPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
	}
	catch(const Ice::Exception& ex)
	{
		cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
		return EXIT_FAILURE;
	}
	rInfo("SpeechProxy initialized Ok!");
	mprx["SpeechProxy"] = (::IceProxy::Ice::Object*)(&speech_proxy);//Remote server proxy creation example


	try
	{
		if (not GenericMonitor::configGetString(communicator(), prefix, "AGMExecutiveProxy", proxy, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy AGMExecutiveProxy\n";
		}
		agmexecutive_proxy = AGMExecutivePrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
	}
	catch(const Ice::Exception& ex)
	{
		cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
		return EXIT_FAILURE;
	}
	rInfo("AGMExecutiveProxy initialized Ok!");
	mprx["AGMExecutiveProxy"] = (::IceProxy::Ice::Object*)(&agmexecutive_proxy);//Remote server proxy creation example

	IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));


	SpecificWorker *worker = new SpecificWorker(mprx);
	//Monitor thread
	SpecificMonitor *monitor = new SpecificMonitor(worker,communicator());
	QObject::connect(monitor, SIGNAL(kill()), &a, SLOT(quit()));
	QObject::connect(worker, SIGNAL(kill()), &a, SLOT(quit()));
	monitor->start();

	if ( !monitor->isRunning() )
		return status;
	
	while (!monitor->ready)
	{
		usleep(10000);
	}
	
	try
	{
		// Server adapter creation and publication
		if (not GenericMonitor::configGetString(communicator(), prefix, "CommonBehavior.Endpoints", tmp, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CommonBehavior\n";
		}
		Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapterWithEndpoints("commonbehavior", tmp);
		CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
		adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
		adapterCommonBehavior->activate();




		// Server adapter creation and publication
		if (not GenericMonitor::configGetString(communicator(), prefix, "AGMCommonBehavior.Endpoints", tmp, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy AGMCommonBehavior";
		}
		Ice::ObjectAdapterPtr adapterAGMCommonBehavior = communicator()->createObjectAdapterWithEndpoints("AGMCommonBehavior", tmp);
		AGMCommonBehaviorI *agmcommonbehavior = new AGMCommonBehaviorI(worker);
		adapterAGMCommonBehavior->add(agmcommonbehavior, communicator()->stringToIdentity("agmcommonbehavior"));
		adapterAGMCommonBehavior->activate();
		cout << "[" << PROGRAM_NAME << "]: AGMCommonBehavior adapter created in port " << tmp << endl;





		// Server adapter creation and publication
		if (not GenericMonitor::configGetString(communicator(), prefix, "AGMExecutiveTopicTopic.Endpoints", tmp, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy AGMExecutiveTopicProxy";
		}
		Ice::ObjectAdapterPtr AGMExecutiveTopic_adapter = communicator()->createObjectAdapterWithEndpoints("agmexecutivetopic", tmp);
		AGMExecutiveTopicPtr agmexecutivetopicI_ = new AGMExecutiveTopicI(worker);
		Ice::ObjectPrx agmexecutivetopic = AGMExecutiveTopic_adapter->addWithUUID(agmexecutivetopicI_)->ice_oneway();
		IceStorm::TopicPrx agmexecutivetopic_topic;
		if(!agmexecutivetopic_topic){
		try {
			agmexecutivetopic_topic = topicManager->create("AGMExecutiveTopic");
		}
		catch (const IceStorm::TopicExists&) {
		//Another client created the topic
		try{
			agmexecutivetopic_topic = topicManager->retrieve("AGMExecutiveTopic");
		}
		catch(const IceStorm::NoSuchTopic&)
		{
			//Error. Topic does not exist
			}
		}
		IceStorm::QoS qos;
		agmexecutivetopic_topic->subscribeAndGetPublisher(qos, agmexecutivetopic);
		}
		AGMExecutiveTopic_adapter->activate();

		// Server adapter creation and publication
		cout << SERVER_FULL_NAME " started" << endl;

		// User defined QtGui elements ( main window, dialogs, etc )

#ifdef USE_QTGUI
		//ignoreInterrupt(); // Uncomment if you want the component to ignore console SIGINT signal (ctrl+c).
		a.setQuitOnLastWindowClosed( true );
#endif
		// Run QT Application Event Loop
		a.exec();
		status = EXIT_SUCCESS;
	}
	catch(const Ice::Exception& ex)
	{
		status = EXIT_FAILURE;

		cout << "[" << PROGRAM_NAME << "]: Exception raised on main thread: " << endl;
		cout << ex;

#ifdef USE_QTGUI
		a.quit();
#endif
		monitor->exit(0);
}

	return status;
}
Example #5
0
int ::AprilTagsComp::run(int argc, char* argv[])
{
	QCoreApplication a(argc, argv);  // NON-GUI application


	sigset_t sigs;
	sigemptyset(&sigs);
	sigaddset(&sigs, SIGHUP);
	sigaddset(&sigs, SIGINT);
	sigaddset(&sigs, SIGTERM);
	sigprocmask(SIG_UNBLOCK, &sigs, 0);



	int status=EXIT_SUCCESS;

	RGBDPrx rgbd_proxy;
	RGBDBusPrx rgbdbus_proxy;
	AprilTagsPrx apriltags_proxy;
	CameraPrx camera_proxy;

	string proxy, tmp;
	initialize();


	try
	{
		if (not GenericMonitor::configGetString(communicator(), prefix, "RGBDProxy", proxy, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy RGBDProxy\n";
		}
		rgbd_proxy = RGBDPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
	}
	catch(const Ice::Exception& ex)
	{
		cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
		return EXIT_FAILURE;
	}
	rInfo("RGBDProxy initialized Ok!");
	mprx["RGBDProxy"] = (::IceProxy::Ice::Object*)(&rgbd_proxy);//Remote server proxy creation example


	try
	{
		if (not GenericMonitor::configGetString(communicator(), prefix, "RGBDBusProxy", proxy, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy RGBDBusProxy\n";
		}
		rgbdbus_proxy = RGBDBusPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
	}
	catch(const Ice::Exception& ex)
	{
		cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
		return EXIT_FAILURE;
	}
	rInfo("RGBDBusProxy initialized Ok!");
	mprx["RGBDBusProxy"] = (::IceProxy::Ice::Object*)(&rgbdbus_proxy);//Remote server proxy creation example


	try
	{
		if (not GenericMonitor::configGetString(communicator(), prefix, "CameraProxy", proxy, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CameraProxy\n";
		}
		camera_proxy = CameraPrx::uncheckedCast( communicator()->stringToProxy( proxy ) );
	}
	catch(const Ice::Exception& ex)
	{
		cout << "[" << PROGRAM_NAME << "]: Exception: " << ex;
		return EXIT_FAILURE;
	}
	rInfo("CameraProxy initialized Ok!");
	mprx["CameraProxy"] = (::IceProxy::Ice::Object*)(&camera_proxy);//Remote server proxy creation example

	IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));

	IceStorm::TopicPrx apriltags_topic;
	while (!apriltags_topic)
	{
		try
		{
			apriltags_topic = topicManager->retrieve("AprilTags");
		}
		catch (const IceStorm::NoSuchTopic&)
		{
			try
			{
				apriltags_topic = topicManager->create("AprilTags");
			}
			catch (const IceStorm::TopicExists&){
				// Another client created the topic.
			}
		}
	}
	Ice::ObjectPrx apriltags_pub = apriltags_topic->getPublisher()->ice_oneway();
	AprilTagsPrx apriltags = AprilTagsPrx::uncheckedCast(apriltags_pub);
	mprx["AprilTagsPub"] = (::IceProxy::Ice::Object*)(&apriltags);



	SpecificWorker *worker = new SpecificWorker(mprx);
	//Monitor thread
	SpecificMonitor *monitor = new SpecificMonitor(worker,communicator());
	QObject::connect(monitor, SIGNAL(kill()), &a, SLOT(quit()));
	QObject::connect(worker, SIGNAL(kill()), &a, SLOT(quit()));
	monitor->start();

	if ( !monitor->isRunning() )
		return status;
	
	while (!monitor->ready)
	{
		usleep(10000);
	}
	
	try
	{
		// Server adapter creation and publication
		if (not GenericMonitor::configGetString(communicator(), prefix, "CommonBehavior.Endpoints", tmp, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CommonBehavior\n";
		}
		Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapterWithEndpoints("commonbehavior", tmp);
		CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
		adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
		adapterCommonBehavior->activate();




		// Server adapter creation and publication
		if (not GenericMonitor::configGetString(communicator(), prefix, "GetAprilTags.Endpoints", tmp, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy GetAprilTags";
		}
		Ice::ObjectAdapterPtr adapterGetAprilTags = communicator()->createObjectAdapterWithEndpoints("GetAprilTags", tmp);
		GetAprilTagsI *getapriltags = new GetAprilTagsI(worker);
		adapterGetAprilTags->add(getapriltags, communicator()->stringToIdentity("getapriltags"));
		adapterGetAprilTags->activate();
		cout << "[" << PROGRAM_NAME << "]: GetAprilTags adapter created in port " << tmp << endl;





		// Server adapter creation and publication
		cout << SERVER_FULL_NAME " started" << endl;

		// User defined QtGui elements ( main window, dialogs, etc )

#ifdef USE_QTGUI
		//ignoreInterrupt(); // Uncomment if you want the component to ignore console SIGINT signal (ctrl+c).
		a.setQuitOnLastWindowClosed( true );
#endif
		// Run QT Application Event Loop
		a.exec();
		status = EXIT_SUCCESS;
	}
	catch(const Ice::Exception& ex)
	{
		status = EXIT_FAILURE;

		cout << "[" << PROGRAM_NAME << "]: Exception raised on main thread: " << endl;
		cout << ex;

#ifdef USE_QTGUI
		a.quit();
#endif
		monitor->exit(0);
}

	return status;
}
Example #6
0
int ::muecasservos::run(int argc, char* argv[])
{
	QCoreApplication a(argc, argv);  // NON-GUI application
	int status=EXIT_SUCCESS;


	string proxy, tmp;
	initialize();



	SpecificWorker *worker = new SpecificWorker(mprx);
	//Monitor thread
	SpecificMonitor *monitor = new SpecificMonitor(worker,communicator());
	QObject::connect(monitor, SIGNAL(kill()), &a, SLOT(quit()));
	QObject::connect(worker, SIGNAL(kill()), &a, SLOT(quit()));
	monitor->start();

	if ( !monitor->isRunning() )
		return status;
	
	while (!monitor->ready)
	{
		usleep(10000);
	}
	
	try
	{
		// Server adapter creation and publication
		if (not GenericMonitor::configGetString(communicator(), prefix, "CommonBehavior.Endpoints", tmp, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy CommonBehavior\n";
		}
		Ice::ObjectAdapterPtr adapterCommonBehavior = communicator()->createObjectAdapterWithEndpoints("commonbehavior", tmp);
		CommonBehaviorI *commonbehaviorI = new CommonBehaviorI(monitor );
		adapterCommonBehavior->add(commonbehaviorI, communicator()->stringToIdentity("commonbehavior"));
		adapterCommonBehavior->activate();




		// Server adapter creation and publication
		if (not GenericMonitor::configGetString(communicator(), prefix, "JointMotor.Endpoints", tmp, ""))
		{
			cout << "[" << PROGRAM_NAME << "]: Can't read configuration for proxy JointMotor";
		}
		Ice::ObjectAdapterPtr adapterJointMotor = communicator()->createObjectAdapterWithEndpoints("JointMotor", tmp);
		JointMotorI *jointmotor = new JointMotorI(worker);
		adapterJointMotor->add(jointmotor, communicator()->stringToIdentity("jointmotor"));
		adapterJointMotor->activate();




		// Server adapter creation and publication
		cout << SERVER_FULL_NAME " started" << endl;

		// User defined QtGui elements ( main window, dialogs, etc )

#ifdef USE_QTGUI
		//ignoreInterrupt(); // Uncomment if you want the component to ignore console SIGINT signal (ctrl+c).
		a.setQuitOnLastWindowClosed( true );
#endif
		// Run QT Application Event Loop
		a.exec();
		status = EXIT_SUCCESS;
	}
	catch(const Ice::Exception& ex)
	{
		status = EXIT_FAILURE;

		cout << "[" << PROGRAM_NAME << "]: Exception raised on main thread: " << endl;
		cout << ex;

#ifdef USE_QTGUI
		a.quit();
#endif
		monitor->exit(0);
}

	return status;
}