Commit fee30679 authored by Sergio Poppi's avatar Sergio Poppi
Browse files

HolographyImpl patches

parent 2f5c3ce7
Loading
Loading
Loading
Loading
+43 −25
Original line number Original line Diff line number Diff line
@@ -85,18 +85,20 @@ class DigitalXCorrelator(DXC__POA.DigitalXCorrelator, ACSComponent, ContainerSer
        ACSComponent.__init__(self)
        ACSComponent.__init__(self)
        ContainerServices.__init__(self)
        ContainerServices.__init__(self)
        self.corr = corr2serial.Correlator()
        self.corr = corr2serial.Correlator()
	self.name=ContainerServices.getName(self)
#	self.name=ContainerServices.getName(self)


    def initialize(self):
    def initialize(self):
        """Retrieve the CDB parameters."""
        """Retrieve the CDB parameters."""
#        dal=Acspy.Util.ACSCorba.cdb()
#        dal=Acspy.Util.ACSCorba.cdb()
        name=self.getName()
        dal=Acspy.Util.ACSCorba.cdb()


	try:
	try:
#	    dao=dal.get_DAO_Servant("alma/%s" %self.name)
	    dao=dal.get_DAO_Servant("alma/"+name)
            print self.name
            print self.name
#	    self.port = int(dao.get_double("PORT"))
	    self.port = int(dao.get_double("PORT"))
#           self.baudrate = int(dao.get_double("BAUDRATE"))
#           self.baudrate = int(dao.get_double("BAUDRATE"))
#            self.out_file_name = dao.get_string("OUT_FILE_FP")
            self.out_file_name = dao.get_string("OUT_FILE_FP")
#            self.max_attempts =int(dao.get_double("MAX_ATTEMPTS"))
#            self.max_attempts =int(dao.get_double("MAX_ATTEMPTS"))
            self.max_attempts =1
            self.max_attempts =1


@@ -122,30 +124,14 @@ class DigitalXCorrelator(DXC__POA.DigitalXCorrelator, ACSComponent, ContainerSer
            self.getLogger().logDebug("Error in initialize: cannot connect to FPGA")
            self.getLogger().logDebug("Error in initialize: cannot connect to FPGA")
            self.getLogger().logError("Error... cannot connect to FPGA")
            self.getLogger().logError("Error... cannot connect to FPGA")
            raise ACSErrTypeFPGAConnectionImpl.CannotConnectExImpl()
            raise ACSErrTypeFPGAConnectionImpl.CannotConnectExImpl()
        try:
            # Version 051:
	    print self.out_file_name
            dt = datetime.datetime.now()
            file_id = "_%04d%02d%02d_%02d%02d" %(dt.year, dt.month, dt.day, dt.hour, dt.minute)
            self.out_file = open(self.out_file_name + file_id, 'a', 0)
            self.out_file.write("Azimuth".ljust(15) + "Elevation".ljust(15))
            for item in ordered_key_list:
                self.out_file.write(item.ljust(15))
            self.out_file.write("Timestamp".ljust(30))
            # End 051
      
      
            # self.out_file = open(out_file, 'w', 0) # V.05
        except IOError:
            self.getLogger().logDebug("Error in initialize: cannot create out_file")
            self.getLogger().logError("Error creating out_file")
            raise ComponentErrorsImpl.FileIOErrorExImpl()
	
	
    def cleanUp(self):
    def cleanUp(self):
        self.corr.disconnect()
        self.corr.disconnect()
        self.getLogger().logDebug("CleanUp")
        self.getLogger().logDebug("CleanUp")


        self.out_file.close()
        self.out_file.close()
        ComponentLifecycle.cleanUp()
        #ComponentLifecycle.cleanUp()
        
        
    def aboutToAbort(self):
    def aboutToAbort(self):
        self.getLogger().logDebug("About to Abort")
        self.getLogger().logDebug("About to Abort")
@@ -245,3 +231,35 @@ class DigitalXCorrelator(DXC__POA.DigitalXCorrelator, ACSComponent, ContainerSer
        except Exception:
        except Exception:
            print "disconnect exception"
            print "disconnect exception"
            raise ACSErrTypeFPGACommunicationImpl.CannotRunExImpl()
            raise ACSErrTypeFPGACommunicationImpl.CannotRunExImpl()
        
    def openFile(self,name):
           
       try:
            self.out_file_name=name

            print self.out_file_name
            dt = datetime.datetime.now()
            file_id = "_%04d%02d%02d_%02d%02d" %(dt.year, dt.month, dt.day, dt.hour, dt.minute)
            self.out_file = open(self.out_file_name + file_id, 'a', 0)
            self.out_file.write("Azimuth".ljust(15) + "Elevation".ljust(15))
            for item in ordered_key_list:
                self.out_file.write(item.ljust(15))
            self.out_file.write("Timestamp".ljust(30))
            # End 051

            # self.out_file = open(out_file, 'w', 0) # V.05
       except IOError:
            self.getLogger().logDebug("Error in initialize: cannot create out_file")
            self.getLogger().logError("Error creating out_file")
            raise ComponentErrorsImpl.FileIOErrorExImpl()
    def closeFile(self):
      
        self.out_file.close()

    def reset(self):
        try:
          self.corr.reset()
        except Exception:
            print "reset exception"
            raise ACSErrTypeFPGACommunicationImpl.CannotRunExImpl()
        
 No newline at end of file
+22 −11
Original line number Original line Diff line number Diff line
@@ -169,14 +169,24 @@ void HolographyImpl::execute() throw (ACSErr::ACSbaseExImpl)
	ACS_LOG(LM_FULL_INFO,"HolographyImpl::execute()",(LM_INFO,"BACKEND_INITIAL_CONFIGURATION"));
	ACS_LOG(LM_FULL_INFO,"HolographyImpl::execute()",(LM_INFO,"BACKEND_INITIAL_CONFIGURATION"));
	ACS::Time time;
	ACS::Time time;
        try{		
        try{		
		//sets the property defaults....some of them cannot be changed any more (hardware dependent) 
              m_pbackendName->getDevIO()->write(getComponent()->getName(),time);
              m_pbackendName->getDevIO()->write(getComponent()->getName(),time);
              m_correlator=getContainerServices()->getDefaultComponent<DXC::DigitalXCorrelator>("IDL:alma/DXC/DigitalXCorrelator:1.0");
                if (m_LogObservedPositions)
                {
                        m_antennaBoss=getContainerServices()->getDefaultComponent<Antenna::AntennaBoss>(ANTENNA_BOSS_INTERFACE);
                        m_sender_thread_param.antennaBoss=m_antennaBoss;
                } 
                } 
	catch (ACSErr::ACSbaseExImpl& ex) {
        } catch (std::bad_alloc& ex) {
		_ADD_BACKTRACE(ComponentErrors::InitializationProblemExImpl,impl,ex,"TotalPowerImpl::execute()");
		_EXCPT(ComponentErrors::MemoryAllocationExImpl,dummy,"HolographyImpl::sendHeader()");
		throw impl;
		
		throw dummy;
        }catch (ComponentErrors::ComponentErrorsExImpl& ex) {
                ex.log(LM_DEBUG);
                throw ex.getComponentErrorsEx();
        }
        }



 
}
}




@@ -185,7 +195,7 @@ void HolographyImpl::sendHeader() throw (CORBA::SystemException, BackendsErrors:
{
{
	AUTO_TRACE("HolographyImpl::sendHeader()");
	AUTO_TRACE("HolographyImpl::sendHeader()");


            try{
   /*         try{
              m_correlator=getContainerServices()->getDefaultComponent<DXC::DigitalXCorrelator>("IDL:alma/DXC/DigitalXCorrelator:1.0");
              m_correlator=getContainerServices()->getDefaultComponent<DXC::DigitalXCorrelator>("IDL:alma/DXC/DigitalXCorrelator:1.0");
                if (m_LogObservedPositions)
                if (m_LogObservedPositions)
                {
                {
@@ -201,11 +211,12 @@ void HolographyImpl::sendHeader() throw (CORBA::SystemException, BackendsErrors:
                throw ex.getComponentErrorsEx();
                throw ex.getComponentErrorsEx();
        }
        }



*/
	try{
	try{




		DWORD sampling_time;
		DWORD sampling_time;
                m_correlator->reset();
		sampling_time=m_configuration.getSamplingTime(); 
		sampling_time=m_configuration.getSamplingTime(); 
 		cout << "***********************************************" << endl;
 		cout << "***********************************************" << endl;
                cout << "samplingTime:" << sampling_time;
                cout << "samplingTime:" << sampling_time;