Loading Common/Servers/Roach/config/CDB/schemas/TotalPower.xsd→Common/Servers/Roach/config/CDB/schemas/Roach.xsd +5 −5 Original line number Diff line number Diff line <?xml version="1.0" encoding="ISO-8859-1"?> <!-- - $Id: TotalPower.xsd,v 1.3 2011-05-12 14:14:31 a.orlati Exp $ - $Id: Roach.xsd,v 1.3 2011-05-12 14:14:31 a.orlati Exp $ - Author: Andrea Orlati - - History: Loading @@ -8,8 +8,8 @@ --> <xs:schema targetNamespace="urn:schemas-cosylab-com:TotalPower:1.0" xmlns="urn:schemas-cosylab-com:TotalPower:1.0" targetNamespace="urn:schemas-cosylab-com:Roach:1.0" xmlns="urn:schemas-cosylab-com:Roach:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" Loading Loading @@ -69,7 +69,7 @@ </xs:complexContent> </xs:complexType> <xs:complexType name="TotalPowerType"> <xs:complexType name="RoachType"> <xs:complexContent> <xs:extension base="bcknd:GenericBackendType"> <xs:sequence> Loading Loading @@ -129,6 +129,6 @@ </xs:complexContent> </xs:complexType> <xs:element name="TotalPower" type="TotalPowerType"/> <xs:element name="Roach" type="RoachType"/> </xs:schema> Common/Servers/Roach/config/CDB/schemas/TotalPowerSetup.xsd→Common/Servers/Roach/config/CDB/schemas/RoachSetup.xsd +5 −5 Original line number Diff line number Diff line <?xml version="1.0" encoding="ISO-8859-1"?> <!-- - $Id: TotalPowerSetup.xsd,v 1.1 2011-03-14 14:15:07 a.orlati Exp $ - $Id: RoachSetup.xsd,v 1.1 2011-03-14 14:15:07 a.orlati Exp $ - Author: Andrea Orlati - - History: Loading @@ -8,8 +8,8 @@ --> <xs:schema targetNamespace="urn:schemas-cosylab-com:TotalPowerSetup:1.0" xmlns="urn:schemas-cosylab-com:TotalPowerSetup:1.0" targetNamespace="urn:schemas-cosylab-com:RoachSetup:1.0" xmlns="urn:schemas-cosylab-com:RoachSetup:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" Loading Loading @@ -124,13 +124,13 @@ </xs:sequence> </xs:complexType> <xs:complexType name="TTotalPowerSetup"> <xs:complexType name="TRoachSetup"> <xs:sequence> <xs:element name="Configuration" type="TTableHeader" minOccurs="1" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> <xs:element name="TotalPowerSetup" type="TTotalPowerSetup"/> <xs:element name="RoachSetup" type="TRoachSetup"/> </xs:schema> Common/Servers/Roach/include/CommandLine.h +8 −3 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ public: /** * Call this function in order to get the component status back */ void getBackendStatus(DWORD& status) const; void getBackendStatus(DWORD& status); /** * Call this function in order to get the feed connected to each section. Loading Loading @@ -439,6 +439,11 @@ public: * @return true if the resulting integration has to be rounded to match the two input parameters */ static bool resultingSampleRate(const long& integration,const double& sr,long& result); int getConfiguration(char* configuration); int getCommProtVersion(char* version); protected: /** * Automatically called by the framework as a result of a connection request. See super-class for more details. Loading Loading @@ -630,7 +635,7 @@ private: * @throw BackendsErrors::ConnectionExImp * @throw BackendsErrors::NakExImpl */ void setDefaultConfiguration() throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, void setDefaultConfiguration(const IRA::CString & config) throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, ComponentErrors::SocketErrorExImpl,BackendsErrors::NakExImpl); /** Loading Loading @@ -692,7 +697,7 @@ private: * @return a number greater than zero if the operation is succesfully, else FAIL in case of error, WOULDBLOCK if the timeout expires, * 0 if the remoteside disconnected or -100 is the answer of the backend is malformed */ int getConfiguration(); //int getConfiguration(char* configuration); /** * This function will set the status bit corresponding to the given field Loading Common/Servers/Roach/include/RoachImpl.h +4 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,10 @@ public: */ virtual CORBA::Boolean command(const char *cmd,CORBA::String_out answer) throw (CORBA::SystemException); virtual void getConfiguration (CORBA::String_out configuration) throw (CORBA::SystemException); virtual void getCommProtVersion (CORBA::String_out version) throw (CORBA::SystemException); /** * Call this function to set the current time (from the local computer) into the backend. * @thorw CORBA::SystemException Loading Common/Servers/Roach/src/CommandLine.cpp +125 −101 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ void CCommandLine::Init(CConfiguration *config) throw (ComponentErrors::SocketEr IRA::CIRATools::Wait(0,200000); try { //stopDataAcquisitionForced(); // this will force the backend to a normal status in case the connection came from an abnormal close setDefaultConfiguration(); //could throw exceptions........ //setDefaultConfiguration(conf); //could throw exceptions........ } catch (ACSErr::ACSbaseExImpl& ex) { // these are not real error so we do not want to give up Loading Loading @@ -564,7 +564,7 @@ void CCommandLine::getZeroTPI(DWORD *tpi) throw (ComponentErrors::TimeoutExImpl, _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getZeroTPI()"); } integration=(long)round(1.0/ (m_commonSampleRate*1000.0)); res=getConfiguration(); // refresh the m_currentSampleRate.......... //res=getConfiguration(); // refresh the m_currentSampleRate.......... if (res>0) { // load OK // do nothing } Loading Loading @@ -713,7 +713,7 @@ void CCommandLine::getSample(ACS::doubleSeq& tpi,bool zero) throw (ComponentErro if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getSample()"); } res=getConfiguration(); // refresh the m_currentSampleRate.......... //res=getConfiguration(); // refresh the m_currentSampleRate.......... if (res>0) { // load OK // do nothing } Loading Loading @@ -829,7 +829,7 @@ void CCommandLine::getSample(ACS::doubleSeq& tpi,bool zero) throw (ComponentErro } } void CCommandLine::setDefaultConfiguration() throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, void CCommandLine::setDefaultConfiguration(const IRA::CString & config) throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, ComponentErrors::SocketErrorExImpl,BackendsErrors::NakExImpl) { AUTO_TRACE("CCommandLine::setDefaultConfiguration()"); Loading @@ -841,74 +841,18 @@ void CCommandLine::setDefaultConfiguration() throw (ComponentErrors::TimeoutExIm if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setDefaultConfiguration()"); } if (m_defaultInputSize==1) { len=CProtocol::setConfiguration_broadcast(sBuff,m_defaultInput[0],m_attenuation[0],m_bandWidth[0]); // 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::setDefaultConfiguration()"); } } 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::setDefaultConfiguration()"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::setDefaultConfiguration()"); } else { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setDefaultConfiguration()"); } } else { for (DWORD k=0;k<m_defaultInputSize;k++) { if (m_sections[k]==-1) { //*************************************************************************** // This should be changed in order to read the Attenuation on board basis and to apply proper db for each board //**************************************************************************** len=CProtocol::setConfiguration(sBuff,(long)k,m_defaultInput[k],13.0,2350.0); } else { len=CProtocol::setConfiguration(sBuff,(long)k,m_defaultInput[k],m_attenuation[m_sections[k]],m_bandWidth[m_sections[k]]); } 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::setDefaultConfiguration()"); } } 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::setDefaultConfiguration()"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::setDefaultConfiguration()"); } else { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setDefaultConfiguration()"); } } } IRA::CIRATools::Wait(0,200000); long integration=(long)round(1.0/ (m_commonSampleRate*1000.0)); len=CProtocol::setIntegrationTime(sBuff,integration); // get the buffer strcpy (sBuff,"?set-configuration,"); strcat (sBuff,(const char*)config); strcat (sBuff,"\r\n"); len = strlen (sBuff); 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::setDefaultConfiguration()"); } //if (!CProtocol::isAck(rBuff)) { // _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setDefaultConfiguration()"); //} } else if (res==FAIL) { _EXCPT_FROM_ERROR(ComponentErrors::IRALibraryResourceExImpl,dummy,m_Error); Loading @@ -924,8 +868,6 @@ void CCommandLine::setDefaultConfiguration() throw (ComponentErrors::TimeoutExIm _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setDefaultConfiguration()"); } ACS_LOG(LM_FULL_INFO,"CCommandLine::setDefaultConfiguration()",(LM_INFO,"DEFAULTS_ARE_SET")); m_setTpiIntegration=false; } void CCommandLine::setup(const char *conf) throw (BackendsErrors::BackendBusyExImpl,BackendsErrors::ConfigurationErrorExImpl,ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, Loading @@ -940,8 +882,8 @@ void CCommandLine::setup(const char *conf) throw (BackendsErrors::BackendBusyExI _EXCPT(BackendsErrors::ConfigurationErrorExImpl,impl,"CCommandLine::setup()"); throw impl; } setDefaultConfiguration(); //could throw exceptions........ ACS_LOG(LM_FULL_INFO,"CCommandLine::setup()",(LM_NOTICE,"BACKEND_INITIALIZED: %s",conf)); setDefaultConfiguration(conf); //could throw exceptions........ ACS_LOG(LM_FULL_INFO,"CCommandLine::setup()",(LM_NOTICE,"BACKEND_ROACH2_INITIALIZED, CONFIGURATION: %s",conf)); } void CCommandLine::checkTime() throw (BackendsErrors::ConnectionExImpl,BackendsErrors::MalformedAnswerExImpl,ComponentErrors::SocketErrorExImpl,ComponentErrors::TimeoutExImpl) Loading Loading @@ -1105,7 +1047,7 @@ void CCommandLine::getAttenuation(ACS::doubleSeq& att) throw (ComponentErrors::S if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getAttenuation()"); } res=getConfiguration(); //res=getConfiguration(); if (res>0) { // load OK att.length(m_sectionsNumber); for (int i=0;i<m_sectionsNumber;i++) { Loading @@ -1123,8 +1065,42 @@ void CCommandLine::getFrequency(ACS::doubleSeq& freq) const } } void CCommandLine::getBackendStatus(DWORD& status) const void CCommandLine::getBackendStatus(DWORD& status) { AUTO_TRACE("CCommandLine::getBackendStatus()"); int res; WORD len; char sBuff[SENDBUFFERSIZE]; char rBuff[RECBUFFERSIZE]; // I do not check for backend busy because this is a call done at the initialization and never repeated if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getBackendStatus()"); } strcpy (sBuff,"?status\r\n"); len = strlen (sBuff); if ((res=sendBuffer(sBuff,len))==SUCCESS) { res=receiveBuffer(rBuff,RECBUFFERSIZE); } if (res>0) { // operation was ok. //if (!CProtocol::status(rBuff)) { // _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setDefaultConfiguration()"); //} } 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::getBackendStatus()"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::getBackendStatus()"); } else { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getBackendStatus()"); } ACS_LOG(LM_FULL_INFO,"CCommandLine::getBackendStatus()",(LM_INFO,"GETTING BACKEND STATUS")); status=m_backendStatus; } Loading Loading @@ -1200,7 +1176,7 @@ void CCommandLine::getBandWidth(ACS::doubleSeq& bw) throw (ComponentErrors::Sock if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getBandWidth()"); } res=getConfiguration(); //res=getConfiguration(); if (res>0) { // load OK bw.length(m_sectionsNumber); for (int i=0;i<m_sectionsNumber;i++) { Loading @@ -1218,7 +1194,7 @@ void CCommandLine::getTime(ACS::Time& tt) throw (ComponentErrors::SocketErrorExI if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getTime()"); } res=getConfiguration(); //res=getConfiguration(); if (res>0) { // load OK tt=m_backendTime.value().value; } Loading Loading @@ -1423,37 +1399,85 @@ int CCommandLine::sendCommand(char *inBuff,const WORD& inLen,char *outBuff) } } int CCommandLine::getConfiguration() int CCommandLine::getConfiguration(char* configuration) { TIMEVALUE Now; char sBuff[SENDBUFFERSIZE]; char rBuff[RECBUFFERSIZE]; WORD len; int rBytes; OperationResult Res; CIRATools::getTime(Now); if (CIRATools::timeDifference(m_lastUpdate,Now)>m_configuration->getPropertyRefreshTime()) { //check if we have to go to the backend! // prepare the buffer........ len=CProtocol::askBackendConfiguration(sBuff); //send and wait for the answer........... if ((Res=sendBuffer(sBuff,len))==SUCCESS) { rBytes=receiveBuffer(rBuff,RECBUFFERSIZE); if (rBytes>0) { if (CProtocol::decodeBackendConfiguration(rBuff,m_sectionsNumber,m_configuration->getBoardsNumber(),m_attenuation,m_bandWidth,m_input,m_backendTime,m_currentSampleRate,m_boards)) { CIRATools::getTime(m_lastUpdate); int res; if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getConfiguration()"); } strcpy (sBuff,"?configuration\r\n"); len = strlen (sBuff); if ((res=sendBuffer(sBuff,len))==SUCCESS) { res=receiveBuffer(rBuff,RECBUFFERSIZE); strcpy (configuration,rBuff); } if (res>0) { // operation was ok. //if (!CProtocol::status(rBuff)) { // _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setDefaultConfiguration()"); //} } 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::getConfigurationu)"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::getConfiguration()"); } else { return DECODE_ERROR; _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getConfiguration()"); } ACS_LOG(LM_FULL_INFO,"CCommandLine::getConfiguration()",(LM_INFO,"GETTING BACKEND CONFIGURATION")); return SENDBUFFERSIZE; } // this could be 0 (communication fell down), FAIL error (m_Error set accordingly) , WOULDBLOCK timeout, >0 ok return rBytes; int CCommandLine::getCommProtVersion(char* version) { TIMEVALUE Now; char sBuff[SENDBUFFERSIZE]; char rBuff[RECBUFFERSIZE]; WORD len; int res; if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getCommProtVersion()"); } else { // send fails....m_Error already set by sendBuffer return Res; strcpy (sBuff,"?version\r\n"); len = strlen (sBuff); if ((res=sendBuffer(sBuff,len))==SUCCESS) { res=receiveBuffer(rBuff,RECBUFFERSIZE); strcpy (version,rBuff); } if (res>0) { // operation was ok. //if (!CProtocol::status(rBuff)) { // _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setDefaultConfiguration()"); //} } // the last value is still valid..nothing to do so return a value that is grater than zero 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::getCommProtVersion()"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::getCommProtVersion()"); } else { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getCommProtVersion()"); } ACS_LOG(LM_FULL_INFO,"CCommandLine::getCommProtVersion()",(LM_INFO,"GETTING COMMUNICATION PROTOCOL VERSION")); return SENDBUFFERSIZE; } Loading Loading
Common/Servers/Roach/config/CDB/schemas/TotalPower.xsd→Common/Servers/Roach/config/CDB/schemas/Roach.xsd +5 −5 Original line number Diff line number Diff line <?xml version="1.0" encoding="ISO-8859-1"?> <!-- - $Id: TotalPower.xsd,v 1.3 2011-05-12 14:14:31 a.orlati Exp $ - $Id: Roach.xsd,v 1.3 2011-05-12 14:14:31 a.orlati Exp $ - Author: Andrea Orlati - - History: Loading @@ -8,8 +8,8 @@ --> <xs:schema targetNamespace="urn:schemas-cosylab-com:TotalPower:1.0" xmlns="urn:schemas-cosylab-com:TotalPower:1.0" targetNamespace="urn:schemas-cosylab-com:Roach:1.0" xmlns="urn:schemas-cosylab-com:Roach:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" Loading Loading @@ -69,7 +69,7 @@ </xs:complexContent> </xs:complexType> <xs:complexType name="TotalPowerType"> <xs:complexType name="RoachType"> <xs:complexContent> <xs:extension base="bcknd:GenericBackendType"> <xs:sequence> Loading Loading @@ -129,6 +129,6 @@ </xs:complexContent> </xs:complexType> <xs:element name="TotalPower" type="TotalPowerType"/> <xs:element name="Roach" type="RoachType"/> </xs:schema>
Common/Servers/Roach/config/CDB/schemas/TotalPowerSetup.xsd→Common/Servers/Roach/config/CDB/schemas/RoachSetup.xsd +5 −5 Original line number Diff line number Diff line <?xml version="1.0" encoding="ISO-8859-1"?> <!-- - $Id: TotalPowerSetup.xsd,v 1.1 2011-03-14 14:15:07 a.orlati Exp $ - $Id: RoachSetup.xsd,v 1.1 2011-03-14 14:15:07 a.orlati Exp $ - Author: Andrea Orlati - - History: Loading @@ -8,8 +8,8 @@ --> <xs:schema targetNamespace="urn:schemas-cosylab-com:TotalPowerSetup:1.0" xmlns="urn:schemas-cosylab-com:TotalPowerSetup:1.0" targetNamespace="urn:schemas-cosylab-com:RoachSetup:1.0" xmlns="urn:schemas-cosylab-com:RoachSetup:1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" Loading Loading @@ -124,13 +124,13 @@ </xs:sequence> </xs:complexType> <xs:complexType name="TTotalPowerSetup"> <xs:complexType name="TRoachSetup"> <xs:sequence> <xs:element name="Configuration" type="TTableHeader" minOccurs="1" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> <xs:element name="TotalPowerSetup" type="TTotalPowerSetup"/> <xs:element name="RoachSetup" type="TRoachSetup"/> </xs:schema>
Common/Servers/Roach/include/CommandLine.h +8 −3 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ public: /** * Call this function in order to get the component status back */ void getBackendStatus(DWORD& status) const; void getBackendStatus(DWORD& status); /** * Call this function in order to get the feed connected to each section. Loading Loading @@ -439,6 +439,11 @@ public: * @return true if the resulting integration has to be rounded to match the two input parameters */ static bool resultingSampleRate(const long& integration,const double& sr,long& result); int getConfiguration(char* configuration); int getCommProtVersion(char* version); protected: /** * Automatically called by the framework as a result of a connection request. See super-class for more details. Loading Loading @@ -630,7 +635,7 @@ private: * @throw BackendsErrors::ConnectionExImp * @throw BackendsErrors::NakExImpl */ void setDefaultConfiguration() throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, void setDefaultConfiguration(const IRA::CString & config) throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, ComponentErrors::SocketErrorExImpl,BackendsErrors::NakExImpl); /** Loading Loading @@ -692,7 +697,7 @@ private: * @return a number greater than zero if the operation is succesfully, else FAIL in case of error, WOULDBLOCK if the timeout expires, * 0 if the remoteside disconnected or -100 is the answer of the backend is malformed */ int getConfiguration(); //int getConfiguration(char* configuration); /** * This function will set the status bit corresponding to the given field Loading
Common/Servers/Roach/include/RoachImpl.h +4 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,10 @@ public: */ virtual CORBA::Boolean command(const char *cmd,CORBA::String_out answer) throw (CORBA::SystemException); virtual void getConfiguration (CORBA::String_out configuration) throw (CORBA::SystemException); virtual void getCommProtVersion (CORBA::String_out version) throw (CORBA::SystemException); /** * Call this function to set the current time (from the local computer) into the backend. * @thorw CORBA::SystemException Loading
Common/Servers/Roach/src/CommandLine.cpp +125 −101 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ void CCommandLine::Init(CConfiguration *config) throw (ComponentErrors::SocketEr IRA::CIRATools::Wait(0,200000); try { //stopDataAcquisitionForced(); // this will force the backend to a normal status in case the connection came from an abnormal close setDefaultConfiguration(); //could throw exceptions........ //setDefaultConfiguration(conf); //could throw exceptions........ } catch (ACSErr::ACSbaseExImpl& ex) { // these are not real error so we do not want to give up Loading Loading @@ -564,7 +564,7 @@ void CCommandLine::getZeroTPI(DWORD *tpi) throw (ComponentErrors::TimeoutExImpl, _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getZeroTPI()"); } integration=(long)round(1.0/ (m_commonSampleRate*1000.0)); res=getConfiguration(); // refresh the m_currentSampleRate.......... //res=getConfiguration(); // refresh the m_currentSampleRate.......... if (res>0) { // load OK // do nothing } Loading Loading @@ -713,7 +713,7 @@ void CCommandLine::getSample(ACS::doubleSeq& tpi,bool zero) throw (ComponentErro if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getSample()"); } res=getConfiguration(); // refresh the m_currentSampleRate.......... //res=getConfiguration(); // refresh the m_currentSampleRate.......... if (res>0) { // load OK // do nothing } Loading Loading @@ -829,7 +829,7 @@ void CCommandLine::getSample(ACS::doubleSeq& tpi,bool zero) throw (ComponentErro } } void CCommandLine::setDefaultConfiguration() throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, void CCommandLine::setDefaultConfiguration(const IRA::CString & config) throw (ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, ComponentErrors::SocketErrorExImpl,BackendsErrors::NakExImpl) { AUTO_TRACE("CCommandLine::setDefaultConfiguration()"); Loading @@ -841,74 +841,18 @@ void CCommandLine::setDefaultConfiguration() throw (ComponentErrors::TimeoutExIm if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setDefaultConfiguration()"); } if (m_defaultInputSize==1) { len=CProtocol::setConfiguration_broadcast(sBuff,m_defaultInput[0],m_attenuation[0],m_bandWidth[0]); // 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::setDefaultConfiguration()"); } } 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::setDefaultConfiguration()"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::setDefaultConfiguration()"); } else { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setDefaultConfiguration()"); } } else { for (DWORD k=0;k<m_defaultInputSize;k++) { if (m_sections[k]==-1) { //*************************************************************************** // This should be changed in order to read the Attenuation on board basis and to apply proper db for each board //**************************************************************************** len=CProtocol::setConfiguration(sBuff,(long)k,m_defaultInput[k],13.0,2350.0); } else { len=CProtocol::setConfiguration(sBuff,(long)k,m_defaultInput[k],m_attenuation[m_sections[k]],m_bandWidth[m_sections[k]]); } 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::setDefaultConfiguration()"); } } 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::setDefaultConfiguration()"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::setDefaultConfiguration()"); } else { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setDefaultConfiguration()"); } } } IRA::CIRATools::Wait(0,200000); long integration=(long)round(1.0/ (m_commonSampleRate*1000.0)); len=CProtocol::setIntegrationTime(sBuff,integration); // get the buffer strcpy (sBuff,"?set-configuration,"); strcat (sBuff,(const char*)config); strcat (sBuff,"\r\n"); len = strlen (sBuff); 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::setDefaultConfiguration()"); } //if (!CProtocol::isAck(rBuff)) { // _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setDefaultConfiguration()"); //} } else if (res==FAIL) { _EXCPT_FROM_ERROR(ComponentErrors::IRALibraryResourceExImpl,dummy,m_Error); Loading @@ -924,8 +868,6 @@ void CCommandLine::setDefaultConfiguration() throw (ComponentErrors::TimeoutExIm _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::setDefaultConfiguration()"); } ACS_LOG(LM_FULL_INFO,"CCommandLine::setDefaultConfiguration()",(LM_INFO,"DEFAULTS_ARE_SET")); m_setTpiIntegration=false; } void CCommandLine::setup(const char *conf) throw (BackendsErrors::BackendBusyExImpl,BackendsErrors::ConfigurationErrorExImpl,ComponentErrors::TimeoutExImpl,BackendsErrors::ConnectionExImpl, Loading @@ -940,8 +882,8 @@ void CCommandLine::setup(const char *conf) throw (BackendsErrors::BackendBusyExI _EXCPT(BackendsErrors::ConfigurationErrorExImpl,impl,"CCommandLine::setup()"); throw impl; } setDefaultConfiguration(); //could throw exceptions........ ACS_LOG(LM_FULL_INFO,"CCommandLine::setup()",(LM_NOTICE,"BACKEND_INITIALIZED: %s",conf)); setDefaultConfiguration(conf); //could throw exceptions........ ACS_LOG(LM_FULL_INFO,"CCommandLine::setup()",(LM_NOTICE,"BACKEND_ROACH2_INITIALIZED, CONFIGURATION: %s",conf)); } void CCommandLine::checkTime() throw (BackendsErrors::ConnectionExImpl,BackendsErrors::MalformedAnswerExImpl,ComponentErrors::SocketErrorExImpl,ComponentErrors::TimeoutExImpl) Loading Loading @@ -1105,7 +1047,7 @@ void CCommandLine::getAttenuation(ACS::doubleSeq& att) throw (ComponentErrors::S if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getAttenuation()"); } res=getConfiguration(); //res=getConfiguration(); if (res>0) { // load OK att.length(m_sectionsNumber); for (int i=0;i<m_sectionsNumber;i++) { Loading @@ -1123,8 +1065,42 @@ void CCommandLine::getFrequency(ACS::doubleSeq& freq) const } } void CCommandLine::getBackendStatus(DWORD& status) const void CCommandLine::getBackendStatus(DWORD& status) { AUTO_TRACE("CCommandLine::getBackendStatus()"); int res; WORD len; char sBuff[SENDBUFFERSIZE]; char rBuff[RECBUFFERSIZE]; // I do not check for backend busy because this is a call done at the initialization and never repeated if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getBackendStatus()"); } strcpy (sBuff,"?status\r\n"); len = strlen (sBuff); if ((res=sendBuffer(sBuff,len))==SUCCESS) { res=receiveBuffer(rBuff,RECBUFFERSIZE); } if (res>0) { // operation was ok. //if (!CProtocol::status(rBuff)) { // _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setDefaultConfiguration()"); //} } 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::getBackendStatus()"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::getBackendStatus()"); } else { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getBackendStatus()"); } ACS_LOG(LM_FULL_INFO,"CCommandLine::getBackendStatus()",(LM_INFO,"GETTING BACKEND STATUS")); status=m_backendStatus; } Loading Loading @@ -1200,7 +1176,7 @@ void CCommandLine::getBandWidth(ACS::doubleSeq& bw) throw (ComponentErrors::Sock if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getBandWidth()"); } res=getConfiguration(); //res=getConfiguration(); if (res>0) { // load OK bw.length(m_sectionsNumber); for (int i=0;i<m_sectionsNumber;i++) { Loading @@ -1218,7 +1194,7 @@ void CCommandLine::getTime(ACS::Time& tt) throw (ComponentErrors::SocketErrorExI if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getTime()"); } res=getConfiguration(); //res=getConfiguration(); if (res>0) { // load OK tt=m_backendTime.value().value; } Loading Loading @@ -1423,37 +1399,85 @@ int CCommandLine::sendCommand(char *inBuff,const WORD& inLen,char *outBuff) } } int CCommandLine::getConfiguration() int CCommandLine::getConfiguration(char* configuration) { TIMEVALUE Now; char sBuff[SENDBUFFERSIZE]; char rBuff[RECBUFFERSIZE]; WORD len; int rBytes; OperationResult Res; CIRATools::getTime(Now); if (CIRATools::timeDifference(m_lastUpdate,Now)>m_configuration->getPropertyRefreshTime()) { //check if we have to go to the backend! // prepare the buffer........ len=CProtocol::askBackendConfiguration(sBuff); //send and wait for the answer........... if ((Res=sendBuffer(sBuff,len))==SUCCESS) { rBytes=receiveBuffer(rBuff,RECBUFFERSIZE); if (rBytes>0) { if (CProtocol::decodeBackendConfiguration(rBuff,m_sectionsNumber,m_configuration->getBoardsNumber(),m_attenuation,m_bandWidth,m_input,m_backendTime,m_currentSampleRate,m_boards)) { CIRATools::getTime(m_lastUpdate); int res; if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getConfiguration()"); } strcpy (sBuff,"?configuration\r\n"); len = strlen (sBuff); if ((res=sendBuffer(sBuff,len))==SUCCESS) { res=receiveBuffer(rBuff,RECBUFFERSIZE); strcpy (configuration,rBuff); } if (res>0) { // operation was ok. //if (!CProtocol::status(rBuff)) { // _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setDefaultConfiguration()"); //} } 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::getConfigurationu)"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::getConfiguration()"); } else { return DECODE_ERROR; _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getConfiguration()"); } ACS_LOG(LM_FULL_INFO,"CCommandLine::getConfiguration()",(LM_INFO,"GETTING BACKEND CONFIGURATION")); return SENDBUFFERSIZE; } // this could be 0 (communication fell down), FAIL error (m_Error set accordingly) , WOULDBLOCK timeout, >0 ok return rBytes; int CCommandLine::getCommProtVersion(char* version) { TIMEVALUE Now; char sBuff[SENDBUFFERSIZE]; char rBuff[RECBUFFERSIZE]; WORD len; int res; if (!checkConnection()) { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getCommProtVersion()"); } else { // send fails....m_Error already set by sendBuffer return Res; strcpy (sBuff,"?version\r\n"); len = strlen (sBuff); if ((res=sendBuffer(sBuff,len))==SUCCESS) { res=receiveBuffer(rBuff,RECBUFFERSIZE); strcpy (version,rBuff); } if (res>0) { // operation was ok. //if (!CProtocol::status(rBuff)) { // _THROW_EXCPT(BackendsErrors::NakExImpl,"CCommandLine::setDefaultConfiguration()"); //} } // the last value is still valid..nothing to do so return a value that is grater than zero 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::getCommProtVersion()"); } else if (res==WOULDBLOCK) { _THROW_EXCPT(ComponentErrors::TimeoutExImpl,"CCommandLine::getCommProtVersion()"); } else { _THROW_EXCPT(BackendsErrors::ConnectionExImpl,"CCommandLine::getCommProtVersion()"); } ACS_LOG(LM_FULL_INFO,"CCommandLine::getCommProtVersion()",(LM_INFO,"GETTING COMMUNICATION PROTOCOL VERSION")); return SENDBUFFERSIZE; } Loading