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