Skip to content

Commit 4240783

Browse files
Added AMC Server Parameter Overrides, added Configuration API
1 parent 27d6dca commit 4240783

23 files changed

+630
-6
lines changed

ACT/LibMC.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,11 @@
838838
<param name="XMLString" type="string" pass="in" description="XML Configuration String." />
839839
</method>
840840

841+
<method name="SetParameterOverride" description="overrides a parameter with a certain value. Fails if parameter group or parameter does not exist. Fails if Value is not fitting the parameter type.">
842+
<param name="ParameterPath" type="string" pass="in" description="Path of the parameter. Example: main.configgroup.currentjob" />
843+
<param name="ParameterValue" type="string" pass="in" description="New Value of the parameter" />
844+
</method>
845+
841846
<method name="StartAllThreads" description="starts the threads for all the state machines.">
842847
</method>
843848

ACT/LibMCEnv.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,10 @@
290290
<error name="INVALIDREACTIONTIMEOUT" code="10250" description="Invalid reaction timeout." />
291291
<error name="COULDNOTSETREACTIONTIMEOUT" code="10251" description="Could not set reaction timeout." />
292292
<error name="MACHINECONFIGURATIONSCHEMATYPEALREADYREGISTERED" code="10252" description="Schema type already registered, but with a different name." />
293+
<error name="NOCONFIGURATIONVERSIONFOUND" code="10253" description="No configuration version found." />
294+
<error name="NOCONFIGURATIONVERSIONACTIVE" code="10254" description="No configuration version active." />
293295

294296

295-
296-
297-
298297
</errors>
299298

300299
<enum name="AlertLevel">

