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

Fix #627, added a check for the commanded profile to the USD component (#630)

The component now accepts only known and available profiles
parent 6e0f9cc8
Loading
Loading
Loading
Loading
+57 −52
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ module ASErrors
	 const ACSErr::ErrorCode USDStillRunning = 21;
	 const ACSErr::ErrorCode USDunCalibrated = 22;
	 const ACSErr::ErrorCode CannotGetUSD = 23;
	 const ACSErr::ErrorCode UnknownProfile = 24;

	// excption for type:
	exception ASErrorsEx {
@@ -158,6 +159,10 @@ module ASErrors
		ACSErr::ErrorTrace errorTrace;
	};

	exception UnknownProfileEx {
		ACSErr::ErrorTrace errorTrace;
	};


}; // module ASErrors

+1 −0
Original line number Diff line number Diff line
@@ -47,4 +47,5 @@
 <ErrorCode name="USDStillRunning" shortDescription=" " description="USD still running while shouldn't be!.Error"/>
 <ErrorCode name="USDunCalibrated" shortDescription=" " description="USD not calibrated.Warning"/>
 <ErrorCode name="CannotGetUSD" shortDescription=" " description="USD not activated.Warning"/>
 <ErrorCode name="UnknownProfile" shortDescription=" " description="Set profile is unknown for this station.Error"/>
 </Type>
+21 −4
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@

//error
#include <ASErrors.h>
#include <ManagementErrors.h>

//others
#include <time.h>
@@ -479,9 +480,16 @@ public:
	* @param prof	0 shaped, 1 shaped fixed, 2 parabolic, 3 parabolic fixed
	*/
	virtual void setProfile(CORBA::Long prof) throw (CORBA::SystemException, ASErrors::ASErrorsEx)
	{
		if(m_accepted_profiles.count(prof))
		{
			m_profile = prof;
		}
		else
		{
			_THROW_EX(UnknownProfile,"::usdImpl::setProfile()", prof);
		}
	}
	 
	/**
	* correction().The last minute coorection to be applied.
@@ -585,7 +593,16 @@ public:
	BYTE m_ploop;

private:
	/**
	 * current profile;
	 */
	CORBA::Long m_profile;

	/**
	 * accepted profiles
	 */
	std::set<CORBA::Long> m_accepted_profiles;

	/**
	* pointer to LAN/485 component
	*/
+7 −1
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ void USDImpl::initialize() throw (ACSErr::ACSbaseExImpl)
{
    cs = getContainerServices();

    IRA::CString accepted_profiles;
    if(CIRATools::getDBValue(cs,"sector",(long&)m_sector) &&
        CIRATools::getDBValue(cs,"lan",(long&)m_lanNum) &&
        CIRATools::getDBValue(cs,"serialAddress",(long&)m_addr) &&
@@ -58,7 +59,8 @@ void USDImpl::initialize() throw (ACSErr::ACSbaseExImpl)
        CIRATools::getDBValue(cs,"cammaPos",(double&)m_cammaPos) &&
        CIRATools::getDBValue(cs,"step_giro",(long&)m_step_giro) &&
        CIRATools::getDBValue(cs,"step_res",(long&) m_rs) &&
        CIRATools::getDBValue(cs,"calibrate",(long&)m_calibrate))
        CIRATools::getDBValue(cs,"calibrate",(long&)m_calibrate) &&
        CIRATools::getDBValue(cs,"accepted_profiles",accepted_profiles))
    {
        ACS_SHORT_LOG((LM_INFO,"USD%d: CDB parameter read",m_addr));

@@ -67,6 +69,10 @@ void USDImpl::initialize() throw (ACSErr::ACSbaseExImpl)
        m_top = -m_zeroRef;
        m_bottom = m_fullRange-m_zeroRef;
        m_lastCmdStep = m_top + 1; // a value outside of full range will never be commanded, so the next commanded position will for sure be different
        std::stringstream ss((const char *)accepted_profiles);
        int buffer;
        while(ss >> buffer)
            m_accepted_profiles.insert(buffer);
    }
    else
    {
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@
     <xs:attribute name="zeroRef" 	type="xs:int"		use="optional" default="-21000"/>
     <xs:attribute name="step_giro" 	type="xs:int"		use="optional" default="200"/>
     <xs:attribute name="step_res" 	type="xs:unsignedByte" 	use="optional" default="1"/>
     <xs:attribute name="accepted_profiles"  type="xs:string"    use="optional" default="0 1 2 3 4"/>
    </xs:extension>
   </xs:complexContent>
  </xs:complexType>