Commit e10e5790 authored by TheDebbio's avatar TheDebbio
Browse files

Broken: basic conf handler proto

Now ready to ad LOs
parent c7f5a051
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -395,13 +395,7 @@ private:
        UNLOCKED=11
    };


    /**@brief LO device anda data collector */        
    struct LO{
        Receivers::LocalOscillator_var m_localOscillatorDevice; /**< LO HPIB connected device */
        bool m_localOscillatorFault;    /**< Falut flag */
        double m_localOscillatorValue;  /**< Frequency Value */
    }

    CConfiguration m_configuration;
    maci::ContainerServices* m_services;
@@ -413,8 +407,14 @@ private:
    ACS::longSeq m_polarization;
    IRA::CString m_setupMode;

    struct LO{
        Receivers::LocalOscillator_var m_localOscillatorDevice; /**< LO  connected device */
        bool m_localOscillatorFault;    /**< Falut flag */
        double m_localOscillatorValue;  /**< Frequency Value */
    };

    LO m_lo_1st;        /**< 1st stage mixer */
    LO m_lo_2st;        /**< 2st stage mixer */
    LO m_lo_2nd;        /**< 2st stage mixer */

    double m_vacuum;
    CConfiguration::BoardValue m_environmentTemperature;
+8 −5
Original line number Diff line number Diff line
@@ -42,8 +42,9 @@ public:

	/* *** COMPONENT *** */
	/**
    * This member function is used to configure component by reading the configuration parameter from the CDB.
	 * This must be the first call before using any other function of this class.
    *  @brief This member function is used to configure component by reading the configuration parameter from the CDB.
	 * @details This must be the first call before using any other function of this class.
	 * 			This call applies CCC_Normal configuration as default
	 * @throw ComponentErrors::CDBAccess
	 * @param Services pointer to the container services object
	*/
@@ -217,6 +218,10 @@ public:
	 */
	inline double const * const  getLOMax() const { return  m_LOMax; }

public: 

	ReceiverConfHandler m_conf_hnd;	/**< Receiver Configuration  helper */	

private:

	/**
@@ -273,8 +278,6 @@ private:
	IRA::CString m_localOscillatorInstance1st; /**< 1st stage mixer component instance name */
	IRA::CString m_localOscillatorInstance2nd; /**< 2nd stage mixer component instance name */
	
	ReceiverConfHandler m_conf_hnd;	/**< Receiver Configuration  helper */
	
	IRA::CDBTable *m_taperTable;	/**< Helper reading xml taper table */
	IRA::CDBTable *m_feedsTable;	/**< Helper reading xml feeds table */
	IRA::CDBTable *m_loTable;		/**< Helper reading xml local synth data table */
+145 −9
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@

/**
 * @brief Receiver configuration holder/helper
 * @details Singleton implementation
 * It keeps receiver configuration usefull datain one place
 */
struct ReceiverConfHandler{
@@ -24,6 +23,25 @@ struct ReceiverConfHandler{
        CHC_Narrow
    } ConfigurationName; 

    typedef enum{
        CCC=0,
        CHC=1
    } ReceiverName;

    typedef enum{
        Normal=0,
        Narrow
    }ModeName;

    /**
     * @brief Infos on current selected configuration
     */
    struct CurrentConfiguration{
        ConfigurationName m_name;
        ReceiverName m_receiver;
        ModeName m_mode;
    };

