Example #1
0
int main(int argc, char *argv[])
{
    if (argc < 2)
	return -1;
    
    SimpleClient client;
    
    if (client.init(argc,argv) == 0)
	{
	ACE_DEBUG((LM_DEBUG,"Cannot init client"));
	return -1;
	}
    client.login();
    
    
    try
	{
	ACS_SHORT_LOG((LM_INFO, "Getting COB: %s", argv[1]));
	acsexmplBuilding::Building_var tower = client.get_object<acsexmplBuilding::Building>(argv[1], 0, true);
	
	
	if (!CORBA::is_nil(tower.in()))
	    {	  
	    ACS_SHORT_LOG((LM_INFO, "Got COB: %s", argv[1]));
	    }
	else
	    {
	    ACS_SHORT_LOG((LM_INFO, "Unable to access COB: %s", argv[1]));
	    }
	}
    catch( CORBA::Exception &ex )
	{
	ACE_PRINT_EXCEPTION (ex, "main");
	}
    
    try
	{
	ACS_SHORT_LOG((LM_INFO,"Releasing..."));
	client.manager()->release_component(client.handle(), argv[1]);
	client.logout();
	}
    catch( CORBA::Exception &_ex )
	{
	ACE_PRINT_EXCEPTION (_ex, "main");
	}
    
    ACE_OS::sleep(3);
    return 0;
}
int main(int argc, char *argv[])
{
    SimpleClient client;

    if (client.init(argc,argv) == 0)
    {
        return -1;
    }
    else
    {
        client.login();
    }

    try
    {
        bulkdata::BulkDataSender_var sender = client.get_object<bulkdata::BulkDataSender>("BulkDataNotifSender", 0, true);
        if (CORBA::is_nil(sender.in()))
        {
            ACS_SHORT_LOG((LM_ERROR,"Could not retrieve BulkDataNotifSender component"));
            return -1;
        }

        bulkdata::BulkDataDistributer_var distributer = client.get_object<bulkdata::BulkDataDistributer>("BulkDataNotifDistributer", 0, true);
        if (CORBA::is_nil(distributer.in()))
        {
            ACS_SHORT_LOG((LM_ERROR,"Could not retrieve BulkDataNotifDistributer component"));
            return -1;
        }

        bulkdata::BulkDataReceiver_var receiver = client.get_object<bulkdata::BulkDataReceiver>("BulkDataNotifReceiver", 0, true);
        if (CORBA::is_nil(receiver.in()))
        {
            ACS_SHORT_LOG((LM_ERROR,"Could not retrieve BulkDataNotifReceiver component"));
            return -1;
        }

        bulkdata::BulkDataReceiver_var receiver1 = client.get_object<bulkdata::BulkDataReceiver>("BulkDataNotifReceiver1", 0, true);
        if (CORBA::is_nil(receiver1.in()))
        {
            ACS_SHORT_LOG((LM_ERROR,"Could not retrieve BulkDataNotifReceiver1 component"));
            return -1;
        }


// Receiver connected to the Distributor

        sender->connect(distributer.in());

        distributer->multiConnect(receiver.in());

        // instantiate and activate user callbacks for the notification
        BulkDataTestNotificationCb *notifCb = new BulkDataTestNotificationCb();
        ACS::CBvoid_var cb = notifCb->_this();

        // subscribe to the notification mechanism
        distributer->subscribeNotification(cb);


        sender->startSend();

        sender->paceData();

        sender->stopSend();


        sender->disconnect();

        distributer->closeReceiver();

        distributer->multiDisconnect(receiver.in());

        notifCb->_remove_ref();



// Receiver 1 connected directly to the Sender

        sender->connect(receiver1.in());

        // instantiate and activate user callbacks for the notification
        BulkDataTestNotificationCb *notifCb1 = new BulkDataTestNotificationCb();
        ACS::CBvoid_var cb1 = notifCb1->_this();

        // subscribe to the notification mechanism
        receiver1->subscribeNotification(cb1);


        sender->startSend();

        sender->paceData();

        sender->stopSend();


        sender->disconnect();

        receiver1->closeReceiver();

        notifCb1->_remove_ref();
    }

    catch (AVConnectErrorEx & ex)
    {
        ACS_SHORT_LOG((LM_ERROR, "AVConnectErrorEx exception catched !"));
        AVConnectErrorExImpl ex1(ex);
        ex1.log();
    }
    catch (AVStartSendErrorEx & ex)
    {
        ACS_SHORT_LOG((LM_ERROR, "AVStartSendErrorEx exception catched !"));
        AVStartSendErrorExImpl ex1(ex);
        ex1.log();
    }
    catch (AVPaceDataErrorEx & ex)
    {
        ACS_SHORT_LOG((LM_ERROR, "AVPaceDataErrorEx exception catched !"));
        AVPaceDataErrorExImpl ex1(ex);
        ex1.log();
    }
    catch (AVStopSendErrorEx & ex)
    {
        ACS_SHORT_LOG((LM_ERROR, "AVStopSendErrorEx exception catched !"));
        AVStopSendErrorExImpl ex1(ex);
        ex1.log();
    }
    catch (AVDisconnectErrorEx & ex)
    {
        ACS_SHORT_LOG((LM_ERROR, "AVDisconnectErrorEx exception catched !"));
        AVDisconnectErrorExImpl ex1(ex);
        ex1.log();
    }
    catch (AVCloseReceiverErrorEx & ex)
    {
        ACS_SHORT_LOG((LM_ERROR, "AVCloseReceiverErrorEx exception catched !"));
        AVCloseReceiverErrorExImpl ex1(ex);
        ex1.log();
    }
    catch (ACSErrTypeCommon::CORBAProblemEx & ex)
    {
        ACS_SHORT_LOG((LM_ERROR, "CORBAProblemEx exception catched !"));
        ACSErrTypeCommon::CORBAProblemExImpl ex1(ex);
        ex1.log();
    }
    catch (AVNotificationMechanismErrorEx & ex)
    {
        ACS_SHORT_LOG((LM_ERROR, "AVNotificationMechanismErrorEx exception catched !"));
        AVNotificationMechanismErrorExImpl ex1(ex);
        ex1.log();
    }
    catch(...)
    {
        ACS_SHORT_LOG((LM_ERROR,"UNKNOWN exception catched!"));
    }

    //We release our component and logout from manager
    client.manager()->release_component(client.handle(), "BulkDataNotifReceiver1");
    client.manager()->release_component(client.handle(), "BulkDataNotifReceiver");
    client.manager()->release_component(client.handle(), "BulkDataDistributer");
    client.manager()->release_component(client.handle(), "BulkDataNotifSender");

    client.logout();

    ACS_SHORT_LOG((LM_INFO,"Sleeping 3 sec to allow everything to cleanup and stabilize"));

    ACE_OS::sleep(3);

    return 0;
}
Example #3
0
int main(int argc, char *argv[])
{
    if(argc < 2)
    {
        printUsageAndExit();
    }
    int numAlarmsToSend = atoi(argv[1]);

    // Create and initialize the SimpleClient object
    SimpleClient client;
    if (client.init(argc,argv) == 0)
    {
        return -1;
    }
    else
    {
        // Must log into manager before we can really do anything
        client.login();
    }

    // Get the component which will be used to generate alarms
    testalarmsystem::AlarmTestMount_var alarmTestMount = client.get_object<testalarmsystem::AlarmTestMount>("ALARM_SOURCE_MOUNTCPP", 0, true);

    // set up a consumer to listen to the notification channel for alarms
    int receivedEvtCount = 0;
    nc::SimpleConsumer<com::cosylab::acs::jms::ACSJMSMessageEntity> *m_simpConsumer_p = 0;
    ACS_NEW_SIMPLE_CONSUMER(m_simpConsumer_p, com::cosylab::acs::jms::ACSJMSMessageEntity,
                            "CMW.ALARM_SYSTEM.ALARMS.SOURCES.ALARM_SYSTEM_SOURCES", myHandlerFunction, (void*) & receivedEvtCount);
    m_simpConsumer_p->consumerReady();

    ACE_Time_Value tv(30);
    client.run(tv);

    int sentEvtCount = 0;
    int MAX_TIME_TO_WAIT = 30;
    int timeWaited = 0;
    while(receivedEvtCount < numAlarmsToSend && (timeWaited < MAX_TIME_TO_WAIT))
    {
        // generate an alarm
        if(sentEvtCount < numAlarmsToSend)
        {
            alarmTestMount->faultMount();
            sentEvtCount++;
        }
        ACE_Time_Value tv(1);
        client.run(tv);
        timeWaited++;
    }

    if(receivedEvtCount >= numAlarmsToSend)
    {
        std::cout << "disconnecting consumer" << std::endl;
        std::cout << "received: " << receivedEvtCount << " events, and sent: " << sentEvtCount << " events" << std::endl;
    }
    else
    {
        std::cout << "ERROR: never detected all the events before the timeout elapsed" << std::endl;
    }
    m_simpConsumer_p->disconnect();
    m_simpConsumer_p = 0;

    // release the component and logout from manager
    client.manager()->release_component(client.handle(), "ALARM_SOURCE_MOUNTCPP");
    client.logout();

    // Sleep for 10 sec to allow everything to cleanup and stablize
    ACE_OS::sleep(10);
    return 0;
}
int main(int argc, char *argv[])
{

    ACS::TimeInterval samplingFrequency;
    ACS::TimeInterval reportRate;

    if (argc == 3)
	{
	samplingFrequency=atoll(argv[1]);
	reportRate=atoll(argv[2]);
	}
    else if (argc == 1)
	{
	samplingFrequency=1000000;
	reportRate=10000000;
	}
    else
	{
	ACS_SHORT_LOG((LM_INFO, "usage: acssampOnlyNCServer <sampFrequency> <reportRate>"));
	cout << endl;
	return -1;
	}

    cout << "used value >> samplingFrequency: " << samplingFrequency 
	 << "; reportRate: " << reportRate << endl;

    signal(SIGINT,stopLoop);

    /// Creates and initializes the SimpleClient object
    SimpleClient client;
    if (!client.init(argc,argv))
	{
	return -1;
	}
    else
	{
	client.login();
	}
    
    
    ACS_SHORT_LOG((LM_INFO, "Getting Component"));

    try
	{
	
        // obtain the reference to the SAMP (factory) object
        acssamp::Samp_var foo = client.get_object<acssamp::Samp>("SAMP1", 0, true);

	if (!CORBA::is_nil(foo.in()))
	    {

	    ACS_SHORT_LOG((LM_DEBUG, "Got samp descriptor()."));

	    // calls the initSampObj to create dynamically a new sampling object
	    acssamp::SampObj_ptr fooNew = 
		foo->initSampObj("LAMP1","brightness",samplingFrequency,reportRate);

	    ACS_SHORT_LOG((LM_INFO,"*** Start to sample ***"));

	    ACS_SHORT_LOG((LM_INFO,"Not Channel: %s",fooNew->getChannelName()));
	  
	  
	    ACS_SHORT_LOG((LM_INFO,"Sleeping 15 seconds to allow NC Client connection ..."));
	    ACE_OS::sleep(15);
	    ACS_SHORT_LOG((LM_INFO," ... done"));


	    // starts the sampling
	    fooNew->start();

	    cout << "Infinite loop started; press Ctrl-C to stop it ..." << endl;
	    while(endme)
		ACE_OS::sleep(1);
	    cout << "... out of the loop!" << endl;

	    // stop and clen-up everything
	    fooNew->stop();
	    ACE_OS::sleep(2);
	    fooNew->destroy();

	    CORBA::release(fooNew);

	    }	
	} /* end main try */
    catch (OutOfBoundsEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "OutOfBoundsEx exception catched !"));
	OutOfBoundsExImpl err(ex);
	err.log();
	}
    catch (CouldntAccessComponentEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "CouldntAccessComponentEx exception catched !"));
	CouldntAccessComponentExImpl err(ex);
	err.log();
	}
    catch (CouldntAccessPropertyEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "CouldntAccessPropertyEx exception catched !"));
	CouldntAccessPropertyExImpl err(ex);
	err.log();
	}
   catch (CouldntCreateObjectEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "CouldntCreateObjectEx exception catched !"));
	CouldntCreateObjectExImpl err(ex);
	err.log();
	}
   catch (TypeNotSupportedEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "TypeNotSupportedEx exception catched !"));
	TypeNotSupportedExImpl err(ex);
	err.log();
	}
    catch (...)
	{
	ACS_SHORT_LOG((LM_INFO, "XXXXXXXX Exception ... catched !"));
//	ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "main");
	}


    /// We release our Ccomponent and logout from the Manager
    client.manager()->release_component(client.handle(), "SAMP1");
    client.logout();
    
    
    /// sleep for 3 sec to allow everytihng to cleanup and stableize
    ACE_OS::sleep(3);
    
    return 0;
}
Example #5
0
int main(int argc, char *argv[])
{
    // Checks command-line arguments.
    if (argc < 2)
	{
	ACS_SHORT_LOG((LM_INFO, "Usage: %s <component name> <options>", argv[0]));
	return -1;
	}
    else
	{
	ACS_SHORT_LOG((LM_INFO, "Welcome to %s!", argv[0]));
	}
    
    //Creates and initializes the SimpleClient object
    SimpleClient client;
    if (client.init(argc,argv) == 0)
	{
	ACE_DEBUG((LM_DEBUG,"Cannot init client"));
	return -1;
	}
    else
	{
	//Must log into manager before we can really do anything
	client.login();
	}

    try
	{
	//List all components of type "*Mount*" the Manager knows of. 
	ACS_SHORT_LOG((LM_INFO, "Listing all components of type *Mount*"));
	maci::HandleSeq seq;
	//See the doxygen documentation for maci.idl to understand what these parameters
	//are.
	maci::ComponentInfoSeq_var components = client.manager()->get_component_info(client.handle(), 
										     seq, 
										     "*", 
										     "*Mount*", 
										     false);
	
	for (CORBA::ULong i = static_cast<CORBA::ULong>(0); i < components->length(); i++)
	    {
	    //just print out all known mount components
	    ACS_SHORT_LOG((LM_INFO,"%s (%s)", components[i].name.in(), components[i].type.in()));
	    }
	
	// Now get the specific component we have requested from the command-line
	ACS_SHORT_LOG((LM_INFO, "Getting component: %s", argv[1]));

	//getComponent can throw an exception if it fails
	MOUNT_ACS::Mount_var mount = client.getComponent<MOUNT_ACS::Mount>(argv[1], 0, true);
	
	
	//Prints the descriptor of the requested component
	ACS_SHORT_LOG((LM_DEBUG, "Requesting descriptor()... "));
	ACS::CharacteristicComponentDesc_var descriptor = mount->descriptor();
	ACS_SHORT_LOG((LM_DEBUG, "Got descriptor()."));
	ACS_SHORT_LOG((LM_INFO,"Descriptor:"));
	ACS_SHORT_LOG((LM_INFO,"\tname: %s", descriptor->name.in()));
	
	//Get the reference to the  actAz double property
	ACS_SHORT_LOG((LM_INFO, "Getting component property: %s:actAz", argv[1]));
	ACS::ROdouble_var actAz = mount->actAz();
	    
	if (actAz.ptr() != ACS::ROdouble::_nil())
	    {
	    //Get the current value of the property synchronously
	    ACSErr::Completion_var completion;
	    CORBA::Double val = actAz->get_sync(completion.out());
	    ACS_SHORT_LOG((LM_INFO,"Value: %f", val));
	    
	    
	    //Create the CBdouble property
	    ACS_SHORT_LOG((LM_INFO, "Trying to narrow CB for actAz... "));
	    MyCBdouble myCallback("actAz");
	    //Activate it as a CORBA object
	    ACS::CBdouble_var cb = myCallback._this(); 
	    ACS_SHORT_LOG((LM_INFO, "OK"));
	    
	    //Invoke the asynchronous method.
	    ACS_SHORT_LOG((LM_INFO, "Call get_async for actAz..."));
	    ACS::CBDescIn desc;
	    actAz->get_async(cb.in(), desc);    //returns control immediately
	    
	    //Here some other useful things should be done
	    //while the asyncrhonous reply comes
	    //...
	    //...
	    //...
	    
	    //Enter main loop and stays there for a fixed amount of time (1s)
	    //This is done to give the asynchronous method a chance to finish.
	    ACE_Time_Value tv(1);
	    client.run(tv);
	    }//if
	}
    catch(maciErrType::CannotGetComponentExImpl &_ex) // can be thrown by getComponent<..>(...)
	{
	_ex.log();
	return -1;
	}
    catch( CORBA::SystemException &_ex ) // can be thrown by get_component_info
	{
	ACSErrTypeCommon::CORBAProblemExImpl corbaProblemEx(__FILE__, __LINE__,
							    "main");
	corbaProblemEx.setMinor(_ex.minor());
	corbaProblemEx.setCompletionStatus(_ex.completed());
	corbaProblemEx.setInfo(_ex._info().c_str());
	corbaProblemEx.log();
	return -1;
	}
    catch(...)
	{
	ACSErrTypeCommon::UnexpectedExceptionExImpl uex(__FILE__, __LINE__, 
							"main");
	uex.log();
	return -1;
	}//try-catch
  
    //Another try section where we release our component and logout from the Manager
    try
	{
	ACS_SHORT_LOG((LM_INFO,"Releasing..."));
	client.releaseComponent( argv[1]);	
	client.logout();
	}
    catch(maciErrType::CannotReleaseComponentExImpl &_ex)
	{
	_ex.log();
	return -1;
	}
    catch(...)
	{
	ACSErrTypeCommon::UnexpectedExceptionExImpl uex(__FILE__, __LINE__, 
							"main");
	uex.log();
	return -1;
	}//try-catch
    
    
    //sleep for 3 sec to allow everytihng to cleanup and stabilize
    //so that the tests can be determinitstic.
    ACE_OS::sleep(3);   
    return 0;
}
Example #6
0
int main(int argc, char *argv[])
{
    // Creates and initializes the SimpleClient object
    SimpleClient client;

    if (client.init(argc,argv) == 0)
	{
	return -1;
	}
    else
	{
	//Must log into manager before we can really do anything
	client.login();
	}
	
    try
	{
	// Get the specific component we have requested on the command-line
	bulkdata::BulkDataReceiver1Perf_var receiver1 = client.get_object<bulkdata::BulkDataReceiver1Perf>("BulkDataReceiver1Perf", 0, true);
	if (CORBA::is_nil (receiver1.in ()))
	    {
	    ACS_SHORT_LOG((LM_INFO,"Could not retrieve BulkDataReceiver1Perf Component."));
	    return -1;
	    }

	bulkdata::BulkDataSenderPerf_var sender = client.get_object<bulkdata::BulkDataSenderPerf>("BulkDataSenderPerf", 0, true);
	if (CORBA::is_nil (sender.in ()))
	    {
	    ACS_SHORT_LOG((LM_INFO,"Could not retrieve BulkDataSenderPerf Component."));
	    return -1;
	    }

	sender->connect(receiver1.in());

	sender->startSend();

	sender->paceData();

	sender->stopSend();

	sender->disconnect();

	receiver1->closeReceiver();
	}

    catch (AVConnectErrorEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "AVConnectErrorEx exception catched !"));
	AVConnectErrorExImpl ex1(ex);
	ex1.log();
	}
    catch (AVStartSendErrorEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "AVStartSendErrorEx exception catched !"));
	AVStartSendErrorExImpl ex1(ex);
	ex1.log();
	}
    catch (AVPaceDataErrorEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "AVPaceDataErrorEx exception catched !"));
	AVPaceDataErrorExImpl ex1(ex);
	ex1.log();
	}
    catch (AVStopSendErrorEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "AVStopSendErrorEx exception catched !"));
	AVStopSendErrorExImpl ex1(ex);
	ex1.log();
	}
    catch (AVDisconnectErrorEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "AVDisconnectErrorEx exception catched !"));
	AVDisconnectErrorExImpl ex1(ex);
	ex1.log();
	}
    catch (AVCloseReceiverErrorEx & ex)
	{   
	ACS_SHORT_LOG((LM_INFO, "AVCloseReceiverErrorEx exception catched !"));
	AVCloseReceiverErrorExImpl ex1(ex);
	ex1.log();
	}


    catch(...)
	{
	ACS_SHORT_LOG((LM_INFO,"UNKNOWN exception catched!"));
	}
    
    //We release our component and logout from manager
    client.manager()->release_component(client.handle(), "BulkDataSenderPerf");

    ACS_SHORT_LOG((LM_INFO,"Sleeping 3 sec to allow everything to cleanup and stabilize"));    
    ACE_OS::sleep(3);

    client.manager()->release_component(client.handle(), "BulkDataReceiver1Perf");
    
    client.logout();

    //   ACS_SHORT_LOG((LM_INFO,"Sleeping 3 sec to allow everything to cleanup and stabilize"));
    //   ACE_OS::sleep(3);
    
    return 0;
}