コード例 #1
0
ファイル: testXML.cpp プロジェクト: ACS-Community/ACS
/**
 * Private method to orchestrate the XML parsing using DOM.
 * @param xmlData - ptr to an InMemoryXmlData object (OR NULL if we are using a file)
 * NOTE: one of the params, but not both, should be NULL for a given parse - i.e.
 * either we are parsing from a file or parsing from memory, but not both (nor neither -
 * i.e. NULL for both params should not occur either).
 */
DOMDocument* AcsAlarmTestCase::parseDOM(std::string xmlData)
{
	DOMDocument *doc = 0;
	MemBufInputSource *mbis = NULL;

	bool caughtException = false;
	try {
		mbis = new  MemBufInputSource((const XMLByte *) xmlData.c_str(), xmlData.length(), "ID", false);
		Wrapper4InputSource wrapper4InputSource(mbis);
		doc = parser->parse(wrapper4InputSource);
	}
	catch (const XMLException& toCatch) {
		char* message = XMLString::transcode(toCatch.getMessage());
		ACS_LOG(LM_ERROR, "AcsAlarmTestCase::parseDOM", (LM_ERROR,
			"***** XMLException message: ***** \n\n%s \n *****\n", message))
		XMLString::release(&message);
		caughtException = true;
	}
	catch (const DOMException& toCatch) {
		char* message = XMLString::transcode(toCatch.msg);
		ACS_LOG(LM_ERROR, "AcsAlarmTestCase::parseDOM", (LM_ERROR, "***** DOMException message: %s *****", message))
		XMLString::release(&message);
		caughtException = true;
	}

	CPPUNIT_ASSERT_MESSAGE("parseDOM received an exception during parsing", (false == caughtException));

	return doc;
}
コード例 #2
0
void MountVertexLLamaCompSimImpl::initialize() {

  MountVertexLLamaCompSimBase::initialize();
  /*std::vector<CAN::byte_t> sn(8,0x00);
  AMB::node_t node = 0x00;	*/
  const std::string fnName("MountVertexLLamaCompSimImpl::initialize");
  AUTO_TRACE(fnName);
  std::string componentName(compName_m);
  unsigned long long hashed_sn=AMB::Utils::getSimSerialNumber(componentName,"MountVertexLLama");
  std::ostringstream msg;
  msg<< "simSerialNumber for  " << compName_m << "  with assembly name " << "MountVertexLLama" << " is " << std::hex << "0x" << hashed_sn << std::endl;
  ACS_LOG(LM_SOURCE_INFO, fnName, (LM_DEBUG, msg.str().c_str()));

  std::vector< CAN::byte_t > sn;
  AMB::node_t node = 0x00;
  AMB::TypeConversion::valueToData(sn,hashed_sn, 8U);

  // Antenna name conversion for shared simulator.
  SharedSimAntNameMapping ss_antID = SharedSimAntNameMapping();

  try{
    device_m = new AMB::MountVertexLLamaHWSimImpl(node,
					     sn,
					     ss_antID.getAntennaID(compName_m),
					     getContainerServices()->getDefaultComponent<SHARED_SIMULATOR::SharedSimulator>("IDL:alma/SHARED_SIMULATOR/SharedSimulator:1.0"));
  }
  catch(maciErrType::CannotGetComponentExImpl &_ex)
    {
      device_m = new AMB::MountVertexLLamaHWSimImpl(node,sn);
    }
  simulationIf_m.setSimObj(device_m);
  device_m->start();
}
コード例 #3
0
ファイル: Lx200EMCVelDevIO.cpp プロジェクト: javarias/csat
Lx200EMCVelDevIO::Lx200EMCVelDevIO(char *deviceName, int axis, bool reversed) throw (csatErrors::CannotOpenDeviceEx)
{
		  char *_METHOD_=(char *)"Lx200EMCVelDevIO::Lx200EMCVelDevIO";
		  ACS::Time time = getTimeStamp();
		  CORBA::Double initialSlewRate(0.0);

		  try{
					 this->sp = new SerialRS232(deviceName,100);
		  } catch(SerialRS232::SerialRS232Exception serialEx) {
					 ACS_LOG( LM_ERROR , _METHOD_ , (LM_ERROR, "CannotOpenDeviceEx: %s", serialEx.what()) );
					 csatErrors::CannotOpenDeviceExImpl ex(__FILE__,__LINE__,_METHOD_);
					 ex.addData("Reason",serialEx.what());
					 throw ex.getCannotOpenDeviceEx();
		  }

		  /* Check telescope connection by setting initial slew rate */
		  try{
					this->axis = axis;
					write(initialSlewRate, time);

		  } catch(SerialRS232::SerialRS232Exception serialEx) {
					 csatErrors::CannotOpenDeviceExImpl ex(__FILE__,__LINE__,_METHOD_);
					 ex.addData("Reason",serialEx.what());
					 throw ex.getCannotOpenDeviceEx();
		  }

	if(this->axis == ALTITUDE_AXIS)
      this->slewRateElevation = 0;
   else
      this->slewRateAzimuth = 0;
	this->reversed = reversed;
}
コード例 #4
0
ファイル: NexstarVelDevIO.cpp プロジェクト: javarias/csat
NexstarVelDevIO::NexstarVelDevIO(char *deviceName, int axis, bool reversed) throw (csatErrors::CannotOpenDeviceEx){

	char *_METHOD_=(char *)"NexstarVelDevIO::NexstarVelDevIO";

	try{
		ACS_TRACE("Creating SeriaRS232 device");
		this->sp = new SerialRS232(deviceName);
	} catch(SerialRS232::SerialRS232Exception serialEx) {
		ACS_LOG( LM_ERROR , _METHOD_ , (LM_ERROR, "CannotOpenDeviceEx: %s", serialEx.what()) );
		csatErrors::CannotOpenDeviceExImpl ex(__FILE__,__LINE__,_METHOD_);
		ex.addData("Reason",serialEx.what());
		throw ex.getCannotOpenDeviceEx();
	}
	this->sp->flush_RS232();

	/* Test if the telescope is connected */
	try{
		this->sp->write_RS232("Kx",2);
		this->sp->read_RS232();
	} catch(SerialRS232::SerialRS232Exception serialEx) {
		csatErrors::CannotOpenDeviceExImpl ex(__FILE__,__LINE__,_METHOD_);
		ex.addData("Reason",serialEx.what());
		throw ex.getCannotOpenDeviceEx();
	}

	this->axis = axis;
	if(this->axis == ALTITUDE_AXIS)
      this->slewRateElevation = 0;
   else
      this->slewRateAzimuth = 0;

	this->reversed = reversed;
}
コード例 #5
0
void CheckDevIOValue::checkValue<double>(double value)
{
	double absValue = fabs(value);
	if (absValue > 2.0e17 || (absValue > 0.0 && absValue < 1.0e-9))
	{
		ACS_LOG(LM_FULL_INFO ,"CheckDevIOValue::checkValue<double>", (LM_WARNING, "Value of property: %s (%f) read from DevIO has non meaningful physical value. Probably problem in DevIO impl!",
				propName_m.c_str(),
				value));
	}
}//checkMonitorValue<double>
コード例 #6
0
int main(int argc, char *argv[])
{
    LoggingProxy logger_m(0, 0, 31);
    LoggingProxy::init(&logger_m);

    ACS::ThreadManager tm;

    /*
     * Creates an autodelete thread that runs every 300 mseconds
     * and stops it after 10 iterations.
     */
    ACS::TimeInterval ti = 3000000;  /* 300ms */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Creating thread with time interval %ld", ti));

    /*
     * Since the Thread is autodelete and
     * we do n access it,
     * we do not need to assign it to a variable
     */
    // TestACSThread *a = 
	tm.create<TestACSThread>("TestThreadA", 
				 ti, ti,
				 true);
    tm.resume("TestThreadA");

    /**
     * TODO GCH
     * Add here measure of time.
     * For the time being we simply assume that in 4 seconds
     * it will have completed.
     */
    sleep(4);

    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Done"));
    return 0;

}
コード例 #7
0
    TestACSThreadWithParameter(const ACE_CString& name,
			       char  *parmMsg,
			       const ACS::TimeInterval& responseTime,
			       const ACS::TimeInterval& sleepTime,
			       bool del,
			       const long thrFlags,
			       const size_t stackSize) :
	ACS::Thread(name, responseTime, sleepTime, del, thrFlags, stackSize)
	{
	    ACS_TRACE("TestACSThreadWithParameter::TestACSThreadWithParameter");
	    msg = parmMsg;
	    ACS_LOG(LM_SOURCE_INFO, "TestACSThreadWithParameter::TestACSThreadWithParameter",
		    (LM_INFO, "Thread parameter: %s", parmMsg));
	}
