예제 #1
0
ENUMPROP_TEST::ROStates_ptr enumpropTestDeviceImpl::currentState (
    
  )

{
  if (!m_currentState)
    return ENUMPROP_TEST::ROStates::_nil();
  ENUMPROP_TEST::ROStates_var prop = ENUMPROP_TEST::ROStates::_narrow(m_currentState->getCORBAReference());
  return prop._retn();
}
예제 #2
0
 AlarmCBpattern(ENUMPROP_TEST::ROStates_ptr _rostates) : rostates(ENUMPROP_TEST::ROStates::_duplicate(_rostates)) 
 {
   prop = rostates->description();
   description = rostates->statesDescription();
 }
예제 #3
0
/*******************************************************************************************
 * main
 ********************************************************************************************/
int main(int argc, char* argv[]) 
{

    if (argc<2)
    {
      ACE_OS::printf ("usage: %s <object_name>\n", argv[0]);
      return -1;
    }
    
    
    try
	{
	ACE_CString g_strCmdLn;
	for (int i=argc-1; i>=0; i--)
	    g_strCmdLn = ACE_CString(argv[i])+ " " + g_strCmdLn;

	if (g_strCmdLn.find("-ORBDottedDecimalAddresses")==ACE_CString::npos)
	    g_strCmdLn += " -ORBDottedDecimalAddresses 1";

	ACE_TCHAR **m_argv = argv;
	int m_argc = argc;
	ACE_OS::string_to_argv((ACE_TCHAR*)g_strCmdLn.c_str(),
			 m_argc,
			 m_argv);
	BACI_CORBA::InitCORBA(m_argc, m_argv);

	LoggingProxy EP_log (0, 0, 31, 0, 0, 1);
	LoggingProxy::init (&EP_log);

	/**
	 * Get reference to a device
	 */

	char fileName[64];
	sprintf(fileName, "file://%s.ior", argv[1]);
	CORBA::Object_var object = BACI_CORBA::getORB()->string_to_object (fileName);
	

	if (CORBA::is_nil(object.in())) 
	    {
	    ACE_DEBUG ((LM_DEBUG, "Cannot get Object"));
	    return -1;
	    }

	// Try to narrow the object reference to a PowerSupply reference.
	ENUMPROP_TEST::enumpropTestDevice_var dev = ENUMPROP_TEST::enumpropTestDevice::_narrow (object.in ());
	
	if (CORBA::is_nil(dev.in())) 
	    {
	    ACS_SHORT_LOG((LM_DEBUG, "Failed to narrow enumnTestDevice "));
	    return 0;
	    }
	ACS_SHORT_LOG((LM_DEBUG, "Device narrowed."));

	//dev->off();

	// Get current stat
	ENUMPROP_TEST::ROStates_var currentState = dev->currentState();

	//   get states description	
	ACS::stringSeq_var description = currentState->statesDescription( );

	AlarmCBpattern alarmCB (currentState.in());
        ACS::Alarmpattern_var alarmCBObj = alarmCB._this();

        ACS::CBDescIn desc;
	desc.id_tag = 1;

	ACS::Subscription_var monitor = currentState->new_subscription_AlarmEnum(alarmCBObj.in(), desc);
	//	monitor->set_timer_trigger(10000000);

	SetterThread setterThread("setter thread", dev);
	setterThread.resume();

	ACS_SHORT_LOG((LM_DEBUG, "(main thread) Going in main loop sleep..."));
	ACE_Time_Value tv(20);
	BACI_CORBA::getORB()->run(tv);

	ACS_SHORT_LOG((LM_DEBUG, "(main thread) Exit ... "));
	monitor->destroy();

        /* Allow time for the done() callback to come back */
	BACI_CORBA::getORB()->run(tv);

	dev->serverShutdown();

	ACS_SHORT_LOG((LM_INFO, "Exiting ...."));

	/*EP_log.flush();
    LoggingProxy::done();
    delete &EP_log;*/

	BACI_CORBA::DoneCORBA();
	}
    catch( CORBA::Exception &ex )
	{
	ex._tao_print_exception("Error!");
	return -1;
	}


    return 0;
}
예제 #4
0
int main(int argc, char* argv[]) 
{

    
    
    try
	{
	ACE_CString g_strCmdLn;
	for (int i=argc-1; i>=0; i--)
	    g_strCmdLn = ACE_CString(argv[i])+ " " + g_strCmdLn;

	if (g_strCmdLn.find("-ORBDottedDecimalAddresses")==ACE_CString::npos)
	    g_strCmdLn += " -ORBDottedDecimalAddresses 1";

	ACE_TCHAR **m_argv = argv;
	int m_argc = argc;
	ACE_OS::string_to_argv((ACE_TCHAR*)g_strCmdLn.c_str(),
			 m_argc,
			 m_argv);
	BACI_CORBA::InitCORBA(m_argc, m_argv);
	/**
	 * Get reference to a device
	 */

	char fileName[64];
	sprintf(fileName, "file://%s.ior", argv[1]);
	CORBA::Object_var object = BACI_CORBA::getORB()->string_to_object (fileName);
	
	
	if (CORBA::is_nil(object.in())) 
	    {
	    ACE_DEBUG ((LM_DEBUG, "Cannot get Object"));
	    return -1;
	    }

	// Try to narrow the object reference to a PowerSupply reference.
	ENUMPROP_TEST::enumpropTestDevice_var dev = ENUMPROP_TEST::enumpropTestDevice::_narrow (object.in ());
	
	if (CORBA::is_nil(dev.in())) 
	    {
	    ACS_SHORT_LOG((LM_DEBUG, "Failed to narrow enumnTestDevice "));
	    return 0;
	    }
	ACS_SHORT_LOG((LM_DEBUG, "Device narrowed."));

	// Get current stat
	ENUMPROP_TEST::ROStates_var currentState = dev->currentState();
	
	
	//   get states description	
	ACS::stringSeq_var description = currentState->statesDescription( );
	
        
	TestCBpattern cbStates (currentState.in());
        ACS::CBpattern_var cbStatesObj = cbStates._this();

        ACS::CBDescIn desc;
	desc.id_tag = 1;
	ACS::Monitor_var monitor = currentState->create_monitor(cbStatesObj.in(), desc);
	monitor->set_timer_trigger(10000000);
	/**
	 * Enter main loop and stays there for a 
	 * fixed amount of time
	 */
	ACS_SHORT_LOG((LM_DEBUG, "(BACIClient main thread) Going in main loop sleep..."));
 
	BACI_CORBA::getORB()->run();

	BACI_CORBA::DoneCORBA();

	}
    catch( CORBA::Exception &ex )
	{
	ACE_PRINT_EXCEPTION (ex,"Error!");
	return -1;
	}
    
    return 0;
}
예제 #5
0
 TestCBpattern(ENUMPROP_TEST::ROStates_ptr _rostates) : rostates(_rostates) 
 {
   prop = rostates->description();
   description = rostates->statesDescription();
 }