Framework/HeadersCore/CppDynamic/libmc_dynamic.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ typedef LibMCResult (*PLibMCMCContext_SetTempBasePathPtr) (LibMC_MCContext pMCCo
242242
*/
243243
typedef LibMCResult (*PLibMCMCContext_ParseConfigurationPtr) (LibMC_MCContext pMCContext, const char * pXMLString);
244244

245+
/**
246+
* overrides a parameter with a certain value. Fails if parameter group or parameter does not exist. Fails if Value is not fitting the parameter type.
247+
*
248+
* @param[in] pMCContext - MCContext instance.
249+
* @param[in] pParameterPath - Path of the parameter. Example: main.configgroup.currentjob
250+
* @param[in] pParameterValue - New Value of the parameter
251+
* @return error code or 0 (success)
252+
*/
253+
typedef LibMCResult (*PLibMCMCContext_SetParameterOverridePtr) (LibMC_MCContext pMCContext, const char * pParameterPath, const char * pParameterValue);
254+
245255
/**
246256
* starts the threads for all the state machines.
247257
*
@@ -430,6 +440,7 @@ typedef struct {
430440
PLibMCMCContext_RegisterLibraryPathPtr m_MCContext_RegisterLibraryPath;
431441
PLibMCMCContext_SetTempBasePathPtr m_MCContext_SetTempBasePath;
432442
PLibMCMCContext_ParseConfigurationPtr m_MCContext_ParseConfiguration;
443+
PLibMCMCContext_SetParameterOverridePtr m_MCContext_SetParameterOverride;
433444
PLibMCMCContext_StartAllThreadsPtr m_MCContext_StartAllThreads;
434445
PLibMCMCContext_TerminateAllThreadsPtr m_MCContext_TerminateAllThreads;
435446
PLibMCMCContext_StartInstanceThreadPtr m_MCContext_StartInstanceThread;

Framework/HeadersCore/CppDynamic/libmc_dynamic.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,7 @@ class CMCContext : public CBase {
16461646
inline void RegisterLibraryPath(const std::string & sLibraryName, const std::string & sLibraryPath, const std::string & sLibraryResource);
16471647
inline void SetTempBasePath(const std::string & sTempBasePath);
16481648
inline void ParseConfiguration(const std::string & sXMLString);
1649+
inline void SetParameterOverride(const std::string & sParameterPath, const std::string & sParameterValue);
16491650
inline void StartAllThreads();
16501651
inline void TerminateAllThreads();
16511652
inline void StartInstanceThread(const std::string & sInstanceName);
@@ -1783,6 +1784,7 @@ class CMCContext : public CBase {
17831784
pWrapperTable->m_MCContext_RegisterLibraryPath = nullptr;
17841785
pWrapperTable->m_MCContext_SetTempBasePath = nullptr;
17851786
pWrapperTable->m_MCContext_ParseConfiguration = nullptr;
1787+
pWrapperTable->m_MCContext_SetParameterOverride = nullptr;
17861788
pWrapperTable->m_MCContext_StartAllThreads = nullptr;
17871789
pWrapperTable->m_MCContext_TerminateAllThreads = nullptr;
17881790
pWrapperTable->m_MCContext_StartInstanceThread = nullptr;
@@ -2003,6 +2005,15 @@ class CMCContext : public CBase {
20032005
if (pWrapperTable->m_MCContext_ParseConfiguration == nullptr)
20042006
return LIBMC_ERROR_COULDNOTFINDLIBRARYEXPORT;
20052007

2008+
#ifdef _WIN32
2009+
pWrapperTable->m_MCContext_SetParameterOverride = (PLibMCMCContext_SetParameterOverridePtr) GetProcAddress(hLibrary, "libmc_mccontext_setparameteroverride");
2010+
#else // _WIN32
2011+
pWrapperTable->m_MCContext_SetParameterOverride = (PLibMCMCContext_SetParameterOverridePtr) dlsym(hLibrary, "libmc_mccontext_setparameteroverride");
2012+
dlerror();
2013+
#endif // _WIN32
2014+
if (pWrapperTable->m_MCContext_SetParameterOverride == nullptr)
2015+
return LIBMC_ERROR_COULDNOTFINDLIBRARYEXPORT;
2016+
20062017
#ifdef _WIN32
20072018
pWrapperTable->m_MCContext_StartAllThreads = (PLibMCMCContext_StartAllThreadsPtr) GetProcAddress(hLibrary, "libmc_mccontext_startallthreads");
20082019
#else // _WIN32
@@ -2240,6 +2251,10 @@ class CMCContext : public CBase {
22402251
if ( (eLookupError != 0) || (pWrapperTable->m_MCContext_ParseConfiguration == nullptr) )
22412252
return LIBMC_ERROR_COULDNOTFINDLIBRARYEXPORT;
22422253

2254+
eLookupError = (*pLookup)("libmc_mccontext_setparameteroverride", (void**)&(pWrapperTable->m_MCContext_SetParameterOverride));
2255+
if ( (eLookupError != 0) || (pWrapperTable->m_MCContext_SetParameterOverride == nullptr) )
2256+
return LIBMC_ERROR_COULDNOTFINDLIBRARYEXPORT;
2257+
22432258
eLookupError = (*pLookup)("libmc_mccontext_startallthreads", (void**)&(pWrapperTable->m_MCContext_StartAllThreads));
22442259
if ( (eLookupError != 0) || (pWrapperTable->m_MCContext_StartAllThreads == nullptr) )
22452260
return LIBMC_ERROR_COULDNOTFINDLIBRARYEXPORT;
@@ -2546,6 +2561,16 @@ class CMCContext : public CBase {
25462561
CheckError(m_pWrapper->m_WrapperTable.m_MCContext_ParseConfiguration(m_pHandle, sXMLString.c_str()));
25472562
}
25482563

2564+
/**
2565+
* CMCContext::SetParameterOverride - overrides a parameter with a certain value. Fails if parameter group or parameter does not exist. Fails if Value is not fitting the parameter type.
2566+
* @param[in] sParameterPath - Path of the parameter. Example: main.configgroup.currentjob
2567+
* @param[in] sParameterValue - New Value of the parameter
2568+
*/
2569+
void CMCContext::SetParameterOverride(const std::string & sParameterPath, const std::string & sParameterValue)
2570+
{
2571+
CheckError(m_pWrapper->m_WrapperTable.m_MCContext_SetParameterOverride(m_pHandle, sParameterPath.c_str(), sParameterValue.c_str()));
2572+
}
2573+
25492574
/**
25502575
* CMCContext::StartAllThreads - starts the threads for all the state machines.
25512576
*/

Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8840,6 +8840,15 @@ typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationVersion_GetParentUUIDPtr)
88408840
*/
88418841
typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationVersion_GetConfigurationXMLStringPtr) (LibMCEnv_MachineConfigurationVersion pMachineConfigurationVersion, const LibMCEnv_uint32 nXMLStringBufferSize, LibMCEnv_uint32* pXMLStringNeededChars, char * pXMLStringBuffer);
88428842

