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
7b0db877
Commit
7b0db877
authored
2 months ago
by
Alexandre MALFREYT
Browse files
Options
Downloads
Patches
Plain Diff
fix: enhance error handling and add comments in get_device_property()
parent
22905c6e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/SingleShotAO.cpp
+15
-5
15 additions, 5 deletions
src/SingleShotAO.cpp
with
15 additions
and
5 deletions
src/SingleShotAO.cpp
+
15
−
5
View file @
7b0db877
...
@@ -736,6 +736,8 @@ void SingleShotAO::get_device_property()
...
@@ -736,6 +736,8 @@ void SingleShotAO::get_device_property()
// Create properties if empty and set default values
// Create properties if empty and set default values
//--------------------------------------------
//--------------------------------------------
DEBUG_STREAM
<<
"Creating properties if empty"
<<
endl
;
DEBUG_STREAM
<<
"Creating properties if empty"
<<
endl
;
// boardNum, boardType, enableRamps and outputMemorizedChannelsAtInit variables
// contain the default values at this point if the properties are not set in the database.
yat4tango
::
PropertyHelper
::
create_property_if_empty
(
this
,
dev_prop
,
boardNum
,
"BoardNum"
);
yat4tango
::
PropertyHelper
::
create_property_if_empty
(
this
,
dev_prop
,
boardNum
,
"BoardNum"
);
yat4tango
::
PropertyHelper
::
create_property_if_empty
(
this
,
dev_prop
,
boardType
,
"BoardType"
);
yat4tango
::
PropertyHelper
::
create_property_if_empty
(
this
,
dev_prop
,
boardType
,
"BoardType"
);
yat4tango
::
PropertyHelper
::
create_property_if_empty
(
this
,
dev_prop
,
enableRamps
,
"EnableRamps"
);
yat4tango
::
PropertyHelper
::
create_property_if_empty
(
this
,
dev_prop
,
enableRamps
,
"EnableRamps"
);
...
@@ -746,8 +748,11 @@ void SingleShotAO::get_device_property()
...
@@ -746,8 +748,11 @@ void SingleShotAO::get_device_property()
DEBUG_STREAM
<<
"Checking if critical properties are valid:"
<<
endl
;
DEBUG_STREAM
<<
"Checking if critical properties are valid:"
<<
endl
;
critical_properties_missing
=
false
;
critical_properties_missing
=
false
;
yat
::
OSStream
errorMessages
;
yat
::
OSStream
errorMessages
;
errorMessages
<<
"
\n
Critical properties are missing or invalid:
\n
"
<<
endl
;
//- <BoardNum> -----------------------
//- <BoardNum> -----------------------
// Case 1 (error): boardNum is set to the default value in the database
// (compare the current value with the default value)
Tango
::
DbDatum
&
boardNumDatum
=
Tango
::
DbDatum
(
"BoardNum"
);
Tango
::
DbDatum
&
boardNumDatum
=
Tango
::
DbDatum
(
"BoardNum"
);
std
::
string
defaultBoardNum_str
;
std
::
string
defaultBoardNum_str
;
def_prop
=
ds_class
->
get_default_device_property
(
boardNumDatum
.
name
);
def_prop
=
ds_class
->
get_default_device_property
(
boardNumDatum
.
name
);
...
@@ -756,20 +761,24 @@ void SingleShotAO::get_device_property()
...
@@ -756,20 +761,24 @@ void SingleShotAO::get_device_property()
if
(
boardNum
==
defaultBoardNum
)
if
(
boardNum
==
defaultBoardNum
)
{
{
errorMessages
<<
"Device property <BoardNum> is not set (default value "
<<
defaultBoardNum
<<
" needs to be replaced)"
<<
endl
;
errorMessages
<<
"Device property <BoardNum> is not set (default value "
<<
defaultBoardNum
<<
" needs to be replaced)"
<<
endl
;
ERROR_STREAM
<<
"Device property <BoardNum> is not set (default value "
<<
defaultBoardNum
<<
" needs to be replaced)"
<<
endl
;
critical_properties_missing
=
true
;
critical_properties_missing
=
true
;
}
}
// Case 2 (error): boardNum is set to a value outside the valid range
else
if
(
boardNum
<
0
||
boardNum
>
7
)
else
if
(
boardNum
<
0
||
boardNum
>
7
)
{
{
boardNum
=
0
;
boardNum
=
0
;
errorMessages
<<
"Device property <BoardNum> is invalid. Valid range is [0..7]"
<<
endl
;
errorMessages
<<
"Device property <BoardNum> is invalid. Valid range is [0..7]"
<<
endl
;
ERROR_STREAM
<<
"Device property <BoardNum> is invalid. Valid range is [0..7]"
<<
endl
;
critical_properties_missing
=
true
;
critical_properties_missing
=
true
;
}
else
{
}
// Case 3 (ok): boardNum is set to a valid value
else
{
INFO_STREAM
<<
"BoardNum resolved to "
<<
boardNum
<<
endl
;
INFO_STREAM
<<
"BoardNum resolved to "
<<
boardNum
<<
endl
;
}
}
//- <BoardType> -----------------------
//- <BoardType> -----------------------
// Case 1 (error): boardType is set to the default value in the database
// (compare the current value with the default value)
Tango
::
DbDatum
&
boardTypeDatum
=
Tango
::
DbDatum
(
"BoardType"
);
Tango
::
DbDatum
&
boardTypeDatum
=
Tango
::
DbDatum
(
"BoardType"
);
std
::
string
defaultBoardType
;
std
::
string
defaultBoardType
;
def_prop
=
ds_class
->
get_default_device_property
(
boardTypeDatum
.
name
);
def_prop
=
ds_class
->
get_default_device_property
(
boardTypeDatum
.
name
);
...
@@ -777,9 +786,9 @@ void SingleShotAO::get_device_property()
...
@@ -777,9 +786,9 @@ void SingleShotAO::get_device_property()
if
(
boardType
==
defaultBoardType
)
if
(
boardType
==
defaultBoardType
)
{
{
errorMessages
<<
"Device property <BoardType> is not set (default value "
<<
defaultBoardType
<<
" needs to be replaced)"
<<
endl
;
errorMessages
<<
"Device property <BoardType> is not set (default value "
<<
defaultBoardType
<<
" needs to be replaced)"
<<
endl
;
ERROR_STREAM
<<
"Device property <BoardType> is not set (default value "
<<
defaultBoardType
<<
" needs to be replaced)"
<<
endl
;
critical_properties_missing
=
true
;
critical_properties_missing
=
true
;
}
}
// Case 2 (ok): boardType is set to a valid
else
if
(
boardType
==
"MAO_6208"
)
else
if
(
boardType
==
"MAO_6208"
)
{
{
boardType
=
k6208_BOARD_TYPE
;
boardType
=
k6208_BOARD_TYPE
;
...
@@ -792,15 +801,16 @@ void SingleShotAO::get_device_property()
...
@@ -792,15 +801,16 @@ void SingleShotAO::get_device_property()
boardTypeId
=
adl
::
PCI6216
;
boardTypeId
=
adl
::
PCI6216
;
INFO_STREAM
<<
"BoardType resolved to PCI6216"
<<
endl
;
INFO_STREAM
<<
"BoardType resolved to PCI6216"
<<
endl
;
}
}
// Case 3 (error): boardType is set to an invalid value
else
else
{
{
boardType
=
kDEFAULT_BOARD_TYPE
;
boardType
=
kDEFAULT_BOARD_TYPE
;
boardTypeId
=
adl
::
PCI6208
;
boardTypeId
=
adl
::
PCI6208
;
errorMessages
<<
"Device property <BoardType> is invalid [supported hw: MAO_6208 or MAO_6216]"
<<
endl
;
errorMessages
<<
"Device property <BoardType> is invalid [supported hw: MAO_6208 or MAO_6216]"
<<
endl
;
ERROR_STREAM
<<
"Device property <BoardType> is invalid [supported hw: MAO_6208 or MAO_6216]"
<<
endl
;
critical_properties_missing
=
true
;
critical_properties_missing
=
true
;
}
}
// If any critical property is missing or invalid, throw an exception
if
(
critical_properties_missing
)
if
(
critical_properties_missing
)
{
{
DEBUG_STREAM
<<
"Critical properties are missing, throwing exception."
<<
endl
;
DEBUG_STREAM
<<
"Critical properties are missing, throwing exception."
<<
endl
;
...
...
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