Commit 1529d090 authored by mfioren's avatar mfioren
Browse files

Updated dbesm in case of no sensor, handling of board addresses

parent 122cc8bf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -88,6 +88,8 @@ public:
 	
 	virtual void get_firm(short b_addr);
 	
 	virtual void handle_addr(short * b_addr);

	/** 
	 * Returns a reference to addr_1.
	 * @return pointer to long property addr_1
+32 −2
Original line number Diff line number Diff line
@@ -375,6 +375,11 @@ void CCommandSocket::set_mode_command(short b_addr, const char * cfg_name) //thr
    //cout << "Message to send is: " << msg << endl;
    sendCommand(msg, &outBuff, 0);

    if (outBuff.find("not existing") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_mode_command()");
		impl.setReason("Board address entered not valid");
		throw impl;
	   }
    if (outBuff.find("unreachable") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_mode_command()");
		impl.setReason("DBESM board unreachable, timeout error");
@@ -394,6 +399,11 @@ void CCommandSocket::set_att_command(short b_addr, short out_ch, double att_val)
    //cout << "Message to send is: " << msg << endl;
    sendCommand(msg, &outBuff, 0);
    
    if (outBuff.find("not existing") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_att_command()");
		impl.setReason("Board address entered not valid");
		throw impl;
	   }
    if (outBuff.find("unreachable") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_att_command()");
		impl.setReason("DBESM board unreachable, timeout error");
@@ -451,6 +461,11 @@ string CCommandSocket::get_status_command(short b_addr) //throw (BackendsErrors:
    //cout << "Message to send is: " << msg << endl;
    sendCommand(msg, &response, 0);

    if (response.find("not existing") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_status_command()");
		impl.setReason("Board address entered not valid");
		throw impl;
	   }
    if (response.find("unreachable") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_status_command()");
		impl.setReason("DBESM board unreachable, timeout error");
@@ -471,6 +486,11 @@ string CCommandSocket::get_comp_command(short b_addr) //throw (BackendsErrors::B
    //cout << "Message to send is: " << msg << endl;
    sendCommand(msg, &response, 0);

    if (response.find("not existing") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_comp_command()");
		impl.setReason("Board address entered not valid");
		throw impl;
	   }
    if (response.find("unreachable") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_comp_command()");
		impl.setReason("DBESM board unreachable, timeout error");
@@ -491,6 +511,11 @@ string CCommandSocket::get_diag_command(short b_addr) //throw (BackendsErrors::B
    //cout << "Message to send is: " << msg << endl;
    sendCommand(msg, &response, 0);

    if (response.find("not existing") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_diag_command()");
		impl.setReason("Board address entered not valid");
		throw impl;
	   }
    if (response.find("unreachable") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_diag_command()");
		impl.setReason("DBESM board unreachable, timeout error");
@@ -571,6 +596,11 @@ string CCommandSocket::get_firm_command(short b_addr) //throw (BackendsErrors::B
    //cout << "Message to send is: " << msg << endl;
    sendCommand(msg, &response, 0);

    if (response.find("not existing") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_firm_command()");
		impl.setReason("Board address entered not valid");
		throw impl;
	   }
    if (response.find("unreachable") != string::npos) {
		_EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_firm_command()");
		impl.setReason("DBESM board unreachable, timeout error");
+50 −4
Original line number Diff line number Diff line
@@ -240,6 +240,27 @@ void SRTDBESMImpl::aboutToAbort()
	_IRA_LOGFILTER_DESTROY;
}

void SRTDBESMImpl::handle_addr(short * b_addr)
{
	  ACS::Time timestamp;
     if (*b_addr == 1)
    		 {
    				*b_addr = m_paddr_1->getDevIO()->read(timestamp);
    		 }
     else if (*b_addr == 2)
   	  	 {
    				*b_addr = m_paddr_2->getDevIO()->read(timestamp);
    		 }
     else if (*b_addr == 3)
   	  	 {
    				*b_addr = m_paddr_3->getDevIO()->read(timestamp); 
    		 }
     else if (*b_addr == 4)
   	  	 {
    				*b_addr = m_paddr_4->getDevIO()->read(timestamp); 
    		 }
     }

void SRTDBESMImpl::set_all(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx)
{
	 AUTO_TRACE("SRTDBESMImpl::set_all()");
@@ -268,6 +289,9 @@ void SRTDBESMImpl::set_all(const char * cfg_name) //throw (BackendsErrors::Backe
void SRTDBESMImpl::set_mode(short b_addr, const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx)
{
	AUTO_TRACE("SRTDBESMImpl::set_mode()");
	
   handle_addr(&b_addr);	
	
	try {
		
   	 m_commandSocket.set_mode(b_addr, cfg_name);
@@ -292,6 +316,9 @@ void SRTDBESMImpl::set_mode(short b_addr, const char * cfg_name) //throw (Backen
void SRTDBESMImpl::set_att(short b_addr, short out_ch, double att_val) //throw (BackendsErrors::BackendsErrorsEx)
{
	AUTO_TRACE("SRTDBESMImpl::set_att()");
	
	handle_addr(&b_addr);
	
	try {
		
    	m_commandSocket.set_att(b_addr, out_ch, att_val);
@@ -371,6 +398,8 @@ void SRTDBESMImpl::get_status(short b_addr)// throw (BackendsErrors::BackendsErr
	 new_att_vals.length(17);
    string output;
    
    handle_addr(&b_addr);
 
    try {
    	
    	output= m_commandSocket.get_status(b_addr);
@@ -447,6 +476,8 @@ void SRTDBESMImpl::get_comp(short b_addr) //throw (BackendsErrors::BackendsError
	 new_bpf_vals.length(11);
	 string output;
	 
    handle_addr(&b_addr);	 
	 
	 try {
	 	
      output = m_commandSocket.get_comp(b_addr);
@@ -528,6 +559,8 @@ void SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsError
	 double new_temp_val;
	 string output;
	 
    handle_addr(&b_addr);	 
	 
	 try {
	 	
    	 output = m_commandSocket.get_diag(b_addr);
@@ -555,14 +588,24 @@ void SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsError
    	 m_commandSocket.parse_double_response(output, "5V ", " 3V3", &new_volt_val);
  		 new_volt_vals[0] = new_volt_val;  														
         
   	 m_commandSocket.parse_double_response(output, "3V3 ", "\nT0", &new_volt_val2);
   	 m_commandSocket.parse_double_response(output, "3V3 ", "\n", &new_volt_val2);
       new_volt_vals[1] = new_volt_val2;
    }
    catch (std::out_of_range) {
			_EXCPT(BackendsErrors::MalformedAnswerExImpl,impl,"SRTDBESMImpl::get_diag()");
			throw impl; }
			
    try {  
   	 m_commandSocket.parse_double_response(output, "T0 ", "\r\n", &new_temp_val);
    }
    catch (std::out_of_range) {
   	    if (output.find("temp sensor not present") != std::string::npos) {
             new_temp_val = 0.0;
             }
          else {
			 _EXCPT(BackendsErrors::MalformedAnswerExImpl,impl,"SRTDBESMImpl::get_diag()");
			 throw impl; }
		 }
			
   try {
   	 
@@ -607,6 +650,7 @@ void SRTDBESMImpl::get_cfg()
	 AUTO_TRACE("SRTDBESMImpl::get_cfg()");
	 string cfg_message;
	 int newlines =0; 
	 
	 try {
	 	
    	 cfg_message = m_commandSocket.get_cfg();
@@ -826,6 +870,8 @@ void SRTDBESMImpl::get_firm(short b_addr) //throw (BackendsErrors::BackendsError
	 AUTO_TRACE("SRTDBESMImpl::get_firm()");
	 string output;
	 
    handle_addr(&b_addr);	 
	 
	 try {
	 	
    	 output = m_commandSocket.get_firm(b_addr);