diff --git a/CHANGELOG.md b/CHANGELOG.md index f12d48bf9067329e30796dc8fb4faeab8cb56d96..df21abc5a7df57d1a713be1dc97c99cb48d60448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Common/Servers/Sardara/src/CommandLine.cpp b/Common/Servers/Sardara/src/CommandLine.cpp index d8dd17334a53c644a2c40fd5bcbc05b1c3798900..050946a6a2d7b373e35728776801b4e2e61db9a5 100644 --- a/Common/Servers/Sardara/src/CommandLine.cpp +++ b/Common/Servers/Sardara/src/CommandLine.cpp @@ -353,241 +353,259 @@ 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 newBW(m_sectionsNumber); + std::vector newSR(m_sectionsNumber); + std::vector newFreq(m_sectionsNumber); + std::vector newBins(m_sectionsNumber); + std::vector newFeed(m_sectionsNumber); + std::vector newPol(m_sectionsNumber); double filter; int j; + size_t minSection, maxSection; - if (m_SardaraInitialized == true) { - /* if (getIsBusy()) { + if (m_SardaraInitialized == true) { + /* if (getIsBusy()) { _EXCPT(BackendsErrors::BackendBusyExImpl,impl,"CCommandLine::setConfiguration()"); throw impl; - }*/ - if (inputId>=0) { //check the section id is in valid ranges - //if (inputId>=m_sectionsNumber) { - if (inputId>m_sectionsNumber) { - _EXCPT(ComponentErrors::ValidationErrorExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setReason("the section identifier is out of range"); - throw impl; - } - } - else { - _EXCPT(ComponentErrors::ValidationErrorExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setReason("the section identifier is out of range"); - throw impl; - } + }*/ + if (inputId>=0) { //check the section id is in valid ranges + //if (inputId>=m_sectionsNumber) { + if (inputId>m_sectionsNumber) { + _EXCPT(ComponentErrors::ValidationErrorExImpl,impl,"CCommandLine::setConfiguration()"); + 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; + } - if (bw>=0) { // the user ask for a new value - if (bwMAX_BAND_WIDTH) { - _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setValueName("bandWidth"); - impl.setValueLimit(MAX_BAND_WIDTH); - throw impl; - } - newBW=bw; - } - else { // else keep the present value - newBW=m_bandWidth[inputId]; - } + for(size_t i=minSection; i=0) { // the user ask for a new value + if (bwMAX_BAND_WIDTH) { + _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); + impl.setValueName("bandWidth"); + impl.setValueLimit(MAX_BAND_WIDTH); + throw impl; + } + newBW[i]=bw; + } + else { // else keep the present value + newBW[i]=m_bandWidth[i]; + } - if (sr>=0) {// the user ask for a new value - if ((sr > MAX_SAMPLE_RATE) || (sr != 2*newBW)) { - _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setValueName("sampleRate"); - impl.setValueLimit(MAX_SAMPLE_RATE); - throw impl; - } - newSR=sr; - } - else { - newSR=m_sampleRate[inputId]; - } + if (sr>=0) {// the user ask for a new value + 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[i]=sr; + } + else { + newSR[i]=m_sampleRate[i]; + } - if (freq >= 0) { // the user ask for a new value - if (freq >= MIN_FREQUENCY && freq <= MAX_FREQUENCY) { - newFreq = freq; - } - else { - _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setValueName("freq"); - throw impl; - } - } - else - newFreq = m_frequency[inputId]; + if (freq >= 0) { // the user ask for a new value + if (freq >= MIN_FREQUENCY && freq <= MAX_FREQUENCY) { + newFreq[i] = freq; + } + else { + _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); + impl.setValueName("freq"); + throw impl; + } + } + else + 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 + _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); + impl.setValueName("feed"); + throw impl; + } + newFeed[i] = feed; + } + else + newFeed[i] = m_feedNumber[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 - _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setValueName("feed"); - throw impl; - } - newFeed = feed; - } - else - newFeed = m_feedNumber[inputId]; - - if (pol >= 0) { // the user ask for a new value - if ((pol == 0) || (pol == 1)) { // LCP or RCP - newPol = pol; - } - if (pol == 2) { // FULL STOKES - newPol = pol; - } - if (pol >= 3) { - _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setValueName("pol"); - throw impl; - } - newPol = pol; - } - else - newPol = m_polarization[inputId]; - - if (bins>=0) { // the user ask for a new value - if (bins != MIN_BINS && bins != MAX_BINS) { - _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setValueName("bins"); - /*if (bins != MIN_BINS) - impl.setValue(MIN_BINS); - if (bins != MAX_BINS) - impl.setValue(MAX_BINS);*/ - throw impl; - } - newBins=bins; - } - else - newBins = m_bins[inputId]; - - if (m_stationSRT == true) { - try { - Message request = Command::setSection(inputId, newFreq, newBW, newFeed, newPol, newSR, newBins); - Message reply = sendBackendCommand(request); - if (reply.is_success_reply()) { - for (j=0;jsetSection(j,-1, filter, -1, -1, -1, -1); - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"TOTALPOWER_FILTER_CONFIGURED %ld,FILTER=%lf",inputId,filter)); - } - } - /*if ((m_SL00==true || m_SL00S==true) && m_stationSRT == true) { - try { - if (newBW==128.00) { - m_ifDistributor->setup("BW-NARROW"); - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-NARROW")); - } - if (newBW==420.00) { - m_ifDistributor->setup("BW-MEDIUM"); - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-MEDIUM")); - } - if (newBW==500.00) { - m_ifDistributor->setup("BW-WIDE"); - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-WIDE")); - } - if (newBW==512.00) { - m_ifDistributor->setup("BW-UNFILTERED"); - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-UNFILTERED")); - } - } - catch (...) { - _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CCommandLine::setAttenuation()"); - impl.log(LM_ERROR); - } - }*/ - } - } - catch (...) { - ACS_LOG(LM_FULL_INFO,"CCommandLine::setSection()",(LM_NOTICE,"BACKEND_SARDARA_SET_SECTION ERROR")); - } - } + if (pol >= 0) { // the user ask for a new value + if ((pol == 0) || (pol == 1)) { // LCP or RCP + newPol[i] = pol; + } + if (pol == 2) { // FULL STOKES + newPol[i] = pol; + } + if (pol >= 3) { + _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); + impl.setValueName("pol"); + throw impl; + } + newPol[i] = pol; + } + else + newPol[i] = m_polarization[i]; + + if (bins>=0) { // the user ask for a new value + if (bins != MIN_BINS && bins != MAX_BINS) { + _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); + impl.setValueName("bins"); + /*if (bins != MIN_BINS) + impl.setValue(MIN_BINS); + if (bins != MAX_BINS) + impl.setValue(MAX_BINS);*/ + throw impl; + } + newBins[i]=bins; + } + else + newBins[i] = m_bins[i]; + } - if (m_stationMEDNT == true) { - try { - Message request = Command::setSection(inputId, newFreq, newBW, newFeed, newPol, newSR, newBins); - Message reply = sendBackendCommand(request); - if (reply.is_success_reply()) { - for (int j=0;jsetSection(j,-1, filter, -1, -1, -1, -1); - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"TOTALPOWER_FILTER_CONFIGURED %ld,FILTER=%lf",inputId,filter)); - } - } - } - } - } - catch (...) { - ACS_LOG(LM_FULL_INFO,"CCommandLine::setSection()",(LM_NOTICE,"BACKEND_SARDARA_SET_SECTION ERROR")); - } - } - } + for(size_t i=minSection; isetSection(j,-1, filter, -1, -1, -1, -1); + 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[i]==128.00) { + m_ifDistributor->setup("BW-NARROW"); + ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-NARROW")); + } + 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[i]==500.00) { + m_ifDistributor->setup("BW-WIDE"); + ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-WIDE")); + } + if (newBW[i]==512.00) { + m_ifDistributor->setup("BW-UNFILTERED"); + ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"IFDISTRIBUTOR_FILTER_BW-UNFILTERED")); + } + } + catch (...) { + _EXCPT(ComponentErrors::UnexpectedExImpl,impl,"CCommandLine::setAttenuation()"); + impl.log(LM_ERROR); + } + }*/ + } + } + catch (...) { + ACS_LOG(LM_FULL_INFO,"CCommandLine::setSection()",(LM_NOTICE,"BACKEND_SARDARA_SET_SECTION ERROR")); + } + } + + if (m_stationMEDNT == true) { + try { + 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;jsetSection(j,-1, filter, -1, -1, -1, -1); + ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_NOTICE,"TOTALPOWER_FILTER_CONFIGURED %ld,FILTER=%lf",i,filter)); + } + } + } + } + } + catch (...) { + ACS_LOG(LM_FULL_INFO,"CCommandLine::setSection()",(LM_NOTICE,"BACKEND_SARDARA_SET_SECTION ERROR")); + } + } + } + } } void CCommandLine::getZeroTPI(DWORD *tpi) throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, diff --git a/Common/Servers/TotalPower/src/CommandLine.cpp b/Common/Servers/TotalPower/src/CommandLine.cpp index bfee254882f106c162e64d7304d8da74c04e578d..7ec0519e9482882abbd7566c95a1847bc9dafe99 100644 --- a/Common/Servers/TotalPower/src/CommandLine.cpp +++ b/Common/Servers/TotalPower/src/CommandLine.cpp @@ -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 newBW(m_sectionsNumber); + std::vector newAtt(m_sectionsNumber); + std::vector newSR(m_sectionsNumber); + size_t minSection, maxSection; if (getIsBusy()) { _EXCPT(BackendsErrors::BackendBusyExImpl,impl,"CCommandLine::setConfiguration()"); throw impl; @@ -499,94 +502,108 @@ 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; } - if (bw>=0) { // the user ask for a new value - if (bwMAX_BAND_WIDTH) { - _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setValueName("bandWidth"); - impl.setValueLimit(MAX_BAND_WIDTH); - throw impl; + + for(size_t i=minSection; i=0) { // the user ask for a new value + if (bwMAX_BAND_WIDTH) { + _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); + impl.setValueName("bandWidth"); + impl.setValueLimit(MAX_BAND_WIDTH); + throw impl; + } + newBW[i]=bw; } - newBW=bw; - } - else { // else keep the present value - newBW=m_bandWidth[inputId]; - } - if (sr>=0) {// the user ask for a new value - if (sr>MAX_SAMPLE_RATE) { - _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); - impl.setValueName("sampleRate"); - impl.setValueLimit(MAX_SAMPLE_RATE); - throw impl; + else { // else keep the present value + newBW[i]=m_bandWidth[i]; } - newSR=sr; - } - else { - newSR=m_sampleRate[inputId]; + if (sr>=0) {// the user ask for a new value + if (sr>MAX_SAMPLE_RATE) { + _EXCPT(ComponentErrors::ValueOutofRangeExImpl,impl,"CCommandLine::setConfiguration()"); + impl.setValueName("sampleRate"); + impl.setValueLimit(MAX_SAMPLE_RATE); + throw impl; + } + newSR[i]=sr; + } + else { + 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 - if ((res=sendBuffer(sBuff,len))==SUCCESS) { - res=receiveBuffer(rBuff,RECBUFFERSIZE); - } - if (res>0) { // operation was ok. - if (!CProtocol::isAck(rBuff)) { - _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setConfiguration()"); - } - m_bandWidth[inputId]=newBW; - for (int j=0;j=0) { - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_WARNING,"CANNOT_CHANGE_FREQUENCY")); - } - if (feed>=0) { - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_WARNING,"CANNOT_CHANGE_FEED")); - } - if (bins>=0) { - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_WARNING,"CANNOT_CHANGE_BINS_NUMBER")); + for(size_t i=minSection; i=0) { - ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_WARNING,"CANNOT_CHANGE_POLARIZATION")); + if (res>0) { // operation was ok. + if (!CProtocol::isAck(rBuff)) { + _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setConfiguration()"); + } + m_bandWidth[i]=newBW[i]; + for (int j=0;j=0) { + ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_WARNING,"CANNOT_CHANGE_FREQUENCY")); + } + if (feed>=0) { + ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_WARNING,"CANNOT_CHANGE_FEED")); + } + if (bins>=0) { + ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_WARNING,"CANNOT_CHANGE_BINS_NUMBER")); + } + if (pol>=0) { + ACS_LOG(LM_FULL_INFO,"CCommandLine::setConfiguration()",(LM_WARNING,"CANNOT_CHANGE_POLARIZATION")); + } + IRA::CString temp; + 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",i,m_frequency[i],newBW[i],m_feedNumber[i], + (const char *)temp,newSR[i],m_bins[i])); } - IRA::CString temp; - if (m_polarization[inputId]==Backends::BKND_LCP) { //FULL STOKE not possible.... - temp="LCP"; + else if (res==FAIL) { + _EXCPT_FROM_ERROR(ComponentErrors::IRALibraryResourceExImpl,dummy,m_Error); + dummy.setCode(m_Error.getErrorCode()); + dummy.setDescription((const char*)m_Error.getDescription()); + m_Error.Reset(); + _THROW_EXCPT_FROM_EXCPT(ComponentErrors::SocketErrorExImpl,dummy,"CCommandLine::setConfiguration()"); + } + else if (res==WOULDBLOCK) { + _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::setConfiguration()"); } else { - temp="RCP"; + _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setConfiguration()"); } - 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])); - } - else if (res==FAIL) { - _EXCPT_FROM_ERROR(ComponentErrors::IRALibraryResourceExImpl,dummy,m_Error); - dummy.setCode(m_Error.getErrorCode()); - dummy.setDescription((const char*)m_Error.getDescription()); - m_Error.Reset(); - _THROW_EXCPT_FROM_EXCPT(ComponentErrors::SocketErrorExImpl,dummy,"CCommandLine::setConfiguration()"); - } - else if (res==WOULDBLOCK) { - _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::setConfiguration()"); } - else { - _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setConfiguration()"); - } } void CCommandLine::getZeroTPI(DWORD *tpi) throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl,