Commit 5c14128c authored by Giuseppe Carboni's avatar Giuseppe Carboni Committed by GitHub
Browse files

Fix #572, improved communication between Noto DISCOS and FieldSystem (#576)



Also this:
Fix #573, updated Noto PointingModel
Fix #574, updated Noto StationProcedures
Fix #575, updated Noto SourceCatalogue

Co-authored-by: default avataraorlati <discos@discos-manager.noto.ira.inaf.it>
parent f188a641
Loading
Loading
Loading
Loading
+641 −492
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@ using namespace ComponentErrors;
using namespace ManagementErrors;

CExternalClientsSocketServer::CExternalClientsSocketServer (ContainerServices * service):CSocket (),
	m_services(service)
m_services
(service)
{
  AUTO_TRACE ("CExternalClientsSocketServer::CExternalClientsSocketServer()");
  setExternalClientSocketStatus (ExternalClientSocketStatus_NOTCNTD);
@@ -27,50 +28,64 @@ CExternalClientsSocketServer::CExternalClientsSocketServer(ContainerServices *se

CExternalClientsSocketServer::~CExternalClientsSocketServer ()
{
	AUTO_TRACE("CExternalClientsSocketServer::~CExternalClientsSocketServer()");
  AUTO_TRACE
    ("CExternalClientsSocketServer::~CExternalClientsSocketServer()");
  setExternalClientSocketStatus (ExternalClientSocketStatus_NOTCNTD);
  Close (m_Error);
}

void CExternalClientsSocketServer::initialize(CConfiguration *config) throw (SocketErrorExImpl)
void
CExternalClientsSocketServer::initialize (CConfiguration * config)
throw (SocketErrorExImpl)
{
  AUTO_TRACE ("CExternalClientsSocketServer::Init()");
  m_configuration = config;
  // Create server socket in blocking mode
  CString ipAdd;
  ipAdd = m_configuration->ipAddress ();
	if (Create(m_Error,STREAM,m_configuration->Port(),&ipAdd) == FAIL) {
  if (Create (m_Error, STREAM, m_configuration->Port (), &ipAdd) == FAIL)
    {
      _EXCPT_FROM_ERROR (IRALibraryResourceExImpl, dummy, m_Error);
      dummy.setCode (m_Error.getErrorCode ());
      dummy.setDescription ((const char *) m_Error.getDescription ());
      m_Error.Reset ();
		_THROW_EXCPT_FROM_EXCPT(SocketErrorExImpl,dummy,"CExternalClientsSocketServer::Init()");
      _THROW_EXCPT_FROM_EXCPT (SocketErrorExImpl, dummy,
			       "CExternalClientsSocketServer::Init()");
    }
  // Listen
	if (Listen(m_Error) == FAIL) {
  if (Listen (m_Error) == FAIL)
    {
      _EXCPT_FROM_ERROR (IRALibraryResourceExImpl, dummy, m_Error);
      dummy.setCode (m_Error.getErrorCode ());
      dummy.setDescription ((const char *) m_Error.getDescription ());
      m_Error.Reset ();
		_THROW_EXCPT_FROM_EXCPT(SocketErrorExImpl,dummy,"CExternalClientsSocketServer::Init()");
      _THROW_EXCPT_FROM_EXCPT (SocketErrorExImpl, dummy,
			       "CExternalClientsSocketServer::Init()");
    }
	else {
  else
    {
      setExternalClientSocketStatus (ExternalClientSocketStatus_CNTD);
    }
  // TO BE VERIFIED
  int Val = 1000;
	if (setSockOption(m_Error,SO_RCVBUF,&Val,sizeof(int)) == FAIL) {
  if (setSockOption (m_Error, SO_RCVBUF, &Val, sizeof (int)) == FAIL)
    {
      _EXCPT_FROM_ERROR (IRALibraryResourceExImpl, dummy, m_Error);
      dummy.setCode (m_Error.getErrorCode ());
      dummy.setDescription ((const char *) m_Error.getDescription ());
      m_Error.Reset ();
		_THROW_EXCPT_FROM_EXCPT(SocketErrorExImpl,dummy,"CExternalClientsSocketServer::Init()");
      _THROW_EXCPT_FROM_EXCPT (SocketErrorExImpl, dummy,
			       "CExternalClientsSocketServer::Init()");
    }
}

void CExternalClientsSocketServer::execute() throw (ComponentErrors::CouldntGetComponentExImpl,ComponentErrors::CORBAProblemExImpl)
void
CExternalClientsSocketServer::execute ()
throw (ComponentErrors::CouldntGetComponentExImpl,
       ComponentErrors::CORBAProblemExImpl)
{
  if (getStatus () == ExternalClientSocketStatus_CNTD)
    {
	if (getStatus() == ExternalClientSocketStatus_CNTD) {
      m_Scheduler = Management::Scheduler::_nil ();
      CString sVisor = m_configuration->superVisor ();
      if (sVisor.Compare ("Gavino") == 0)
@@ -79,76 +94,107 @@ void CExternalClientsSocketServer::execute() throw (ComponentErrors::CouldntGetC
	strcpy (superVisorName, PALMIRO);
      if (sVisor.Compare ("Ducezio") == 0)
	strcpy (superVisorName, DUCEZIO);
		try {
			m_Scheduler = m_services->getComponent<Management::Scheduler>(superVisorName);
      try
      {
	m_Scheduler =
	  m_services->getComponent < Management::Scheduler > (superVisorName);
      }
		catch (maciErrType::CannotGetComponentExImpl& ex) {
			_ADD_BACKTRACE(ComponentErrors::CouldntGetComponentExImpl,Impl,ex,"CExternalClientsSocketServer::execute()");
      catch (maciErrType::CannotGetComponentExImpl & ex)
      {
	_ADD_BACKTRACE (ComponentErrors::CouldntGetComponentExImpl, Impl, ex,
			"CExternalClientsSocketServer::execute()");
	Impl.setComponentName (superVisorName);
	throw Impl;
      }
		ACS_LOG(LM_FULL_INFO,"CExternalClientsSocketServer::execute()",(LM_INFO,"CExternalClientsSocketServer::SCHEDULER_LOCATED"));
      ACS_LOG (LM_FULL_INFO, "CExternalClientsSocketServer::execute()",
	       (LM_INFO, "CExternalClientsSocketServer::SCHEDULER_LOCATED"));
      m_antennaBoss = Antenna::AntennaBoss::_nil ();
		try {
			m_antennaBoss = m_services->getComponent<Antenna::AntennaBoss>("ANTENNA/Boss");
      try
      {
	m_antennaBoss =
	  m_services->getComponent < Antenna::AntennaBoss > ("ANTENNA/Boss");
      }
		catch (maciErrType::CannotGetComponentExImpl& ex) {
			_ADD_BACKTRACE(ComponentErrors::CouldntGetComponentExImpl,Impl,ex,"CExternalClientsSocketServer::execute()");
      catch (maciErrType::CannotGetComponentExImpl & ex)
      {
	_ADD_BACKTRACE (ComponentErrors::CouldntGetComponentExImpl, Impl, ex,
			"CExternalClientsSocketServer::execute()");
	Impl.setComponentName ("ANTENNA/Boss");
	throw Impl;
      }
      m_receiversBoss = Receivers::ReceiversBoss::_nil ();
		try {
			m_receiversBoss = m_services->getComponent<Receivers::ReceiversBoss>("RECEIVERS/Boss");
      try
      {
	m_receiversBoss =
	  m_services->getComponent < Receivers::ReceiversBoss >
	  ("RECEIVERS/Boss");
      }
		catch (maciErrType::CannotGetComponentExImpl& ex) {
			_ADD_BACKTRACE(ComponentErrors::CouldntGetComponentExImpl,Impl,ex,"CExternalClientsSocketServer::execute()");
      catch (maciErrType::CannotGetComponentExImpl & ex)
      {
	_ADD_BACKTRACE (ComponentErrors::CouldntGetComponentExImpl, Impl, ex,
			"CExternalClientsSocketServer::execute()");
	Impl.setComponentName ("RECEIVERS/Boss");
	throw Impl;
      }
      m_mount = Antenna::Mount::_nil ();
		try {
			m_mount = m_services->getComponent<Antenna::Mount>("ANTENNA/Mount");
      try
      {
	m_mount =
	  m_services->getComponent < Antenna::Mount > ("ANTENNA/Mount");
      }
		catch (maciErrType::CannotGetComponentExImpl& ex) {
			_ADD_BACKTRACE(ComponentErrors::CouldntGetComponentExImpl,Impl,ex,"CExternalClientsSocketServer::execute()");
      catch (maciErrType::CannotGetComponentExImpl & ex)
      {
	_ADD_BACKTRACE (ComponentErrors::CouldntGetComponentExImpl, Impl, ex,
			"CExternalClientsSocketServer::execute()");
	Impl.setComponentName ("ANTENNA/Mount");
	throw Impl;
      }
    }
}

void CExternalClientsSocketServer::cleanUp()
void
CExternalClientsSocketServer::cleanUp ()
{
  try
  {
	try {
    m_services->releaseComponent ((const char *) m_Scheduler->name ());
  }
	catch (maciErrType::CannotReleaseComponentExImpl& ex) {
		_ADD_BACKTRACE(ComponentErrors::CouldntReleaseComponentExImpl,Impl,ex,"CExternalClientsSocketServer::cleanUp()");
  catch (maciErrType::CannotReleaseComponentExImpl & ex)
  {
    _ADD_BACKTRACE (ComponentErrors::CouldntReleaseComponentExImpl, Impl, ex,
		    "CExternalClientsSocketServer::cleanUp()");
    Impl.setComponentName ((const char *) m_Scheduler->name ());
    Impl.log (LM_DEBUG);
  }
	try {
  try
  {
    m_services->releaseComponent ((const char *) m_antennaBoss->name ());
  }
	catch (maciErrType::CannotReleaseComponentExImpl& ex) {
		_ADD_BACKTRACE(ComponentErrors::CouldntReleaseComponentExImpl,Impl,ex,"CExternalClientsSocketServer::cleanUp()");
  catch (maciErrType::CannotReleaseComponentExImpl & ex)
  {
    _ADD_BACKTRACE (ComponentErrors::CouldntReleaseComponentExImpl, Impl, ex,
		    "CExternalClientsSocketServer::cleanUp()");
    Impl.setComponentName ((const char *) m_antennaBoss->name ());
    Impl.log (LM_DEBUG);
  }
	try {
  try
  {
    m_services->releaseComponent ((const char *) m_receiversBoss->name ());
  }
	catch (maciErrType::CannotReleaseComponentExImpl& ex) {
		_ADD_BACKTRACE(ComponentErrors::CouldntReleaseComponentExImpl,Impl,ex,"CExternalClientsSocketServer::cleanUp()");
  catch (maciErrType::CannotReleaseComponentExImpl & ex)
  {
    _ADD_BACKTRACE (ComponentErrors::CouldntReleaseComponentExImpl, Impl, ex,
		    "CExternalClientsSocketServer::cleanUp()");
    Impl.setComponentName ((const char *) m_receiversBoss->name ());
    Impl.log (LM_DEBUG);
  }
	try {
  try
  {
    m_services->releaseComponent ((const char *) m_mount->name ());
  }
	catch (maciErrType::CannotReleaseComponentExImpl& ex) {
		_ADD_BACKTRACE(ComponentErrors::CouldntReleaseComponentExImpl,Impl,ex,"CExternalClientsSocketServer::cleanUp()");
  catch (maciErrType::CannotReleaseComponentExImpl & ex)
  {
    _ADD_BACKTRACE (ComponentErrors::CouldntReleaseComponentExImpl, Impl, ex,
		    "CExternalClientsSocketServer::cleanUp()");
    Impl.setComponentName ((const char *) m_mount->name ());
    Impl.log (LM_DEBUG);
  }
@@ -156,7 +202,8 @@ void CExternalClientsSocketServer::cleanUp()
  m_accept = false;
}

void CExternalClientsSocketServer::cmdToScheduler()
void
CExternalClientsSocketServer::cmdToScheduler ()
{
  BYTE inBuffer[BUFFERSIZE];
  BYTE outBuffer[BUFFERSIZE];
@@ -167,16 +214,19 @@ void CExternalClientsSocketServer::cmdToScheduler()
  OperationResult Res;
  bool ans = false;

	if (m_accept == false) {
  if (m_accept == false)
    {
      // Accept
      OperationResult Res;
      Res = Accept (m_Error, newExternalClientsSocketServer);
    		if (Res == FAIL) {
      if (Res == FAIL)
	{
	  _EXCPT_FROM_ERROR (IRALibraryResourceExImpl, dummy, m_Error);
	  dummy.setCode (m_Error.getErrorCode ());
	  dummy.setDescription ((const char *) m_Error.getDescription ());
	  m_Error.Reset ();
        		_ADD_BACKTRACE(SocketErrorExImpl,_dummy,dummy,"CExternalClientsSocketServer::cmdToScheduler()");
	  _ADD_BACKTRACE (SocketErrorExImpl, _dummy, dummy,
			  "CExternalClientsSocketServer::cmdToScheduler()");
	  _dummy.log (LM_ERROR);
	}
      if (Res == WOULDBLOCK)
@@ -186,10 +236,12 @@ void CExternalClientsSocketServer::cmdToScheduler()

  rBytes = receiveBuffer (inBuffer, BUFFERSIZE);

	if (rBytes > 0 ) {
  if (rBytes > 0)
    {
      inBuffer[rBytes] = '\0';
      //printf ("Command received = %s\n", inBuffer);
		if (strncmp ((const char*)inBuffer, "antennaParameters",18)== 0) {
      if (strncmp ((const char *) inBuffer, "antennaParameters", 17) == 0)
	{
	  TIMEVALUE now;
	  const char answerDelimiter = '\\';
	  const char fieldDelimiter = ',';
@@ -222,7 +274,8 @@ void CExternalClientsSocketServer::cmdToScheduler()
	  double lo[2];
	  ACS::ROdouble_var azErr_var, elErr_var;
	  double azErr, elErr;
            		ACS::ROdouble_var pointingAzCorr_var, pointingElCorr_var, refractionCorr_var;
	  ACS::ROdouble_var pointingAzCorr_var, pointingElCorr_var,
	    refractionCorr_var;
	  double pointingAzCorr, pointingElCorr, refractionCorr;
	  double azOff, elOff, raOff, decOff, lonOff, latOff;
	  double azComm, elComm;
@@ -237,9 +290,11 @@ void CExternalClientsSocketServer::cmdToScheduler()
	  out.Concat (outTime);
	  m_fieldDelimiter = IRA::CString (fieldDelimiter);
	  out += m_fieldDelimiter;
                    	try {
	  try
	  {
	    antennaBossStatus_var = m_antennaBoss->status ();
                        	antennaBossStatus_val = antennaBossStatus_var->get_sync(completion.out());
	    antennaBossStatus_val =
	      antennaBossStatus_var->get_sync (completion.out ());
	    if (antennaBossStatus_val == Management::MNG_OK)
	      status_val = "OK";
	    else if (antennaBossStatus_val == Management::MNG_WARNING)
@@ -249,40 +304,52 @@ void CExternalClientsSocketServer::cmdToScheduler()
	    else
	      status_val = "UNKNOWN";
	  }
                    	catch (...) {
				_EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    status_val = "NA";
	  }
	  out.Concat (status_val);
	  out += m_fieldDelimiter;
            		try {
	  try
	  {
	    targetRef = m_antennaBoss->target ();
	    target = targetRef->get_sync (completion.out ());
	  }
            		catch (...) {
				_EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    target = "NA";
	  }
	  out.Concat (target);
	  out += m_fieldDelimiter;
            		try {
                		m_antennaBoss->getObservedHorizontal(now.value().value,1,az,el);
                m_antennaBoss->getObservedEquatorial(now.value().value,1,ra,dec);
                m_antennaBoss->getObservedGalactic(now.value().value,1,lon,lat);
	  try
	  {
	    m_antennaBoss->getObservedHorizontal (now.value ().value, 1, az,
						  el);
	    m_antennaBoss->getObservedEquatorial (now.value ().value, 1, ra,
						  dec);
	    m_antennaBoss->getObservedGalactic (now.value ().value, 1, lon,
						lat);
	    IRA::CIRATools::radToAngle (az, azStr);
	    IRA::CIRATools::radToAngle (el, elStr);
	    IRA::CIRATools::radToHourAngle (ra, raStr);
	    IRA::CIRATools::radToSexagesimalAngle (dec, decStr);
	    IRA::CIRATools::radToSexagesimalAngle (lon, lonStr);
	    IRA::CIRATools::radToSexagesimalAngle (lat, latStr);
		m_antennaBoss->getRawCoordinates(now.value().value,azComm,elComm);
	    m_antennaBoss->getRawCoordinates (now.value ().value, azComm,
					      elComm);
	    IRA::CIRATools::radToAngle (azComm, azCommStr);
	    IRA::CIRATools::radToAngle (elComm, elCommStr);
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    azStr = "NA";
	    elStr = "NA";
@@ -309,66 +376,86 @@ void CExternalClientsSocketServer::cmdToScheduler()
	  out += m_fieldDelimiter;
	  out.Concat (elCommStr);
	  out += m_fieldDelimiter;
            try {
	  try
	  {
	    azErr_var = m_mount->azimuthError ();
	    azErr = azErr_var->get_sync (completion.out ());
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    azErr = 0.0;
	  }
	  out.Concat (azErr);
	  out += m_fieldDelimiter;
            try {
	  try
	  {
	    elErr_var = m_mount->elevationError ();
	    elErr = elErr_var->get_sync (completion.out ());
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    elErr = 0.0;
	  }
	  out.Concat (elErr);
	  out += m_fieldDelimiter;
            try {
	  try
	  {
	    pointingAzCorr_var = m_antennaBoss->pointingAzimuthCorrection ();
	    pointingAzCorr = pointingAzCorr_var->get_sync (completion.out ());
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    pointingAzCorr = 0.0;
	  }
	  out.Concat (pointingAzCorr);
	  out += m_fieldDelimiter;
            try {
                pointingElCorr_var = m_antennaBoss->pointingElevationCorrection();
	  try
	  {
	    pointingElCorr_var =
	      m_antennaBoss->pointingElevationCorrection ();
	    pointingElCorr = pointingElCorr_var->get_sync (completion.out ());
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    pointingElCorr = 0.0;
	  }
	  out.Concat (pointingElCorr);
	  out += m_fieldDelimiter;
            try {
	  try
	  {
	    refractionCorr_var = m_antennaBoss->refractionCorrection ();
	    refractionCorr = refractionCorr_var->get_sync (completion.out ());
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    refractionCorr = 0.0;
	  }
	  out.Concat (refractionCorr);
	  out += m_fieldDelimiter;
            try {
                m_antennaBoss->getAllOffsets(azOff,elOff,raOff,decOff,lonOff,latOff);
	  try
	  {
	    m_antennaBoss->getAllOffsets (azOff, elOff, raOff, decOff, lonOff,
					  latOff);
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    azOff = 0.0;
	    elOff = 0.0;
@@ -389,84 +476,113 @@ void CExternalClientsSocketServer::cmdToScheduler()
	  out += m_fieldDelimiter;
	  out.Concat (latOff);
	  out += m_fieldDelimiter;
            try {
	  try
	  {
	    receiverRef = m_receiversBoss->actualSetup ();
	    receiver = receiverRef->get_sync (completion.out ());
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    receiver = "NA";
	  }
	  out.Concat (receiver);
	  out += m_fieldDelimiter;
            try {
	  try
	  {
	    loRef = m_receiversBoss->LO ();
	    lo_var = loRef->get_sync (completion.out ());
	    lo[0] = lo_var[0];
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    lo[0] = 0.0;
	  }
	  out.Concat (lo[0]);
	  out += m_fieldDelimiter;
            try {
	  try
	  {
	    tracking_var = m_Scheduler->tracking ();
	    tracking_val = tracking_var->get_sync (completion.out ());
                if (tracking_val == Management::MNG_TRUE) {
	    if (tracking_val == Management::MNG_TRUE)
	      {
		trackingStr = "TRACKING";
	      }
                else {
	    else
	      {
		trackingStr = "SLEWING";
	      }
	  }
            catch (...) {
                _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    trackingStr = "NA";
	  }
	  out.Concat (trackingStr);
		}
		else {
			try {
	}			// end of antennaParameters command
      else
	{
	  try
	  {
	    ans = m_Scheduler->command ((const char *) inBuffer, ret_val);
	    out = IRA::CString (ret_val);
		//printf("dentro try\n");
	  }
        		catch (CORBA::SystemException& ex) {
                		_EXCPT(ComponentErrors::CORBAProblemExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (CORBA::SystemException & ex)
	  {
	    _EXCPT (ComponentErrors::CORBAProblemExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.setName (ex._name ());
	    impl.setMinor (ex.minor ());
	    impl.log (LM_ERROR);
	    ret_val = "CORBA Error";
	    out = IRA::CString (ret_val);
	  }
        		catch (...) {
				_EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
	  catch (...)
	  {
	    _EXCPT (ComponentErrors::UnexpectedExImpl, impl,
		    "CExternalClientsSocketServer::cmdToScheduler()");
	    impl.log (LM_ERROR);
	    ret_val = "Unexpected Error";
	    out = IRA::CString (ret_val);
	  }
			    if (ans == false) {
	  /*if (ans == false)
	    {
	      //ret_val = "Nuraghe Error"; // TBD!!
	      out = IRA::CString (ret_val);
	      printf("dentro ans==false\n");
	    }*/
	}
        	}
	out.Replace('\n','-');
      Len = out.GetLength ();
      int i;
        	for (i = 0; i < Len; i++) {
      for (i = 0; i < Len; i++)
	{
	  outBuffer[i] = out.CharAt (i);
	}
      out.Empty();
      outBuffer[Len] = '\n';
      //printf ("Command returned = %s", outBuffer);
      Res = sendBuffer (outBuffer, Len + 1);
        	if (Res == WOULDBLOCK || Res == FAIL) {
            		_EXCPT(SocketErrorExImpl,impl,"CExternalClientsSocketServer::cmdToScheduler()");
      if (Res == WOULDBLOCK || Res == FAIL)
	{
	  _EXCPT (SocketErrorExImpl, impl,
		  "CExternalClientsSocketServer::cmdToScheduler()");
	  impl.log (LM_ERROR);
	//	printf("error dopo sendBuffer\n");
	}
      for (i = 0; i < BUFFERSIZE; i++)
	outBuffer[i]='\0';
    }
     	else { 
  else
    {
      newExternalClientsSocketServer.Close (m_Error);
      m_accept = false;
    }
@@ -474,57 +590,83 @@ void CExternalClientsSocketServer::cmdToScheduler()

// private methods

CExternalClientsSocketServer::OperationResult CExternalClientsSocketServer::sendBuffer(BYTE *Msg,WORD Len)
CExternalClientsSocketServer::OperationResult CExternalClientsSocketServer::
sendBuffer (BYTE * Msg, WORD Len)
{
	int NWrite;
	int BytesSent;
  int
    NWrite;
  int
    BytesSent;
  BytesSent = 0;
	while (BytesSent<Len) {
		if ((NWrite = newExternalClientsSocketServer.Send(m_Error,(const void *)(Msg+BytesSent),Len-BytesSent))<0) {
			if (NWrite==WOULDBLOCK) {
				setExternalClientSocketStatus(ExternalClientSocketStatus_NOTCNTD);
  while (BytesSent < Len)
    {
      if ((NWrite =
	   newExternalClientsSocketServer.Send (m_Error,
						(const void *) (Msg +
								BytesSent),
						Len - BytesSent)) < 0)
	{
	  if (NWrite == WOULDBLOCK)
	    {
	      setExternalClientSocketStatus
		(ExternalClientSocketStatus_NOTCNTD);
	      return WOULDBLOCK;
	    }
			else {
				setExternalClientSocketStatus(ExternalClientSocketStatus_NOTCNTD);
	  else
	    {
	      setExternalClientSocketStatus
		(ExternalClientSocketStatus_NOTCNTD);
	      return FAIL;
	    }
	}
		else { // success
      else
	{			// success
	  BytesSent += NWrite;
	}
    }
	if (BytesSent==Len) {
  if (BytesSent == Len)
    {
      return SUCCESS;
    }
	else {
		_SET_ERROR(m_Error,CError::SocketType,CError::SendError,"CExternalClientsSocketServer::SendBuffer()");
  else
    {
      _SET_ERROR (m_Error, CError::SocketType, CError::SendError,
		  "CExternalClientsSocketServer::SendBuffer()");
      return FAIL;
    }
}

int CExternalClientsSocketServer::receiveBuffer(BYTE *Msg,WORD Len)
int
CExternalClientsSocketServer::receiveBuffer (BYTE * Msg, WORD Len)
{
  int nRead;
  TIMEVALUE Now;
  TIMEVALUE Start;
  CIRATools::getTime (Start);
	while (true) {
		nRead = newExternalClientsSocketServer.Receive(m_Error,(void *)Msg,Len);
		if (nRead == WOULDBLOCK) {
  while (true)
    {
      nRead =
	newExternalClientsSocketServer.Receive (m_Error, (void *) Msg, Len);
      if (nRead == WOULDBLOCK)
	{
	  CIRATools::getTime (Now);
			if (CIRATools::timeDifference(Start,Now)>m_configuration->receiveTimeout()) {
	  if (CIRATools::timeDifference (Start, Now) >
	      m_configuration->receiveTimeout ())
	    {
	      return WOULDBLOCK;
	    }
			else {
	  else
	    {
	      CIRATools::Wait (0, 5000);
	      continue;
	    }
	}
		else if (nRead == FAIL) { 
      else if (nRead == FAIL)
	{
	  return nRead;
	}
		else if (nRead == 0) {
      else if (nRead == 0)
	{
	  return nRead;
	}
      else
@@ -532,19 +674,26 @@ int CExternalClientsSocketServer::receiveBuffer(BYTE *Msg,WORD Len)
    }
}

void CExternalClientsSocketServer::setExternalClientSocketStatus(ExternalClientSocketStatus status)
void
CExternalClientsSocketServer::
setExternalClientSocketStatus (ExternalClientSocketStatus status)
{
  m_Status = status;
	if (m_Status == ExternalClientSocketStatus_BSY) m_bBusy=true;
	else if (m_Status == ExternalClientSocketStatus_CNTD) m_bBusy=false;
  if (m_Status == ExternalClientSocketStatus_BSY)
    m_bBusy = true;
  else if (m_Status == ExternalClientSocketStatus_CNTD)
    m_bBusy = false;
}

bool CExternalClientsSocketServer::isBusy() 
bool
CExternalClientsSocketServer::isBusy ()
{
  return (m_bBusy);
}

CExternalClientsSocketServer::ExternalClientSocketStatus CExternalClientsSocketServer:: getStatus() const
CExternalClientsSocketServer::
  ExternalClientSocketStatus CExternalClientsSocketServer::
getStatus () const
{
  return m_Status;
}
+25 −0
Original line number Diff line number Diff line
@@ -180,6 +180,31 @@
    <modelCoeff6>0.0</modelCoeff6>
</Source>

<Source>
	<sourceName>3c273</sourceName>
	<rightAscension>12:29:06.6996828061</rightAscension>
	<declination>+02:03:08.598846466</declination>
	<epoch>J2000</epoch>
	<pmRA/>
	<pmDec/>
	<parallax/>
	<radialVelocity/>
    <type>c</type>
    <nFreqRange>1</nFreqRange>
    <freqRange>500.0-23780.0</freqRange>
    <fluxCoeff1>1</fluxCoeff1>
    <fluxCoeff2>0</fluxCoeff2>
    <fluxCoeff3>0</fluxCoeff3>
    <size>1</size>
    <model>GAUSS</model>
    <modelCoeff1>1.0</modelCoeff1>
    <modelCoeff2>0</modelCoeff2>
    <modelCoeff3>0</modelCoeff3>
    <modelCoeff4>0.0</modelCoeff4>
    <modelCoeff5>0.0</modelCoeff5>
    <modelCoeff6>0.0</modelCoeff6>
</Source>

<Source>
	<sourceName>3c286</sourceName>
	<rightAscension>13:31:08.286</rightAscension>
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+0 −0

File moved.

+1 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading