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
e3d05be3
Commit
e3d05be3
authored
4 months ago
by
Alexandre MALFREYT
Committed by
Florent LANGLOIS
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: always synchronize read and write values (except during ramps)
parent
5551cf17
No related branches found
No related tags found
2 merge requests
!4
develop -> main
,
!3
EnableRamps and OutputMemorizedChannelsAtInit properties
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/SingleShotAO.cpp
+52
-9
52 additions, 9 deletions
src/SingleShotAO.cpp
src/SingleShotAO.h
+4
-0
4 additions, 0 deletions
src/SingleShotAO.h
with
56 additions
and
9 deletions
src/SingleShotAO.cpp
+
52
−
9
View file @
e3d05be3
...
@@ -455,7 +455,6 @@ void SingleShotAO::init_device()
...
@@ -455,7 +455,6 @@ void SingleShotAO::init_device()
dai_channel
.
tai
.
min_value
=
"-10.0"
;
dai_channel
.
tai
.
min_value
=
"-10.0"
;
dai_channel
.
tai
.
description
=
"Output value for channel "
+
oss
.
str
()
+
" (in measurementUnit)."
;
dai_channel
.
tai
.
description
=
"Output value for channel "
+
oss
.
str
()
+
" (in measurementUnit)."
;
dai_channel
.
tai
.
format
=
"%1.2f"
;
dai_channel
.
tai
.
format
=
"%1.2f"
;
dai_channel
.
memorized
=
true
;
dai_channel
.
cdb
=
false
;
dai_channel
.
cdb
=
false
;
//- read callback
//- read callback
...
@@ -494,7 +493,6 @@ void SingleShotAO::init_device()
...
@@ -494,7 +493,6 @@ void SingleShotAO::init_device()
dai_speed
.
tai
.
format
=
"%1.2f"
;
dai_speed
.
tai
.
format
=
"%1.2f"
;
//- cleanup tango db option: cleanup tango db when removing this dyn. attr. (i.e. erase its properties from db)
//- cleanup tango db option: cleanup tango db when removing this dyn. attr. (i.e. erase its properties from db)
dai_speed
.
memorized
=
true
;
dai_speed
.
cdb
=
false
;
dai_speed
.
cdb
=
false
;
//- read callback
//- read callback
...
@@ -528,7 +526,6 @@ void SingleShotAO::init_device()
...
@@ -528,7 +526,6 @@ void SingleShotAO::init_device()
dai_initial
.
tai
.
format
=
"%1.2f"
;
dai_initial
.
tai
.
format
=
"%1.2f"
;
//- cleanup tango db option: cleanup tango db when removing this dyn. attr. (i.e. erase its properties from db)
//- cleanup tango db option: cleanup tango db when removing this dyn. attr. (i.e. erase its properties from db)
dai_initial
.
memorized
=
true
;
dai_initial
.
cdb
=
false
;
dai_initial
.
cdb
=
false
;
//- read callback
//- read callback
...
@@ -595,7 +592,12 @@ void SingleShotAO::init_device()
...
@@ -595,7 +592,12 @@ void SingleShotAO::init_device()
std
::
string
attrName
=
attrPrefix
+
oss
.
str
();
std
::
string
attrName
=
attrPrefix
+
oss
.
str
();
double
val
=
yat4tango
::
PropertyHelper
::
get_memorized_attribute
<
double
>
(
this
,
attrName
);
double
val
=
yat4tango
::
PropertyHelper
::
get_memorized_attribute
<
double
>
(
this
,
attrName
);
DEBUG_STREAM
<<
"Found memorized value for "
<<
attrName
<<
": "
<<
val
<<
endl
;
DEBUG_STREAM
<<
"Found memorized value for "
<<
attrName
<<
": "
<<
val
<<
endl
;
// Write the value to the manager (that contains the "read" attributes values)
(
m_manager
->*
setter
)(
l_cpt
,
val
);
(
m_manager
->*
setter
)(
l_cpt
,
val
);
// Write the value to the "write" attributes using helper function
setDynamicAttributeWriteValue
(
attrName
,
val
);
}
}
catch
(...)
{
catch
(...)
{
// nothing to do
// nothing to do
...
@@ -954,6 +956,7 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
...
@@ -954,6 +956,7 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
{
{
double
l_val
;
double
l_val
;
cbd
.
tga
->
get_write_value
(
l_val
);
cbd
.
tga
->
get_write_value
(
l_val
);
cbd
.
tga
->
set_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
,
kCHANNEL
);
// extract channel nb
yat
::
uint16
l_idx
=
extractNumber
(
l_attr_name
,
kCHANNEL
);
// extract channel nb
...
@@ -981,7 +984,12 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
...
@@ -981,7 +984,12 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
DEBUG_STREAM
<<
"SingleShotAO::write_channel(): channel "
<<
l_idx
<<
" value set to "
<<
l_val
<<
endl
;
DEBUG_STREAM
<<
"SingleShotAO::write_channel(): channel "
<<
l_idx
<<
" value set to "
<<
l_val
<<
endl
;
yat4tango
::
PropertyHelper
::
set_memorized_attribute
(
this
,
l_attr_name
,
l_val
);
yat4tango
::
PropertyHelper
::
set_memorized_attribute
(
this
,
l_attr_name
,
l_val
);
yat4tango
::
PropertyHelper
::
set_memorized_attribute
(
this
,
kINITIAL
+
std
::
to_string
(
l_idx
),
l_val
);
// Update the initial attribute to match the channel value
std
::
string
initialAttrName
=
kINITIAL
+
std
::
to_string
(
l_idx
);
yat4tango
::
PropertyHelper
::
set_memorized_attribute
(
this
,
initialAttrName
,
l_val
);
setDynamicAttributeWriteValue
(
initialAttrName
,
l_val
);
DEBUG_STREAM
<<
"SingleShotAO::write_channel(): memorized attribute "
<<
l_attr_name
<<
" set to "
<<
l_val
<<
endl
;
DEBUG_STREAM
<<
"SingleShotAO::write_channel(): memorized attribute "
<<
l_attr_name
<<
" set to "
<<
l_val
<<
endl
;
}
}
...
@@ -1116,6 +1124,37 @@ void SingleShotAO::write_initial(yat4tango::DynamicAttributeWriteCallbackData &
...
@@ -1116,6 +1124,37 @@ void SingleShotAO::write_initial(yat4tango::DynamicAttributeWriteCallbackData &
}
}
//+------------------------------------------------------------------
/**
* set the write value of a dynamic attribute
* used to keep read and write values in sync
*/
bool
SingleShotAO
::
setDynamicAttributeWriteValue
(
const
std
::
string
&
attrName
,
double
value
)
{
try
{
Tango
::
DeviceImpl
*
dev
=
static_cast
<
Tango
::
DeviceImpl
*>
(
this
);
Tango
::
DevDouble
val_to_write
=
value
;
// Get the attribute
Tango
::
WAttribute
&
attr
=
dev
->
get_device_attr
()
->
get_w_attr_by_name
(
attrName
.
c_str
());
// Set the write value
attr
.
set_write_value
(
&
val_to_write
,
1
);
DEBUG_STREAM
<<
"Set write value for "
<<
attrName
<<
" to "
<<
value
<<
endl
;
return
true
;
}
catch
(
Tango
::
DevFailed
&
df
)
{
ERROR_STREAM
<<
"Failed to set write value for "
<<
attrName
<<
": "
<<
df
<<
endl
;
return
false
;
}
catch
(...)
{
ERROR_STREAM
<<
"Unknown exception setting write value for "
<<
attrName
<<
endl
;
return
false
;
}
}
//+------------------------------------------------------------------
//+------------------------------------------------------------------
/**
/**
* method: SingleShotAO::abort
* method: SingleShotAO::abort
...
@@ -1160,11 +1199,15 @@ void SingleShotAO::_abort()
...
@@ -1160,11 +1199,15 @@ void SingleShotAO::_abort()
DEBUG_STREAM
<<
"Channel "
<<
l_cpt
<<
" is running. Memorizing values..."
<<
std
::
endl
;
DEBUG_STREAM
<<
"Channel "
<<
l_cpt
<<
" is running. Memorizing values..."
<<
std
::
endl
;
double
l_val_channel
=
m_manager
->
get_channel
(
l_cpt
);
double
l_val_channel
=
m_manager
->
get_channel
(
l_cpt
);
yat4tango
::
PropertyHelper
::
set_memorized_attribute
(
this
,
kCHANNEL
+
std
::
to_string
(
l_cpt
),
l_val_channel
);
std
::
string
l_channel_attr_name
=
kCHANNEL
+
std
::
to_string
(
l_cpt
);
DEBUG_STREAM
<<
"Memorizing channel "
<<
l_cpt
<<
" to "
<<
l_val_channel
<<
std
::
endl
;
yat4tango
::
PropertyHelper
::
set_memorized_attribute
(
this
,
l_channel_attr_name
,
l_val_channel
);
setDynamicAttributeWriteValue
(
l_channel_attr_name
,
l_val_channel
);
yat4tango
::
PropertyHelper
::
set_memorized_attribute
(
this
,
kINITIAL
+
std
::
to_string
(
l_cpt
),
l_val_channel
);
DEBUG_STREAM
<<
"Memorizing "
<<
l_channel_attr_name
<<
" to "
<<
l_val_channel
<<
std
::
endl
;
DEBUG_STREAM
<<
"Memorizing initial "
<<
l_cpt
<<
" to "
<<
l_val_channel
<<
std
::
endl
;
std
::
string
l_initial_attr_name
=
kINITIAL
+
std
::
to_string
(
l_cpt
);
yat4tango
::
PropertyHelper
::
set_memorized_attribute
(
this
,
l_initial_attr_name
,
l_val_channel
);
setDynamicAttributeWriteValue
(
l_initial_attr_name
,
l_val_channel
);
DEBUG_STREAM
<<
"Memorizing "
<<
l_initial_attr_name
<<
" to "
<<
l_val_channel
<<
std
::
endl
;
}
}
}
}
m_manager
->
abort
();
m_manager
->
abort
();
...
...
This diff is collapsed.
Click to expand it.
src/SingleShotAO.h
+
4
−
0
View file @
e3d05be3
...
@@ -290,6 +290,10 @@ protected :
...
@@ -290,6 +290,10 @@ protected :
void
_abort
();
void
_abort
();
// set the write value of a dynamic attribute
// used to keep read and write values in sync
bool
setDynamicAttributeWriteValue
(
const
std
::
string
&
attrName
,
double
value
);
};
};
}
// namespace_ns
}
// namespace_ns
...
...
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