Exemplo n.º 1
0
ACS::RWdouble_ptr NexsimImpl::altVel() throw (CORBA::SystemException){
	if( m_altVel_sp == 0 ){
		return ACS::RWdouble::_nil();
	}
	ACS::RWdouble_var prop = ACS::RWdouble::_narrow(m_altVel_sp->getCORBAReference());
	return prop._retn();
}
Exemplo n.º 2
0
ACS::RWdouble_ptr
FridgeControl::refTemperature ()
{
    if (m_refTemperature_sp == 0)
	{
	return ACS::RWdouble::_nil();
	}
    
    ACS::RWdouble_var prop = ACS::RWdouble::_narrow(m_refTemperature_sp->getCORBAReference());
    return prop._retn();
}
Exemplo n.º 3
0
ACS::RWdouble_ptr
Door::ref_position ()
{
    if (m_ref_position_sp == 0)
	{
	return ACS::RWdouble::_nil();
	}
    
    ACS::RWdouble_var prop = ACS::RWdouble::_narrow(m_ref_position_sp->getCORBAReference());
    return prop._retn();
}
Exemplo n.º 4
0
ACS::RWdouble_ptr
PowerSupply::current ()
{
    if (m_current_sp == 0)
	{
	return ACS::RWdouble::_nil();
	}
    
    ACS::RWdouble_var prop = ACS::RWdouble::_narrow(m_current_sp->getCORBAReference());
    return prop._retn();
}
Exemplo n.º 5
0
/*
 * Main procedure
 */
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();
	}

    //Create an instance of our user-defined callback class
    MyCBdouble myCallback("refTemp");

    try
	{
	//Get the specific component we have requested on the command-line
	FRIDGE::FridgeControl_var fridge = client.getComponent<FRIDGE::FridgeControl>(argv[1], 0, true);
	    
	//Get one of the component's BACI properties
	ACS::RWdouble_var refTemperature = fridge->refTemperature();
	
	if (refTemperature.ptr() != ACS::RWdouble::_nil())
	    {
	    ACSErr::Completion_var completion;
	    
	    //Just synchronously reading the value of refTemp
	    CORBA::Double val = refTemperature->get_sync(completion.out());
	    ACS_SHORT_LOG((LM_INFO,"Value: %f", val));
	    
	    //Activate the callback as a CORBA object
	    ACS::CBdouble_var cb = myCallback._this();
	    ACS_SHORT_LOG((LM_INFO, "OK"));
	    
	    ACS::CBDescIn desc;
	    desc.id_tag = 2;
	    ACS_SHORT_LOG((LM_INFO, "Trying to create monitor for refTemperature..."));

	    //Create the actual monitor
	    ACS::Monitordouble_var md = refTemperature->create_monitor(cb.in(), desc);
	    if (md.ptr() != ACS::Monitordouble::_nil())
		{
		ACS_SHORT_LOG((LM_INFO, "OK"));
		//Set the timer trigger to one second.
		md->set_timer_trigger(10000000);
		}
	    else
		{
		ACS_SHORT_LOG((LM_INFO, "Failed"));
		}

	    //Give the callback some time to run.
	    ACE_Time_Value time(20);
	    client.run(time);
	    
	    //Must explicitly destroy the callback before exiting
	    md->destroy();
	    //Give the callback time to be really destroyed
	    ACE_OS::sleep(15);
	    }
	}
    catch(maciErrType::CannotGetComponentExImpl &_ex)
	{
	_ex.log();
	return -1;
	}
    catch(...)
	{
	ACSErrTypeCommon::UnexpectedExceptionExImpl uex(__FILE__, __LINE__, 
							"main");
	uex.log();
	return -1;
	}//try-catch
        
    try
	{
	//Must release components and logout from manager	
	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.
    ACE_OS::sleep(3);
    return 0;
}