ACS::ROpattern_ptr BaciPropTest::testPatternVar () { if (m_testPatternVar_sp == 0) { return ACS::ROpattern::_nil(); } ACS::ROpattern_var prop = ACS::ROpattern::_narrow(m_testPatternVar_sp->getCORBAReference()); return prop._retn(); }
ACS::ROpattern_ptr MCtestComponentImpl::patternProp () { if (m_patternProp_p == 0) { return ACS::ROpattern::_nil(); } ACS::ROpattern_var prop = ACS::ROpattern::_narrow(m_patternProp_p ->getCORBAReference()); return prop._retn(); }
ACS::ROpattern_ptr PowerSupply::status () { if (m_status_sp == 0) { return ACS::ROpattern::_nil(); } ACS::ROpattern_var prop = ACS::ROpattern::_narrow(m_status_sp->getCORBAReference()); return prop._retn(); }
int main (int argc, char **argv) #endif { try { // create logging proxy LoggingProxy *m_logger = new LoggingProxy(0, 0, 31, 0); LoggingProxy::init(m_logger); LoggingProxy::ProcessName(argv[0]); LoggingProxy::ThreadName("main"); ACS_TEST_INIT_LOGGING; // // Initialysation of CORBA, POA and related CORBA internals // 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); std::string readIOR; int result = read_IOR_from_file ("BACIALARM", readIOR); if (result != 0) { ACS_SHORT_LOG((LM_ERROR, "Cannot read IOR from file")); return -1; } // Get an object reference from the argument string. CORBA::Object_var object = BACI_CORBA::getORB()->string_to_object (readIOR.c_str()); if (CORBA::is_nil(object.in())) { ACS_SHORT_LOG ((LM_DEBUG, "Cannot create OBJ from IOR")); return -1; } // Try to narrow the object reference to a BaciTestAlarmClass reference. BACI_TEST::BaciTestAlarmClass_var comp = BACI_TEST::BaciTestAlarmClass::_narrow(object.in()); CORBA::String_var ior = BACI_CORBA::getORB()->object_to_string (comp.in()); ACS_SHORT_LOG((LM_INFO,"baciTestAlarmClient: Connecting to: %s", ior.in())); /********************* pattern alarm subscription ******************/ ACS::ROpattern_var roPattern = comp->roPatternProperty(); ACS::RWpattern_var rwPattern = comp->rwPatternProperty(); //create an instance of our alarm class MyAlarmpattern macb("roPatternProperty"); //activate it as a CORBA object ACS::Alarmpattern_var acb = macb._this(); //create the actual BACI double alarm ACS::CBDescIn desc; ACS::Subscription_var alarmSub = roPattern->new_subscription_Alarm(acb.in(), desc); ACS_SHORT_LOG((LM_INFO,"Alarmpattern subscription created")); // create the thread WorkerThreadPattern threadPattern_p ("actionThreadPattern", comp, ThreadBase::defaultResponseTime, ThreadBase::defaultSleepTime*10 /*=1s*/); // by default threads that are not created using a thread manager are creatd suspended so we have to resume them!! threadPattern_p.resume(); //--------------------------------------------------------------- //Enter main loop and stays there for a fixed amount of time. Really we are //just allowing the thread we just created to run for awhile before exiting out //of this example. ACS_SHORT_LOG((LM_INFO,"baciTestAlarmClient: main thread, entering ORB loop to sleep...")); ACE_Time_Value tv(25); BACI_CORBA::getORB()->run(tv); //Must cleanly destroy the alarm ACS_SHORT_LOG((LM_INFO,"Alarm subscriptions deleted")); alarmSub->destroy(); ACS_SHORT_LOG((LM_INFO,"baciTestAlarmClient: main thread, shutting down...")); comp->shutdown(); sleep(10); BACI_CORBA::DoneCORBA(); // Delete the logger last. delete m_logger; } catch(CORBA::Exception &ex) { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"Error!"); return -1; } ACE_CHECK_RETURN (-1); // Wait for the servant to complete cleanup before exiting. sleep(2); return 0; } /* end main() */