コード例 #8
0
ファイル: testLoggerStats.cpp プロジェクト: jjpopski/ACS
void logBatchUsingMacrosGeneralLogger()
{
	std::cout << "Log batch for logger [" << "GeneralLogger" << "]. USING ACS MACROS." << std::endl;

	// Test macros
	{
		AUTO_TRACE("TEST_MACROS");
		ACS_LOG(LM_RUNTIME_CONTEXT, __PRETTY_FUNCTION__, (LM_INFO, "LM_RUNTIME_CONTEXT inside TEST_MACROS"));
		ACS_LOG(LM_SOURCE_INFO, __PRETTY_FUNCTION__, (LM_INFO, "LM_SOURCE_INFO inside TEST_MACROS"));
	}

	ACS_LOG(LM_RUNTIME_CONTEXT, __PRETTY_FUNCTION__, (LM_INFO, "LM_RUNTIME_CONTEXT outside TEST_MACROS"));
	ACS_LOG( LM_SOURCE_INFO, __PRETTY_FUNCTION__, (LM_INFO, "LM_SOURCE_INFO outside TEST_MACROS"));

	ACS_TRACE(__PRETTY_FUNCTION__);

    ACS_SHORT_LOG((LM_INFO, "Test ACS_SHORT_LOG with LM_INFO"));

    //ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_SHUTDOWN, "Test of LM_SHUTDOWN log")); // NOT logging a thing
    ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_TRACE, "Test of LM_TRACE log"));
    //ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_DELOUSE, "Test of LM_DELOUSE log")); // Not logginf a thing
    ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_DEBUG, "Test of LM_DEBUG log"));
    ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_INFO, "Test of LM_INFO log"));
    ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_NOTICE, "Test of LM_NOTICE log"));
    ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_WARNING, "Test of LM_WARNING log"));
    ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_ERROR, "Test of LM_ERROR log"));
    ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_CRITICAL, "Test of LM_CRITICAL log"));
    ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_ALERT, "Test of LM_ALERT log"));
    ACS_LOG( LM_FULL_INFO, __PRETTY_FUNCTION__, (LM_EMERGENCY, "Test of LM_EMERGENCY log"));

    // Debug messages
    ACS_DEBUG(__PRETTY_FUNCTION__, "Test of ACS_DEBUG macro");
    ACS_DEBUG_PARAM(__PRETTY_FUNCTION__, "Test of ACS_DEBUG_PARAM macro with param: %s", "param1");
} // 17 + 2 messages (entering + exiting)
コード例 #9
0
int main(int argc, char *argv[])
{

	int i, n;
	int STACKSIZE;
	ACS::Thread *threads[MAX_THREAD];
	ACS::ThreadManager tm;

	if (argc < 2)
	{
		printf ("Usage: %s threads# [stacksize in kB]\n", argv[0]);
		return 1;
	}


	n = atoi(argv[1]);

	if ((n < 1) || (n > MAX_THREAD))
	{
		printf ("The # of thread should between 1 and %d.\n",MAX_THREAD);
		return 2;
	}//if

	LoggingProxy logger_m(0, 0, 31);
	LoggingProxy::init(&logger_m);

	STACKSIZE = atoi(argv[2]) * 1024;

	ACS_LOG(LM_SOURCE_INFO,"main",
			(LM_INFO, "=============== 1 - Trying to create %d threads with a parameter and stack size, n"));
	char *msg="Thread msg";
	try
	{
		for(i=0; i<n; i++)
		{
			std::ostringstream c;
			c << "Thread#" << i  << std::ends;
			threads[i]=
				tm.create<TestACSThreadWithParameter, char*>(c.str().c_str(),
						msg,
						ACS::ThreadBase::defaultResponseTime,
						ACS::ThreadBase::defaultSleepTime,
						false,
						THR_NEW_LWP | THR_DETACHED,
						STACKSIZE);
				threads[i]->resume();
				ACS_LOG(LM_SOURCE_INFO,"main",
						(LM_INFO, "Thread with a parameter #%d created", i));
		}//for
	}
	catch(ACSErr::ACSbaseExImpl &ex)
	{
		ex.log();
	}
	ACS_LOG(LM_SOURCE_INFO,"main",
			(LM_INFO, "Created %d threads with a parameter with stack size %d kB", i, atoi(argv[2])));

	ACS_LOG(LM_SOURCE_INFO,"main",
			(LM_INFO, "Going to destroy threads"));
	for(--i;i>=0;i--)
	{
		tm.destroy(threads[i]);
	//	ACS_LOG(LM_SOURCE_INFO,"main", (LM_INFO, "Thread #%d deleted", i));
	}//for

	sleep(1);

	ACS_LOG(LM_SOURCE_INFO,"main",
			(LM_INFO, "=============== 2 - Trying to create %d threads with stack size", n));

	try
		{
			for(i=0; i<n; i++)
			{
				std::ostringstream c;
				c << "Thread#" << i  << std::ends;
				threads[i]=
					tm.create<TestACSThread>(c.str().c_str(),
							ACS::ThreadBase::defaultResponseTime,
							ACS::ThreadBase::defaultSleepTime,
							false,
							THR_NEW_LWP | THR_DETACHED,
							STACKSIZE);
					threads[i]->resume();
					ACS_LOG(LM_SOURCE_INFO,"main",
							(LM_INFO, "Thread #%d created", i));
			}//for
		}
		catch(ACSErr::ACSbaseExImpl &ex)
		{
			ex.log();
		}
		ACS_LOG(LM_SOURCE_INFO,"main",
				(LM_INFO, "Created %d threads with stack size %d kB", i, atoi(argv[2])));

		ACS_LOG(LM_SOURCE_INFO,"main",
				(LM_INFO, "Going to destroy threads"));
		for(--i;i>=0;i--)
		{
			tm.destroy(threads[i]);
		//	ACS_LOG(LM_SOURCE_INFO,"main", (LM_INFO, "Thread #%d deleted", i));
		}//for


	/**
	 * Wait for everything to cleanup and go home
	 */
	sleep(5);
	ACS_LOG(LM_SOURCE_INFO,"main",
			(LM_INFO, "=============== The end"));

	return 0;
}
コード例 #10
0
ファイル: bulkDataNTCallback.cpp プロジェクト: jjpopski/ACS
void AcsBulkdata::BulkDataNTCallback::setCBReceiveAvgProcessTimeout(double to) {
    cbReceiveAvgProcessTimeout_m=to;
    ACS_LOG(LM_RUNTIME_CONTEXT, __PRETTY_FUNCTION__, (LM_DEBUG, "cbReceiveAvgProcessTimeout set to: %f sec",
            cbReceiveAvgProcessTimeout_m));
}
コード例 #11
0
/*
 * This test manipulates threads without the support
 * of a Thread Manager
 */
