Commit 7d123e20 authored by Andrea Orlat's avatar Andrea Orlat
Browse files

New TP component that supports external control of the fast cal switching

parent 18eca172
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -107,21 +107,25 @@ module Backends {
	interface TotalPower : GenericBackend {
				
		/**
		 * This method can be called to activate or disactivate the switching of the calibration noise diode. The mode the switching is done is controlled
		 * This method can be called to activate or deactivate the switching of the calibration noise diode. The mode the switching is done is controlled
		 * by the parameter and by the <i>sampleRate</i> attribute. If the component is busy it is not allowed to call this method. This method is
		 * only available if the connected receiver support it. 
		 * @throw ComponentErrors::ComponentErrorsEx
 		 * @throw BackendsErrors::BackendsErrorsEx  
		 * @param interleave this parmater controls the switching frequency of the calibration diode. If it is zero (default) the diode is not 
 		 * @param argument the parameter controls how the backend reacts to the command. The backend could be configured so that the switching is
 		 * 		   performed by the backend itself. in that case th argument is an integer value that is considered to be the interleave argument.
 		 * 		   Interleave controls the switching frequency of the calibration diode. If it is zero (default) the diode is not
		 *         switched (always turned off). if a one is given the backend will produce one sample (using the <i>sampleRate</i>)
		 *               with the mark switecehd off and one with the mark switched on. A two means two sample with the mark switched off and
		 *         with the mark switched off and one with the mark switched on. A two means two sample with the mark switched off and
		 * 	       one with the mark switched on.....and so on. A negative will not change the value of the parameter.
		 * 	       The other legal values are "EXT" meaning the switching is enabled but the trigger is issued by external sources and "OFF" meaning
		 * 	       the switching is turned off.
		*/
		void activateNoiseCalibrationSwitching(in long interleave) raises (ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx);
		void activateNoiseCalibrationSwitching(in string argument) raises (ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx);
				
		/**
		 * This method can be used to initialize the backend. Since this hardware can be connected to various receiver some parameter must be set before
		 * any further use. This parameter will stay fixed until a new initilization is issued. At start up a default initialization is commanded but can be 
		 * any further use. This parameter will stay fixed until a new initialization is issued. At start up a default initialization is commanded but can be
		 * changed at any time.  If the component is busy it is not allowed to call this method.
 		 * @throw ComponentErrors::ComponentErrorsEx 
 		 * @throw BackendsErrors::BackendsErrorsEx
@@ -129,6 +133,15 @@ module Backends {
 		 *               known an excpetion is thrown
		 */
		void initialize(in string configuration) raises (ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx);

		/**
		 * This method enables the fast switching of the calibration mark from external sources.
		 * @param on this argument defines if the external source can or cannot control the fast switching. 1 enabled, 0 disables.
		 * Other values are not legal.
 		 * @throw ComponentErrors::ComponentErrorsEx
 		 * @throw BackendsErrors::BackendsErrorsEx
		*/
		//void externalCalibrationSwitching(in long on) raises (ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx);
	};
	
};
+21 −0
Original line number Diff line number Diff line
@@ -720,6 +720,27 @@ void CCore::_setProjectCode(const char* code) throw (ManagementErrors::UnkownPro
	}
}

/*void CCore::_winkingMark(const char *arg) throw (ComponentErrors::ValidationErrorExImpl);
{
	baci::ThreadSyncGuard guard(&m_mutex);
	IRA::CString par(arg);
	par.MakeUpper();
	long interleave;
	if (par=="EXT") {

	}
	else if (par=="OFF") {
		// get the receiver boss.....
		loadReceiversBoss(m_receiversBoss,m_receiversBossError); // throw ComponentErrors::CouldntGetComponentExImpl)
	}
	else { // assign an interleave value

		_EXCPT(ComponentErrors::ValidationErrorExImpl,impl,"CCore::setDevice()");
		impl.setReason("device identifier does not exist in the current backend");
		throw impl;
	}
}*/

