Skip to content
Snippets Groups Projects
Commit fbef1f8e authored by Jacques Gouno's avatar Jacques Gouno
Browse files

TANGODEVIC-1647: point1 & 2, fixed

parent bea91b56
No related branches found
No related tags found
No related merge requests found
......@@ -46,9 +46,6 @@ TIMIQCurl::TIMIQCurl(const std::string& ip_address, const std::string& num_port)
m_error_string = "";
// use the static timiq internal buffer
// m_timiq_internal_buff.clear();
m_hw_curl = NULL;
}
......@@ -294,26 +291,31 @@ E_timiq_errno_t TIMIQCurl::read_state_and_status(std::string& status, E_timiq_c
// ============================================================================
E_timiq_errno_t TIMIQCurl::connect_i()
{
// std::cout << "TIMIQCurl::connect() called..." << std::endl;
E_timiq_errno_t err_num = timiq_internal_ERROR;
m_error_string = "";
try
{
m_hw_curl = curl_easy_init();
if (m_hw_curl)
if (!m_hw_curl)
{
err_num = timiq_NO_ERROR;
m_hw_curl = curl_easy_init();
if (m_hw_curl)
{
err_num = timiq_NO_ERROR;
}
else
{
m_error_string = "INTERNAL_ERROR\n";
m_error_string += "TIMIQ WebServer access is not available, null pointer detected!\n";
m_error_string += "TIMIQCurl::connect()";
}
}
else
{
m_error_string = "INTERNAL_ERROR\n";
m_error_string += "TIMIQ WebServer access is not available, null pointer detected!\n";
m_error_string = "TIMIQ WebServer access allows only single session!\n";
m_error_string += "TIMIQCurl::connect()";
}
}
}
catch (...)
{
......@@ -362,6 +364,7 @@ bool TIMIQCurl::write_i(std::string& url, std::string& strData)
#else
m_timiq_internal_buff = "\ncommand=1\n";
m_timiq_internal_buff += "command=2\n";
m_timiq_internal_buff += "command=3\n";
m_timiq_internal_buff += "iValue=-0.000001\n";
m_timiq_internal_buff += "qValue=-0.000002";
......@@ -447,7 +450,7 @@ bool TIMIQCurl::read_float_i(const std::string& url, const std::string& strData,
//- value
std::string floatStr = tokfloatStr.next_token();
//- convert data to flaot
//- convert data to float
value = (float)yat::XString<float>::to_num(floatStr);
}
catch(...)
......@@ -579,16 +582,19 @@ CURLcode TIMIQCurl:: send_to_webserver_i(const std::string& url)
curl_easy_setopt(m_hw_curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(m_hw_curl, CURLOPT_PROXY, "");
curl_easy_setopt(m_hw_curl, CURLOPT_WRITEFUNCTION, &write_callback);
/* complete within 1500 ms */
curl_easy_setopt(m_hw_curl, CURLOPT_TIMEOUT_MS, 1500L);
/* ask libcurl to show us the verbose output */
// curl_easy_setopt(m_hw_curl, CURLOPT_VERBOSE, 1L);
//- perform the query
result = curl_easy_perform(m_hw_curl);
//- clean up
curl_easy_cleanup(m_hw_curl);
m_hw_curl = NULL;
return result;
}
......
......@@ -122,7 +122,7 @@ void TIMIQLib::data_end_task()
{
if (m_timiq_task->m_ti_cfg.ti_err != timiq_NO_ERROR)
{
//std::cout <<"exit task done ..." <<std::endl;
// std::cout <<"exit task done ..." <<std::endl;
m_timiq_task->exit();
delete m_timiq_task;
m_timiq_task = NULL;
......@@ -162,7 +162,7 @@ void TIMIQLib::set_iValue(float iValue)
{
//- force timiq state = Busy
m_internal_timiq_state = Busy;
m_timiq_task = new ThreadedAction(static_cast<yat::Thread::IOArg>(this), l_ti_cfg);
if (m_timiq_task == NULL)
{
......@@ -186,14 +186,12 @@ void TIMIQLib::iVal_end_task()
// std::cout <<"iVal_end_task ..." <<std::endl;
//- Delete task
if (this->m_timiq_task)
{
{
if (m_timiq_task->m_ti_cfg.ti_err != timiq_NO_ERROR)
{
//std::cout <<"exit task done ..." <<std::endl;
{
m_timiq_task->exit();
delete m_timiq_task;
m_timiq_task = NULL;
CHECK_TIMIQ_HW;
std::string msg_err = "Set I value error -msg: " + m_timiq_hw->get_err_msg();
......@@ -201,11 +199,10 @@ void TIMIQLib::iVal_end_task()
static_cast<const char*>(msg_err.c_str()),
static_cast<const char*>("TIMIQLib::set_iValue"));
}
//- destroy otherwise
m_timiq_task->exit();
delete m_timiq_task;
m_timiq_task = NULL;
}
//- update state of TIMIQ equipment
......@@ -256,9 +253,7 @@ void TIMIQLib::qVal_end_task()
{
if (m_timiq_task->m_ti_cfg.ti_err != timiq_NO_ERROR)
{
//std::cout <<"exit task done ..." <<std::endl;
m_timiq_task->exit();
delete m_timiq_task;
m_timiq_task = NULL;
CHECK_TIMIQ_HW;
......@@ -271,7 +266,6 @@ void TIMIQLib::qVal_end_task()
//- destroy otherwise
m_timiq_task->exit();
delete m_timiq_task;
m_timiq_task = NULL;
}
......@@ -319,13 +313,12 @@ void TIMIQLib::boardT_end_task()
{
// std::cout <<"boardT_end_task ..." <<std::endl;
//- Delete task
if (this->m_timiq_task)
if (this->m_timiq_task)
{
if (m_timiq_task->m_ti_cfg.ti_err != timiq_NO_ERROR)
{
//std::cout <<"exit task done ..." <<std::endl;
m_timiq_task->exit();
delete m_timiq_task;
m_timiq_task = NULL;
CHECK_TIMIQ_HW;
......@@ -338,7 +331,6 @@ void TIMIQLib::boardT_end_task()
//- destroy otherwise
m_timiq_task->exit();
delete m_timiq_task;
m_timiq_task = NULL;
}
......@@ -365,6 +357,9 @@ void TIMIQLib::set_command(E_timiq_cmd_t& cmd)
static_cast<const char*>(msg_err.c_str()),
static_cast<const char*>("TIMIQLib::set_command()"));
}
//- update state of TIMIQ equipment
m_internal_timiq_state = OK;
}
// ============================================================================
......@@ -586,21 +581,13 @@ void TIMIQLib::ExecuteAction(timIQConfig & cfg)
CHECK_TIMIQ_HW;
// E_timiq_code_t l_timiq_state = m_internal_timiq_state;
// if ( l_timiq_state != Busy )
// {
//- force timiq state = Busy
// m_internal_timiq_state = Busy;
// Actions to be threaded
switch(cfg.id)
{
//- write "I" value
case TI_IVAL:
std::cout<<"Start executeAction - "<< cfg.id<< std::endl;
cfg.ti_err = m_timiq_hw->write_iValue(cfg.value);
std::cout<<"after executeAction - "<< cfg.id<< std::endl;
this->iVal_end_task();
std::cout<<"End executeAction - "<< cfg.id<< std::endl;
break;
//- write "Q" value
......@@ -618,15 +605,11 @@ void TIMIQLib::ExecuteAction(timIQConfig & cfg)
//- write "BOARD Temperature" value
case TI_BTEMP:
cfg.ti_err = m_timiq_hw->write_data(cfg.value);
this->data_end_task();
this->boardT_end_task();
break;
default:
break;
}
//- rollback timiq state to previous state
// m_internal_timiq_state = l_timiq_state;
// }
}
} // namespace timiqlib
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment