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