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

Updates for threaded tasks (TANGODEVIC-1647)

parent 6317046e
No related branches found
No related tags found
No related merge requests found
......@@ -26,165 +26,185 @@
// via a http web protocol.
// ===========================================================================
namespace TIMIQLib_ns {
//------------------------------------------------------------------------
// Class Description:
// Thread to write the values and commands on the TimIQ equipment
//------------------------------------------------------------------------
class ThreadedAction : public yat::Thread
{
friend class TIMIQLib;
namespace TIMIQLib_ns {
//------------------------------------------------------------------------
// Class Description:
// Thread to write the values and commands on the TimIQ equipment
//------------------------------------------------------------------------
class ThreadedAction : public yat::Thread
{
friend class TIMIQLib;
protected:
//- ctor ---------------------------------
ThreadedAction ( yat::Thread::IOArg ioa, timIQConfig& cfg);
protected:
//- ctor ---------------------------------
ThreadedAction(yat::Thread::IOArg ioa, timIQConfig& cfg);
//- dtor ---------------------------------
virtual ~ThreadedAction (void);
//- dtor ---------------------------------
virtual ~ThreadedAction();
//- thread's entry point
virtual yat::Thread::IOArg run_undetached (yat::Thread::IOArg ioa);
//- thread's entry point
virtual yat::Thread::IOArg run_undetached (yat::Thread::IOArg ioa);
//- asks this ThreadedAction to quit
virtual void exit (void);
//- asks this ThreadedAction to quit
virtual void exit();
//- Thread state
bool isThreadAlive()
{
return m_goOn;
}
//- Thread state
bool isThreadAlive()
{
return m_goOn;
}
bool isWriteDone()
{
return m_isActionDone;
}
bool isWriteDone()
{
return m_isActionDone;
}
private:
private:
//- thread's ctrl flag
bool m_goOn;
//- thread's ctrl flag
bool m_goOn;
//- indicates if the threaded action is done
bool m_isActionDone;
//- indicates if the threaded action is done
bool m_isActionDone;
//- indicates if the threaded action has generated an error
bool m_isActionInError;
//- indicates if the threaded action has generated an error
bool m_isActionInError;
//- Thread action configuration member
timIQConfig m_ti_cfg;
};
//- Thread action configuration member
timIQConfig m_ti_cfg;
};
//- low layer TimIQ curl class
//-----------------------------
class TIMIQCurl;
//- low layer TimIQ curl class
//-----------------------------
class TIMIQCurl;
//------------------------------------------------------------------------
//- TIMIQProxy Class
//- Ensures the interface of the timIQ equipment with
//- a tango software control system
//------------------------------------------------------------------------
class TIMIQLib
{
friend class ThreadedAction;
//------------------------------------------------------------------------
//- TIMIQProxy Class
//- Ensures the interface of the timIQ equipment with
//- a tango software control system
//------------------------------------------------------------------------
class TIMIQLib
{
friend class ThreadedAction;
public:
// Contructor
TIMIQLib ();
public:
// Contructor
TIMIQLib();
// Destructor
~TIMIQLib();
//- Write functions
//---------------------------------------------------------------------------
// Sets data to TimIQ equipment
// @param data float value.
void set_data(float data) throw (Exception);
// Regulates "I" tension to TimIQ equipment
// @param iValue float value.
void set_iValue(float iValue)throw (Exception);
// Regulates "Q" tension to TimIQ equipment
// @param qValue float value.
void set_qValue(float qValue)throw (Exception);
// Sets board temperature to TimIQ equipment
// @param boardTemperature float value.
void set_boardTemperature(float boardTemperature) throw (Exception);
// Sets command to TimIQ equipment
// @param cmd TimIQCmd_t value.
void set_command(E_timiq_cmd_t& cmd) throw (Exception);
// Destructor
~TIMIQLib();
//- Write functions
//---------------------------------------------------------------------------
// Sets data to TimIQ equipment
// @param data float value.
void set_data(float data)
throw (Exception);
// Regulates "I" tension to TimIQ equipment
// @param iValue float value.
void set_iValue(float iValue)
throw (Exception);
// Regulates "Q" tension to TimIQ equipment
// @param qValue float value.
void set_qValue(float qValue)
throw (Exception);
// Sets board temperature to TimIQ equipment
// @param boardTemperature float value.
void set_boardTemperature(float boardTemperature)
throw (Exception);
// Sets command to TimIQ equipment
// @param cmd TimIQCmd_t value.
void set_command(E_timiq_cmd_t& cmd)
throw (Exception);
//- Read functions
//---------------------------------------------------------------------------
// Gets data from TimIQ equipment
// @param [out] data float pointer.
void get_data(float &data)throw (Exception);
// Gets "I" value from TimIQ equipment
// @param [out] iValue float pointer.
void get_iValue(float& iValue)throw (Exception);
// Gets "Q" value from TimIQ equipment
// @param [out] qValue float pointer.
void get_qValue(float& qValue)throw (Exception);
// Gets the mixer cosinus output from TimIQ equipment
// @param [out] mixerCosOutput float pointer.
void get_mixerCosOutput(float& mixerCosOutput)throw (Exception);
// Gets the mixer sinus output from TimIQ equipment
// @param [out] mixerSinOutput float pointer.
void get_mixerSinOutput(float& mixerSinOutput)throw (Exception);
// Gets the board temperature from TimIQ equipment
// @param [out] boardTemperature float pointer.
void get_boardTemperature(float& boardTemperature)throw (Exception);
//- Read functions
//---------------------------------------------------------------------------
// Gets data from TimIQ equipment
// @param [out] data float pointer.
void get_data(float &data)
throw (Exception);
// Gets "I" value from TimIQ equipment
// @param [out] iValue float pointer.
void get_iValue(float& iValue)
throw (Exception);
// Gets "Q" value from TimIQ equipment
// @param [out] qValue float pointer.
void get_qValue(float& qValue)
throw (Exception);
// Gets the mixer cosinus output from TimIQ equipment
// @param [out] mixerCosOutput float pointer.
void get_mixerCosOutput(float& mixerCosOutput)
throw (Exception);
// Gets the mixer sinus output from TimIQ equipment
// @param [out] mixerSinOutput float pointer.
void get_mixerSinOutput(float& mixerSinOutput)
throw (Exception);
// Gets the board temperature from TimIQ equipment
// @param [out] boardTemperature float pointer.
void get_boardTemperature(float& boardTemperature)
throw (Exception);
// Gets state of TimIQ equipment
// @param [out] status string
E_timiq_code_t get_state(std::string& status) throw (Exception);
// Initialize TimIQCurl library
// @param ip_address string, port_number string
void init (const std::string& ip_address, const short& port_number) throw (Exception);
private:
//- internal members
//--------------------------
TIMIQCurl * m_timiq_hw;
//- ip address number
std::string m_ipAddress;
//- port number
std::string m_numPort;
//- internal timiq state
E_timiq_code_t m_internal_timiq_state;
// Gets state of TimIQ equipment
// @param [out] status string
E_timiq_code_t get_state(std::string& status)
throw (Exception);
// Initialize TimIQCurl library
// @param ip_address string, port_number string
void init (const std::string& ip_address, const short& port_number)
throw (Exception);
private:
//- internal members
//--------------------------
TIMIQCurl * m_timiq_hw;
//- ip address number
std::string m_ipAddress;
//- port number
std::string m_numPort;
//- internal timiq state
E_timiq_code_t m_internal_timiq_state;
protected:
//- internal function
//-------------------------
// ...
//- manage command by using task
ThreadedAction * m_timiq_task;
protected:
//- internal functions
//-------------------------
//- manage command by using task
ThreadedAction * m_timiq_task;
void ExecuteAction(timIQConfig & cfg);
void end_task() throw (Exception);
// execute action specified in argument
void ExecuteAction(timIQConfig & cfg)
throw (Exception);
// end of task notification
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);
};
};
} // namespace TIMIQLib_ns
......
This diff is collapsed.
......@@ -35,47 +35,49 @@ namespace TIMIQLib_ns
// Writes "I" tension on TimIQ equipment
// @param iValue float value.
E_timiq_errno_t write_iValue(float& iValue);
E_timiq_errno_t write_iValue(float& iValue);
// Writes "Q" tension to TimIQ equipment
// @param qValue float value.
E_timiq_errno_t write_qValue(float& qValue);
E_timiq_errno_t write_qValue(float& qValue);
// Writes board temperature to TimIQ equipment
// @param boardTemperature float value.
E_timiq_errno_t write_boardTemperature(float& boardTemperature);
E_timiq_errno_t write_boardTemperature(float& boardTemperature);
// Writes command on TimIQ equipment
// @param cmd TimIQCmd_t value.
E_timiq_errno_t write_command(E_timiq_cmd_t& cmd);
// @param thr thr = true: use threaded curl reference, otherwise,
// use standard curl reference
E_timiq_errno_t write_command(E_timiq_cmd_t& cmd, bool thr = true);
// Reads data from TimIQ equipment
// @param [out] data float pointer.
E_timiq_errno_t read_data(float& data);
E_timiq_errno_t read_data(float& data);
// Reads "I" value from TimIQ equipment
// @param [out] iValue float pointer.
E_timiq_errno_t read_iValue(float& iValue);
E_timiq_errno_t read_iValue(float& iValue);
// Reads "Q" value from TimIQ equipment
// @param [out] qValue float pointer.
E_timiq_errno_t read_qValue(float& qValue);
E_timiq_errno_t read_qValue(float& qValue);
// Reads the mixer cosinus output from TimIQ equipment
// @param [out] mixerCosOutput float pointer.
E_timiq_errno_t read_mixerCosOutput(float& mixerCosOutput);
E_timiq_errno_t read_mixerCosOutput(float& mixerCosOutput);
// Reads the mixer sinus output from TimIQ equipment
// @param [out] mixerSinOutput float pointer.
E_timiq_errno_t read_mixerSinOutput(float& mixerSinOutput);
E_timiq_errno_t read_mixerSinOutput(float& mixerSinOutput);
// Reads the board temperature from TimIQ equipment
// @param [out] boardTemperature float pointer.
E_timiq_errno_t read_boardTemperature(float& boardTemperature);
E_timiq_errno_t read_boardTemperature(float& boardTemperature);
// Reads TimIQ state of TimIQ equipment
// @param [out] state vector of string
E_timiq_errno_t read_state_and_status(std::string& status, E_timiq_code_t& codeRet);
E_timiq_errno_t read_state_and_status(std::string& status, E_timiq_code_t& codeRet);
// Gets error messages
// @return string variable
......@@ -92,7 +94,10 @@ namespace TIMIQLib_ns
//- CURL easy handle
CURL * m_hw_curl;
//- CURL easy handle for threaded write actions // soso added
CURL * m_thr_hw_curl;
// message error
std::string m_error_string;
......@@ -108,14 +113,19 @@ namespace TIMIQLib_ns
//--------------------
// connects to api
// connects to an easy handle using curl
// @return 0: no error, others: an internal error occurred
E_timiq_errno_t connect_i();
// @param thr thr = true: use threaded curl reference, otherwise,
// use standard curl reference
// @return 0: no error, others: an internal error occurred
E_timiq_errno_t connect_i(bool thr = false);
// writes on timiq WebServer
// @param url of the page, strData data to send
// @param url Url of the page
// @param strData Data to send
// @param thr thr = true: use threaded curl reference, otherwise,
// use standard curl reference
// @return true if success, false otherwise
bool write_i(std::string& url, std::string& strData);
bool write_i(std::string& url, std::string& strData, bool thr = true);
// reads float data from timiq WebServer
// @param url of the page, strData data value to find, [out]flaot value to extracted
......@@ -128,9 +138,11 @@ namespace TIMIQLib_ns
bool read_state_and_status_i(const std::string& url, std::string& state, E_timiq_code_t& codeRet );
// send data to webserver
// @param string
// @param url Url to use
// @param thr thr = true: use threaded curl reference, otherwise,
// use standard curl reference
// @return CURLcode
CURLcode send_to_webserver_i(const std::string& url);
CURLcode send_to_webserver_i(const std::string& url, bool thr = false);
};
}
......
This diff is collapsed.
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