diff --git a/src/SingleShotAO.cpp b/src/SingleShotAO.cpp index e101a1274e0c06c12daaf61f8363e6fff3053593..b90b3c54ccdf129c0bb4838fcffaea1b6f19c94c 100755 --- a/src/SingleShotAO.cpp +++ b/src/SingleShotAO.cpp @@ -737,6 +737,8 @@ void SingleShotAO::get_device_property() // Create properties if empty and set default values //-------------------------------------------- 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, boardType, "BoardType"); yat4tango::PropertyHelper::create_property_if_empty(this, dev_prop, enableRamps, "EnableRamps"); @@ -747,8 +749,11 @@ void SingleShotAO::get_device_property() DEBUG_STREAM << "Checking if critical properties are valid:" << endl; critical_properties_missing = false; yat::OSStream errorMessages; + errorMessages << "\nCritical properties are missing or invalid:\n" << endl; //- <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"); std::string defaultBoardNum_str; def_prop = ds_class->get_default_device_property(boardNumDatum.name); @@ -757,20 +762,24 @@ void SingleShotAO::get_device_property() 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; } + // Case 2 (error): boardNum is set to a value outside the valid range else if (boardNum < 0 || boardNum > 7) { boardNum = 0; 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; - } else { + } + // Case 3 (ok): boardNum is set to a valid value + else + { INFO_STREAM << "BoardNum resolved to " << boardNum << endl; } //- <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"); std::string defaultBoardType; def_prop = ds_class->get_default_device_property(boardTypeDatum.name); @@ -778,9 +787,9 @@ void SingleShotAO::get_device_property() 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; } + // Case 2 (ok): boardType is set to a valid else if (boardType == "MAO_6208") { boardType = k6208_BOARD_TYPE; @@ -793,15 +802,16 @@ void SingleShotAO::get_device_property() boardTypeId = adl::PCI6216; INFO_STREAM << "BoardType resolved to PCI6216" << endl; } + // Case 3 (error): boardType is set to an invalid value else { boardType = kDEFAULT_BOARD_TYPE; boardTypeId = adl::PCI6208; 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; } + // If any critical property is missing or invalid, throw an exception if (critical_properties_missing) { DEBUG_STREAM << "Critical properties are missing, throwing exception." << endl;