Changeset 92:6bce4856b4ba in finroc_plugins_parameters
- Timestamp:
- 17.05.2020 07:49:22 (8 months ago)
- Branch:
- 17.03
- Phase:
- public
- Location:
- internal
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
internal/tParameterInfo.cpp
r90 r92 161 161 } 162 162 163 void tParameterInfo::LoadValue(bool ignore_ready) 164 { 165 core::tAbstractPort* ann = this->GetAnnotated<core::tAbstractPort>(); 166 { 167 rrlib::thread::tLock lock(ann->GetStructureMutex()); 168 if (ann && (ignore_ready || ann->IsReady())) 163 void tParameterInfo::LoadValue(bool ignore_ready, const std::string& alternative_config_entry) 164 { 165 core::tFrameworkElement* annotated = this->GetAnnotated<core::tFrameworkElement>(); 166 if ((!annotated) || (!(ignore_ready || annotated->IsReady()))) 167 { 168 return; 169 } 170 171 rrlib::thread::tLock lock(annotated->GetStructureMutex()); 172 if (annotated->GetFlag(core::tFrameworkElementFlag::COMPOSITE_PORT)) // == INTERFACE flag in case this is not a port 173 { 174 auto& config_entry = alternative_config_entry.length() ? alternative_config_entry : GetConfigEntry(); 175 if (config_entry.length()) 176 { 177 // Load values of unconfigured child parameters also 178 for (auto child = annotated->ChildPortsBegin(); child != annotated->ChildPortsEnd(); ++child) 179 { 180 tParameterInfo* child_info = child->GetAnnotation<tParameterInfo>(); 181 if (child_info && child_info->Settings().empty() && (ignore_ready || child->IsReady())) 182 { 183 child_info->LoadValue(ignore_ready, config_entry + "/" + child->GetName()); 184 } 185 } 186 } 187 } 188 else if (annotated->IsPort() && data_ports::IsDataFlowType(static_cast<core::tAbstractPort&>(*annotated).GetDataType())) 189 { 190 auto& abstract_port = static_cast<data_ports::common::tAbstractDataPort&>(*annotated); 169 191 { 170 192 // command line option … … 175 197 if (arg.length() > 0) 176 198 { 177 if (data_ports::IsDataFlowType(a nn->GetDataType()))199 if (data_ports::IsDataFlowType(abstract_port.GetDataType())) 178 200 { 179 201 rrlib::serialization::tStringInputStream sis(arg); 180 data_ports::tGenericPort port = data_ports::tGenericPort::Wrap( *ann);202 data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(abstract_port); 181 203 data_ports::tPortDataPointer<rrlib::rtti::tGenericObject> buffer = port.GetUnusedBuffer(); 182 204 try … … 186 208 if (error.size() > 0) 187 209 { 188 FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", a nn, "' from command line argument '", arg, "': ", error);210 FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", abstract_port, "' from command line argument '", arg, "': ", error); 189 211 } 190 212 return; … … 192 214 catch (const std::exception& e) 193 215 { 194 FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", a nn, "' from command line argument '", arg, "': ", e);216 FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", abstract_port, "' from command line argument '", arg, "': ", e); 195 217 } 196 218 } … … 203 225 204 226 // config file entry 205 tConfigFile* cf = tConfigFile::Find( *ann);206 auto& config_entry = GetConfigEntry();227 tConfigFile* cf = tConfigFile::Find(abstract_port); 228 auto& config_entry = alternative_config_entry.length() ? alternative_config_entry : GetConfigEntry(); 207 229 if (cf && config_entry.length() > 0) 208 230 { 209 std::string full_config_entry = tConfigNode::GetFullConfigEntry( *ann, config_entry);231 std::string full_config_entry = tConfigNode::GetFullConfigEntry(abstract_port, config_entry); 210 232 if (cf->HasEntry(full_config_entry)) 211 233 { 212 234 #ifdef _LIB_RRLIB_XML_PRESENT_ 213 235 rrlib::xml::tNode& node = cf->GetEntry(full_config_entry, false); 214 if (data_ports::IsDataFlowType(a nn->GetDataType()))215 { 216 data_ports::tGenericPort port = data_ports::tGenericPort::Wrap( *ann);236 if (data_ports::IsDataFlowType(abstract_port.GetDataType())) 237 { 238 data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(abstract_port); 217 239 data_ports::tPortDataPointer<rrlib::rtti::tGenericObject> buffer = port.GetUnusedBuffer(); 218 240 … … 223 245 if (error.size() > 0) 224 246 { 225 FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", a nn, "' from config entry '", full_config_entry, "': ", error);247 FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", abstract_port, "' from config entry '", full_config_entry, "': ", error); 226 248 } 227 249 return; … … 229 251 catch (const std::exception& e) 230 252 { 231 FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", a nn, "' from config entry '", full_config_entry, "': ", e);253 FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", abstract_port, "' from config entry '", full_config_entry, "': ", e); 232 254 } 233 255 } … … 244 266 if (finstruct_default.length() > 0) 245 267 { 246 if (data_ports::IsDataFlowType(a nn->GetDataType()))268 if (data_ports::IsDataFlowType(abstract_port.GetDataType())) 247 269 { 248 270 rrlib::serialization::tStringInputStream sis(finstruct_default); 249 data_ports::tGenericPort port = data_ports::tGenericPort::Wrap( *ann);271 data_ports::tGenericPort port = data_ports::tGenericPort::Wrap(abstract_port); 250 272 data_ports::tPortDataPointer<rrlib::rtti::tGenericObject> buffer = port.GetUnusedBuffer(); 251 273 … … 256 278 if (error.size() > 0) 257 279 { 258 FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", a nn, "' from finstruct default '", finstruct_default, "': ", error);280 FINROC_LOG_PRINT(WARNING, "Failed to load parameter '", abstract_port, "' from finstruct default '", finstruct_default, "': ", error); 259 281 } 260 282 return; … … 262 284 catch (const std::exception& e) 263 285 { 264 FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", a nn, "' from finstruct default '", finstruct_default, "': ", e);286 FINROC_LOG_PRINT(ERROR, "Failed to load parameter '", abstract_port, "' from finstruct default '", finstruct_default, "': ", e); 265 287 } 266 288 } -
internal/tParameterInfo.h
r89 r92 103 103 104 104 /*! 105 * Clear all settings 106 */ 107 void ClearSettings() 108 { 109 settings.clear(); 110 } 111 112 /*! 105 113 * \return Command line option to set this parameter 106 114 * (set by outer-most finstructable group) … … 146 154 * 147 155 * \param ignore_ready Ignore ready flag? 148 */ 149 void LoadValue(bool ignore_ready = false); 156 * \param alternative_config_entry If set, this config entry is used for loading (instead of any set in this object) 157 */ 158 void LoadValue(bool ignore_ready = false, const std::string& alternative_config_entry = ""); 150 159 151 160 /*!
Note: See TracChangeset
for help on using the changeset viewer.