Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TIMIQLib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Control System
Libraries
TIMIQLib
Commits
530acbb6
Commit
530acbb6
authored
7 years ago
by
Sonia Minolli
Browse files
Options
Downloads
Patches
Plain Diff
Updates for threaded tasks (TANGODEVIC-1647)
parent
6317046e
No related branches found
No related tags found
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/timiq/TIMIQLib.h
+152
-132
152 additions, 132 deletions
include/timiq/TIMIQLib.h
src/TIMIQCurl.cpp
+472
-378
472 additions, 378 deletions
src/TIMIQCurl.cpp
src/TIMIQCurl.h
+30
-18
30 additions, 18 deletions
src/TIMIQCurl.h
src/TIMIQLib.cpp
+401
-389
401 additions, 389 deletions
src/TIMIQLib.cpp
with
1055 additions
and
917 deletions
include/timiq/TIMIQLib.h
+
152
−
132
View file @
530acbb6
...
...
@@ -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.
Click to expand it.
src/TIMIQCurl.cpp
+
472
−
378
View file @
530acbb6
This diff is collapsed.
Click to expand it.
src/TIMIQCurl.h
+
30
−
18
View file @
530acbb6
...
...
@@ -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.
Click to expand it.
src/TIMIQLib.cpp
+
401
−
389
View file @
530acbb6
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment