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
5551cf17
Commit
5551cf17
authored
4 months ago
by
Alexandre MALFREYT
Committed by
Florent LANGLOIS
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor: split write_channel method into write_channel_direct and start_channel_ramp
parent
646f4650
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!4
develop -> main
,
!3
EnableRamps and OutputMemorizedChannelsAtInit properties
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/SingleShotAO.cpp
+4
-1
4 additions, 1 deletion
src/SingleShotAO.cpp
src/SingleShotAOManager.cpp
+69
-52
69 additions, 52 deletions
src/SingleShotAOManager.cpp
src/SingleShotAOManager.h
+6
-0
6 additions, 0 deletions
src/SingleShotAOManager.h
with
79 additions
and
53 deletions
src/SingleShotAO.cpp
+
4
−
1
View file @
5551cf17
...
...
@@ -609,7 +609,7 @@ void SingleShotAO::init_device()
}
if
(
outputMemorizedChannelsAtInit
)
{
applyMemorizedAttr
(
kCHANNEL
,
&
SingleShotAOManager
::
write_channel
);
// write memorized value to board output
applyMemorizedAttr
(
kCHANNEL
,
&
SingleShotAOManager
::
write_channel
_direct
);
// write memorized value to board output
(directly, without ramp)
}
else
{
applyMemorizedAttr
(
kCHANNEL
,
&
SingleShotAOManager
::
set_channel
);
// only apply memorized value to the device
}
...
...
@@ -978,8 +978,11 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
"could not write channel [unknown error]"
,
"SingleShotAO::write_channel"
);
}
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
,
kINITIAL
+
std
::
to_string
(
l_idx
),
l_val
);
DEBUG_STREAM
<<
"SingleShotAO::write_channel(): memorized attribute "
<<
l_attr_name
<<
" set to "
<<
l_val
<<
endl
;
}
...
...
This diff is collapsed.
Click to expand it.
src/SingleShotAOManager.cpp
+
69
−
52
View file @
5551cf17
...
...
@@ -250,6 +250,7 @@ void SingleShotAOManager::periodic_job_i()
m_currentIndex
[
l_cpt
]
+=
1
;
if
(
m_currentIndex
[
l_cpt
]
==
m_ramps
[
l_cpt
].
capacity
())
{
DEBUG_STREAM
<<
"Ramp finished for channel"
<<
l_cpt
<<
endl
;
m_currentIndex
[
l_cpt
]
=
-
1
;
m_initials
[
l_cpt
]
=
m_channels
[
l_cpt
];
m_ramps
[
l_cpt
].
clear
();
...
...
@@ -283,14 +284,9 @@ void SingleShotAOManager::set_channel(ChannelId_t p_chIdx, double p_val)
}
// ============================================================================
// SingleShotAOManager::write_channel ()
// SingleShotAOManager::write_channel
_direct
()
// ============================================================================
void
SingleShotAOManager
::
write_channel
(
ChannelId_t
p_chIdx
,
double
p_val
)
{
DEBUG_STREAM
<<
"write_channel "
<<
p_chIdx
<<
" : "
<<
p_val
<<
endl
;
// if the speed is 0, write the value directly and skip ramp
if
(
m_speeds
[
p_chIdx
]
==
0.0
||
!
m_enable_ramps
)
void
SingleShotAOManager
::
write_channel_direct
(
ChannelId_t
p_chIdx
,
double
p_val
)
{
try
{
...
...
@@ -298,7 +294,7 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val)
m_ssao
->
write_scaled_channel
((
adl
::
ChanId
)
p_chIdx
,
p_val
);
m_channels
[
p_chIdx
]
=
p_val
;
m_initials
[
p_chIdx
]
=
p_val
;
DEBUG_STREAM
<<
"
Speed is 0, w
riting directly the value"
<<
std
::
endl
;
DEBUG_STREAM
<<
"
W
riting directly the value"
<<
std
::
endl
;
}
catch
(
const
asl
::
DAQException
&
de
)
{
...
...
@@ -308,42 +304,23 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val)
RETHROW_DEVFAILED
(
df
,
"DRIVER_FAILURE"
,
"could not write channel [caught asl::DAQException]"
,
"SingleShotAOManager::write_channel"
);
"SingleShotAOManager::write_channel
_direct
"
);
}
catch
(...)
{
ERROR_STREAM
<<
"SingleShotAOManager::write_channel::unknown exception caught"
<<
std
::
endl
;
ERROR_STREAM
<<
"SingleShotAOManager::write_channel
_direct
::unknown exception caught"
<<
std
::
endl
;
m_state
=
Tango
::
FAULT
;
THROW_DEVFAILED
(
"DRIVER_FAILURE"
,
"could not write channel [unknown error]"
,
"SingleShotAOManager::write_channel"
);
"SingleShotAOManager::write_channel
_direct
"
);
}
return
;
}
// if a ramp is running, error
if
(
m_isRunning
[
p_chIdx
])
{
THROW_DEVFAILED
(
"DEVICE_FAILURE"
,
"could not write channel : a ramp is still in progress on this channel"
,
"SingleShotAOManager::write_channel"
);
}
// if frequency = 0, error
if
(
m_frequency
==
0
)
{
THROW_DEVFAILED
(
"DRIVER_FAILURE"
,
"could not set a ramp on this channel. The frequency is 0"
,
"SingleShotAOManager::write_channel"
);
}
// if initial = channel, skip
if
(
m_initials
[
p_chIdx
]
==
p_val
)
// ============================================================================
// SingleShotAOManager::start_channel_ramp ()
// ============================================================================
void
SingleShotAOManager
::
start_channel_ramp
(
ChannelId_t
p_chIdx
,
double
p_val
)
{
DEBUG_STREAM
<<
"Initial value is the same as the given value, skipping"
<<
endl
;
return
;
}
// ramp determination
double
l_delta
=
p_val
-
m_initials
[
p_chIdx
];
bool
isDown
=
false
;
...
...
@@ -389,7 +366,47 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val)
m_ramps
[
p_chIdx
].
force_length
(
0
);
m_currentIndex
[
p_chIdx
]
=
0
;
m_ramps
[
p_chIdx
]
=
l_buffer
;
//m_channels[p_chIdx] = m_ramps[p_chIdx][0]; -- soso on ne met rien ici => à l'application
}
// ============================================================================
// SingleShotAOManager::write_channel ()
// ============================================================================
void
SingleShotAOManager
::
write_channel
(
ChannelId_t
p_chIdx
,
double
p_val
)
{
DEBUG_STREAM
<<
"write_channel "
<<
p_chIdx
<<
" : "
<<
p_val
<<
endl
;
// if the speed is 0, write the value directly and skip ramp
if
(
m_speeds
[
p_chIdx
]
==
0.0
||
!
m_enable_ramps
)
{
write_channel_direct
(
p_chIdx
,
p_val
);
return
;
}
// if a ramp is running, error
if
(
m_isRunning
[
p_chIdx
])
{
THROW_DEVFAILED
(
"DEVICE_FAILURE"
,
"could not write channel : a ramp is still in progress on this channel"
,
"SingleShotAOManager::write_channel"
);
}
// if frequency = 0, error
if
(
m_frequency
==
0
)
{
THROW_DEVFAILED
(
"DRIVER_FAILURE"
,
"could not set a ramp on this channel. The frequency is 0"
,
"SingleShotAOManager::write_channel"
);
}
// if initial = channel, skip
if
(
m_initials
[
p_chIdx
]
==
p_val
)
{
DEBUG_STREAM
<<
"Initial value is the same as the given value, skipping"
<<
endl
;
return
;
}
// Create and start a ramp
start_channel_ramp
(
p_chIdx
,
p_val
);
}
// ============================================================================
...
...
This diff is collapsed.
Click to expand it.
src/SingleShotAOManager.h
+
6
−
0
View file @
5551cf17
...
...
@@ -59,6 +59,12 @@ public:
//- write channel
void
write_channel
(
ChannelId_t
p_chIdx
,
double
p_val
);
//- write a channel directly (without ramp)
void
write_channel_direct
(
ChannelId_t
p_chIdx
,
double
p_val
);
//- create and start a ramp for channel
void
start_channel_ramp
(
ChannelId_t
p_chIdx
,
double
p_val
);
//- change period
void
write_frequency
(
double
p_frequency
);
...
...
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