8843+
/**
8844+
* Returns the configuration XML instance.
8845+
*
8846+
* @param[in] pMachineConfigurationVersion - MachineConfigurationVersion instance.
8847+
* @param[out] pXMLInstance - XML Document.
8848+
* @return error code or 0 (success)
8849+
*/
8850+
typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationVersion_GetConfigurationXMLPtr) (LibMCEnv_MachineConfigurationVersion pMachineConfigurationVersion, LibMCEnv_XMLDocument * pXMLInstance);
8851+
88438852
/**
88448853
* Returns the User UUID.
88458854
*
@@ -8984,6 +8993,19 @@ typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationType_GetLatestXSDNumericVe
89848993
*/
89858994
typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationType_RegisterNewXSDPtr) (LibMCEnv_MachineConfigurationType pMachineConfigurationType, const char * pXSDString, LibMCEnv_uint32 nXSDVersion, LibMCEnv_MachineConfigurationXSD * pXSDInstance);
89868995

8996+
/**
8997+
* Registers a XSD from a resource file including its default configuration.
8998+
*
8999+
* @param[in] pMachineConfigurationType - MachineConfigurationType instance.
9000+
* @param[in] pXSDResourceName - XSD Resource Name. Resource MUST exist.
9001+
* @param[in] pDefaultXMLResourceName - Default XML Resource Name. Resource MUST exist.
9002+
* @param[in] nXSDVersion - New Version to add. MUST be larger than GetLatestXSDVersion if FailIfExisting is true.
9003+
* @param[in] bFailIfExisting - If true, the call will fail if XSDVersion is not larger than GetLatestXSDVersion. If false, the call will return the new XSDInstance, if XSDVersion is larger than GetLatestXSDVersion, null otherwise.
9004+
* @param[out] pXSDInstance - Returns the new XSD of the configuration type, if it has been newly registered.
9005+
* @return error code or 0 (success)
9006+
*/
9007+
typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationType_RegisterXSDFromResourcePtr) (LibMCEnv_MachineConfigurationType pMachineConfigurationType, const char * pXSDResourceName, const char * pDefaultXMLResourceName, LibMCEnv_uint32 nXSDVersion, bool bFailIfExisting, LibMCEnv_MachineConfigurationXSD * pXSDInstance);
9008+
89879009
/**
89889010
* Finds a specific XSD of this type by its Numeric Version Number.
89899011
*
@@ -9063,6 +9085,24 @@ typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationType_GetActiveConfiguratio
90639085
*/
90649086
typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationType_GetLatestConfigurationVersionPtr) (LibMCEnv_MachineConfigurationType pMachineConfigurationType, LibMCEnv_MachineConfigurationVersion * pVersion);
90659087

