Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
  • release_0_1
  • release_1_0_0
  • release_1_0_1
  • release_1_0_2
  • release_1_0_3
  • release_1_0_4
  • release_2_0_0
  • release_2_0_1
  • release_2_0_2
  • release_2_0_4
  • release_2_1_0
  • v0
13 results

Target

Select target project
  • software-control-system/tango-devices/inputoutput/adlink/singleshotao
1 result
Select Git revision
  • main
  • release_0_1
  • release_1_0_0
  • release_1_0_1
  • release_1_0_2
  • release_1_0_3
  • release_1_0_4
  • release_2_0_0
  • release_2_0_1
  • release_2_0_2
  • release_2_0_4
  • release_2_1_0
  • v0
13 results
Show changes
Commits on Source (5)
...@@ -231,6 +231,30 @@ void SingleShotAO::init_device() ...@@ -231,6 +231,30 @@ void SingleShotAO::init_device()
//- trace/profile this method //- trace/profile this method
yat4tango::TraceHelper t("SingleShotAO::init_device", this); yat4tango::TraceHelper t("SingleShotAO::init_device", this);
// construct the AO manager
//--------------------------------------------
try
{
m_manager = new SingleShotAOManager(this);
}
catch (...)
{
ERROR_STREAM << "initialization failed - failed to create manager" << std::endl;
m_currStatus = "initialization failed [failed to create manager]. See log for details";
m_state = Tango::FAULT;
return;
}
// test the manager
if (!m_manager)
{
ERROR_STREAM << "initialization failed - the manager is not created" << std::endl;
m_currStatus = "initialization failed [the manager is not created]. See log for details";
m_state = Tango::FAULT;
return;
}
// Initialise variables to default values // Initialise variables to default values
//-------------------------------------------- //--------------------------------------------
...@@ -253,8 +277,15 @@ void SingleShotAO::init_device() ...@@ -253,8 +277,15 @@ void SingleShotAO::init_device()
ERROR_STREAM << "SingleShotAO::init_device::Tango::DevFailed exception caught " ERROR_STREAM << "SingleShotAO::init_device::Tango::DevFailed exception caught "
<< "while trying to read device properties from TANGO database" << "while trying to read device properties from TANGO database"
<< std::endl; << std::endl;
ERROR_STREAM << df << std::endl; std::string error_msg = df.errors[0].desc;
m_currStatus = "Failed to get property. See log for details"; std::istringstream error_stream(error_msg);
std::string line;
std::getline(error_stream, line); // Read the first line
ERROR_STREAM << line << std::endl;
while (std::getline(error_stream, line)) { // Read the rest of the lines
ERROR_STREAM << " - " << line << std::endl;
}
m_currStatus = error_msg;
m_state = Tango::FAULT; m_state = Tango::FAULT;
return; return;
} }
...@@ -320,29 +351,6 @@ void SingleShotAO::init_device() ...@@ -320,29 +351,6 @@ void SingleShotAO::init_device()
INFO_STREAM << "Board has " << m_nb_chan << " channels" << endl; INFO_STREAM << "Board has " << m_nb_chan << " channels" << endl;
// construct the AO manager
//--------------------------------------------
try
{
m_manager = new SingleShotAOManager(this);
}
catch (...)
{
ERROR_STREAM << "initialization failed - failed to create manager" << std::endl;
m_currStatus = "initialization failed [failed to create manager]. See log for details";
m_state = Tango::FAULT;
return;
}
// test the manager
if (!m_manager)
{
ERROR_STREAM << "initialization failed - the manager is not created" << std::endl;
m_currStatus = "initialization failed [the manager is not created]. See log for details";
m_state = Tango::FAULT;
return;
}
// get frequency value in database // get frequency value in database
//-------------------------------------------- //--------------------------------------------
...@@ -670,6 +678,7 @@ void SingleShotAO::get_device_property() ...@@ -670,6 +678,7 @@ void SingleShotAO::get_device_property()
dev_prop.push_back(Tango::DbDatum("EnableRamps")); dev_prop.push_back(Tango::DbDatum("EnableRamps"));
dev_prop.push_back(Tango::DbDatum("OutputMemorizedChannelsAtInit")); dev_prop.push_back(Tango::DbDatum("OutputMemorizedChannelsAtInit"));
// Call database and extract values // Call database and extract values
//-------------------------------------------- //--------------------------------------------
if (Tango::Util::instance()->_UseDb==true) if (Tango::Util::instance()->_UseDb==true)
...@@ -688,7 +697,11 @@ void SingleShotAO::get_device_property() ...@@ -688,7 +697,11 @@ void SingleShotAO::get_device_property()
else { 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); def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> boardNum; if (def_prop.is_empty() == false)
{
def_prop >> boardNum_default;
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; if (dev_prop[i].is_empty() == false) dev_prop[i] >> boardNum;
...@@ -701,7 +714,11 @@ void SingleShotAO::get_device_property() ...@@ -701,7 +714,11 @@ void SingleShotAO::get_device_property()
else { 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); def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> boardType; if (def_prop.is_empty() == false)
{
def_prop >> boardType_default;
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; if (dev_prop[i].is_empty() == false) dev_prop[i] >> boardType;
...@@ -714,7 +731,11 @@ void SingleShotAO::get_device_property() ...@@ -714,7 +731,11 @@ void SingleShotAO::get_device_property()
else { else {
// Try to initialize EnableRamps from default device value // Try to initialize EnableRamps from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name); def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty() == false) def_prop >> enableRamps; if (def_prop.is_empty() == false)
{
def_prop >> enableRamps_default;
def_prop >> enableRamps;
}
} }
// And try to extract EnableRamps value from database // And try to extract EnableRamps value from database
if (dev_prop[i].is_empty() == false) dev_prop[i] >> enableRamps; if (dev_prop[i].is_empty() == false) dev_prop[i] >> enableRamps;
...@@ -727,59 +748,61 @@ void SingleShotAO::get_device_property() ...@@ -727,59 +748,61 @@ void SingleShotAO::get_device_property()
else { else {
// Try to initialize OutputMemorizedChannelsAtInit from default device value // Try to initialize OutputMemorizedChannelsAtInit from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name); def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty() == false) def_prop >> outputMemorizedChannelsAtInit; if (def_prop.is_empty() == false)
{
def_prop >> outputMemorizedChannelsAtInit_default;
def_prop >> outputMemorizedChannelsAtInit;
}
} }
// And try to extract OutputMemorizedChannelsAtInit value from database // And try to extract OutputMemorizedChannelsAtInit value from database
if (dev_prop[i].is_empty() == false) dev_prop[i] >> outputMemorizedChannelsAtInit; if (dev_prop[i].is_empty() == false) dev_prop[i] >> outputMemorizedChannelsAtInit;
INFO_STREAM << "OutputMemorizedChannelsAtInit parsed: " << (outputMemorizedChannelsAtInit ? "true" : "false") << endl; INFO_STREAM << "OutputMemorizedChannelsAtInit parsed: " << (outputMemorizedChannelsAtInit ? "true" : "false") << endl;
// 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;
yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, boardNum, "BoardNum"); yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, boardNum_default, "BoardNum");
yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, boardType, "BoardType"); yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, boardType_default, "BoardType");
yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, enableRamps, "EnableRamps"); yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, enableRamps_default, "EnableRamps");
yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, outputMemorizedChannelsAtInit, "OutputMemorizedChannelsAtInit"); yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, outputMemorizedChannelsAtInit_default, "OutputMemorizedChannelsAtInit");
// Check critical properties being valid // Check critical properties being valid
//-------------------------------------------- //--------------------------------------------
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 << "Critical properties are missing or invalid:" << endl;
//- <BoardNum> ----------------------- //- <BoardNum> -----------------------
Tango::DbDatum &boardNumDatum = Tango::DbDatum("BoardNum"); // Case 1 (error): boardNum is set to the default value in the database
std::string defaultBoardNum_str; if (boardNum == boardNum_default)
def_prop = ds_class->get_default_device_property(boardNumDatum.name); {
if (def_prop.is_empty() == false) def_prop >> defaultBoardNum_str; errorMessages << "Device property <BoardNum> is not set (default value " << boardNum_default << " needs to be replaced)" << endl;
Tango::DevShort defaultBoardNum = atoi(defaultBoardNum_str.c_str());
if (boardNum == defaultBoardNum)
{
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> -----------------------
Tango::DbDatum &boardTypeDatum = Tango::DbDatum("BoardType"); // Case 1 (error): boardType is set to the default value in the database
std::string defaultBoardType; if (boardType == boardType_default || boardType == "")
def_prop = ds_class->get_default_device_property(boardTypeDatum.name); {
if (def_prop.is_empty() == false) def_prop >> defaultBoardType; errorMessages << "Device property <BoardType> is not set (default value " << boardType_default << " needs to be replaced)" << endl;
if (boardType == defaultBoardType)
{
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 +815,17 @@ void SingleShotAO::get_device_property() ...@@ -792,15 +815,17 @@ 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;
......
...@@ -121,10 +121,26 @@ public : ...@@ -121,10 +121,26 @@ public :
//@} //@}
/** /**
* @name Device properties * @name Device properties default values
* Device property member data. * Device properties default values.
*/ */
//@{ //@{
/**
* Default value for boardNum property
*/
Tango::DevShort boardNum_default;
/**
* Default value for boardType property
*/
string boardType_default;
/**
* Default value for enableRamps property
*/
Tango::DevBoolean enableRamps_default;
/**
* Default value for outputMemorizedChannelsAtInit property
*/
Tango::DevBoolean outputMemorizedChannelsAtInit_default;
//@} //@}
/**@name Constructors /**@name Constructors
......