Loading SRT/Servers/SRTDBESM/src/CommandSocket.cpp +149 −13 Original line number Diff line number Diff line Loading @@ -126,6 +126,15 @@ string CCommandSocket::get_diag(short b_addr) //throw (BackendsErrors::BackendsE return get_diag_command(b_addr); } string CCommandSocket::get_cfg() //throw (BackendsErrors::BackendsErrorsEx) { return get_cfg_command(); } string CCommandSocket::dbe_att(const char * out_dbe, const char * att_val) //throw (BackendsErrors::BackendsErrorsEx) { return dbe_att_command(out_dbe, att_val); } void CCommandSocket::parse_longSeq_response(string status_str, string start, string end, ACS::longSeq* vals) //throw (BackendsErrors::BackendsErrorsEx) { Loading @@ -144,7 +153,7 @@ void CCommandSocket::parse_longSeq_response(string status_str, string start, str } } catch (std::out_of_range outofrange) { //if the index is out of range std::cout << "OUT OF RANGE\n" << outofrange.what(); //throw this exception throw outofrange; //throw this exception } } Loading @@ -167,7 +176,7 @@ void CCommandSocket::parse_doubleSeq_response(string status_str, string start, s } } catch (std::out_of_range outofrange) { //if the index is out of range std::cout << "OUT OF RANGE\n" << outofrange.what(); //throw this exception throw outofrange; //throw this exception } } Loading @@ -183,7 +192,7 @@ void CCommandSocket::parse_double_response(string status_str, string start, stri *val=temp; } catch (std::out_of_range outofrange) { //if the index is out of range std::cout << "OUT OF RANGE\n" << outofrange.what(); //throw this exception throw outofrange; //throw this exception } } Loading Loading @@ -284,7 +293,7 @@ int CCommandSocket::receiveBuffer(std::string* Msg,CError& error, int all) if(Receive(error, &buf, 1) == 1) { (*Msg) += buf; cout << "buf " << buf << endl; //cout << "buf " << buf << endl; // Reset the timer CIRATools::getTime(Start); } Loading Loading @@ -320,49 +329,116 @@ void CCommandSocket::set_all_command(const char * cfg_name) //throw (BackendsErr { string outBuff; string msg = CDBESMCommand::comm_set_allmode(cfg_name); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; //ACS_LOG(LM_FULL_INFO,"CCommandSocket::set_all_command()",(LM_INFO,msg)); sendCommand(msg, &outBuff, 1); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_all_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_all_command()"); impl.setReason("Error in setting whole dbesm configuration, check parameters"); throw impl; } } void CCommandSocket::set_mode_command(short b_addr, const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { string outBuff; string msg = CDBESMCommand::comm_set_mode(to_string(b_addr), cfg_name); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &outBuff, 0); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_mode_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_mode_command()"); impl.setReason("Error in setting single dbesm board configuration, check parameters"); throw impl; } } void CCommandSocket::set_att_command(short b_addr, short out_ch, double att_val) //throw (BackendsErrors::BackendsErrorsEx) { string outBuff; string msg = CDBESMCommand::comm_set_att(to_string(b_addr), to_string(out_ch), to_string(att_val)); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &outBuff, 0); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_att_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_att_command()"); impl.setReason("Error in setting dbesm attenuator, check parameters"); throw impl; } } void CCommandSocket::store_allmode_command(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { string outBuff; string msg = CDBESMCommand::comm_store_allmode(cfg_name); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &outBuff, 0); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::store_allmode_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::store_allmode_command()"); impl.setReason("Error in storing dbesm configuration file, check parameters"); throw impl; } } void CCommandSocket::clr_mode_command(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { string outBuff; string msg = CDBESMCommand::comm_clr_mode(cfg_name); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &outBuff, 0); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::clr_mode_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::clr_mode_command()"); impl.setReason("Error in deleting dbesm configuration file, check parameters"); throw impl; } } string CCommandSocket::get_status_command(short b_addr) //throw (BackendsErrors::BackendsErrorsEx) { string response; string msg = CDBESMCommand::comm_get_status(to_string(b_addr)); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_status_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_status_command()"); impl.setReason("Error in getting dbesm status info, check parameters"); throw impl; } return response; } Loading @@ -370,9 +446,19 @@ string CCommandSocket::get_comp_command(short b_addr) //throw (BackendsErrors::B { string response; string msg = CDBESMCommand::comm_get_comp(to_string(b_addr)); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_comp_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_comp_command()"); impl.setReason("Error in getting dbesm components values, check parameters"); throw impl; } return response; } Loading @@ -380,8 +466,58 @@ string CCommandSocket::get_diag_command(short b_addr) //throw (BackendsErrors::B { string response; string msg = CDBESMCommand::comm_get_diag(to_string(b_addr)); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_diag_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_diag_command()"); impl.setReason("Error in getting dbesm diagnostic info, check parameters"); throw impl; } return response; } string CCommandSocket::get_cfg_command() //throw (BackendsErrors::BackendsErrorsEx) { string response; string msg = CDBESMCommand::comm_get_cfg(); //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_cfg_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_cfg_command()"); impl.setReason("Error in getting dbesm configuration, check parameters"); throw impl; } return response; } string CCommandSocket::dbe_att_command(const char * out_dbe, const char * att_val) //throw (BackendsErrors::BackendsErrorsEx) { string response; string msg = CDBESMCommand::comm_dbe_att(out_dbe, att_val); //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::dbe_att_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::dbe_att_command()"); impl.setReason("Error in setting dbesm output attenuation, check parameters"); throw impl; } return response; } No newline at end of file SRT/Servers/SRTDBESM/src/SRTDBESMImpl.cpp +107 −17 Original line number Diff line number Diff line Loading @@ -229,6 +229,7 @@ void SRTDBESMImpl::aboutToAbort() void SRTDBESMImpl::set_all(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::set_all()"); try { m_commandSocket.set_all(cfg_name); Loading @@ -247,10 +248,13 @@ void SRTDBESMImpl::set_all(const char * cfg_name) //throw (BackendsErrors::Backe dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::set_all()",(LM_INFO,"Whole DBESM configuration set")); } void SRTDBESMImpl::set_mode(short b_addr, const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::set_mode()"); try { m_commandSocket.set_mode(b_addr, cfg_name); Loading @@ -269,10 +273,12 @@ void SRTDBESMImpl::set_mode(short b_addr, const char * cfg_name) //throw (Backen dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::set_mode()",(LM_INFO,"Single board configuration set")); } void SRTDBESMImpl::set_att(short b_addr, short out_ch, double att_val) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::set_att()"); try { m_commandSocket.set_att(b_addr, out_ch, att_val); Loading @@ -291,10 +297,12 @@ void SRTDBESMImpl::set_att(short b_addr, short out_ch, double att_val) //throw ( dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::set_att()",(LM_INFO,"Attenuator set")); } void SRTDBESMImpl::store_allmode(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::store_allmode()"); try { m_commandSocket.store_allmode(cfg_name); Loading @@ -313,10 +321,12 @@ void SRTDBESMImpl::store_allmode(const char * cfg_name) //throw (BackendsErrors: dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::store_allmode()",(LM_INFO,"Configuration file written")); } void SRTDBESMImpl::clr_mode(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::clr_mode()"); try { m_commandSocket.clr_mode(cfg_name); Loading @@ -335,10 +345,12 @@ void SRTDBESMImpl::clr_mode(const char * cfg_name) //throw (BackendsErrors::Back dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::clr_mode()",(LM_INFO,"Configuration file deleted")); } char * SRTDBESMImpl::get_status(short b_addr)// throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::get_status()"); ACS::Time timestamp, timestamp2, timestamp3; ACS::longSeq new_reg_vals; ACS::doubleSeq new_att_vals; Loading @@ -360,7 +372,7 @@ char * SRTDBESMImpl::get_status(short b_addr)// throw (BackendsErrors::BackendsE throw ex.getBackendsErrorsEx(); } catch (...) { _EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SRTDBESMImpl::clr_mode()"); _EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SRTDBESMImpl::get_status()"); dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } Loading @@ -369,8 +381,13 @@ char * SRTDBESMImpl::get_status(short b_addr)// throw (BackendsErrors::BackendsE std::copy(output.begin(), (output.end()-2), c); c[output.length()-2] = '\0'; try { m_commandSocket.parse_longSeq_response(output, "REG=[ ", " ]\n\n", &new_reg_vals); // parsing errors are thrown m_commandSocket.parse_doubleSeq_response(output, "ATT=[ ", " ]\r\n", &new_att_vals); // by the commandSocket m_commandSocket.parse_doubleSeq_response(output, "ATT=[ ", " ]\r\n", &new_att_vals); // by the CommandSocket } catch (std::out_of_range) { _EXCPT(BackendsErrors::MalformedAnswerExImpl,impl,"SRTDBESMImpl::get_status()"); throw impl; } try { Loading Loading @@ -404,12 +421,13 @@ char * SRTDBESMImpl::get_status(short b_addr)// throw (BackendsErrors::BackendsE _ADD_BACKTRACE(ComponentErrors::InitializationProblemExImpl,impl,ex,"SRTDBESMImpl::get_status()"); throw impl; } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::get_status()",(LM_INFO,c)); return c; } char * SRTDBESMImpl::get_comp(short b_addr) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::get_comp()"); ACS::Time timestamp, timestamp2, timestamp3, timestamp4; ACS::longSeq new_amp_vals, new_eq_vals, new_bpf_vals; new_amp_vals.length(10); Loading Loading @@ -440,9 +458,14 @@ char * SRTDBESMImpl::get_comp(short b_addr) //throw (BackendsErrors::BackendsErr std::copy(output.begin(), (output.end()-2), c); c[output.length()-2] = '\0'; try { m_commandSocket.parse_longSeq_response(output, "AMP=[ ", " ]\n", &new_amp_vals); m_commandSocket.parse_longSeq_response(output, "EQ=[ ", " ]\nBPF", &new_eq_vals); m_commandSocket.parse_longSeq_response(output, "BPF=[ ", " ]\r\n", &new_bpf_vals); } catch (std::out_of_range) { _EXCPT(BackendsErrors::MalformedAnswerExImpl,impl,"SRTDBESMImpl::get_comp()"); throw impl; } try { Loading Loading @@ -480,12 +503,13 @@ char * SRTDBESMImpl::get_comp(short b_addr) //throw (BackendsErrors::BackendsErr _ADD_BACKTRACE(ComponentErrors::InitializationProblemExImpl,impl,ex,"SRTDBESMImpl::get_comp()"); throw impl; } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::get_comp()",(LM_INFO,c)); return c; } char * SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::get_diag()"); ACS::Time timestamp, timestamp2, timestamp3; ACS::doubleSeq new_volt_vals; new_volt_vals.length(2); Loading Loading @@ -516,6 +540,7 @@ char * SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsErr std::copy(output.begin(), (output.end()-2), c); c[output.length()-2] = '\0'; try { m_commandSocket.parse_double_response(output, "5V ", " 3V3", &new_volt_val); new_volt_vals[0] = new_volt_val; Loading @@ -523,6 +548,10 @@ char * SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsErr new_volt_vals[1] = new_volt_val2; m_commandSocket.parse_double_response(output, "T0 ", "\r\n", &new_temp_val); } catch (std::out_of_range) { _EXCPT(BackendsErrors::MalformedAnswerExImpl,impl,"SRTDBESMImpl::get_diag()"); throw impl; } try { Loading Loading @@ -559,10 +588,71 @@ char * SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsErr _ADD_BACKTRACE(ComponentErrors::InitializationProblemExImpl,impl,ex,"SRTDBESMImpl::get_diag()"); throw impl; } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::get_diag()",(LM_INFO,c)); return c; } char * SRTDBESMImpl::get_cfg() { AUTO_TRACE("SRTDBESMImpl::get_cfg()"); string cfg_message; try { cfg_message = m_commandSocket.get_cfg(); } catch (ComponentErrors::ComponentErrorsExImpl& ex) { ex.log(LM_DEBUG); throw ex.getComponentErrorsEx(); } catch (BackendsErrors::BackendsErrorsExImpl& ex) { ex.log(LM_DEBUG); throw ex.getBackendsErrorsEx(); } catch (...) { _EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SRTDBESMImpl::get_cfg()()"); dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } char *c = new char[cfg_message.length()-2 + 1]; // discard \r\n std::copy(cfg_message.begin(), (cfg_message.end()-2), c); c[cfg_message.length()-2] = '\0'; CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::get_cfg()",(LM_INFO,c)); return c; } char * SRTDBESMImpl::dbe_att(const char * out_dbe, const char * att_val) { AUTO_TRACE("SRTDBESMImpl::dbe_att()"); string out_dbe_message; try { out_dbe_message = m_commandSocket.dbe_att(out_dbe, att_val); } catch (ComponentErrors::ComponentErrorsExImpl& ex) { ex.log(LM_DEBUG); throw ex.getComponentErrorsEx(); } catch (BackendsErrors::BackendsErrorsExImpl& ex) { ex.log(LM_DEBUG); throw ex.getBackendsErrorsEx(); } catch (...) { _EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SRTDBESMImpl::dbe_att()"); dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } char *c = new char[out_dbe_message.length()-2 + 1]; // discard \r\n std::copy(out_dbe_message.begin(), (out_dbe_message.end()-2), c); c[out_dbe_message.length()-2] = '\0'; CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::dbe_att()",(LM_INFO,c)); return c; } GET_PROPERTY_REFERENCE(ACS::ROlong,m_paddr_1,addr_1); GET_PROPERTY_REFERENCE(ACS::ROlong,m_paddr_2,addr_2); GET_PROPERTY_REFERENCE(ACS::ROlong,m_paddr_3,addr_3); Loading Loading
SRT/Servers/SRTDBESM/src/CommandSocket.cpp +149 −13 Original line number Diff line number Diff line Loading @@ -126,6 +126,15 @@ string CCommandSocket::get_diag(short b_addr) //throw (BackendsErrors::BackendsE return get_diag_command(b_addr); } string CCommandSocket::get_cfg() //throw (BackendsErrors::BackendsErrorsEx) { return get_cfg_command(); } string CCommandSocket::dbe_att(const char * out_dbe, const char * att_val) //throw (BackendsErrors::BackendsErrorsEx) { return dbe_att_command(out_dbe, att_val); } void CCommandSocket::parse_longSeq_response(string status_str, string start, string end, ACS::longSeq* vals) //throw (BackendsErrors::BackendsErrorsEx) { Loading @@ -144,7 +153,7 @@ void CCommandSocket::parse_longSeq_response(string status_str, string start, str } } catch (std::out_of_range outofrange) { //if the index is out of range std::cout << "OUT OF RANGE\n" << outofrange.what(); //throw this exception throw outofrange; //throw this exception } } Loading @@ -167,7 +176,7 @@ void CCommandSocket::parse_doubleSeq_response(string status_str, string start, s } } catch (std::out_of_range outofrange) { //if the index is out of range std::cout << "OUT OF RANGE\n" << outofrange.what(); //throw this exception throw outofrange; //throw this exception } } Loading @@ -183,7 +192,7 @@ void CCommandSocket::parse_double_response(string status_str, string start, stri *val=temp; } catch (std::out_of_range outofrange) { //if the index is out of range std::cout << "OUT OF RANGE\n" << outofrange.what(); //throw this exception throw outofrange; //throw this exception } } Loading Loading @@ -284,7 +293,7 @@ int CCommandSocket::receiveBuffer(std::string* Msg,CError& error, int all) if(Receive(error, &buf, 1) == 1) { (*Msg) += buf; cout << "buf " << buf << endl; //cout << "buf " << buf << endl; // Reset the timer CIRATools::getTime(Start); } Loading Loading @@ -320,49 +329,116 @@ void CCommandSocket::set_all_command(const char * cfg_name) //throw (BackendsErr { string outBuff; string msg = CDBESMCommand::comm_set_allmode(cfg_name); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; //ACS_LOG(LM_FULL_INFO,"CCommandSocket::set_all_command()",(LM_INFO,msg)); sendCommand(msg, &outBuff, 1); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_all_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_all_command()"); impl.setReason("Error in setting whole dbesm configuration, check parameters"); throw impl; } } void CCommandSocket::set_mode_command(short b_addr, const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { string outBuff; string msg = CDBESMCommand::comm_set_mode(to_string(b_addr), cfg_name); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &outBuff, 0); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_mode_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_mode_command()"); impl.setReason("Error in setting single dbesm board configuration, check parameters"); throw impl; } } void CCommandSocket::set_att_command(short b_addr, short out_ch, double att_val) //throw (BackendsErrors::BackendsErrorsEx) { string outBuff; string msg = CDBESMCommand::comm_set_att(to_string(b_addr), to_string(out_ch), to_string(att_val)); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &outBuff, 0); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_att_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::set_att_command()"); impl.setReason("Error in setting dbesm attenuator, check parameters"); throw impl; } } void CCommandSocket::store_allmode_command(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { string outBuff; string msg = CDBESMCommand::comm_store_allmode(cfg_name); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &outBuff, 0); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::store_allmode_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::store_allmode_command()"); impl.setReason("Error in storing dbesm configuration file, check parameters"); throw impl; } } void CCommandSocket::clr_mode_command(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { string outBuff; string msg = CDBESMCommand::comm_clr_mode(cfg_name); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &outBuff, 0); if (outBuff.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::clr_mode_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (outBuff.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::clr_mode_command()"); impl.setReason("Error in deleting dbesm configuration file, check parameters"); throw impl; } } string CCommandSocket::get_status_command(short b_addr) //throw (BackendsErrors::BackendsErrorsEx) { string response; string msg = CDBESMCommand::comm_get_status(to_string(b_addr)); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_status_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_status_command()"); impl.setReason("Error in getting dbesm status info, check parameters"); throw impl; } return response; } Loading @@ -370,9 +446,19 @@ string CCommandSocket::get_comp_command(short b_addr) //throw (BackendsErrors::B { string response; string msg = CDBESMCommand::comm_get_comp(to_string(b_addr)); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_comp_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_comp_command()"); impl.setReason("Error in getting dbesm components values, check parameters"); throw impl; } return response; } Loading @@ -380,8 +466,58 @@ string CCommandSocket::get_diag_command(short b_addr) //throw (BackendsErrors::B { string response; string msg = CDBESMCommand::comm_get_diag(to_string(b_addr)); cout << "Message to send is: " << msg << endl; //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_diag_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_diag_command()"); impl.setReason("Error in getting dbesm diagnostic info, check parameters"); throw impl; } return response; } string CCommandSocket::get_cfg_command() //throw (BackendsErrors::BackendsErrorsEx) { string response; string msg = CDBESMCommand::comm_get_cfg(); //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_cfg_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::get_cfg_command()"); impl.setReason("Error in getting dbesm configuration, check parameters"); throw impl; } return response; } string CCommandSocket::dbe_att_command(const char * out_dbe, const char * att_val) //throw (BackendsErrors::BackendsErrorsEx) { string response; string msg = CDBESMCommand::comm_dbe_att(out_dbe, att_val); //cout << "Message to send is: " << msg << endl; sendCommand(msg, &response, 0); if (response.find("unreachable") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::dbe_att_command()"); impl.setReason("DBESM board unreachable, timeout error"); throw impl; } else if (response.find("ERR") != string::npos) { _EXCPT(BackendsErrors::BackendFailExImpl,impl,"CCommandSocket::dbe_att_command()"); impl.setReason("Error in setting dbesm output attenuation, check parameters"); throw impl; } return response; } No newline at end of file
SRT/Servers/SRTDBESM/src/SRTDBESMImpl.cpp +107 −17 Original line number Diff line number Diff line Loading @@ -229,6 +229,7 @@ void SRTDBESMImpl::aboutToAbort() void SRTDBESMImpl::set_all(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::set_all()"); try { m_commandSocket.set_all(cfg_name); Loading @@ -247,10 +248,13 @@ void SRTDBESMImpl::set_all(const char * cfg_name) //throw (BackendsErrors::Backe dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::set_all()",(LM_INFO,"Whole DBESM configuration set")); } void SRTDBESMImpl::set_mode(short b_addr, const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::set_mode()"); try { m_commandSocket.set_mode(b_addr, cfg_name); Loading @@ -269,10 +273,12 @@ void SRTDBESMImpl::set_mode(short b_addr, const char * cfg_name) //throw (Backen dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::set_mode()",(LM_INFO,"Single board configuration set")); } void SRTDBESMImpl::set_att(short b_addr, short out_ch, double att_val) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::set_att()"); try { m_commandSocket.set_att(b_addr, out_ch, att_val); Loading @@ -291,10 +297,12 @@ void SRTDBESMImpl::set_att(short b_addr, short out_ch, double att_val) //throw ( dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::set_att()",(LM_INFO,"Attenuator set")); } void SRTDBESMImpl::store_allmode(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::store_allmode()"); try { m_commandSocket.store_allmode(cfg_name); Loading @@ -313,10 +321,12 @@ void SRTDBESMImpl::store_allmode(const char * cfg_name) //throw (BackendsErrors: dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::store_allmode()",(LM_INFO,"Configuration file written")); } void SRTDBESMImpl::clr_mode(const char * cfg_name) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::clr_mode()"); try { m_commandSocket.clr_mode(cfg_name); Loading @@ -335,10 +345,12 @@ void SRTDBESMImpl::clr_mode(const char * cfg_name) //throw (BackendsErrors::Back dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::clr_mode()",(LM_INFO,"Configuration file deleted")); } char * SRTDBESMImpl::get_status(short b_addr)// throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::get_status()"); ACS::Time timestamp, timestamp2, timestamp3; ACS::longSeq new_reg_vals; ACS::doubleSeq new_att_vals; Loading @@ -360,7 +372,7 @@ char * SRTDBESMImpl::get_status(short b_addr)// throw (BackendsErrors::BackendsE throw ex.getBackendsErrorsEx(); } catch (...) { _EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SRTDBESMImpl::clr_mode()"); _EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SRTDBESMImpl::get_status()"); dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } Loading @@ -369,8 +381,13 @@ char * SRTDBESMImpl::get_status(short b_addr)// throw (BackendsErrors::BackendsE std::copy(output.begin(), (output.end()-2), c); c[output.length()-2] = '\0'; try { m_commandSocket.parse_longSeq_response(output, "REG=[ ", " ]\n\n", &new_reg_vals); // parsing errors are thrown m_commandSocket.parse_doubleSeq_response(output, "ATT=[ ", " ]\r\n", &new_att_vals); // by the commandSocket m_commandSocket.parse_doubleSeq_response(output, "ATT=[ ", " ]\r\n", &new_att_vals); // by the CommandSocket } catch (std::out_of_range) { _EXCPT(BackendsErrors::MalformedAnswerExImpl,impl,"SRTDBESMImpl::get_status()"); throw impl; } try { Loading Loading @@ -404,12 +421,13 @@ char * SRTDBESMImpl::get_status(short b_addr)// throw (BackendsErrors::BackendsE _ADD_BACKTRACE(ComponentErrors::InitializationProblemExImpl,impl,ex,"SRTDBESMImpl::get_status()"); throw impl; } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::get_status()",(LM_INFO,c)); return c; } char * SRTDBESMImpl::get_comp(short b_addr) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::get_comp()"); ACS::Time timestamp, timestamp2, timestamp3, timestamp4; ACS::longSeq new_amp_vals, new_eq_vals, new_bpf_vals; new_amp_vals.length(10); Loading Loading @@ -440,9 +458,14 @@ char * SRTDBESMImpl::get_comp(short b_addr) //throw (BackendsErrors::BackendsErr std::copy(output.begin(), (output.end()-2), c); c[output.length()-2] = '\0'; try { m_commandSocket.parse_longSeq_response(output, "AMP=[ ", " ]\n", &new_amp_vals); m_commandSocket.parse_longSeq_response(output, "EQ=[ ", " ]\nBPF", &new_eq_vals); m_commandSocket.parse_longSeq_response(output, "BPF=[ ", " ]\r\n", &new_bpf_vals); } catch (std::out_of_range) { _EXCPT(BackendsErrors::MalformedAnswerExImpl,impl,"SRTDBESMImpl::get_comp()"); throw impl; } try { Loading Loading @@ -480,12 +503,13 @@ char * SRTDBESMImpl::get_comp(short b_addr) //throw (BackendsErrors::BackendsErr _ADD_BACKTRACE(ComponentErrors::InitializationProblemExImpl,impl,ex,"SRTDBESMImpl::get_comp()"); throw impl; } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::get_comp()",(LM_INFO,c)); return c; } char * SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsErrorsEx) { AUTO_TRACE("SRTDBESMImpl::get_diag()"); ACS::Time timestamp, timestamp2, timestamp3; ACS::doubleSeq new_volt_vals; new_volt_vals.length(2); Loading Loading @@ -516,6 +540,7 @@ char * SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsErr std::copy(output.begin(), (output.end()-2), c); c[output.length()-2] = '\0'; try { m_commandSocket.parse_double_response(output, "5V ", " 3V3", &new_volt_val); new_volt_vals[0] = new_volt_val; Loading @@ -523,6 +548,10 @@ char * SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsErr new_volt_vals[1] = new_volt_val2; m_commandSocket.parse_double_response(output, "T0 ", "\r\n", &new_temp_val); } catch (std::out_of_range) { _EXCPT(BackendsErrors::MalformedAnswerExImpl,impl,"SRTDBESMImpl::get_diag()"); throw impl; } try { Loading Loading @@ -559,10 +588,71 @@ char * SRTDBESMImpl::get_diag(short b_addr) //throw (BackendsErrors::BackendsErr _ADD_BACKTRACE(ComponentErrors::InitializationProblemExImpl,impl,ex,"SRTDBESMImpl::get_diag()"); throw impl; } CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::get_diag()",(LM_INFO,c)); return c; } char * SRTDBESMImpl::get_cfg() { AUTO_TRACE("SRTDBESMImpl::get_cfg()"); string cfg_message; try { cfg_message = m_commandSocket.get_cfg(); } catch (ComponentErrors::ComponentErrorsExImpl& ex) { ex.log(LM_DEBUG); throw ex.getComponentErrorsEx(); } catch (BackendsErrors::BackendsErrorsExImpl& ex) { ex.log(LM_DEBUG); throw ex.getBackendsErrorsEx(); } catch (...) { _EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SRTDBESMImpl::get_cfg()()"); dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } char *c = new char[cfg_message.length()-2 + 1]; // discard \r\n std::copy(cfg_message.begin(), (cfg_message.end()-2), c); c[cfg_message.length()-2] = '\0'; CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::get_cfg()",(LM_INFO,c)); return c; } char * SRTDBESMImpl::dbe_att(const char * out_dbe, const char * att_val) { AUTO_TRACE("SRTDBESMImpl::dbe_att()"); string out_dbe_message; try { out_dbe_message = m_commandSocket.dbe_att(out_dbe, att_val); } catch (ComponentErrors::ComponentErrorsExImpl& ex) { ex.log(LM_DEBUG); throw ex.getComponentErrorsEx(); } catch (BackendsErrors::BackendsErrorsExImpl& ex) { ex.log(LM_DEBUG); throw ex.getBackendsErrorsEx(); } catch (...) { _EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SRTDBESMImpl::dbe_att()"); dummy.log(LM_DEBUG); throw dummy.getComponentErrorsEx(); } char *c = new char[out_dbe_message.length()-2 + 1]; // discard \r\n std::copy(out_dbe_message.begin(), (out_dbe_message.end()-2), c); c[out_dbe_message.length()-2] = '\0'; CUSTOM_LOG(LM_FULL_INFO,"SRTDBESMImpl::dbe_att()",(LM_INFO,c)); return c; } GET_PROPERTY_REFERENCE(ACS::ROlong,m_paddr_1,addr_1); GET_PROPERTY_REFERENCE(ACS::ROlong,m_paddr_2,addr_2); GET_PROPERTY_REFERENCE(ACS::ROlong,m_paddr_3,addr_3); Loading