From 915889e15d7f6e1d89442db101d42456127f3040 Mon Sep 17 00:00:00 2001 From: MALFREYT <alexandre.malfreyt@synchrotron-soleil.fr> Date: Fri, 21 Feb 2025 16:40:59 +0100 Subject: [PATCH] fix: rename get_device_properties back to get_device_property for consistency (+ add comments) --- src/SingleShotAO.cpp | 45 +++++++++++++++++++++----------------------- src/SingleShotAO.h | 2 +- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/SingleShotAO.cpp b/src/SingleShotAO.cpp index ee7b789..96a72ba 100755 --- a/src/SingleShotAO.cpp +++ b/src/SingleShotAO.cpp @@ -247,7 +247,7 @@ void SingleShotAO::init_device() //-------------------------------------------- try { - get_device_properties(); + get_device_property(); } catch (const Tango::DevFailed& df) { @@ -570,57 +570,52 @@ void SingleShotAO::init_device() //+---------------------------------------------------------------------------- // -// method : SingleShotAO::get_device_properties() +// method : SingleShotAO::get_device_property() // // description : Read the device properties from database. // //----------------------------------------------------------------------------- -void SingleShotAO::get_device_properties() +void SingleShotAO::get_device_property() { - // Initialize your default values here (if not done with POGO). - //------------------------------------------------------------------ - - // Read device properties from database.(Automatic code generation) + // Read device properties from database //------------------------------------------------------------------ Tango::DbData dev_prop; dev_prop.push_back(Tango::DbDatum("BoardNum")); dev_prop.push_back(Tango::DbDatum("BoardType")); - // Call database and extract values + // Call database and extract values //-------------------------------------------- - if (Tango::Util::instance()->_UseDb==true) + if (Tango::Util::instance()->_UseDb==true) { get_db_device()->get_property(dev_prop); - Tango::DbDatum def_prop, cl_prop; - SingleShotAOClass *ds_class = - (static_cast<SingleShotAOClass *>(get_device_class())); + } + Tango::DbDatum def_prop, cl_prop; + SingleShotAOClass *ds_class = (static_cast<SingleShotAOClass *>(get_device_class())); int i = -1; - // Try to initialize BoardNum from class property + // Try to initialize BoardNum from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> boardNum; else { - // Try to initialize BoardNum from default device value + // Try to initialize BoardNum from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> boardNum; } - // And try to extract BoardNum value from database + // And try to extract BoardNum value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> boardNum; - // Try to initialize BoardType from class property + // Try to initialize BoardType from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if (cl_prop.is_empty()==false) cl_prop >> boardType; else { - // Try to initialize BoardType from default device value + // Try to initialize BoardType from default device value def_prop = ds_class->get_default_device_property(dev_prop[i].name); if (def_prop.is_empty()==false) def_prop >> boardType; } - // And try to extract BoardType value from database + // And try to extract BoardType value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> boardType; - - - // End of Automatic code generation - //------------------------------------------------------------------ + // Check critical properties being present + //-------------------------------------------- critical_properties_missing = false; @@ -639,8 +634,11 @@ void SingleShotAO::get_device_properties() return; } + // Check critical properties being valid + //-------------------------------------------- + //- <BoardNum> ----------------------- - if (boardNum > 7) + if (boardNum < 0 || boardNum > 7) { boardNum = 0; ERROR_STREAM << "device property <BoardNum> is invalid. Valid range is [0..7]" << endl; @@ -665,7 +663,6 @@ void SingleShotAO::get_device_properties() ERROR_STREAM << "device property <BoardType> is invalid [supported hw: MAO_6208 or MAO_6216]" << endl; critical_properties_missing = true; } - } diff --git a/src/SingleShotAO.h b/src/SingleShotAO.h index 8e259d0..7faa182 100755 --- a/src/SingleShotAO.h +++ b/src/SingleShotAO.h @@ -219,7 +219,7 @@ public : /** * Read the device properties from database */ - void get_device_properties(); + void get_device_property(); //@} // Here is the end of the automatic code generation part -- GitLab