Commit 9fd6907c authored by Sergio Poppi's avatar Sergio Poppi
Browse files

Holography BE patches

parent d45211b1
Loading
Loading
Loading
Loading
+19 −39
Original line number Diff line number Diff line
@@ -192,54 +192,29 @@ class DigitalXCorrelator(DXC__POA.DigitalXCorrelator, ACSComponent, ContainerSer
           cannot get the coefficients.
        """

        #try:
            #self.corr.disconnect()
            #err = self.corr.connect(self.port, self.baudrate)
	    #self.corr.set_samples(self.samples)

        #except Exception:
            #self.getLogger().logDebug("Error in save_coeff: cannot connect to FPGA")
            #self.getLogger().logError("Error... cannot connect to FPGA")
            #raise ACSErrTypeFPGAConnectionImpl.CannotConnectExImpl()

#       # Running Correlation
        try:
            err = self.corr.run()
        except Exception:
            self.getLogger().logError("Error running correlation.")
            raise ACSErrTypeFPGACommunicationImpl.CannotRunExImpl()

        i = 0
        while err and i < self.max_attempts:
        try:
            if self.corr.isConnected:
                 self.corr.disconnect()
            err = self.corr.connect(self.port, self.baudrate)
	    self.corr.set_samples(self.samples)

        except Exception:
            self.getLogger().logDebug("Error in save_coeff: cannot connect to FPGA")
            self.getLogger().logError("Error... cannot connect to FPGA")
            raise ACSErrTypeFPGAConnectionImpl.CannotConnectExImpl()

            i += 1
            self.getLogger().logInfo("Attempt %d failed. Retrying..." %i)
            self.corr.reset()
            err = self.corr.connect(self.port, self.baudrate)
#       # Running Correlation
        try:
            err = self.corr.run()
		print "correlation done"

        except Exception:
            self.getLogger().logError("Error running correlation.")
            raise ACSErrTypeFPGACommunicationImpl.CannotRunExImpl()

        if err and i == self.max_attempts:
            self.getLogger().logError(
                    "Error... cannot get correlator coefficient in %d attempts" %self.max_attempts
            )
            self.corr.disconnect()
            raise ACSErrTypeFPGACommunicationImpl.CannotRunExImpl()
        
        # Getting coefficient    
        try:
            self.corr.getCoeff()
	    self.corr.reset()

        except Exception:
            raise ACSErrTypeFPGACommunicationImpl.CannotGetCoefficientsExImpl()
@@ -250,8 +225,9 @@ class DigitalXCorrelator(DXC__POA.DigitalXCorrelator, ACSComponent, ContainerSer
#	phase = (phase_tmp + DPI) % DPI         
        try:
            
#            full_res = self.corr.coeff.copy()
            full_res = self.corr.results.copy()
            self.corr.reset()

#            full_res.update({'module': module, 'phase': phase})
#            print full_res
            # Write values (V. 051)
@@ -264,4 +240,8 @@ class DigitalXCorrelator(DXC__POA.DigitalXCorrelator, ACSComponent, ContainerSer
        except IOError:
            self.getLogger().logError("Error writing out_file")
            raise ComponentErrorsImpl.FileIOErrorExImpl()
        try:	
            self.corr.disconnect()
        except Exception:
            print "disconnect exception"
            raise ACSErrTypeFPGACommunicationImpl.CannotRunExImpl()
+25 −11
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ void HolographyImpl::initialize() throw (ACSErr::ACSbaseExImpl)

        ACS_LOG(LM_FULL_INFO,"HolographyImpl::initialize()",(LM_INFO,"PROPERTY_CREATION"));
	try {	
                m_correlator=getContainerServices()->getDefaultComponent<DXC::DigitalXCorrelator>("IDL:alma/DXC/DigitalXCorrelator:1.0");
           

		m_ptime=new ROuLongLong(getContainerServices()->getName()+":time",getComponent());		
		m_pbackendName=new ROstring(getContainerServices()->getName()+":backendName",getComponent());
@@ -184,22 +184,36 @@ void HolographyImpl::sendHeader() throw (CORBA::SystemException, BackendsErrors:
		ComponentErrors::ComponentErrorsEx)
{
	AUTO_TRACE("HolographyImpl::sendHeader()");

            try{
            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 (std::bad_alloc& ex) {
		_EXCPT(ComponentErrors::MemoryAllocationExImpl,dummy,"HolographyImpl::sendHeader()");
		
		DWORD sampling_time;
		sampling_time=m_configuration.getSamplingTime(); 
		throw dummy;
	}catch (ComponentErrors::ComponentErrorsExImpl& ex) {
                ex.log(LM_DEBUG);
                throw ex.getComponentErrorsEx();
        }


	try{


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


		CSenderThread::TSenderParameter *temp;


       if (m_LogObservedPositions)
 		{
 	 		m_antennaBoss=getContainerServices()->getDefaultComponent<Antenna::AntennaBoss>(ANTENNA_BOSS_INTERFACE);
 	        	m_sender_thread_param.antennaBoss=m_antennaBoss;
 		} 

	
		m_sender_thread_param.sender=this;
+21 −11
Original line number Diff line number Diff line
@@ -25,8 +25,10 @@ class Correlator:
        self.coeff   = { 'real' : 0.00, 'imm' : 0.00 }
        self.buffer  = ""
        self.ser     = serial.Serial()
        self.isConnected=False
    
    def connect(self, portname, baudrate):
        
        conn_byte = 'c'
        ack_byte  = 'A'

@@ -43,10 +45,11 @@ class Correlator:
        self.ser.write(conn_byte)
        
        rx_byte = self.ser.read(1)

        if len(rx_byte) != 1 or rx_byte != ack_byte:
            sys.stderr.write("Connection Failed. rx_byte = %s, len = %d\n" % (rx_byte,len(rx_byte)))
            self.isConnected=False
            return -1
        self.isConnected=True
        
        return 0

@@ -58,6 +61,7 @@ class Correlator:

    def disconnect(self):
        self.ser.close()
        self.isConnected=False
        
    def set_samples(self, n_samples):
	send_sample = 't'
@@ -187,3 +191,9 @@ class Correlator:
    def printCoeff(self, message):

         message = ""

    #    if message == "":
    #       sys.stdout.write("%10.6f\t%10.6f\n" % (self.coeff['real'], self.coeff['imm']))
    #    else:
    #        sys.stdout.write("%s\t%10.6f\t%10.6f\n" % (message, self.coeff['real'], self.coeff['imm']))
		
 No newline at end of file
+2 −2

File changed.

Contains only whitespace changes.