Skip to content
Snippets Groups Projects
Commit a4de2927 authored by Sonia Minolli's avatar Sonia Minolli
Browse files

Updates for threaded tasks (TANGODEVIC-1647)

parent d2a76dbd
No related branches found
No related tags found
No related merge requests found
......@@ -175,10 +175,13 @@ namespace TIMIQLib_ns {
ThreadedAction * m_timiq_task;
void ExecuteAction(timIQConfig & cfg);
void end_task() throw (Exception);
// soso à supprimer:
void iVal_end_task() throw (Exception);
void qVal_end_task() throw (Exception);
void data_end_task() throw (Exception);
void boardT_end_task() throw (Exception);
};
......
......@@ -25,6 +25,7 @@ if (!m_timiq_hw) \
static_cast<const char*>("CHECK_TIMIQ_HW()")); \
}
// ============================================================================
// ============================================================================
// TIMIQLib::TIMIQLib
// ============================================================================
......@@ -36,6 +37,7 @@ TIMIQLib::TIMIQLib ()
m_internal_timiq_state = Undefined;
m_timiq_task = NULL;
}
// ============================================================================
// TIMIQLib::~TIMIQLib()
// ============================================================================
......@@ -51,10 +53,11 @@ TIMIQLib::~TIMIQLib()
if (m_timiq_task)
{
m_timiq_task->exit();
delete m_timiq_task;
//delete m_timiq_task; // soso debug - sure needs delete ?
m_timiq_task = NULL;
}
}
// ============================================================================
// TIMIQLib::init
// ============================================================================
......@@ -78,6 +81,7 @@ void TIMIQLib::init(const std::string& ip_address, const short& num_port)
CHECK_TIMIQ_HW;
}
// ============================================================================
// TIMIQLib::set_data
// ============================================================================
......@@ -209,6 +213,35 @@ void TIMIQLib::iVal_end_task()
m_internal_timiq_state = OK;
}
// soso add
// ============================================================================
// TIMIQLib::end_task
// ============================================================================
void TIMIQLib::end_task()
throw (Exception)
{
//- Delete task
if (this->m_timiq_task)
{
if (m_timiq_task->m_ti_cfg.ti_err != timiq_NO_ERROR)
{
m_timiq_task->exit();
m_timiq_task = NULL;
std::string msg_err = "Threaded task error -msg: " + m_timiq_hw->get_err_msg();
throw Exception(static_cast<const char*>("SOFTWARE_FAILURE"),
static_cast<const char*>(msg_err.c_str()),
static_cast<const char*>("TIMIQLib::end_task"));
}
//- destroy otherwise
m_timiq_task->exit();
m_timiq_task = NULL;
}
//- update state of TIMIQ equipment
//m_internal_timiq_state = OK; -- est mis à jour par get state
}
// ============================================================================
// TIMIQLib::set_qValue
// ============================================================================
......@@ -349,17 +382,45 @@ void TIMIQLib::set_command(E_timiq_cmd_t& cmd)
CHECK_TIMIQ_HW;
//- write command on TIMIQ equipment
err = m_timiq_hw->write_command(cmd);
if (err != timiq_NO_ERROR)
// soso add
// thread PLL calibration command:
if (cmd == RECALIBRATE_PLL)
{
if ( m_internal_timiq_state != Busy )
{
timIQConfig l_ti_cfg;
l_ti_cfg.id = TI_CALIB;
//- 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)
{
std::string msg_err = "Set Q value error -msg: " + m_timiq_hw->get_err_msg();
throw Exception(static_cast<const char*>("SOFTWARE_FAILURE"),
static_cast<const char*>(msg_err.c_str()),
static_cast<const char*>("TIMIQLib::set_command"));
}
//- start the task to do the pll calibration
m_timiq_task->start_undetached();
}
}
else
{
err = m_timiq_hw->write_command(cmd);
if (err != timiq_NO_ERROR)
{
std::string msg_err = "Set command error -msg: " + m_timiq_hw->get_err_msg();
throw Exception(static_cast<const char*>("SOFTWARE_FAILURE"),
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;
//- update state of TIMIQ equipment
m_internal_timiq_state = OK;
}
}
// ============================================================================
......@@ -500,7 +561,7 @@ E_timiq_code_t TIMIQLib::get_state(std::string& status)
CHECK_TIMIQ_HW;
//- get internal timiq state
if (m_internal_timiq_state != Busy)
//if (m_internal_timiq_state != Busy) -- soso debug : update qqsoit l'état
{
//- read status of TIMIQ equipment
err = m_timiq_hw->read_state_and_status(status, m_internal_timiq_state);
......@@ -571,7 +632,6 @@ void ThreadedAction::exit (void)
this->m_goOn = false;
}
// ============================================================================
// TIMIQLib::ExecuteAction
// ============================================================================
......@@ -587,26 +647,33 @@ void TIMIQLib::ExecuteAction(timIQConfig & cfg)
//- write "I" value
case TI_IVAL:
cfg.ti_err = m_timiq_hw->write_iValue(cfg.value);
this->iVal_end_task();
this->end_task(); // soso meme fonction end, non ?
break;
//- write "Q" value
case TI_QVAL:
cfg.ti_err = m_timiq_hw->write_qValue(cfg.value);
this->qVal_end_task();
this->end_task(); // soso meme fonction end, non ?
break;
//- write "DATA" value
case TI_DATA:
cfg.ti_err = m_timiq_hw->write_data(cfg.value);
this->data_end_task();
this->end_task(); // soso meme fonction end, non ?
break;
//- write "BOARD Temperature" value
case TI_BTEMP:
cfg.ti_err = m_timiq_hw->write_data(cfg.value);
this->boardT_end_task();
break;
this->end_task(); // soso meme fonction end, non ?
break;
//- PLL calibration -- soso add
case TI_CALIB:
cfg.ti_err = m_timiq_hw->write_command(RECALIBRATE_PLL);
this->end_task();
break;
default:
break;
}
......
......@@ -105,13 +105,15 @@ typedef enum
//------------------------------
//- timIQ struct config
//------------------------------
// threaded action type
typedef enum
{
Undef = 0,
TI_IVAL,
TI_QVAL,
TI_BTEMP,
TI_DATA
TI_DATA,
TI_CALIB // soso add
} E_ti_t;
typedef struct timIQConfig
......
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