void CCore::_setDevice(const long& deviceID) throw (ComponentErrors::CouldntGetComponentExImpl,ComponentErrors::CORBAProblemExImpl,ComponentErrors::ValidationErrorExImpl,
		ComponentErrors::OperationErrorExImpl,ComponentErrors::CouldntReleaseComponentExImpl,ComponentErrors::UnexpectedExImpl)
{
+5 −5
Original line number Diff line number Diff line
@@ -58,13 +58,13 @@
	<xs:complexType name="BackendStatusType">
		<xs:complexContent>
			<xs:restriction base="baci:ROpattern">
				<xs:attribute name="resolution" type="xs:unsignedLong" use="optional" default="64"/>
				<xs:attribute name="resolution" type="xs:unsignedLong" use="optional" default="1024"/>
            	<xs:attribute name="bitDescription" type="xs:string" use="optional" default=
                	"Time_Sync,Busy,Suspended,Sampling,CmdLine,DataLine"/>
                	"Time_Sync,Busy,Suspended,Sampling,CmdLine,DataLine,ExternalMark,FastSwitching,Calon,ZeroRef"/>
				<xs:attribute name="whenSet" type="xs:string" use="optional" default=
                	"0, 1, 1, 1, 0, 0"/>
                	"0, 1, 1, 1, 0, 0, 1, 1, 1, 1"/>
            	<xs:attribute name="whenCleared" type="xs:string" use="optional" default=
            		"2, 3, 3, 3, 2, 2"/>
            		"2, 3, 3, 3, 2, 2, 3, 3, 3, 3"/>
			</xs:restriction>
		</xs:complexContent>
	</xs:complexType>	
+21 −11
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ public:
			BackendsErrors::BackendBusyExImpl);
	
	/**
	 * This function is called by the control thread in order to check the beackend clock matches with the host computer clock. In the two times do not
	 * This function is called by the control thread in order to check the backend clock matches with the host computer clock. In the two times do not
	 * match a log file in sent and the TIME_SYNC flag is set.
	 * @throw ComponentErrors::SocketErrorExImpl
	 *		 @arg \c ComponentErrors::IRALibraryResource
@@ -193,13 +193,11 @@ public:
	
	/**
	 * This method starts the calibration diode switching.
	 * @throw BackendsErrors::BackendBusyExImpl
	 * @thorw ,ComponentErrors::NotAllowedExImpl
	 * @param interleave this will control the switcing mode. An integer positive(N) will command the backend to produce N samples
	 *               when the calibration diode is turned off and then one with the calibration diode turned on. A zero disable the switching
	 *               (default), whilst a negative will not change the current configuration   
	 * @param argument this will control the switching mode.
	 */
	void activateCalSwitching(const long& interleave) throw (BackendsErrors::BackendBusyExImpl,ComponentErrors::NotAllowedExImpl);
	void activateCalSwitching(const char *argument) throw (BackendsErrors::BackendBusyExImpl,ComponentErrors::NotAllowedExImpl,
			BackendsErrors::NakExImpl,ComponentErrors::IRALibraryResourceExImpl,ComponentErrors::SocketErrorExImpl,ComponentErrors::TimeoutExImpl,
			BackendsErrors::ConnectionExImpl,ComponentErrors::ValidationErrorExImpl);
	
	/**
	 * This function must be called in order to change the integration time
@@ -209,7 +207,15 @@ public:
	void setIntegration(const long& integration) throw (BackendsErrors::BackendBusyExImpl);
	
	/**
	 * This methos will changes the current value of the <i>m_enabled</i> array.
	 * This method allows to turn on and off the noise mark switching from external sources.
	 * @param on 0 turns off, 1 turns on
	 */
	void externalCalibrationSwitching(const long& on) throw (BackendsErrors::BackendBusyExImpl,ComponentErrors::NotAllowedExImpl,
			BackendsErrors::NakExImpl,ComponentErrors::IRALibraryResourceExImpl,ComponentErrors::SocketErrorExImpl,ComponentErrors::TimeoutExImpl,
			BackendsErrors::ConnectionExImpl);

	/**
	 * This method will change the current value of the <i>m_enabled</i> array.
	 * @throw BackendsErrors::BackendBusyExImpl
	 * @param en new values sequence for the <i>m_enabled</i> elements. A value grater than zero correspond to a true,
	 *                a zero match to a false, while a negative will keep the things unchanged.
@@ -218,7 +224,7 @@ public:
	
	/**
	 * This function can be called in order to load an initial setup for the backend. Some parameter are fixed and cannot be changed during normal
	 * operation. In order for this call to suceed the backend must be ready and not busy with other operation. This operation will also reset all configuration
	 * operation. In order for this call to succeed the backend must be ready and not busy with other operation. This operation will also reset all configuration
	 * to the defaults.
	 * @throw BackendsErrors::BackendBusyExImpl
	 * @throw BackendsErrors::ConfigurationErrorExImpl
@@ -259,7 +265,7 @@ public:
	
	/**
	 * This function will start an acquisition job. The job will be created suspended and requires an explicit
	 * resum in order to begin the data flow. The backend will just connect to a specific socket.
	 * resume in order to begin the data flow. The backend will just connect to a specific socket.
	 * @throw ComponentErrors::SocketErrorExImpl
	 *		 @arg \c ComponentErrors::IRALibraryResource
	 * @throw ComponentErrors::TimeoutExImpl
@@ -460,7 +466,11 @@ private:
		SUSPEND=2,				  /*!< backend data flow is suspended */
		SAMPLING=3,              /*!< backend is recording */
		CMDLINERROR=4,      /*!< error in the command line */ 
		DATALINERROR=5     /*!< error in the data line */
		DATALINERROR=5,     /*!< error in the data line */
		EXTERNALCAL=6,      /*!< the switching of the calibration mark is external */
		FAST_SWITCHING=7,   /*!< the fast switching is ongoing.... */
		CALON=8,            /*!< the backend issued a calon on the receiver */
		ZERO=9				/*!< inputs are set to 50 Ohm */
	};
	/** Connection status */
	TLineStatus m_status;
