Unverified Commit c26c005a authored by Giuseppe Carboni's avatar Giuseppe Carboni Committed by GitHub
Browse files

Fix #853, allowed setSection=*,... to configure all sections (#854)

* Fix #853, allowed setSection=*,... to configure all sections

This fix is for TotalPower and Sardara backends

* Fix #853, updated changelog
parent c66bd5f6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -108,3 +108,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/
## Changed
	issue #689 - The dataset provided by weather station has been enlarged by the wind direction. The correctponding RAL 'wx' command will noe provided wind direction readout, as well
    issue #621 - The maximum number of chars of the schedule file name is now 37 (extension included). This is done for fits file and archive issue with the lenght of the schedule name.
    issue #853 - The setSection command can now accept a wildcard (*) as section identifier. This will allow to configure all backend sections with a single command
+243 −225
Original line number Diff line number Diff line
@@ -353,10 +353,15 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
		BackendsErrors::BackendBusyExImpl)
{
	AUTO_TRACE("CCommandLine::setConfiguration()");
	double newBW,newSR,newFreq;
	long newBins, newFeed, newPol;
	std::vector<double> newBW(m_sectionsNumber);
	std::vector<double> newSR(m_sectionsNumber);
	std::vector<double> newFreq(m_sectionsNumber);
	std::vector<long> newBins(m_sectionsNumber);
	std::vector<long> newFeed(m_sectionsNumber);
	std::vector<long> newPol(m_sectionsNumber);
	double filter;
	int j;
	size_t minSection, maxSection;

	if (m_SardaraInitialized == true) {
		/*	if (getIsBusy()) {
@@ -370,6 +375,13 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
				impl.setReason("the section identifier is out of range");
				throw impl;
			}
			minSection=inputId;
			maxSection=minSection+1;
		}
		else if (inputId==-1)
		{
			minSection=0;
			maxSection=m_sectionsNumber;
		}
		else {
			_EXCPT(ComponentErrors::ValidationErrorExImpl,impl,"CCommandLine::setConfiguration()");
@@ -377,6 +389,8 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
			throw impl;
		}

		for(size_t i=minSection; i<maxSection; i++)
		{
			if (bw>=0) { // the user ask for a new value
				if (bw<MIN_BAND_WIDTH)  {
					_EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()");
@@ -390,28 +404,28 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
					impl.setValueLimit(MAX_BAND_WIDTH);
					throw impl;
				}
		    newBW=bw;
				newBW[i]=bw;
			}
			else { // else keep the present value
		    newBW=m_bandWidth[inputId];
				newBW[i]=m_bandWidth[i];
			}

			if (sr>=0) {// the user ask for a new value
		    if ((sr > MAX_SAMPLE_RATE) || (sr != 2*newBW)) {
				if ((sr > MAX_SAMPLE_RATE) || (sr != 2*newBW[i])) {
					_EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()");
					impl.setValueName("sampleRate");
					impl.setValueLimit(MAX_SAMPLE_RATE);
					throw impl;
				}
		    newSR=sr;
				newSR[i]=sr;
			}
			else {
		    newSR=m_sampleRate[inputId];
				newSR[i]=m_sampleRate[i];
			}

			if (freq >= 0) { // the user ask for a new value
				if (freq >= MIN_FREQUENCY && freq <= MAX_FREQUENCY) {
        		newFreq = freq;
					newFreq[i] = freq;
				}
				else {
					_EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()");
@@ -420,7 +434,7 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
				}
			}
			else
        	newFreq = m_frequency[inputId];
				newFreq[i] = m_frequency[i];

			if (feed >= 0) { // the user ask for a new value
				if (feed != 0) { // BUT for the moment is it possible to use ONLY feed 0
@@ -428,27 +442,27 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
					impl.setValueName("feed");
					throw impl;
				}
        	newFeed = feed;
				newFeed[i] = feed;
			}
			else
        	newFeed = m_feedNumber[inputId];
				newFeed[i] = m_feedNumber[i];

			if (pol >= 0) { // the user ask for a new value
				if ((pol == 0) || (pol == 1)) { // LCP or RCP
			    newPol = pol;
					newPol[i] = pol;
				}
				if (pol == 2) { // FULL STOKES
			    newPol = pol;
					newPol[i] = pol;
				}
				if (pol >= 3) {
					_EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()");
					impl.setValueName("pol");
					throw impl;
				}
            newPol = pol;
				newPol[i] = pol;
			}
			else
		    newPol = m_polarization[inputId];
				newPol[i] = m_polarization[i];

			if (bins>=0) { // the user ask for a new value
				if (bins != MIN_BINS && bins != MAX_BINS) {
@@ -460,68 +474,71 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
						impl.setValue(MAX_BINS);*/
					throw impl;
				}
        	newBins=bins;
				newBins[i]=bins;
			}
			else
        	newBins = m_bins[inputId];
				newBins[i] = m_bins[i];
		}

		for(size_t i=minSection; i<maxSection; i++)
		{
			if (m_stationSRT == true) {
				try {
			    Message request = Command::setSection(inputId, newFreq, newBW, newFeed, newPol, newSR, newBins);
					Message request = Command::setSection(i, newFreq[i], newBW[i], newFeed[i], newPol[i], newSR[i], newBins[i]);
					Message reply = sendBackendCommand(request);
					if (reply.is_success_reply()) {
						for (j=0;j<m_sectionsNumber;j++)
                        m_sampleRate[j]=newSR; //the given sample rate is taken also for all the others
                	m_commonSampleRate=newSR;
							m_sampleRate[j]=newSR[i]; //the given sample rate is taken also for all the others
						m_commonSampleRate=newSR[i];
						if (m_stokes==true) {
					    m_frequency[2*inputId]=newFreq;
                    	m_frequency[2*inputId+1]=newFreq;
                    	m_bandWidth[2*inputId]=newBW;
                    	m_bandWidth[2*inputId+1]=newBW;
							m_frequency[2*i]=newFreq[i];
							m_frequency[2*i+1]=newFreq[i];
							m_bandWidth[2*i]=newBW[i];
							m_bandWidth[2*i+1]=newBW[i];
						}
						else {
                        m_frequency[inputId]=newFreq;
                    	m_bandWidth[inputId]=newBW;
							m_frequency[i]=newFreq[i];
							m_bandWidth[i]=newBW[i];
						}
                	m_feedNumber[inputId]=newFeed;
                	m_bins[inputId]=newBins;
                	m_polarization[inputId]=newPol;
						m_feedNumber[i]=newFeed[i];
						m_bins[i]=newBins[i];
						m_polarization[i]=newPol[i];
						IRA::CString temp;
                	if (m_polarization[inputId]==Backends::BKND_LCP)
						if (m_polarization[i]==Backends::BKND_LCP)
							temp="LCP";
                	else if (m_polarization[inputId]==Backends::BKND_RCP)
						else if (m_polarization[i]==Backends::BKND_RCP)
							temp="RCP";
						else
							temp="FULL_STOKES";
                	ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"SECTION_CONFIGURED %ld,FREQ=%lf,BW=%lf,FEED=%ld,POL=%s,SR=%lf,BINS=%ld",inputId,m_frequency[inputId],newBW,m_feedNumber[inputId], (const char *)temp,newSR,m_bins[inputId]));		
						ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"SECTION_CONFIGURED %ld,FREQ=%lf,BW=%lf,FEED=%ld,POL=%s,SR=%lf,BINS=%ld",i,m_frequency[i],newBW[i],m_feedNumber[i], (const char *)temp,newSR[i],m_bins[i]));
						if (m_CK == true) {
                        if (newBW==420.00)
							if (newBW[i]==420.00)
								filter=300.00;
                        if (newBW==1500.00)
							if (newBW[i]==1500.00)
								filter=1250.00;
                        if (newBW==2300.00)
							if (newBW[i]==2300.00)
								filter=2350.00;
                        if (newBW == 420.00 || newBW == 1500.00 || newBW == 2300.00) {
							if (newBW[i] == 420.00 || newBW[i] == 1500.00 || newBW[i] == 2300.00) {
								for (j=0; j<m_inputsNumber; j++)
									m_totalPower->setSection(j,-1, filter, -1, -1, -1, -1);
                		   		ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"TOTALPOWER_FILTER_CONFIGURED %ld,FILTER=%lf",inputId,filter));
									ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"TOTALPOWER_FILTER_CONFIGURED %ld,FILTER=%lf",i,filter));
							}
						}
						/*if ((m_SL00==true || m_SL00S==true) && m_stationSRT == true) {
							try {
                            if (newBW==128.00) {
								if (newBW[i]==128.00) {
									m_ifDistributor->setup("BW-NARROW");
									ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-NARROW"));
								}
                            if (newBW==420.00) {
								if (newBW[i]==420.00) {
									m_ifDistributor->setup("BW-MEDIUM");
									ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-MEDIUM"));
								}
                            if (newBW==500.00) {
								if (newBW[i]==500.00) {
									m_ifDistributor->setup("BW-WIDE");
									ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-WIDE"));
								}
                            if (newBW==512.00) {
								if (newBW[i]==512.00) {
									m_ifDistributor->setup("BW-UNFILTERED");
									ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-UNFILTERED"));
								}
@@ -540,44 +557,44 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const

			if (m_stationMEDNT == true) {
				try {
                Message request = Command::setSection(inputId, newFreq, newBW, newFeed, newPol, newSR, newBins);
					Message request = Command::setSection(i, newFreq[i], newBW[i], newFeed[i], newPol[i], newSR[i], newBins[i]);
					Message reply = sendBackendCommand(request);
					if (reply.is_success_reply()) {
						for (int j=0;j<m_sectionsNumber;j++)
                        m_sampleRate[j]=newSR; //the given sample rate is taken also for all the others
		            m_commonSampleRate=newSR;
							m_sampleRate[j]=newSR[i]; //the given sample rate is taken also for all the others
						m_commonSampleRate=newSR[i];
						if (m_stokes==true) {
                        m_frequency[2*inputId]=newFreq;
                        m_frequency[2*inputId+1]=newFreq;
                        m_bandWidth[2*inputId]=newBW;
                        m_bandWidth[2*inputId+1]=newBW;
							m_frequency[2*i]=newFreq[i];
							m_frequency[2*i+1]=newFreq[i];
							m_bandWidth[2*i]=newBW[i];
							m_bandWidth[2*i+1]=newBW[i];
						}
						else {
                        m_frequency[inputId]=newFreq;
                        m_bandWidth[inputId]=newBW;
							m_frequency[i]=newFreq[i];
							m_bandWidth[i]=newBW[i];
						}
                    m_feedNumber[inputId]=newFeed;
                    m_bins[inputId]=newBins;
		            m_polarization[inputId]=newPol;
						m_feedNumber[i]=newFeed[i];
						m_bins[i]=newBins[i];
						m_polarization[i]=newPol[i];
						IRA::CString temp;
		            if (m_polarization[inputId]==Backends::BKND_LCP)
						if (m_polarization[i]==Backends::BKND_LCP)
							temp="LCP";
                    else if (m_polarization[inputId]==Backends::BKND_RCP)
						else if (m_polarization[i]==Backends::BKND_RCP)
							temp="RCP";
						else
							temp="FULL_STOKES";
		            ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"SECTION_CONFIGURED %ld,FREQ=%lf,BW=%lf,FEED=%ld,POL=%s,SR=%lf,BINS=%ld",inputId,m_frequency[inputId],newBW,m_feedNumber[inputId], (const char *)temp,newSR,m_bins[inputId]));
						ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"SECTION_CONFIGURED %ld,FREQ=%lf,BW=%lf,FEED=%ld,POL=%s,SR=%lf,BINS=%ld",i,m_frequency[i],newBW[i],m_feedNumber[i], (const char *)temp,newSR[i],m_bins[i]));
						if (m_CK==true) {
                        if (newBW==420.00)
							if (newBW[i]==420.00)
								filter=300.00;
                        if (newBW==1500.00)
							if (newBW[i]==1500.00)
								filter=1250.00;
                        if (newBW==2300.00)
							if (newBW[i]==2300.00)
								filter=2350.00;
                        if (newBW == 420.00 || newBW == 1500.00 || newBW == 2300.00) {
							if (newBW[i] == 420.00 || newBW[i] == 1500.00 || newBW[i] == 2300.00) {
								for (j=0; j<m_inputsNumber; j++) {
									m_totalPower->setSection(j,-1, filter, -1, -1, -1, -1);
                		   		ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"TOTALPOWER_FILTER_CONFIGURED %ld,FILTER=%lf",inputId,filter));
									ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"TOTALPOWER_FILTER_CONFIGURED %ld,FILTER=%lf",i,filter));
								}
							}
						}
@@ -589,6 +606,7 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
			}
		}
	}
}

void CCommandLine::getZeroTPI(DWORD *tpi) throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl,
		ComponentErrors::SocketErrorExImpl,BackendsErrors::NakExImpl,BackendsErrors::MalformedAnswerExImpl,
+88 −71
Original line number Diff line number Diff line
@@ -488,7 +488,10 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
	WORD len;
	char sBuff[SENDBUFFERSIZE];
	char rBuff[RECBUFFERSIZE];
	double newBW,newAtt,newSR;
	std::vector<double> newBW(m_sectionsNumber);
	std::vector<double> newAtt(m_sectionsNumber);
	std::vector<double> newSR(m_sectionsNumber);
	size_t minSection, maxSection;
	if (getIsBusy()) {
		_EXCPT(BackendsErrors::BackendBusyExImpl,impl,"CCommandLine::setConfiguration()");
		throw impl;
@@ -499,12 +502,22 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
			impl.setReason("the section identifier is out of range");
			throw impl;
		}
		minSection=inputId;
		maxSection=minSection+1;
	}
	else if (inputId==-1)
	{
		minSection=0;
		maxSection=m_sectionsNumber;
	}
	else {
		_EXCPT(ComponentErrors::ValidationErrorExImpl,impl,"CCommandLine::setConfiguration()");
		impl.setReason("the section identifier is out of range");
		throw impl;
	}

	for(size_t i=minSection; i<maxSection; i++)
	{
		if (bw>=0) { // the user ask for a new value
			if (bw<MIN_BAND_WIDTH)  {
				_EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()");
@@ -518,10 +531,10 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
				impl.setValueLimit(MAX_BAND_WIDTH);
				throw impl;
			}
		newBW=bw;
			newBW[i]=bw;
		}
		else { // else keep the present value
		newBW=m_bandWidth[inputId];
			newBW[i]=m_bandWidth[i];
		}
		if (sr>=0) {// the user ask for a new value
			if (sr>MAX_SAMPLE_RATE) {
@@ -530,16 +543,19 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
				impl.setValueLimit(MAX_SAMPLE_RATE);
				throw impl;
			}
		newSR=sr;
			newSR[i]=sr;
		}
		else {
		newSR=m_sampleRate[inputId];
			newSR[i]=m_sampleRate[i];
		}
		newAtt[i]=m_attenuation[i];
	}
	newAtt=m_attenuation[inputId];
	if (!checkConnection()) {
		_THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setConfiguration()");
	}
	len=CProtocol::setConfiguration(sBuff,inputId,m_input[inputId],newAtt,newBW,m_boards); // get the buffer
	for(size_t i=minSection; i<maxSection; i++)
	{
		len=CProtocol::setConfiguration(sBuff,i,m_input[i],newAtt[i],newBW[i],m_boards); // get the buffer
		if ((res=sendBuffer(sBuff,len))==SUCCESS) {
			res=receiveBuffer(rBuff,RECBUFFERSIZE);
		}
@@ -547,9 +563,9 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
			if (!CProtocol::isAck(rBuff)) {
				_THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setConfiguration()");
			}
		m_bandWidth[inputId]=newBW;
		for (int j=0;j<m_sectionsNumber;j++) m_sampleRate[j]=newSR; //the given sample rate is taken also for all the others
		m_commonSampleRate=newSR;
			m_bandWidth[i]=newBW[i];
			for (int j=0;j<m_sectionsNumber;j++) m_sampleRate[j]=newSR[i]; //the given sample rate is taken also for all the others
			m_commonSampleRate=newSR[i];
			m_integration=0;
			// log warning about configuration that are ignored.
			if (freq>=0) {
@@ -565,14 +581,14 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
				ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_WARNING,"CANNOT_CHANGE_POLARIZATION"));
			}
			IRA::CString temp;
		if (m_polarization[inputId]==Backends::BKND_LCP) {  //FULL STOKE not possible....
			if (m_polarization[i]==Backends::BKND_LCP) {  //FULL STOKE not possible....
				temp="LCP";
			}
			else {
				temp="RCP";
			}
		ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"SECTION_CONFIGURED %ld,FREQ=%lf,BW=%lf,FEED=%ld,POL=%s,SR=%lf,BINS=%ld",inputId,m_frequency[inputId],newBW,m_feedNumber[inputId],
				(const char *)temp,newSR,m_bins[inputId]));		
			ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"SECTION_CONFIGURED %ld,FREQ=%lf,BW=%lf,FEED=%ld,POL=%s,SR=%lf,BINS=%ld",i,m_frequency[i],newBW[i],m_feedNumber[i],
					(const char *)temp,newSR[i],m_bins[i]));
		}
		else if (res==FAIL) {
			_EXCPT_FROM_ERROR(ComponentErrors::IRALibraryResourceExImpl,dummy,m_Error);
@@ -588,6 +604,7 @@ void CCommandLine::setConfiguration(const long& inputId,const double& freq,const
			_THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setConfiguration()");
		}
	}
}

void CCommandLine::getZeroTPI(DWORD *tpi) throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl,
		ComponentErrors::SocketErrorExImpl,BackendsErrors::NakExImpl,BackendsErrors::MalformedAnswerExImpl,