int main(int argc, char *argv[])
{
    LoggingProxy logger_m(0, 0, 31);
    LoggingProxy::init(&logger_m);

    /*
     * Creates a thread passing just thread name
     * Given the constructor default parameters, this will have
     * default iteration time and will NOT be auto-delete.
     *
     * Notice that since we do not create it throught a thread manager,
     * the thread will be always created suspended.
     *
     * We let it run for a while, then we ask the ThreadManager to destroy  it.
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "=============== 1 - Creating thread passing just thread name"));
    TestACSThread *a = new TestACSThread("TestThreadA");

    /*
     * Nothing happens here, because the thread is born
     * suspended no matter what parameter we pass.
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Wait a few seconds. Nothing should happen"));
    sleep(5);

    /*
     * Therefore we resume it.
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Resume the thread and wait. The thread should be executed."));
    a->resume();
    sleep(5);

    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Destroy thread"));
    delete a;

    /*
     * Creates a thread as before, but initially suspended.
     *   ( without ThreadMaanger, it always suspended )
     * We wait a while to see if it is really suspended.
     * Then we resume its execution and we let it sun for a while.
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "=============== 2 - Creating thread initially suspended"));
    TestACSThread *b = new TestACSThread("TestThreadB");
    sleep(20);
    b->resume();
    sleep(20);

    /*
     * Here we forcefully delete the thread without stopping it first
     * The thread should automatically stop gracefully and then be deleted.
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Deleting thread"));
    delete b;


    /*
     * Creates a thread as before not initially suspended
     *   ( without a ThreadManager, it created suspended anyway )
     * and with specific responce and sleep times.
     * Then we suspend and resume its execution a few times to
     * see if suspend works properly.
     * We can reuse the pointer to the deleted thread
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "=============== 3 - Creating thread, suspend and resume a few times"));
    b = new TestACSThread("TestThreadC", 
			  100*1000*10/*=100ms*/, 142*100*1000*10 /*14.2 sec*/);
    /*
     * Nothing happens here, because the thread is born
     * suspended no matter what parameter we pass.
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Wait a few seconds. Nothing should happen"));
    sleep(10);
    b->suspend();
    sleep(10);
    b->resume();
    sleep(50);
    b->suspend();
    sleep(20);
    b->resume();
    sleep(50);

    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Deleting thread"));
    delete b;

    /*
     * Creates a thread that is never woken-up
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "=============== 4 - Creating thread that is never woken-up"));
    TestACSThread *forEverSleep = new TestACSThread("SuspendForEver");
    sleep(20);

    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Deleting thread"));
    delete forEverSleep;

    /*
     * Creates a thread with a long period
     * and then stop it.
     * Stop will take as long as the period but fast responce time.
     * Stop should fail.
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "=============== 5 - Creating thread with long period and stop() it"));
    b = new TestACSThread("TestThreadC", 
				 20*100*1000*10 /*=2sec*/, 100*100*1000*10 /*10 sec*/);
    /*
     * Nothing happens here until I resume, because the thread is born
     * suspended no matter what parameter we pass.
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Wait a few seconds. Nothing should happen"));
    b->resume();
    sleep(5);

    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Stopping thread"));
    if(b->stop() == false)
	{
	ACS_LOG(LM_SOURCE_INFO,"main", 
		(LM_INFO, "Stop failed, as expected"));
	}
    else
	{
	ACS_LOG(LM_SOURCE_INFO,"main", 
		(LM_INFO, "Stop succeded but should have failed"));
	}
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Deleting thread"));
    sleep(2);
    delete b;

    /*
     * Creates a thread with a long period
     * and then cancel it.
     * Cancel should be quick.
     */
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "=============== 6 - Creating thread with long period and cancel() it"));
    b = new TestACSThread("TestThreadC", 
			  20*100*1000*10 /*=2 sec*/, 100*100*1000*10 /*10 sec*/);
    sleep(5);
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Cancelling thread"));
    b->cancel();

    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "Deleting thread"));
    delete b;

    /**
     * Wait for everything to cleanup and go home
     */
    sleep(5);
    ACS_LOG(LM_SOURCE_INFO,"main", 
	    (LM_INFO, "=============== The end"));

    return 0;

}
コード例 #12
0
ファイル: baciBACIComponent.cpp プロジェクト: jbarriosc/ACS
void actionThreadWorker(void* param) {

  if (param==0) return;

  BACIThreadParameter* baciParameter_p = static_cast<BACIThreadParameter*>(param);
  BACIThread* myself_p = baciParameter_p->getBACIThread();
  BACIComponent* component_p = (BACIComponent*)baciParameter_p->getParameter();

  if (BACIThread::InitThread)
      {
      BACIThread::InitThread(myself_p->getName().c_str());
      }

  ACS_TRACE("baci::actionThreadWorker");

  BACIAction* action_p = 0;

  bool pushActionBack;
  int callbackID;
  BACICallback* callback_p = 0;
  CBDescOut descOut;
  ActionRequest request = reqNone;

  ACS_DEBUG_PARAM("baci::actionThreadWorker", "%s", component_p->getName());

  while (myself_p->check()==true &&
	 component_p->isInDestructionState()==false)
    {
      if (myself_p->isSuspended()==false &&
	  component_p->isInDestructionState()==false &&
	  (component_p->getActionCount()>0))
	{
	  if ( (action_p = component_p->popAction()) != 0 )
	    {
	      Completion completion;

	      callbackID = action_p->getCallbackID();
	      callback_p = component_p->getCallback(callbackID);

	      if (callback_p==0)
		{
		  //ACS_LOG(LM_RUNTIME_CONTEXT, "baci::actionThreadWorker",
		  //		(LM_CRITICAL, "Callback not found: %s", component_p->getName()));
		  delete action_p;
		  continue;
		}

              if (action_p->isCompleted()==true)
		{
		  completion = action_p->getCompletion();
		  request = reqInvokeDone;
		}
              else
		{
		CompletionImpl co;
		request = action_p->invoke(callback_p->getComponent(),
					   callbackID,
					   callback_p->getDescIn(),
					   action_p->getValueRef(),
					   co,
					   descOut);
		if (co.isErrorFree())
		    {
		    completion = co;
		    }
		else
		    {
		    completion = CouldntPerformActionCompletion(co,
							  __FILE__,
							  __LINE__,
							  "baci::actionThreadWorker");					    }//if-else
		}//if-else

	      pushActionBack = false;

	      switch (request)
		{
		case reqNone: break;
		case reqInvokeWorking:
		  component_p->dispatchCallback(callbackID, action_p->getValue(), descOut, completion);
                  pushActionBack = true;
		  break;
		case reqInvokeDone:
		  pushActionBack = !component_p->finishCallback(callbackID, action_p->getValue(),
							descOut, completion);
		  if (pushActionBack==false)
		    {
		      //component_p->removeCallback(callbackID); /// already removed
		      delete action_p;
		    }
                  else if (callback_p->isOK()==true)
		      {
		      action_p->setCompletion(completion);
		      }
                  else
		    {
		      pushActionBack = false;      // drop message
		      //component_p->removeCallback(callbackID);
		      delete action_p;
		    }
		  break;
		case reqDestroy:
		  component_p->removeCallback(callbackID);
		  delete action_p;
		default:
		  // error msg
		  ACS_LOG(LM_RUNTIME_CONTEXT, "baci::actionThreadWorker",
			  (LM_ERROR, "Wrong request for action in Component %s! Return value must type of 'enum ActionRequest { reqNone, reqInvokeWorking, reqInvokeDone, reqDestroy }'",
			   component_p->getName()));
		  break;
		}

	      if (pushActionBack==true)
		  {
		  component_p->pushAction(action_p);
		  }
	    }
	}
      if (myself_p->exitRequested()==false)
	  {
	  myself_p->sleep();
	  }
    }

  delete baciParameter_p;
  myself_p->setStopped();

  if (BACIThread::DoneThread)
      {
      BACIThread::DoneThread();
      }
}
コード例 #13
0
ファイル: baciBACIMonitor.cpp プロジェクト: ACS-Community/ACS
BACIMonitor::BACIMonitor(const ACE_CString& _name, int _callbackID, 
			 MonitorImplementator* _monitorImplementator_p,
			 const ACS::TimeInterval& _triggerTime, const BACIValue& _triggerValue, 
			 const ACS::TimeInterval& _minTriggerTime, const BACIValue& _minTriggerValue, 
			 BACIProperty* _property, const ACS::TimeInterval& _transmitTime,
			 const UpdateMode& _updateMode, 
			 const bool _archivingMonitor,
			 const bool _suspended,
                         const bool _deltaValueAndTimerInteraction,
                         const unsigned int _priority) :

  name_m(_name), callbackID_m(_callbackID), 
  monitorImplementator_mp(_monitorImplementator_p), updateMode_m(mumLast),
  triggerTime_m(0), minTriggerTime_m(_minTriggerTime),
  transmitTime_m(0), userControlledTransmitTime_m(false), lastTime_m(0), 
  minTriggerValue_m(_minTriggerValue), triggerOnValue_m(false), triggerOnValuePercent_m(false),
  property_mp(_property), archivingMonitor_m(_archivingMonitor), 
  suspended_m(_suspended),
  deltaValueAndTimerInteraction_m(_deltaValueAndTimerInteraction),
  priority_m(_priority),
  inDestructionState_m(false),
  destroyed_m(false)
{
  ACS_TRACE("baci::BACIMonitor::BACIMonitor");

  ACS_LOG(0, "baci::BACIMonitor::BACIMonitor",
	  (static_cast<ACE_Log_Priority>(LM_DELOUSE), "Creating monitor '%s' (archiving: %d, triggerTime: %d)", 
	   name_m.c_str(), archivingMonitor_m, (unsigned)_triggerTime));
  if (archivingMonitor_m==true)
      {
      ACS_LOG(0, "baci::BACIMonitor::BACIMonitor",
	      (LM_DEBUG, "Archiver monitor with priority %d", priority_m));
      }

  // VxWorks (should not be as initializer)
  monitorImplementator_mp = 0;
  
  // set update mode
  setUpdateMode(_updateMode);

  // set monitors
  setTriggerTime(_triggerTime);
  setTriggerValue(_triggerValue);

  
  if (getTriggerValue().isNull()==0 && getTriggerValue().noDelta()==false)
      {
      setTriggerOnValue(true);
      }
  if (getTriggerValuePercent().isNull()==0 && getTriggerValuePercent().noDelta()==false)
      {
      setTriggerOnValuePercent(true);
      }
  
  // set transmit_time
  if (_transmitTime!=0)
    {
      userControlledTransmitTime_m = true;
      setTransmitTime(_transmitTime);    // user now handles monitor sync.
    }

  if (archivingMonitor_m==false) 
    {
      property_mp->getComponent()->getCallback(callbackID_m)->setRemoveOnFailure(false);
    }

  monitorImplementator_mp = _monitorImplementator_p;

  // add monitor
  property_mp->addMonitor(this);

}
コード例 #14
0
/* --------------------- [ CORBA interface ] ----------------------*/
void
ErrorComponent::displayMessage ()
{
    ACS_LOG(LM_RUNTIME_CONTEXT, "ErrorComponent::displayMessage",
	    (LM_INFO, "Hello World"));
}
コード例 #15
0
ファイル: acsLogSvc.cpp プロジェクト: jantogni/ACS
int main(int argc, char *argv[])
{

    CosNaming::NamingContext_var naming_context;
    int  nargc=0;
    char **nargv=0;
    const char *hn=ACSPorts::getIP();
    ACE_CString iorFile;

    if (argc>=2 && !ACE_OS_String::strcmp(argv[1], "-?")) {
        ACE_OS::printf ("USAGE: acsLogSvc  [-ORBInitRef NameService=iiop://yyy:xxxx/NameService] [-ORBEndpoint iiop://ip:port] [-o iorfile] [-silent]\n");
        return -1;
    }

// here we have to unset ACS_LOG_CENTRAL that we prevent filtering of log messages
    char *logCent=getenv("ACS_LOG_CENTRAL");
    if (logCent)
    {
        unsetenv("ACS_LOG_CENTRAL");
        printf("Unset ACS_LOG_CENTRAL which was previously set to %s\n", logCent);
    }//if

// create logging proxy
    LoggingProxy::ProcessName(argv[0]);
    ACE_Log_Msg::instance()->local_host(hn);
    LoggingProxy m_logger (0, 0, 31, 0);
    LoggingProxy::init (&m_logger);
    ACS_SHORT_LOG((LM_INFO, "Logging proxy successfully created !"));

    ACE_CString argStr;

    for(int i=1; i<argc; i++)
    {
        argStr += argv[i];
        argStr += " ";

        if (!ACE_OS_String::strcmp(argv[i], "-o") && (i+1)<argc)
        {
            iorFile = argv[i+1];
        }//if
    }//for

    if (argStr.find ("-ORBEndpoint")==ACE_CString::npos)
    {
        argStr = argStr + "-ORBEndpoint iiop://" + hn + ":" + ACSPorts::getLogPort().c_str();
    }

    ACS_SHORT_LOG((LM_INFO, "New command line is: %s", argStr.c_str()));

    ACE_OS::string_to_argv ((ACE_TCHAR*)argStr.c_str(), nargc, nargv);

    ACE_OS::signal(SIGINT,  TerminationSignalHandler);  // Ctrl+C
    ACE_OS::signal(SIGTERM, TerminationSignalHandler);  // termination request

    try
    {
        // Initialize the ORB
        ACE_OS::printf ("Initialising ORB ... \n");
        orb = CORBA::ORB_init (nargc, nargv, 0);
        ACE_OS::printf ("ORB initialsed !\n");
    }
    catch( CORBA::Exception &ex )
    {
        ex._tao_print_exception("Failed to initalise ORB");
        return -1;
    }


    if (!ACSError::init(orb.in()))
    {
        ACS_SHORT_LOG ((LM_ERROR, "Failed to initalise the ACS Error System"));
        return -1;
    }

// resolve naming service
    try
    {
        ACS_SHORT_LOG((LM_INFO, "Trying to connect to the Naming Service ...."));
        CORBA::Object_var naming_obj = orb->resolve_initial_references ("NameService");

        if (!CORBA::is_nil (naming_obj.in ()))
        {
            naming_context = CosNaming::NamingContext::_narrow (naming_obj.in ());
            ACS_SHORT_LOG((LM_INFO, "Connected to the Name Service"));
        }
        else
        {
            ACS_SHORT_LOG((LM_ERROR, "Could not connect the Name Service!"));
            return -1;
        }//if-else
    }
    catch( CORBA::Exception &_ex )
    {
        ACS_SHORT_LOG((LM_ERROR, "Could not connect the Name Service!"));
        return -1;
    }


    // logging service
    try
    {
        CORBA::Object_var log_obj;
        /*
              if (argStr.find ("-ORBInitRef NameService=")!=ACE_CString::npos)
        	{
        	// Initialize the ORB
        	ACE_OS::printf ("Initialising ORB ... \n");
        	orb = CORBA::ORB_init (nargc, nargv, 0);
        	ACE_OS::printf ("ORB initialsed !\n");
                //Naming Service
        	ACE_OS::printf ("Resolving  Naming service ... \n");
        	CORBA::Object_var naming_obj =
        	  orb->resolve_initial_references ("NameService");
        	if (!CORBA::is_nil (naming_obj.in ()))
        	  {
        	    CosNaming::NamingContext_var naming_context =
        	      CosNaming::NamingContext::_narrow (naming_obj.in ());
        	    ACE_OS::printf ( "Naming Service resolved !\n");
        */

        ACE_OS::printf ( "Resolving Logging Service from Naming service ...\n");
        CosNaming::Name name;
        name.length(1);
        name[0].id = CORBA::string_dup("Log");
        log_obj = naming_context->resolve(name);
        /*
          }
        	else
        	  {
        	    ACS_LOG(LM_SOURCE_INFO, "main", (LM_ERROR,  "Failed to initialise the Name Service!"));
        	  }
        	}//if naming Service

              else
        	{
        	ACE_OS::printf ("Getting Log from the Manager... \n");
        	CORBA::ULong status;
        	maci::Manager_ptr manager = maci::MACIHelper::resolveManager (orb.in(), nargc, nargv, 0, 0);


        	log_obj = manager->get_COB(0, "Log", true,  status);
        	}
        */
        if (!CORBA::is_nil (log_obj.in()))
        {
            Logging::AcsLogService_var logger = Logging::AcsLogService::_narrow(log_obj.in());
            ACE_OS::printf ( "Logging Service resolved !\n");

            m_logger.setCentralizedLogger(logger.in());
        }
        else
        {
            ACS_LOG(LM_SOURCE_INFO, "main", (LM_ERROR, "Failed to initialise the Logging Service!"));
            return -1;
        }//if-else
    }
    catch( CORBA::Exception &__ex )
    {
        __ex._tao_print_exception("Failed to get and set the centralized logger");
        return -1;
    }


    try
    {
        //Get a reference to the RootPOA
        ACE_OS::printf("Creating POA ... \n");
        CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");

        PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());


        PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();


        CORBA::PolicyList policy_list;
        policy_list.length(5);
        policy_list[0] = root_poa->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);

        policy_list[1] =  root_poa->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);

        policy_list[2] = root_poa->create_id_assignment_policy(PortableServer::USER_ID);

        policy_list[3] = root_poa->create_servant_retention_policy(PortableServer::NON_RETAIN);

        policy_list[4] =  root_poa->create_lifespan_policy (PortableServer::PERSISTENT);

        printf("policies are created !\n");

        PortableServer::POA_var poa = root_poa->create_POA("ACSLogSvc", poa_manager.in(), policy_list);

        ACE_OS::printf("POA created !\n");

        for (CORBA::ULong i = 0; i < policy_list.length (); ++i) {
            CORBA::Policy_ptr policy = policy_list[i];
            policy->destroy ();

        }
        printf("Policies are destroyed !\n");

        ACSLogImpl acsLogSvc (m_logger);
        poa->set_servant (&acsLogSvc);


        PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("ACSLogSvc");
        obj = poa->create_reference_with_id (oid.in(),  acsLogSvc._interface_repository_id());


        CORBA::String_var ior = orb->object_to_string (obj.in());


        // if ther is file name write ior in it
        if (iorFile.length()!=0)
        {
            FILE *output_file = ACE_OS::fopen (iorFile.c_str(), "w");
            if (output_file == 0)
            {
                ACS_SHORT_LOG ((LM_ERROR,
                                "Cannot open output files for writing IOR: ior.ior"));
                return  -1;
            }//if

            int result = ACE_OS::fprintf (output_file, "%s", ior.in());
            if (result < 0)
            {
                ACS_SHORT_LOG ((LM_ERROR,
                                "ACE_OS::fprintf failed while writing %s to ior.ior", ior.in()));
                return  -1;
            }//if
            ACE_OS::fclose (output_file);
            ACS_SHORT_LOG((LM_INFO, "ACSLogSvc's IOR has been written into: %s", iorFile.c_str()));
        }//if