9088+
/**
9089+
* Returns the currently active configuration XML for this type.
9090+
*
9091+
* @param[in] pMachineConfigurationType - MachineConfigurationType instance.
9092+
* @param[out] pXMLInstance - XML Document.
9093+
* @return error code or 0 (success)
9094+
*/
9095+
typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationType_GetActiveConfigurationXMLPtr) (LibMCEnv_MachineConfigurationType pMachineConfigurationType, LibMCEnv_XMLDocument * pXMLInstance);
9096+
9097+
/**
9098+
* Returns the most recently created configuration XML for this type.
9099+
*
9100+
* @param[in] pMachineConfigurationType - MachineConfigurationType instance.
9101+
* @param[out] pXMLInstance - XML Document.
9102+
* @return error code or 0 (success)
9103+
*/
9104+
typedef LibMCEnvResult (*PLibMCEnvMachineConfigurationType_GetLatestConfigurationXMLPtr) (LibMCEnv_MachineConfigurationType pMachineConfigurationType, LibMCEnv_XMLDocument * pXMLInstance);
9105+
90669106
/**
90679107
* Sets the active configuration version for this type.
90689108
*
@@ -11792,6 +11832,7 @@ typedef struct {
1179211832
PLibMCEnvMachineConfigurationVersion_GetNumericVersionPtr m_MachineConfigurationVersion_GetNumericVersion;
1179311833
PLibMCEnvMachineConfigurationVersion_GetParentUUIDPtr m_MachineConfigurationVersion_GetParentUUID;
1179411834
PLibMCEnvMachineConfigurationVersion_GetConfigurationXMLStringPtr m_MachineConfigurationVersion_GetConfigurationXMLString;
11835+
PLibMCEnvMachineConfigurationVersion_GetConfigurationXMLPtr m_MachineConfigurationVersion_GetConfigurationXML;
1179511836
PLibMCEnvMachineConfigurationVersion_GetUserUUIDPtr m_MachineConfigurationVersion_GetUserUUID;
1179611837
PLibMCEnvMachineConfigurationVersion_GetTimestampPtr m_MachineConfigurationVersion_GetTimestamp;
1179711838
PLibMCEnvMachineConfigurationVersion_CreateNewVersionPtr m_MachineConfigurationVersion_CreateNewVersion;
@@ -11805,6 +11846,7 @@ typedef struct {
1180511846
PLibMCEnvMachineConfigurationType_ListXSDVersionsPtr m_MachineConfigurationType_ListXSDVersions;
1180611847
PLibMCEnvMachineConfigurationType_GetLatestXSDNumericVersionPtr m_MachineConfigurationType_GetLatestXSDNumericVersion;
1180711848
PLibMCEnvMachineConfigurationType_RegisterNewXSDPtr m_MachineConfigurationType_RegisterNewXSD;
11849+
PLibMCEnvMachineConfigurationType_RegisterXSDFromResourcePtr m_MachineConfigurationType_RegisterXSDFromResource;
1180811850
PLibMCEnvMachineConfigurationType_FindXSDByNumericVersionPtr m_MachineConfigurationType_FindXSDByNumericVersion;
1180911851
PLibMCEnvMachineConfigurationType_FindXSDByUUIDPtr m_MachineConfigurationType_FindXSDByUUID;
1181011852
PLibMCEnvMachineConfigurationType_CreateDefaultConfigurationPtr m_MachineConfigurationType_CreateDefaultConfiguration;
@@ -11813,6 +11855,8 @@ typedef struct {
1181311855
PLibMCEnvMachineConfigurationType_FindConfigurationVersionByUUIDPtr m_MachineConfigurationType_FindConfigurationVersionByUUID;
1181411856
PLibMCEnvMachineConfigurationType_GetActiveConfigurationVersionPtr m_MachineConfigurationType_GetActiveConfigurationVersion;
1181511857
PLibMCEnvMachineConfigurationType_GetLatestConfigurationVersionPtr m_MachineConfigurationType_GetLatestConfigurationVersion;
11858+
PLibMCEnvMachineConfigurationType_GetActiveConfigurationXMLPtr m_MachineConfigurationType_GetActiveConfigurationXML;
11859+
PLibMCEnvMachineConfigurationType_GetLatestConfigurationXMLPtr m_MachineConfigurationType_GetLatestConfigurationXML;
1181611860
PLibMCEnvMachineConfigurationType_SetActiveConfigurationVersionPtr m_MachineConfigurationType_SetActiveConfigurationVersion;
1181711861
PLibMCEnvMachineConfigurationTypeIterator_GetCurrentPtr m_MachineConfigurationTypeIterator_GetCurrent;
1181811862
PLibMCEnvMachineConfigurationHandler_RegisterMachineConfigurationTypePtr m_MachineConfigurationHandler_RegisterMachineConfigurationType;

0 commit comments

Comments
 (0)