Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SingleShotAO
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Control System
Tango devices
InputOutput
ADLINK
SingleShotAO
Commits
2973a71d
Commit
2973a71d
authored
5 months ago
by
Alexandre MALFREYT
Browse files
Options
Downloads
Patches
Plain Diff
refactor: rename get_device_property to get_device_properties and extract channel number logic
parent
c725c419
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!4
develop -> main
,
!2
[CTRLRFC-1594] Apply memorized dynamic attributes at init
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/SingleShotAO.cpp
+33
-39
33 additions, 39 deletions
src/SingleShotAO.cpp
src/SingleShotAO.h
+1
-1
1 addition, 1 deletion
src/SingleShotAO.h
src/SingleShotAOManager.cpp
+0
-2
0 additions, 2 deletions
src/SingleShotAOManager.cpp
with
34 additions
and
42 deletions
src/SingleShotAO.cpp
+
33
−
39
View file @
2973a71d
...
@@ -219,7 +219,7 @@ void SingleShotAO::init_device()
...
@@ -219,7 +219,7 @@ void SingleShotAO::init_device()
//--------------------------------------------
//--------------------------------------------
try
try
{
{
get_device_propert
y
();
get_device_propert
ies
();
}
}
catch
(
const
Tango
::
DevFailed
&
df
)
catch
(
const
Tango
::
DevFailed
&
df
)
{
{
...
@@ -543,12 +543,12 @@ void SingleShotAO::init_device()
...
@@ -543,12 +543,12 @@ void SingleShotAO::init_device()
//+----------------------------------------------------------------------------
//+----------------------------------------------------------------------------
//
//
// method : SingleShotAO::get_device_propert
y
()
// method : SingleShotAO::get_device_propert
ies
()
//
//
// description : Read the device properties from database.
// description : Read the device properties from database.
//
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void
SingleShotAO
::
get_device_propert
y
()
void
SingleShotAO
::
get_device_propert
ies
()
{
{
// Initialize your default values here (if not done with POGO).
// Initialize your default values here (if not done with POGO).
//------------------------------------------------------------------
//------------------------------------------------------------------
...
@@ -664,8 +664,7 @@ void SingleShotAO::always_executed_hook()
...
@@ -664,8 +664,7 @@ void SingleShotAO::always_executed_hook()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void
SingleShotAO
::
read_attr_hardware
(
vector
<
long
>
&
attr_list
)
void
SingleShotAO
::
read_attr_hardware
(
vector
<
long
>
&
attr_list
)
{
{
//DEBUG_STREAM << "SingleShotAO::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
// nothing to do
// Add your own code here
}
}
...
@@ -678,7 +677,6 @@ void SingleShotAO::read_attr_hardware(vector<long> &attr_list)
...
@@ -678,7 +677,6 @@ void SingleShotAO::read_attr_hardware(vector<long> &attr_list)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void
SingleShotAO
::
read_frequency
(
Tango
::
Attribute
&
attr
)
void
SingleShotAO
::
read_frequency
(
Tango
::
Attribute
&
attr
)
{
{
//DEBUG_STREAM << "SingleShotAO::read_frequency(Tango::Attribute &attr) entering... "<< endl;
attr
.
set_value
(
&
m_frequency
);
attr
.
set_value
(
&
m_frequency
);
}
}
...
@@ -757,6 +755,26 @@ Tango::ConstDevString SingleShotAO::dev_status()
...
@@ -757,6 +755,26 @@ Tango::ConstDevString SingleShotAO::dev_status()
}
}
//+------------------------------------------------------------------
/**
* Extract the first number found in a string.
* Used for extracting the channel number from dynamic attribute names
* like "channelX", "speedX", "initialX" where X is the channel number.
*
* @param str The input string to search for numbers
* @return The first number found in the string
* @throws DevFailed if no number is found in the string
*/
int
extractNumber
(
const
std
::
string
&
str
)
{
size_t
pos
=
str
.
find_first_of
(
"0123456789"
);
if
(
pos
==
std
::
string
::
npos
)
raise_error
(
"No number found in string"
,
"extractNumber"
);
std
::
string
numberStr
=
str
.
substr
(
pos
);
return
std
::
stoi
(
numberStr
);
}
//+------------------------------------------------------------------
//+------------------------------------------------------------------
/**
/**
* method: SingleShotAO::read_channel
* method: SingleShotAO::read_channel
...
@@ -768,15 +786,10 @@ Tango::ConstDevString SingleShotAO::dev_status()
...
@@ -768,15 +786,10 @@ Tango::ConstDevString SingleShotAO::dev_status()
void
SingleShotAO
::
read_channel
(
yat4tango
::
DynamicAttributeReadCallbackData
&
cbd
)
void
SingleShotAO
::
read_channel
(
yat4tango
::
DynamicAttributeReadCallbackData
&
cbd
)
{
{
yat
::
AutoMutex
<>
guard
(
m_lock
);
yat
::
AutoMutex
<>
guard
(
m_lock
);
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
yat
::
uint16
l_idx
=
extractNumber
(
l_attr_name
);
// extract channel nb
// name will be channelX
std
::
string
l_str
=
l_attr_name
.
substr
(
7
,
2
);
yat
::
uint16
l_idx
=
atoi
(
l_str
.
c_str
());
CHECK_MANAGER
();
CHECK_MANAGER
();
// choose tab depending on l_idx
double
l_val
=
m_manager
->
get_channel
(
l_idx
);
double
l_val
=
m_manager
->
get_channel
(
l_idx
);
cbd
.
tga
->
set_value
(
&
l_val
);
cbd
.
tga
->
set_value
(
&
l_val
);
}
}
...
@@ -796,10 +809,7 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
...
@@ -796,10 +809,7 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
cbd
.
tga
->
get_write_value
(
l_val
);
cbd
.
tga
->
get_write_value
(
l_val
);
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
yat
::
uint16
l_idx
=
extractNumber
(
l_attr_name
);
// extract channel nb
// name will be channelX
std
::
string
l_str
=
l_attr_name
.
substr
(
7
,
2
);
yat
::
uint16
l_idx
=
atoi
(
l_str
.
c_str
());
CHECK_MANAGER
();
CHECK_MANAGER
();
try
try
...
@@ -835,15 +845,10 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
...
@@ -835,15 +845,10 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
void
SingleShotAO
::
read_speed
(
yat4tango
::
DynamicAttributeReadCallbackData
&
cbd
)
void
SingleShotAO
::
read_speed
(
yat4tango
::
DynamicAttributeReadCallbackData
&
cbd
)
{
{
yat
::
AutoMutex
<>
guard
(
m_lock
);
yat
::
AutoMutex
<>
guard
(
m_lock
);
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
yat
::
uint16
l_idx
=
extractNumber
(
l_attr_name
);
// extract channel nb
// name will be speedX
std
::
string
l_str
=
l_attr_name
.
substr
(
5
,
2
);
yat
::
uint16
l_idx
=
atoi
(
l_str
.
c_str
());
CHECK_MANAGER
();
CHECK_MANAGER
();
// choose tab depending on l_idx
double
l_val
=
m_manager
->
get_speed
(
l_idx
);
double
l_val
=
m_manager
->
get_speed
(
l_idx
);
cbd
.
tga
->
set_value
(
&
l_val
);
cbd
.
tga
->
set_value
(
&
l_val
);
}
}
...
@@ -865,10 +870,7 @@ void SingleShotAO::write_speed(yat4tango::DynamicAttributeWriteCallbackData & cb
...
@@ -865,10 +870,7 @@ void SingleShotAO::write_speed(yat4tango::DynamicAttributeWriteCallbackData & cb
cbd
.
tga
->
get_write_value
(
l_val
);
cbd
.
tga
->
get_write_value
(
l_val
);
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
yat
::
uint16
l_idx
=
extractNumber
(
l_attr_name
);
// extract channel nb
// name will be speedX
std
::
string
l_str
=
l_attr_name
.
substr
(
5
,
2
);
yat
::
uint16
l_idx
=
atoi
(
l_str
.
c_str
());
if
(
l_val
<
0
)
if
(
l_val
<
0
)
{
{
l_val
=
-
l_val
;
l_val
=
-
l_val
;
...
@@ -909,15 +911,10 @@ void SingleShotAO::write_speed(yat4tango::DynamicAttributeWriteCallbackData & cb
...
@@ -909,15 +911,10 @@ void SingleShotAO::write_speed(yat4tango::DynamicAttributeWriteCallbackData & cb
void
SingleShotAO
::
read_initial
(
yat4tango
::
DynamicAttributeReadCallbackData
&
cbd
)
void
SingleShotAO
::
read_initial
(
yat4tango
::
DynamicAttributeReadCallbackData
&
cbd
)
{
{
yat
::
AutoMutex
<>
guard
(
m_lock
);
yat
::
AutoMutex
<>
guard
(
m_lock
);
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
yat
::
uint16
l_idx
=
extractNumber
(
l_attr_name
);
// extract channel nb
// name will be initialX
std
::
string
l_str
=
l_attr_name
.
substr
(
7
,
2
);
yat
::
uint16
l_idx
=
atoi
(
l_str
.
c_str
());
CHECK_MANAGER
();
CHECK_MANAGER
();
// choose tab depending on l_idx
double
l_val
=
m_manager
->
get_initial
(
l_idx
);
double
l_val
=
m_manager
->
get_initial
(
l_idx
);
cbd
.
tga
->
set_value
(
&
l_val
);
cbd
.
tga
->
set_value
(
&
l_val
);
}
}
...
@@ -939,10 +936,7 @@ void SingleShotAO::write_initial(yat4tango::DynamicAttributeWriteCallbackData &
...
@@ -939,10 +936,7 @@ void SingleShotAO::write_initial(yat4tango::DynamicAttributeWriteCallbackData &
cbd
.
tga
->
get_write_value
(
l_val
);
cbd
.
tga
->
get_write_value
(
l_val
);
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
std
::
string
l_attr_name
=
cbd
.
dya
->
get_name
();
yat
::
uint16
l_idx
=
extractNumber
(
l_attr_name
);
// extract channel nb
// name will be initialX
std
::
string
l_str
=
l_attr_name
.
substr
(
7
,
2
);
yat
::
uint16
l_idx
=
atoi
(
l_str
.
c_str
());
CHECK_MANAGER
();
CHECK_MANAGER
();
try
try
...
...
This diff is collapsed.
Click to expand it.
src/SingleShotAO.h
+
1
−
1
View file @
2973a71d
...
@@ -219,7 +219,7 @@ public :
...
@@ -219,7 +219,7 @@ public :
/**
/**
* Read the device properties from database
* Read the device properties from database
*/
*/
void
get_device_propert
y
();
void
get_device_propert
ies
();
//@}
//@}
// Here is the end of the automatic code generation part
// Here is the end of the automatic code generation part
...
...
This diff is collapsed.
Click to expand it.
src/SingleShotAOManager.cpp
+
0
−
2
View file @
2973a71d
...
@@ -180,7 +180,6 @@ void SingleShotAOManager::process_message (yat::Message& msg)
...
@@ -180,7 +180,6 @@ void SingleShotAOManager::process_message (yat::Message& msg)
//- THREAD_PERIODIC ------------------
//- THREAD_PERIODIC ------------------
case
yat
::
TASK_PERIODIC
:
case
yat
::
TASK_PERIODIC
:
{
{
//DEBUG_STREAM << "SingleShotAOManager::handle_message::THREAD_PERIODIC" << std::endl;
periodic_job_i
();
periodic_job_i
();
}
}
break
;
break
;
...
@@ -209,7 +208,6 @@ void SingleShotAOManager::periodic_job_i()
...
@@ -209,7 +208,6 @@ void SingleShotAOManager::periodic_job_i()
//test if a ramp step must occur
//test if a ramp step must occur
if
(
m_currentIndex
[
l_cpt
]
!=
-
1
)
if
(
m_currentIndex
[
l_cpt
]
!=
-
1
)
{
{
//DEBUG_STREAM << "Current index for channel" << l_cpt << ": " << m_currentIndex[l_cpt] << endl;
m_isRunning
[
l_cpt
]
=
true
;
m_isRunning
[
l_cpt
]
=
true
;
double
l_val
=
0
;
double
l_val
=
0
;
l_val
=
m_ramps
[
l_cpt
][
m_currentIndex
[
l_cpt
]];
l_val
=
m_ramps
[
l_cpt
][
m_currentIndex
[
l_cpt
]];
...
...
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