+46 −3
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@
#define PROT_SET_ZERO "Z"
#define PROT_SET_SAMPLE_RATE "S"
#define PROT_GET_SAMPLE "R"
#define PROT_SET_EXT_CAL_SWITCH "M"
#define PROT_SET_CAL_ON "N"

#define PROT_ACK "ack"

@@ -41,8 +43,9 @@ using namespace IRA;
class CProtocol {
public:
	/**
	 * This enum enlists the pssoble configurations that can be done to set the source of  the backend input signal.
	 * This enum enlists the possible configurations that can be done to set the source of the backend input signal.
	 */

	enum TInputs {
		PRIMARY,
		BWG,
@@ -50,6 +53,13 @@ public:
		OHM50
	};
	
	typedef struct StatusWord {
		bool zero;
		bool calon;
		bool fastSwitch;
		bool externalNoise;
	} TStatusWord;

	/** 
	 * Prepare a buffer to be sent to the backend in order to request the backend configuration
	 * @param sBuff pointer to the buffer that contains the message. the buffer must be allocated by the caller.
@@ -140,9 +150,29 @@ public:
	 * @param sBuff pointer to the buffer that contains the message. the buffer must be allocated by the caller.
	 * @param channels number of channels that will be passed through the functionality
	 * @param level given in counts, is the point where the channels level is brought to.
 	 * @return the length of the message
	 */
	static WORD AutoGainControl(char *sBuff,const WORD& channels,const WORD& level);

	/**
	 * Prepare a buffer to be sent to the backend in order to enable/disable the fast switching of noise diode from external sources.
	 * @param sBuff pointer to the buffer that contains the message. the buffer must be allocated by the caller.
	 * @param on true enables, false disables
	 * @return the length of the message
	 *
	*/
	static WORD externalNoiseMark(char *sBuff,bool on);

	/**
	 * Prepare a buffer to be sent to the backend in order to turn on and off the noise diode of the front end.
	 * The hardware configuration must allow this.
	 * @param sBuff pointer to the buffer that contains the message. the buffer must be allocated by the caller.
	 * @param on true turns on, false turns off
	 * @return the length of the message
	 *
	*/
	static WORD noiseMark(char *sBuff,bool on);
	
	/**
	 * Prepare a buffer to be sent to the backend in order to set the sample rate that is used for the slow mode. The slow mode
	 * can be used to get a single tpi measure, so this value has nothing to to with the sampleRate set by the <i>startAcquisition()</i>
@@ -154,7 +184,7 @@ public:
	static WORD setIntegrationTime(char *sBuff,const long& integrationTime);
	
	/**
	 * Prepare a buffer ti be sent to the backend in order to get from the backend a tpi measure using the slow mode. The sample
	 * Prepare a buffer to be sent to the backend in order to get from the backend a tpi measure using the slow mode. The sample
	 * rate used is set by the call to <i>setSampleRate</i>.
	 * @param sBuff pointer to the buffer that contains the message. the buffer must be allocated by the caller.
	 */
@@ -171,9 +201,11 @@ public:
	 * @param tm reports the current time of the backend FPGA.
	 * @param currentSR reports the sample rate currently used in the backend (milliseconds)
	  *@param boards gives the mapping of section over boards, if null the mapping is flat: section 0 on board 0 and so on....
	  *@param status status word extracted from backend configuration
	 * @return true if the answer is correct and could be parsed 
	 */
	static bool decodeBackendConfiguration(const char *rBuff,const long& sectionNumber,const DWORD& boardsNumber,double *att,double *bw,TInputs *in,TIMEVALUE& tm,long& currentSR,long * boards);
	static bool decodeBackendConfiguration(const char *rBuff,const long& sectionNumber,const DWORD& boardsNumber,double *att,
			double *bw,TInputs *in,TIMEVALUE& tm,long& currentSR,long * boards,TStatusWord& status);
	
	/**
	 * Decodes the answer of the backend after it has been commanded a new time. 
@@ -278,6 +310,17 @@ private:
	*/  	
	static bool decodeFPGATime(const DWORD& clock,const double& sampleRate,const WORD& counter,TIMEVALUE& tm);
	
	/**
	 * This method is used to decode the status word coming from the backend configuration readout. Only few values are returned.
	 * @param word status word (8 bits for now)
	 * @param zero return if the inputs are connected to 50 Ohm
	 * @param calon true if the receiver noise diode is switched on
	 * @param fastSwitch true if the fast cal switching is enabled
	 * @param extrenalNoise true if the calibration mark switching is under control of external sources.
	 *
	 */
	static bool decodeStatusWord(const BYTE& word,bool& zero,bool& calon,bool& fastSwitch,bool& externalNoise);

	/**
	 * This method can be used to translate the backend answer regarding the attenuation level to its corresponding
	 * double value (db)
Loading