// adding ACSLog to NamingService
        if (!CORBA::is_nil (naming_context.in ()))
        {
            // register cdb server in Naming service
            CosNaming::Name name (1);
            name.length (1);
            name[0].id = CORBA::string_dup ("ACSLogSvc");
            naming_context->rebind (name, obj.in ());
            ACS_SHORT_LOG((LM_INFO, "ACSLogSvc service registered with Naming Services"));
        }//if

        CORBA::Object_var table_object =
            orb->resolve_initial_references ("IORTable");

        IORTable::Table_var adapter =
            IORTable::Table::_narrow (table_object.in ());

        if (CORBA::is_nil (adapter.in ()))
        {
            ACS_SHORT_LOG ((LM_ERROR, "Nil IORTable"));
        }
        else
        {
            adapter->bind ("ACSLogSvc", ior.in ());
        }

        poa_manager->activate ();


        ACS_SHORT_LOG((LM_INFO, "ACSLogSvc is waiting for incoming log messages ..."));
        if (argStr.find ("-ORBEndpoint")!=ACE_CString::npos)
            m_logger.setStdio(31);
        orb->run ();

        ACSError::done();
        LoggingProxy::done();
    }
    catch( CORBA::Exception &ex )
    {
        ex. _tao_print_exception("EXCEPTION CAUGHT");
        return -1;
    }

    return 0;
}