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
a6daeef3
Commit
a6daeef3
authored
4 months ago
by
Alexandre MALFREYT
Browse files
Options
Downloads
Patches
Plain Diff
refactor: improve code readability and structure in SingleShotAOManager
parent
d4c1f252
No related branches found
No related tags found
2 merge requests
!4
develop -> main
,
!2
[CTRLRFC-1594] Apply memorized dynamic attributes at init
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/SingleShotAOManager.cpp
+123
-124
123 additions, 124 deletions
src/SingleShotAOManager.cpp
with
123 additions
and
124 deletions
src/SingleShotAOManager.cpp
+
123
−
124
View file @
a6daeef3
...
...
@@ -190,12 +190,15 @@ void SingleShotAOManager::process_message (yat::Message& msg)
//- not used in this example
}
break
;
//- UNHANDLED MSG --------------------
default
:
{
DEBUG_STREAM
<<
"SingleShotAOManager::handle_message::unhandled msg type received"
<<
std
::
endl
;
break
;
}
}
}
// ============================================================================
// SingleShotAOManager::periodic_job_i ()
...
...
@@ -206,8 +209,12 @@ void SingleShotAOManager::periodic_job_i()
for
(
unsigned
int
l_cpt
=
0
;
l_cpt
<
m_nb_chan
;
l_cpt
++
)
{
// test if a ramp step must occur
if
(
m_currentIndex
[
l_cpt
]
!
=
-
1
)
if
(
m_currentIndex
[
l_cpt
]
=
=
-
1
)
{
m_isRunning
[
l_cpt
]
=
false
;
continue
;
}
m_isRunning
[
l_cpt
]
=
true
;
double
l_val
=
0
;
l_val
=
m_ramps
[
l_cpt
][
m_currentIndex
[
l_cpt
]];
...
...
@@ -246,11 +253,6 @@ void SingleShotAOManager::periodic_job_i()
m_ramps
[
l_cpt
].
clear
();
}
}
else
{
m_isRunning
[
l_cpt
]
=
false
;
}
}
}
// ============================================================================
...
...
@@ -266,8 +268,9 @@ double SingleShotAOManager::get_channel(ChannelId_t p_chIdx)
// ============================================================================
void
SingleShotAOManager
::
write_channel
(
ChannelId_t
p_chIdx
,
double
p_val
)
{
DEBUG_STREAM
<<
"write_channel
:
"
<<
p_chIdx
<<
" : "
<<
p_val
<<
" : "
<<
endl
;
DEBUG_STREAM
<<
"write_channel "
<<
p_chIdx
<<
" : "
<<
p_val
<<
endl
;
// if the speed is 0, write the value directly
if
(
m_speeds
[
p_chIdx
]
==
0.0
)
{
try
...
...
@@ -276,6 +279,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, writing directly the value"
<<
endl
;
}
catch
(
const
asl
::
DAQException
&
de
)
{
...
...
@@ -295,15 +299,18 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val)
"could not write channel [unknown error]"
,
"SingleShotAOManager::write_channel"
);
}
return
;
}
else
{
// check if a ramp is not running
if
(
!
m_isRunning
[
p_chIdx
])
{
// check if initial = channel
if
(
m_initials
[
p_chIdx
]
!=
p_val
)
// if a ramp is not 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"
,
...
...
@@ -311,6 +318,13 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val)
"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
;
}
// ramp determination
double
l_delta
=
p_val
-
m_initials
[
p_chIdx
];
bool
isDown
=
false
;
...
...
@@ -328,18 +342,12 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val)
l_buffer
.
force_length
(
ramp_size
);
// check if ramp step is integer or not
bool
isDeltaNotInt
=
false
;
if
(
ramp_size
!=
((
size_t
)(
floor
(
l_delta
))))
{
isDeltaNotInt
=
true
;
}
bool
isDeltaNotInt
=
(
ramp_size
!=
((
size_t
)(
floor
(
l_delta
))));
DEBUG_STREAM
<<
"Real ramp steps number : "
<<
ramp_size
<<
endl
;
for
(
unsigned
int
l_cpt
=
0
;
l_cpt
<
ramp_size
;
l_cpt
++
)
{
if
((
l_cpt
==
(
ramp_size
-
1
))
&&
(
isDeltaNotInt
))
if
((
l_cpt
==
(
ramp_size
-
1
))
&&
(
isDeltaNotInt
))
{
// add the setpoint value at the end of table
l_buffer
[
l_cpt
]
=
p_val
;
...
...
@@ -364,15 +372,6 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val)
m_ramps
[
p_chIdx
]
=
l_buffer
;
//m_channels[p_chIdx] = m_ramps[p_chIdx][0]; -- soso on ne met rien ici => à l'application
}
}
else
{
THROW_DEVFAILED
(
"DEVICE_FAILURE"
,
"could not write channel : a ramp is still in progress on this channel"
,
"SingleShotAOManager::write_channel"
);
}
}
}
// ============================================================================
// SingleShotAOManager::get_initial ()
...
...
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