本文整理汇总了C++中SimpleClient::init方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleClient::init方法的具体用法?C++ SimpleClient::init怎么用?C++ SimpleClient::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleClient
的用法示例。
在下文中一共展示了SimpleClient::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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();
}
int nlogs = atoi(argv[1]);
int i;
for ( i=0;i<nlogs;i++)
ACS_SHORT_LOG((LM_INFO,"Sending log number %d", i));
client.logout();
ACE_OS::sleep(3);
return 0;
}
示例2: main
int main(int argc, char *argv[])
{
ACS_SHORT_LOG((LM_INFO, "Welcome to %s!", argv[0]));
long numLogins = std::atol(argv[1]);
long sleepTime = std::atol(argv[2]);
//Creates and initializes the SimpleClient object
SimpleClient client;
if (client.init(argc,argv) == 0)
{
ACE_DEBUG((LM_DEBUG,"Cannot init client"));
return -1;
}
for (long i=0; i< numLogins; i++)
{
client.login();
ACE_OS::sleep(sleepTime);
client.logout();
}
ACS_SHORT_LOG ((LM_INFO, "The end!"));
return 0;
}
示例3: main
int main (int argc, char **argv)
{
ACS_SHORT_LOG ((LM_INFO, "Init maciLogConfigTestClient..."));
SimpleClient client;
MACI_TEST::LogConfigTestClass_ptr comp;
if (client.init(argc,argv) == 0)
{
return -1;
}
else
{
//Must log into manager before we can really do anything
client.login();
}
try
{
comp = client.getComponent<MACI_TEST::LogConfigTestClass>("MACI_LOG_CONFIG",0,true);
comp->log_all();
client.releaseComponent ("MACI_LOG_CONFIG");
client.logout();
}
catch ( CORBA::Exception &ex )
{
ACE_PRINT_EXCEPTION(ex, "main");
}
ACS_SHORT_LOG ((LM_INFO, "Exiting maciLogConfigTestClient..."));
return 0;
} /* end main() */
示例4: main
int main(int argc, char *argv[]) {
SimpleClient client;
if( client.init(argc, argv) == 0 ) {
cerr << "Cannot initialize client, not continuing" << endl;
return 1;
}
client.login();
try {
ACS_SHORT_LOG((LM_INFO,"Obtaining reference to NEWCONFIG_RECEIVER"));
bulkdata::BulkDataReceiver_var receiver = client.getComponent<bulkdata::BulkDataReceiver>("NEWCONFIG_RECEIVER", 0, true);
// This stream is not configuredon the CDB, will use a default configuration
ACS_SHORT_LOG((LM_INFO,"Opening stream 'no_existing_stream' (not in CDB)"));
receiver->openReceiverStream("no_existing_stream");
// This is configured on the CDB, cool
ACS_SHORT_LOG((LM_INFO,"Opening stream 'Name1' (in CDB)"));
receiver->openReceiverStream("Name1");
sleep(2);
// Open the rest of the receivers
ACS_SHORT_LOG((LM_INFO,"Opening all remaining streams (namely, Name7)"));
receiver->openReceiver();
// now sleep a little bit
ACS_SHORT_LOG((LM_INFO,"Sleeping 10 seconds"));
ACE_OS::sleep(10);
// and close the receivers
// woops, this doesn't exist
ACS_SHORT_LOG((LM_INFO,"Closing stream 'name12'"));
receiver->closeReceiverStream("name12");
// This was the one we wanted to close before
ACS_SHORT_LOG((LM_INFO,"Closing stream 'Name1'"));
receiver->closeReceiverStream("Name1");
ACS_SHORT_LOG((LM_INFO,"Closing stream 'no_existing_stream' (but now it does exist)"));
receiver->closeReceiverStream("no_existing_stream");
// close the rest
ACS_SHORT_LOG((LM_INFO,"Closing remaining streams"));
receiver->closeReceiver();
// Close receiver
client.releaseComponent("NEWCONFIG_RECEIVER");
} catch(maciErrType::CannotGetComponentExImpl &ex) {
cerr << "Cannot get component '" << ex.getCURL() << "'. Reason: " << ex.getReason() << endl;
} catch(...) {
cerr << "Unexpected exception while running test code" << endl;
client.logout();
}
}
示例5: main
/** @cond
*/
int main(int argc, char *argv[])
{
SimpleClient client;
int ret;
// Creates and initializes the SimpleClient object
std::cout << "Initializing client..." << std::endl;
std::cout.flush();
if (client.init(argc,argv) == 0) return -1;
//Must log into manager before we can really do anything
client.login();
try
{
ComponentSmartPtr<acsexmplHelloWorld::HelloWorld> foo;
//Get the specific component we have requested on the command-line
foo = client.getComponentSmartPtr<acsexmplHelloWorld::HelloWorld>(argv[1], 0, true);
//Call the displayMessage() method existing in the interface for HelloWorld
foo->displayMessage();
try
{
foo->badMethod();
}
catch(ACSErrTypeCommon::UnknownEx &ex)
{
ACSErrTypeCommon::UnknownExImpl badMethodEx(ex);
badMethodEx.log();
ACS::Time timeStamp = badMethodEx.getTimeStamp();
ACE_CString tString = getStringifiedUTC(timeStamp);
ACS_DEBUG_PARAM(argv[0], "Time of the exception: %s\n", tString.c_str());
}
ret = 0;
}
catch(maciErrType::CannotGetComponentExImpl &_ex)
{
_ex.log();
ret = -1;
}
client.logout();
//Sleep for 3 sec to allow everytihng to cleanup and stablize
ACE_OS::sleep(3);
return 0;
}
示例6: main
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;
}
示例7: main
int main(int argc, char *argv[])
{
SimpleClient client;
if (client.init(argc,argv) == 0)
{
return -1;
}
else
{
client.login();
}
CORBA::ULong invocations = static_cast<CORBA::ULong>(std::atol(argv[1]));
for (unsigned int i=0; i < invocations; i++)
{
ACS_SHORT_LOG((LM_INFO, "A message"));
}
client.logout();
return 0;
}
示例8: main
int main(int argc,char* argv[])
{
// create instance of SimpleClient and init() it.
SimpleClient ci;
if(ci.init(argc,argv) == 0)
{
ACE_DEBUG((LM_DEBUG,"Cannot init client"));
return -1;
}
ci.login();
try
{
// get reference to Clock device
CORBA::Object_var obj = ci.get_object("CLOCK1",0,true);
if(CORBA::is_nil(obj.in()))
{
return -1;
}
// narrow object to obtain Clock reference
acstime::Clock_var dev = acstime::Clock::_narrow(obj.in());
if (CORBA::is_nil(dev.in()))
{
std::cerr << "Nil Clock reference" << std::endl;
return -1;
}
//---------------------------------------------------------------
ACSErr::Completion_var completion;
ACSErr::Completion* c;
int rtnVal;
// get pointer to array2TAI Property
ACS::RWlong_ptr p_a2t = dev->array2TAI();
for (int i = 0; i < 200; i = (i + 1) * 2)
{
// set array2TAI value
c = p_a2t->set_sync(i);
if (c->code == 0)
cout << "Set array2TAI=" << i << endl;
else
cout << "ERROR array2TAI=" << c->code << endl;
// get array2TAI value
rtnVal = p_a2t->get_sync(completion.out());
if (completion->code != 0)
cout << "ERROR array2TAI get=" << completion->code << endl;
else
{
cout << "Got array2TAI=" << rtnVal << endl;
if (i != rtnVal)
cout << "ERROR array2TAI get != set" << endl;
}
}
// get pointer to TAI2UTC Property
ACS::RWlong_ptr p_t2u = dev->TAI2UTC();
for (int i = 0; i < 200; i = (i + 1) * 2)
{
// set TAI2UTC value
c = p_t2u->set_sync(i);
if (c->code == 0)
cout << "Set TAI2UTC=" << i << endl;
else
cout << "ERROR TAI2UTC=" << c->code << endl;
// get TAI2UTC value
rtnVal = p_t2u->get_sync(completion.out());
if (completion->code != 0)
cout << "ERROR TAI2UTC get=" << completion->code << endl;
else
{
cout << "Got TAI2UTC=" << rtnVal << endl;
if (i != rtnVal)
cout << "ERROR TAI2UTC get != set" << endl;
}
}
}
catch( CORBA::Exception &ex )
{
ACE_PRINT_EXCEPTION(ex,"Error!");
ci.logout();
return -1;
}
ci.logout();
return 0;
}
示例9: main
/** @cond
*/
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 initialyses 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
{
//Gets from manager the reference to the requested component.
//Pay special attention that this reference is just a generic
//CORBA object at this point.
ACS_SHORT_LOG((LM_INFO, "Looking for Object '%s' ", argv[1]));
CORBA::Object_var obj = client.getComponent(argv[1], 0 , true);
//Get the stringified IOR of the component. The IOR of CORBA objects
//can be considered to be a unique "phone number" used to access CORBA
//servants.
ACS_SHORT_LOG((LM_INFO, "Getting stringified IOR"));
CORBA::String_var mior = client.getORB()->object_to_string(obj.in());
//Print the IOR to standard out
u_int result;
ACS_SHORT_LOG ((LM_INFO, "IOR for %s is: %s", argv[1], mior.in()));
result = ACE_OS::printf ("%s", mior.in());
}
catch(maciErrType::CannotGetComponentExImpl &_ex)
{
_ex.log();
return -1;
}
catch(...)
{
ACSErrTypeCommon::UnexpectedExceptionExImpl uex(__FILE__, __LINE__,
"main");
uex.log();
return -1;
}
//Normally you would not want to have separate try sections for releasing
//the components and logging out from manager. This is a very special case
//since we do not know ahead of time what will be released. In other words,
//argv[1] could technically be "manager" which would end up raising a
//no-permission exception. To get around this just use separate try/catch
//sections and ignore no-permission exceptions.
try
{
//All clients must cleanly release objects they activate!
client.releaseComponent(argv[1]);
}
catch(maciErrType::CannotReleaseComponentExImpl &_ex)
{
_ex.log();
return -1;
}
catch(...)
{
ACSErrTypeCommon::UnexpectedExceptionExImpl uex(__FILE__, __LINE__,
"main");
uex.log();
return -1;
}
try
{
if (client.logout() == 0)
{
ACS_SHORT_LOG ((LM_INFO, "Cannot logout"));
return -1;
}
}
catch(...)
{
ACS_SHORT_LOG((LM_ERROR, "Exception caught"));
return -1;
}
ACS_SHORT_LOG((LM_INFO,"The end!"));
//.........这里部分代码省略.........
示例10: main
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();
}
//.........这里部分代码省略.........
示例11: main
/**
* A client to send alarms: it expects to find the number of alarm to send
* as a parameter in the command line.
* As an option, it is also possible to set in the command line the
* fault family and the fault member.
* By default the fault family is "ALCLIENT" and the Fault Member is (ALARM).
* The fault code is always set to 1.
* For each alarm to send a triplet like <ALCLIENT, ALARM_1, 1> is created.
* <P>
* For each alarm, the process activates it and then terminates it.
* First all the alarms are activated then terminated.
* <P>
* The purposes of this process are:
* <UL>
* <LI>Check if sending alarms from a client works
* <LI>have a client that sends alarms from the command line
* <LI>allow to investigate problems in the sources without the complexity of the container
* <UL>
*/
int main(int argc, char *argv[])
{
// Checks command-line arguments.
if (argc !=2 && argc!=4)
{
ACS_SHORT_LOG((LM_INFO, "Usage: %s <num. of alarms to send> [<FaultFamily Fault_Member>]", argv[0]));
return -1;
}
//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();
}
// Get the number of alarms to send
int alarmsToSend = (int)strtof(argv[1],NULL);
if (alarmsToSend==0) {
// It can happen if the user set 0 as param or if the conversion made
// by strtof failed
ACS_SHORT_LOG((LM_ERROR, "%d alarms to send: nothing to do. Check val of first param (%s). Is it a number?", alarmsToSend,argv[1]));
return -1;
}
// Init the alarm system factory
ACSAlarmSystemInterfaceFactory::init(client.manager());
ACS_SHORT_LOG((LM_DEBUG, "ACSAlarmSystemInterfaceFactory initialized"));
std::string FF="ALCLIENT";
std::string FM="ALARM";
const int FC=1;
if (argc==4) {
FF=argv[2];
FM=argv[3];
}
ACS_SHORT_LOG((LM_INFO, "Generating %d alarms with triplets like <%s, %s_n, 1>", alarmsToSend,FF.c_str(), FM.c_str()));
// create the AlarmSystemInterface
auto_ptr<acsalarm::AlarmSystemInterface> alarmSource(ACSAlarmSystemInterfaceFactory::createSource());
ACS_SHORT_LOG((LM_DEBUG, "Source created"));
ACS_SHORT_LOG((LM_INFO, "Sending ACTIVE alarms"));
for (int t=0; t<alarmsToSend; t++) {
char tempStr[8];
sprintf(tempStr,"%d",t);
std::string fmTosend=FM;
fmTosend+='_';
fmTosend+=tempStr;
sendAlarm(alarmSource.get(),FF,fmTosend,FC,true);
}
sleep(5);
ACS_SHORT_LOG((LM_INFO, "Sending TERMINATE alarms"));
for (int t=0; t<alarmsToSend; t++) {
char tempStr[8];
sprintf(tempStr,"%d",t);
std::string fmTosend=FM;
fmTosend+='_';
fmTosend+=tempStr;
sendAlarm(alarmSource.get(),FF,fmTosend,FC,false);
}
auto_ptr<acsalarm::AlarmSystemInterface> tstSource(ACSAlarmSystemInterfaceFactory::createSource());
// ACSAlarmSystemInterfaceFactory::done();
client.logout();
ACS_SHORT_LOG((LM_INFO, "%s done.",argv[0]));
return 0;
}
示例12: main
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);
//.........这里部分代码省略.........
示例13: main
/** @cond
*/
int main(int argc, char* argv[])
{
MOUNT_ACS::Mount_var mount;
BACIThreadManager threadManager; // The thread manager is used to manage the thread
ThreadParamStruct param; // The parameter for the thread
// Check the arguments in the command line
if (argc<2) {
std::cerr<<"Usage: "<<argv[0]<<" component azimuth elevation <options>\n";
return -1;
}
double destAz, destEl;
if (sscanf(argv[2],"%lf",&destAz)+sscanf(argv[3],"%lf",&destEl)!=2) {
std::cerr<<"Format error in azimuth and/or elevation"<<std::endl;
std::cerr<<"Usage: "<<argv[0]<<" component azimuth elevation <options>\n";
return -1;
}
// Create the SimpleClient object
SimpleClient mountClient;
// Init the client
if (mountClient.init(argc,argv)==0) {
// Error initing
ACS_SHORT_LOG((LM_ERROR,"Error initing the client"));
return -1;
} else {
ACS_SHORT_LOG((LM_INFO,"SimpleClient built"));
}
// Login the client
if (mountClient.login()==0) {
//Error
ACS_SHORT_LOG((LM_ERROR,"Error logging in the client"));
return -1;
} else {
ACS_SHORT_LOG((LM_INFO,"Client logged in"));
}
try
{
// Get the component
ACS_SHORT_LOG((LM_INFO,"Getting component %s",argv[1]));
mount = mountClient.getComponent<MOUNT_ACS::Mount>(argv[1], 0, true);
}
catch(maciErrType::CannotGetComponentExImpl &_ex)
{
_ex.log();
return -1;
}
param.mount=mount.ptr();
param.az=destAz;
param.el=destEl;
char logStr[128];
sprintf(logStr,"Commanded position az=%lf, el=%lf",destAz,destEl);
ACS_SHORT_LOG((LM_INFO,logStr));
// Start the thread to read the position of the antenna
ACS_SHORT_LOG((LM_INFO,"Starting the thread"));
BACIThread* thread_p = threadManager.create("Position thread", //Name of the new thread
(void *)worker, //Function to run inside the thread
static_cast<void *>(¶m)); //the single parameter
if (thread_p==NULL) {
ACS_SHORT_LOG((LM_ERROR,"Error in spawning thread"));
}
thread_p->resume();
// The thread will run for 30 secs so we wait until it finishes
// There are better (and safer) solution to wait instead of a simple wait
// but... this is the faster one!
sleep(40);
// End of computation: begin to clean up
// Stop all the threads
ACS_SHORT_LOG((LM_INFO,"Terminating the thread"));
threadManager.terminateAll();
// Release the component
try
{
ACS_SHORT_LOG((LM_INFO,"Releasing %s",argv[1]));
mountClient.releaseComponent(argv[1]);
}
catch(maciErrType::CannotReleaseComponentExImpl &_ex)
{
_ex.log();
return -1;
}
// logout the client
try
{
ACS_SHORT_LOG((LM_INFO,"Logging out"));
//.........这里部分代码省略.........
示例14: main
int main(int argc, char *argv[])
{
// Creates and initializes the SimpleClient object
SimpleClient client;
if (client.init(argc,argv) == 0)
{
ACS_SHORT_LOG((LM_ERROR, "acsexmplClientErrorComponent::main, Failed to initialize"));
return -1;
}
else
{
//Must log into manager before we can really do anything
client.login();
}
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main"));
/**************************************************************************
* Here we instantiate the object used to show examples of error handling.
* Each method call demonstrate one aspect of error hanlding.
* See the class documentation for details.
*/
try
{
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, created instance of ClientErrorComponent"));
ClientErrorComponent clientErrorComponent(client, argv[1]);
//Call the displayMessage() method existing in the interface for ErrorComponent
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, calling TestOk()"));
clientErrorComponent.TestOk();
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, calling TestReceiveRemoteException()"));
clientErrorComponent.TestReceiveRemoteException();
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, calling TestReceiveRemoteCompletion()"));
clientErrorComponent.TestReceiveRemoteCompletion();
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, calling TestReceiveCorbaSystemException()"));
clientErrorComponent.TestReceiveCorbaSystemException();
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, calling testCompletionFromCompletion()"));
clientErrorComponent.testCompletionFromCompletion();
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, calling testExceptionFromCompletion()"));
clientErrorComponent.testExceptionFromCompletion();
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, calling testTypeException()"));
clientErrorComponent.testTypeException();
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, calling testCompletionOnStack()"));
clientErrorComponent.testCompletionOnStack();
ACS_SHORT_LOG((LM_TRACE, "acsexmplClientErrorComponent::main, calling testOutCompletion()"));
clientErrorComponent.testOutCompletion();
}
catch(ACSErr::ACSbaseExImpl ex)
{
/*
* We should never get here, because the methods in the example
* should be all self contained and none of them should throw
* any exception.
*/
ACSErrTypeCommon::GenericErrorExImpl badMethodEx(ex, __FILE__, __LINE__,
"main");
badMethodEx.setErrorDesc("Examples of error handling have thrown an ACS exception");
badMethodEx.log();
}
catch(...)
{
/*
* We should never get here, because the methods in the example
* should be all self contained and none of them should throw
* any exception.
*/
ACSErrTypeCommon::GenericErrorExImpl badMethodEx(__FILE__, __LINE__,
"main");
badMethodEx.setErrorDesc("Examples of error handling have thrown an UNEXPECTED exception");
badMethodEx.log();
}
/****************************************************
* We logout from manager
*/
client.logout();
//Sleep for 3 sec to allow everything to cleanup and stablize
ACE_OS::sleep(3);
return 0;
}
示例15: main
/** @cond
*/
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
{
//Get the specific component we have requested on the command-line
FRIDGE::FridgeControl_var fridge = client.getComponent<FRIDGE::FridgeControl>(argv[1], 0, true);
//Run whatever supported command the end-user has specified
//from the command-line
if(strcmp(argv[2],"ON") == 0) // Command ON
{
ACS_SHORT_LOG((LM_INFO, "ON"));
fridge->on();
}
else if(strcmp(argv[2],"OFF") == 0) // Command OFF
{
ACS_SHORT_LOG((LM_INFO, "OFF"));
fridge->off();
}
else if(strcmp(argv[2],"OPEN") == 0) // Command OPEN
{
ACS_SHORT_LOG((LM_INFO, "OPEN"));
fridge->open();
}
else if(strcmp(argv[2],"CLOSE") == 0) // Command CLOSE
{
ACS_SHORT_LOG((LM_INFO, "CLOSE"));
fridge->close();
}
else
{
// User specified some non-existant command
ACS_SHORT_LOG((LM_INFO, "Unknown command"));
}
}
catch(maciErrType::CannotGetComponentExImpl &_ex)
{
_ex.log();
return -1;
}
catch(...)
{
ACSErrTypeCommon::UnexpectedExceptionExImpl uex(__FILE__, __LINE__,
"main");
uex.log();
return -1;
}
try
{
//Release the component and log out 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();
}//try-catch
// sleep for 3 sec.
ACE_OS::sleep(3);
return 0;
}