    /**
     * @brief Configuration file access infos
     */
@@ -41,6 +59,7 @@ struct ReceiverConfHandler{
	struct ConfigurationSetup{
		DWORD m_IFs;
		DWORD m_feeds;
        IRA::CString m_name;
		std::vector<Receivers::TPolarization> m_polarizations;		
		std::vector<double> m_RFMin;
		std::vector<double> m_RFMax;
@@ -70,12 +89,83 @@ struct ReceiverConfHandler{
     */
    static ReceiverConfHandler* getInstance();

    /**
     * @brief Set the Configuration from enum tag
     * @param p_conf_name Desired conf
     * @return true 
     * @return True if requested configuration is valid.
     */
    bool setConfiguration(ConfigurationName p_conf_name);

    /**
     * @brief Set the Configuration from string tag
     * @param p_conf_name Desired conf
     * @return true 
     * @return True if requested configuration is valid.
     */
    bool setConfiguration(IRA::Cstring p_conf_name);

    /**
     * @brief Set configuration starting from given receiver keeping default Normal as mode
     * 
     * @param p_receiver_name Requested receiver
     * @return true receiver correctly set    
     */
    bool setConfigurationReceiver(ReceiverName p_receiver_name);

    /**
     * @brief Set the Receiver keeping default Normal as mode (string tag)
     * 
     * @param p_receiver_name Requested receiver
     * @return true receiver correctly set    
     */
    bool setConfigurationReceiver(IRA::CString p_receiver_name);

    /**
     * @brief Set the Mode keeping actual receiver selected
     * 
     * @param p_mode_name Requeste mode
     * @return true Mode correctly set
     */
    bool setMode(ModeName p_mode_name);

    /**
     * @brief Set the Mode keeping actual receiver selected (string tag)
     * 
     * @param p_mode_name Requeste mode
     * @return true Mode correctly set
     */
    bool setMode(IRA::CString p_mode_name);

    /**
     * @brief Set Setup struct to requested configuration tag
     * 
     * @param p_conf_name Conf name
     * @param p_setup New Setup
     * @return True for valid operation
     */
    bool setConfigurationSetup(ConfigurationName p_conf_name,
                                const ConfigurationSetup & p_setup);

    /**
     * @brief Get the Available configuration by enum name
     * @return Available conf names
     */
    const std::vector<ConfigurationName> getAvailableConfs() const;

    /**
     * @brief Get the Actual configuration by its string tag
     * @details Side-effect, set default in case of conf mismatch 
     * @return Conf string tag
     */
    const IRA::CString getActualConfStr();

    /**
     * @brief Get the Available configuration by enum name
     * @return Available conf names
     */
    const std::map<ConfigurationName, IRA::CString> getAvailableConfsMap() const;

    /**
     * @brief Get the Configuration infos needed to find conf files
     * @details Beware of reference output
@@ -96,22 +186,68 @@ struct ReceiverConfHandler{
    bool getConfigurationSetup(ConfigurationName p_conf_name,
                                ConfigurationSetup & p_out_setup) const;


    private:

    /**
     * @brief Set Setup to requested conf
     * @brief Find if given conf enum tag is present
     * 
     * @param p_conf_name Conf name
     * @param p_setup New Setup
     * @return True for valid operation
     * @param p_conf_name Tag to find
     * @return true If Conf is valid
     */
    bool setConfSetup(ConfigurationName p_conf_name,
                                ConfigurationSetup  p_setup);
    bool findConfiguration(ConfigurationName p_conf_name) const ;

    /**
     * @brief Find if given conf string tag is present
     * 
     * @param p_conf_name Tag  to find
     * @return true If Conf is valid
     */
    bool findConfiguration(IRA::CString p_conf_name) const;

    /**
     * @brief 
     * 
     * @param p_conf_name String tag to find
     * @param[out] p_conf_enum Conf enum tag relative to p_conf_name
     * @return true Requested configuration is valid
     */
    bool findEnumFromString(IRA::CString p_conf_name,
                             ConfigurationName & p_con_enum) const;

    /**
     * @brief Find Receiver enum from string tag
     * 
     * @param p_receiver_name String tag receiver name
     * @param[out] p_receiver_enum Found receiver enum
     * @return true Receiver enum found
     */
    bool findReceiverFromString(IRA::CString p_receiver_name,
                             ReceiverName & p_receiver_enum) const;

    /**
     * @brief Find mode enum from string tag
     * 
     * @param p_mode_name String tag mode name
     * @param[out] p_mode_enum Found mode enum
     * @return true  Mode enum found
     */
    bool findModeFromString(IRA::CString p_mode_name,
                             ReceiverName & p_mode_enum) const;

    private:

    static ReceiverConfHandler* m_instance;  /**< Class instance for singleton impl */
    std::vector<ConfigurationName> m_allowed_conf; /**< Allowed configuration registered */
    std::map<ConfigurationName, IRA::CString> m_conf_name; /**< Map configuration name - mnemonic string */
    std::map<ConfigurationName, ConfigurationAccess> m_conf_access; /**< Map configuration name - conf file access infos */
    std::map<ConfigurationName, ConfigurationSetup> m_conf_data; /**< Map configuration name - conf setup */
    
    std::map<ReceiverName, IRA::CString> m_receiver_name; /**< Map receiver name - mnemonic string */
    std::map<ModeName, IRA::CString> m_mode_name; /**< Map mode name - mnemonic string */
    
    std::map<ConfigurationName, CurrentConfiguration> m_available_current;  /**< Map configuration name - current conf setup */
    CurrentConfiguration m_current_conf;    /**< Currente selected conf */
    
};

#endif
 No newline at end of file
+24 −18
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@ void CComponentCore::initialize(maci::ContainerServices* services)

CConfiguration const * const  CComponentCore::execute() throw (ComponentErrors::CDBAccessExImpl,ComponentErrors::MemoryAllocationExImpl,ComponentErrors::SocketErrorExImpl)
{
    /*
     * This Call sets default Recevier Configuration at CCC_Normal 
     * User has to call for Activate() and setupMode() to be more specific about receiver conf
     */
    m_configuration.init(m_services);  //throw (ComponentErrors::CDBAccessExImpl);
    try {
        m_control=new IRA::ReceiverControl(
@@ -58,18 +62,7 @@ CConfiguration const * const CComponentCore::execute() throw (ComponentErrors::
        _EXCPT(ComponentErrors::SocketErrorExImpl,dummy,"CComponentCore::execute()");
        throw dummy;
    }
    //members initialization
    /**@todo spostare in activate */
    m_startFreq.length(m_configuration.getIFs());
    m_bandwidth.length(m_configuration.getIFs());
    m_polarization.length(m_configuration.getIFs());
    for (WORD i=0;i<m_configuration.getIFs();i++) {
        m_startFreq[i]=m_configuration.getIFMin()[i];
        m_bandwidth[i]=m_configuration.getIFBandwidth()[i];
        m_polarization[i]=(long)m_configuration.getPolarizations()[i];
        m_localOscillatorValue=m_configuration.getDefaultLO()[i];
    }
    m_setupMode="";
    m_setupMode= m_configuration.m_con_hnd.getActualConfStr();
    return &m_configuration;
}

@@ -83,21 +76,33 @@ void CComponentCore::cleanup()
    }
}


void CComponentCore::activate(const char *mode) throw (ReceiversErrors::ModeErrorExImpl,ComponentErrors::ValidationErrorExImpl,ComponentErrors::ValueOutofRangeExImpl,
        ComponentErrors::CouldntGetComponentExImpl,ComponentErrors::CORBAProblemExImpl,ReceiversErrors::LocalOscillatorErrorExImpl,ReceiversErrors::NoRemoteControlErrorExImpl,
        ReceiversErrors::ReceiverControlBoardErrorExImpl)
{
    /**@todo check mode string from configuration and setup mode*/


    /* activate mode */
    baci::ThreadSyncGuard guard(&m_mutex);
    setMode((const char *)m_configuration.getSetupMode()); // Throw ......
    bool l_res= m_configuration.m_conf_hnd.setMode(mode);
    if (! l_res){
        _EXCPT(ReceiversErrors::ModeErrorExImpl,impl,"CComponentErrors::setMode()");
        throw impl;
    }    
    guard.release();
    //members initialization        
    m_startFreq.length(m_configuration.getIFs());
    m_bandwidth.length(m_configuration.getIFs());
    m_polarization.length(m_configuration.getIFs());
    for (WORD i=0;i<m_configuration.getIFs();i++) {
        m_startFreq[i]=m_configuration.getIFMin()[i];
        m_bandwidth[i]=m_configuration.getIFBandwidth()[i];
        m_polarization[i]=(long)m_configuration.getPolarizations()[i];
        /** @todo comporre un oggetto LO con un unica interfaccia come clsse a parte ? */
        m_localOscillatorValue=m_configuration.getDefaultLO()[i];
    }
    // Basic operations
    lnaOn(); // throw (ReceiversErrors::NoRemoteControlErrorExImpl,ReceiversErrors::ReceiverControlBoardErrorExImpl)
    externalCalOff();

    // Remote control check
    bool answer;
    try {
        answer=m_control->isRemoteOn();
@@ -133,6 +138,7 @@ void CComponentCore::setMode(const char * mode) throw (ReceiversErrors::ModeErro
    IRA::CString cmdMode(mode);
    cmdMode.MakeUpper();
    /**@todo CHC - CCC modes allowed? */
    
    /**@todo NarrowBandiwth vs NormalSetupMode ? */
    if (cmdMode!=m_configuration.getSetupMode()) { 
        _EXCPT(ReceiversErrors::ModeErrorExImpl,impl,"CComponentErrors::setMode()");
+9 −9
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ void CConfiguration::init(maci::ContainerServices *Services)
	 *   * CCC Normal
	 *   * CHC NarrowBw.
	 *   * CCC NarrowBw.
	 * 
	 */	
	/* read component configuration */	
	_GET_STRING_ATTRIBUTE("DewarIPAddress","Dewar IP address:",m_dewarIPAddress,"");
@@ -95,14 +94,11 @@ void CConfiguration::init(maci::ContainerServices *Services)
	_GET_DWORD_ATTRIBUTE("LNASamplingTime","Time needed to collect LNA information from control boards (uSec):",m_LNASamplingTime,"");
	_GET_DWORD_ATTRIBUTE("RepetitionCacheTime","Log repetition filter, caching time (uSec):",m_repetitionCacheTime,"");
	_GET_DWORD_ATTRIBUTE("RepetitionExpireTime","Log repetition filter, expire time (uSec):",m_repetitionExpireTime,"");		
	/* now read the setup related configurations <name - con file path> , filling associated parameters struct */	
	/* now read the setup for every available conf <name - con file path> , filling associated parameters struct */	
	const std::vector<ConfigurationName> l_available_confs= m_conf_hnd.getAvailableConfs();
	std::vector<ConfigurationName>::const_iterator l_conf_it;
	for (l_conf_it= m_conf_file.begin(); l_conf_ != m_conf_file.end(); l_conf_++ ){		
		/* Getting configuration file ptah
		 * Reading configuration setup
		 * Filling related setup struct		
		 */
	for (l_conf_it= m_conf_file.begin(); l_conf_it != m_conf_file.end(); l_conf_it++ ){		
		/* Getting configuration file path */
		ReceiverConfHandler::ConfigurationSetup l_setup;
		ReceiverConfHandler::ConfigurationAccess l_access;		
		IRA::CError l_error;		
@@ -112,6 +108,8 @@ void CConfiguration::init(maci::ContainerServices *Services)
			dummy.setFieldName("Configuration");
			throw dummy;
		}
		/* Reading Setup main infos */
		l_setup.m_name= m_conf_hnd.m_conf_name[*l_conf_it];
		readConfigurationSetup(l_access.m_conf_file_path, l_setup );		
		/* noise mark read */		
		readNoiseMarkPoly(l_access.m_noisemark_file_path, l_setup);
@@ -122,7 +120,10 @@ void CConfiguration::init(maci::ContainerServices *Services)
			dummy.setFieldName("Configuration");
			throw dummy;
		}
		 ACS_LOG(LM_FULL_INFO,"CConfiguration::init()",(LM_NOTICE, "CONFIGURATION PROCESSED %s", l_setup.m_name));
	}		
	/* Applying default conf */
	m_conf_hnd.setConfiguration(ReceiverConfHandler::CCC_Normal);
	/* Feeds */
	readFeeds();
	/* Taper */
@@ -167,7 +168,6 @@ DWORD CConfiguration::getTaperTable(double * &freq,double *&taper) const
	return m_taperVectorLen;
}


DWORD CConfiguration::getFeedInfo(WORD *& code,double *& xOffset,double *& yOffset,double *& relativePower) const
{
	code=new WORD[m_feeds];
Loading