29#include <Ice/Properties.h>
30#include <IceUtil/UUID.h>
32#include <SimoxUtility/algorithm/string/string_tools.h>
49 uuid = IceUtil::generateUUID();
55 std::string groupFilepathString =
57 std::string profileName =
67 throw LocalException(
"Could not find profile '" + profileName +
"'");
73 Ice::StringSeq includePaths;
77 for (
const std::string& projectName : packages)
79 if (projectName.empty())
85 auto pathsString = project.getIncludePaths();
86 Ice::StringSeq projectIncludePaths = simox::alg::split(pathsString,
";,");
88 includePaths.end(), projectIncludePaths.begin(), projectIncludePaths.end());
94 reader->readXml(std::filesystem::path(groupFilepathString));
96 auto extraProperties = reader->getConfigurationFileContent();
97 if (!extraProperties.empty())
100 std::filesystem::path temp =
101 std::filesystem::temp_directory_path() / std::to_string(std::random_device{}());
103 std::ofstream file(temp.string().c_str());
104 file << extraProperties;
106 props->load(temp.string());
107 std::filesystem::remove(temp);
108 for (
auto& prop : props->getPropertiesForPrefix(
""))
117 std::string libPath =
"lib" + reader->getGroupName() +
".so";
120 std::vector<std::string> libpathList = simox::alg::split(libPaths,
";");
122 std::string libPathNextGen =
123 "lib" + reader->getPackageName() +
"_" + reader->getGroupName() +
".so";
132 libPathNextGen, libPathNextGen, libpathList,
false))
140 ARMARX_ERROR <<
"Could not find state user code lib file `" << libPath <<
"` or `"
141 << libPathNextGen <<
"`";
151 <<
"\nAvailable classes are:\n"
167 obj->forceComponentCreatedByComponentCreateFunc();
168 StatechartContextPtr::dynamicCast(
offerer)->setReportingTopic(
172 !obj->getProperty<
bool>(
"EnableProfiling").isSet())
174 obj->enableProfiler(
true);
192 simox::alg::trim(state);
204 return "XMLStateComponent";
218 ARMARX_ERROR <<
"Could not find state user code lib file: " << libPath;
245 bool useExisitingPrx)
249 RemoteStateOffererInterfacePrx off =
250 getArmarXManager()->getIceManager()->getProxy<RemoteStateOffererInterfacePrx>(
253 off->createRemoteStateInstance(stateClassName,
nullptr,
"TopLevel", stateClassName);
254 off->callRemoteState(stateId, StringVariantContainerBaseMap());
255 stateIDStartedUsingExisitingPrx = stateId;
260 context->getObjectScheduler()->waitForObjectState(eManagedIceObjectStarted);
261 RemoteStateOffererIceBasePtr off = RemoteStateOffererIceBasePtr::dynamicCast(
offerer);
263 off->createRemoteStateInstance(stateClassName,
nullptr,
"TopLevel", stateClassName);
264 off->callRemoteState(stateId, StringVariantContainerBaseMap());
273 RemoteStateOffererInterfacePrx off =
274 getArmarXManager()->getIceManager()->getProxy<RemoteStateOffererInterfacePrx>(
276 if (stateIDStartedUsingExisitingPrx != -1 &&
277 off->getAvailableStateInstances().count(stateIDStartedUsingExisitingPrx) != 0)
279 ARMARX_DEBUG <<
"Exiting state with id: " << stateIDStartedUsingExisitingPrx
280 <<
" which has been started using already running proxy.";
281 off->breakActiveSubstateRemotely(stateIDStartedUsingExisitingPrx,
nullptr);
282 off->breakRemoteState(stateIDStartedUsingExisitingPrx,
nullptr);
283 off->removeInstance(stateIDStartedUsingExisitingPrx);
#define STATEOFFERERSUFFIX
static SharedPointerType fromName(const std::string &name, StatechartGroupXmlReaderPtr params)
static std::vector< std::string > getAvailableClasses()
static ApplicationPtr getInstance()
Retrieve shared pointer to the application object.
static const std::string & GetProjectName()
static const Ice::StringSeq & GetProjectDependencies()
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
static void RegisterKnownObjectFactoriesWithIce(const Ice::CommunicatorPtr &ic)
Registers all object factories that are known with Ice.
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
std::string getLibraryPaths() const
Returns the library paths seperated by semi-colons.
bool packageFound() const
Returns whether or not this package was found with cmake.
std::string getConfigDomain()
Retrieve config domain for this component as set in constructor.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
The DynamicLibrary class provides a mechanism to load libraries at runtime.
IceManagerPtr getIceManager() const
Returns the IceManager.
Ice::CommunicatorPtr getCommunicator() const
ArmarXManagerPtr getArmarXManager() const
Returns the ArmarX manager used to add and remove components.
Ice::PropertiesPtr getIceProperties() const
Returns the set of Ice properties.
bool tryAddProperty(const std::string &propertyName, const std::string &value)
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
static StatechartProfilesPtr ReadProfileFiles(const std::vector< std::string > &packages)
void onInitComponent() override
Pure virtual hook for the subclass.
StatechartProfilePtr selectedProfile
void createAndEnterInstance(const std::string &stateClassName, bool useExisitingPrx=false)
void onDisconnectComponent() override
Hook for subclass.
XMLStateOffererFactoryBasePtr offerer
std::map< std::string, DynamicLibraryPtr > libraries
void onConnectComponent() override
Pure virtual hook for the subclass.
PropertyDefinitionsPtr createPropertyDefinitions() override
StatechartProfilesPtr profiles
bool loadLib(std::string libPath)
std::string getDefaultName() const override
Retrieve default name of component.
This exception is thrown if an invalid value was specified for a property.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_VERBOSE
The logging level for verbose information.
Ice::PropertiesPtr createProperties()
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< StatechartContext > StatechartContextPtr
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
std::shared_ptr< StatechartGroupXmlReader > StatechartGroupXmlReaderPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< Component > ComponentPtr
Component smart pointer type.
std::shared_ptr< DynamicLibrary > DynamicLibraryPtr