Commit 50b29ba2 authored by Giuseppe Carboni's avatar Giuseppe Carboni
Browse files

Fix #855, added `setAttenuations` command

parent c66bd5f6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -102,7 +102,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/
                 The syntax for the command is the following: `enable=X;Y` with X and Y representing the 2 feeds the user would like to use for the Nodding observation.
                 This command must be placed in the <schedule_name>.bck file in order to work properly.
    issue #619 - Active surface components are now capable of changing look-up tables on the fly via the `asSetLUT` command
    issue #806   Added support for the C-band receiver at the SRT
    issue #806 - Added support for the C-band receiver at the SRT
    issue #855 - Added `setAttenuations` command

## Fixed
## Changed
+2 −0
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@ IRA::CString CParser<OBJ>::executeCommand(const IRA::CString& command,IRA::CStri
			IRA::CString answer("");
			if (outNumber>0) {
				for(int j=0;j<outNumber;++j) {
					if(outParams[j] == "")
						continue;
					answer+=outParams[j];
					answer+=IRA::CString(m_answerDelimiter);
				}
+36 −2
Original line number Diff line number Diff line
@@ -24,6 +24,38 @@ enum _sp_symbols {
#define _SP_MULTI_ARGUMENT_SEPARATOR ';'
#define _SP_MULTI_ARGUMENT_COMPACT_SEP 'x'

#define _SP_JOLLYCHARACTER '*'
#define _SP_JOLLYCHARACTER_REPLACEMENT "-1"

#define _SP_WILDCARD_CLASS(NAME,REPLACE) \
class NAME { \
public: \
	static char *replace(const char *str) { \
		if (str[0]==_SP_JOLLYCHARACTER) { \
			char * out=new char[strlen(REPLACE)+1]; \
			strcpy(out,REPLACE); \
			return out; \
		} \
		else { \
			char *tmp=new char[strlen(str)+1]; \
			strcpy(tmp,str); \
			return tmp; \
		} \
	} \
}; \

_SP_WILDCARD_CLASS(_default_wildcard,_SP_JOLLYCHARACTER_REPLACEMENT);

class _no_wildcard
{
public:
	static char *replace(const char *str) {
		char *tmp=new char[strlen(str)+1];
		strcpy(tmp,str);
		return tmp;
	}
};

class int_converter
{
public:
@@ -397,7 +429,7 @@ public:
	}
};

class longSeq_converter
class longSeq_converter : public _default_wildcard
{
public:
	char *valToStr(const ACS::longSeq& val) {
@@ -439,6 +471,7 @@ public:
			while (IRA::CIRATools::getNextToken(param,start,_SP_MULTI_ARGUMENT_SEPARATOR,ret)) {
				errno=0;
				token=const_cast<char *>((const char *)ret);
				token=_default_wildcard::replace(token);
				val=strtol(token,&endptr,10);
				if ((errno==ERANGE && (val==LONG_MAX || val==LONG_MIN)) || (errno != 0 && val == 0)) {
					_EXCPT(ParserErrors::BadTypeFormatExImpl,ex,"longSeq_converter::strToVal()");
@@ -459,7 +492,7 @@ public:
	}
};

class doubleSeq_converter
class doubleSeq_converter : public _default_wildcard
{
public:
	char *valToStr(const ACS::doubleSeq& val) {
@@ -501,6 +534,7 @@ public:
			while (IRA::CIRATools::getNextToken(param,start,_SP_MULTI_ARGUMENT_SEPARATOR,ret)) {
				errno=0;
				token=const_cast<char *>((const char *)ret);
				token=_default_wildcard::replace(token);
				val=strtod(token,&endptr);
				if ((errno==ERANGE && (val==HUGE_VALF || val==HUGE_VALF)) || (errno != 0 && val == 0)) {
					_EXCPT(ParserErrors::BadTypeFormatExImpl,ex,"doubleSeq_converter::strToVal()");
+0 −32
Original line number Diff line number Diff line
@@ -32,40 +32,8 @@ C11_IGNORE_WARNING_POP

#include "SP_typeConversion.h"

#define _SP_JOLLYCHARACTER '*'
#define _SP_JOLLYCHARACTER_REPLACEMENT "-1"

namespace SimpleParser {

#define _SP_WILDCARD_CLASS(NAME,REPLACE) \
class NAME { \
public: \
	static char *replace(const char *str) { \
		if (str[0]==_SP_JOLLYCHARACTER) { \
			char * out=new char[strlen(REPLACE)+1]; \
			strcpy(out,REPLACE); \
			return out; \
		} \
		else { \
			char *tmp=new char[strlen(str)+1]; \
			strcpy(tmp,str); \
			return tmp; \
		} \
	} \
}; \

_SP_WILDCARD_CLASS(_default_wildcard,_SP_JOLLYCHARACTER_REPLACEMENT);

class _no_wildcard
{
public:
	static char *replace(const char *str) {
		char *tmp=new char[strlen(str)+1];
		strcpy(tmp,str);
		return tmp;
	}
};

/**
 * This is the base class for all types that are known to the parser. New types can be easily added, just providing the converter class.
 * The converter class just have to implement the proper methods, <i>strToVal()</i> and <i>valToStr()</i>.
+15 −0
Original line number Diff line number Diff line
@@ -260,4 +260,19 @@ void _startRecording(const long& subScanId,const ACS::TimeInterval& duration) th
 */
void _terminateScan() throw (ComponentErrors::OperationErrorExImpl,ComponentErrors::CORBAProblemExImpl,ComponentErrors::UnexpectedExImpl,ComponentErrors::CouldntGetComponentExImpl);

/**
 * Sets all the sections attenuations with a single command
 * @param attenuations an ACS::doubleSeq containing all the desired sections attenuations
 * @param message a return message that will return a list of sections that the system was not able to configure
 * @throw ComponentErrors::CouldntGetComponentExImpl when the default backend component was not reachable
 * @throw ComponentErrors::CORBAProblemExImpl when something went wrong while trying to read the current sections from the default backend component
 * @throw ParserErrors::NotEnoughParametersExImpl when the user specifies less attenuations values than the currently configured number of sections
 * @throw ParserErrors::TooManyParametersExImpl when the user specifies more attenuations values than the currently configured number of sections
 */
void _setAttenuations(const ACS::longSeq& attenuations, IRA::CString& message) throw (
		ComponentErrors::CouldntGetComponentExImpl,
		ComponentErrors::CORBAProblemExImpl,
		ParserErrors::NotEnoughParametersExImpl,
		ParserErrors::TooManyParametersExImpl);

#endif /* CORE_OPERATIONS_H_ */
Loading