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
fbef1f8e
Commit
fbef1f8e
authored
8 years ago
by
Jacques Gouno
Browse files
Options
Downloads
Patches
Plain Diff
TANGODEVIC-1647: point1 & 2, fixed
parent
bea91b56
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/TIMIQCurl.cpp
+22
-16
22 additions, 16 deletions
src/TIMIQCurl.cpp
src/TIMIQLib.cpp
+11
-28
11 additions, 28 deletions
src/TIMIQLib.cpp
with
33 additions
and
44 deletions
src/TIMIQCurl.cpp
+
22
−
16
View file @
fbef1f8e
...
...
@@ -46,9 +46,6 @@ TIMIQCurl::TIMIQCurl(const std::string& ip_address, const std::string& num_port)
m_error_string
=
""
;
// use the static timiq internal buffer
// m_timiq_internal_buff.clear();
m_hw_curl
=
NULL
;
}
...
...
@@ -294,26 +291,31 @@ E_timiq_errno_t TIMIQCurl::read_state_and_status(std::string& status, E_timiq_c
// ============================================================================
E_timiq_errno_t
TIMIQCurl
::
connect_i
()
{
// std::cout << "TIMIQCurl::connect() called..." << std::endl;
E_timiq_errno_t
err_num
=
timiq_internal_ERROR
;
m_error_string
=
""
;
try
{
m_hw_curl
=
curl_easy_init
();
if
(
m_hw_curl
)
if
(
!
m_hw_curl
)
{
err_num
=
timiq_NO_ERROR
;
m_hw_curl
=
curl_easy_init
();
if
(
m_hw_curl
)
{
err_num
=
timiq_NO_ERROR
;
}
else
{
m_error_string
=
"INTERNAL_ERROR
\n
"
;
m_error_string
+=
"TIMIQ WebServer access is not available, null pointer detected!
\n
"
;
m_error_string
+=
"TIMIQCurl::connect()"
;
}
}
else
{
m_error_string
=
"INTERNAL_ERROR
\n
"
;
m_error_string
+=
"TIMIQ WebServer access is not available, null pointer detected!
\n
"
;
m_error_string
=
"TIMIQ WebServer access allows only single session!
\n
"
;
m_error_string
+=
"TIMIQCurl::connect()"
;
}
}
}
catch
(...)
{
...
...
@@ -362,6 +364,7 @@ bool TIMIQCurl::write_i(std::string& url, std::string& strData)
#else
m_timiq_internal_buff
=
"
\n
command=1
\n
"
;
m_timiq_internal_buff
+=
"command=2
\n
"
;
m_timiq_internal_buff
+=
"command=3
\n
"
;
m_timiq_internal_buff
+=
"iValue=-0.000001
\n
"
;
m_timiq_internal_buff
+=
"qValue=-0.000002"
;
...
...
@@ -447,7 +450,7 @@ bool TIMIQCurl::read_float_i(const std::string& url, const std::string& strData,
//- value
std
::
string
floatStr
=
tokfloatStr
.
next_token
();
//- convert data to fl
a
ot
//- convert data to flo
a
t
value
=
(
float
)
yat
::
XString
<
float
>::
to_num
(
floatStr
);
}
catch
(...)
...
...
@@ -579,16 +582,19 @@ CURLcode TIMIQCurl:: send_to_webserver_i(const std::string& url)
curl_easy_setopt
(
m_hw_curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
m_hw_curl
,
CURLOPT_PROXY
,
""
);
curl_easy_setopt
(
m_hw_curl
,
CURLOPT_WRITEFUNCTION
,
&
write_callback
);
/* complete within 1500 ms */
curl_easy_setopt
(
m_hw_curl
,
CURLOPT_TIMEOUT_MS
,
1500L
);
/* ask libcurl to show us the verbose output */
// curl_easy_setopt(m_hw_curl, CURLOPT_VERBOSE, 1L);
//- perform the query
result
=
curl_easy_perform
(
m_hw_curl
);
//- clean up
curl_easy_cleanup
(
m_hw_curl
);
m_hw_curl
=
NULL
;
return
result
;
}
...
...
This diff is collapsed.
Click to expand it.
src/TIMIQLib.cpp
+
11
−
28
View file @
fbef1f8e
...
...
@@ -122,7 +122,7 @@ void TIMIQLib::data_end_task()
{
if
(
m_timiq_task
->
m_ti_cfg
.
ti_err
!=
timiq_NO_ERROR
)
{
//std::cout <<"exit task done ..." <<std::endl;
//
std::cout <<"exit task done ..." <<std::endl;
m_timiq_task
->
exit
();
delete
m_timiq_task
;
m_timiq_task
=
NULL
;
...
...
@@ -162,7 +162,7 @@ void TIMIQLib::set_iValue(float iValue)
{
//- 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
)
{
...
...
@@ -186,14 +186,12 @@ void TIMIQLib::iVal_end_task()
// std::cout <<"iVal_end_task ..." <<std::endl;
//- Delete task
if
(
this
->
m_timiq_task
)
{
{
if
(
m_timiq_task
->
m_ti_cfg
.
ti_err
!=
timiq_NO_ERROR
)
{
//std::cout <<"exit task done ..." <<std::endl;
{
m_timiq_task
->
exit
();
delete
m_timiq_task
;
m_timiq_task
=
NULL
;
CHECK_TIMIQ_HW
;
std
::
string
msg_err
=
"Set I value error -msg: "
+
m_timiq_hw
->
get_err_msg
();
...
...
@@ -201,11 +199,10 @@ void TIMIQLib::iVal_end_task()
static_cast
<
const
char
*>
(
msg_err
.
c_str
()),
static_cast
<
const
char
*>
(
"TIMIQLib::set_iValue"
));
}
//- destroy otherwise
m_timiq_task
->
exit
();
delete
m_timiq_task
;
m_timiq_task
=
NULL
;
}
//- update state of TIMIQ equipment
...
...
@@ -256,9 +253,7 @@ void TIMIQLib::qVal_end_task()
{
if
(
m_timiq_task
->
m_ti_cfg
.
ti_err
!=
timiq_NO_ERROR
)
{
//std::cout <<"exit task done ..." <<std::endl;
m_timiq_task
->
exit
();
delete
m_timiq_task
;
m_timiq_task
=
NULL
;
CHECK_TIMIQ_HW
;
...
...
@@ -271,7 +266,6 @@ void TIMIQLib::qVal_end_task()
//- destroy otherwise
m_timiq_task
->
exit
();
delete
m_timiq_task
;
m_timiq_task
=
NULL
;
}
...
...
@@ -319,13 +313,12 @@ void TIMIQLib::boardT_end_task()
{
// std::cout <<"boardT_end_task ..." <<std::endl;
//- Delete task
if
(
this
->
m_timiq_task
)
if
(
this
->
m_timiq_task
)
{
if
(
m_timiq_task
->
m_ti_cfg
.
ti_err
!=
timiq_NO_ERROR
)
{
//std::cout <<"exit task done ..." <<std::endl;
m_timiq_task
->
exit
();
delete
m_timiq_task
;
m_timiq_task
=
NULL
;
CHECK_TIMIQ_HW
;
...
...
@@ -338,7 +331,6 @@ void TIMIQLib::boardT_end_task()
//- destroy otherwise
m_timiq_task
->
exit
();
delete
m_timiq_task
;
m_timiq_task
=
NULL
;
}
...
...
@@ -365,6 +357,9 @@ void TIMIQLib::set_command(E_timiq_cmd_t& cmd)
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
;
}
// ============================================================================
...
...
@@ -586,21 +581,13 @@ void TIMIQLib::ExecuteAction(timIQConfig & cfg)
CHECK_TIMIQ_HW
;
// E_timiq_code_t l_timiq_state = m_internal_timiq_state;
// if ( l_timiq_state != Busy )
// {
//- force timiq state = Busy
// m_internal_timiq_state = Busy;
// Actions to be threaded
switch
(
cfg
.
id
)
{
//- write "I" value
case
TI_IVAL
:
std
::
cout
<<
"Start executeAction - "
<<
cfg
.
id
<<
std
::
endl
;
cfg
.
ti_err
=
m_timiq_hw
->
write_iValue
(
cfg
.
value
);
std
::
cout
<<
"after executeAction - "
<<
cfg
.
id
<<
std
::
endl
;
this
->
iVal_end_task
();
std
::
cout
<<
"End executeAction - "
<<
cfg
.
id
<<
std
::
endl
;
break
;
//- write "Q" value
...
...
@@ -618,15 +605,11 @@ void TIMIQLib::ExecuteAction(timIQConfig & cfg)
//- write "BOARD Temperature" value
case
TI_BTEMP
:
cfg
.
ti_err
=
m_timiq_hw
->
write_data
(
cfg
.
value
);
this
->
data
_end_task
();
this
->
boardT
_end_task
();
break
;
default:
break
;
}
//- rollback timiq state to previous state
// m_internal_timiq_state = l_timiq_state;
// }
}
}
// namespace timiqlib
...
...
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