<?php /** * @class KernelConfigClass * @brief Class that's contain all specific configuration of the AMDA_Kernel module * @details */ class KernelConfigClass { private static $propFile = "app.properties"; private static $cxxCompiler = "g++"; private static $cmakeFlags = "-g -std=c++0x -fPIC -Wall -ggdb -DLINUX -Dlinux -D_REENTRANT -malign-double -pthread"; private static $plotConfigFile = "plotConfig.xml"; private static $spiceKernelConfigFile = "spiceKernelConfig.xml"; private static $binDir = "bin/"; private static $pluginDir = "plugin/"; private static $libDir = "lib/"; private static $requestParamsDir = "params/"; private static $userSrcDir = "src/"; private static $userLibDir = "lib/"; private static $defaultGapThreshold = "5"; private static $nbMaxProcessByUser = 10; private static $nbMaxProcessGlobal = 100; private static $userHost = ""; private static $userName = ""; private static $forceParamsDir = ""; private static $timeToBatchMode = 10; // secs : interval after which batch mode is launched private static $includeArray = array( "InternLib", "Common", "Parameters", "DD_Client_Lib", "helpers", "TimeTableCatalog" ); public static $libArray = array( "Parameters" ); public static function setUserHost($userHost) { self::$userHost = $userHost; } public static function setUserName($user) { self::$userName = $user; } public static function setForceParamsDir($paramsDir) { self::$forceParamsDir = $paramsDir; } public static function getRequestParamsPath($working_dir) { $paramsPath = empty(self::$forceParamsDir) ? $working_dir.self::$requestParamsDir : self::$forceParamsDir; if (!is_dir($paramsPath)) mkdir($paramsPath); return $paramsPath; } public static function getXSDParameterFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/parameter/all.xsd'; } public static function getXSDRequestFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/request/all.xsd'; } public static function getXSDParamInfoFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/info/paramInfo.xsd'; } public static function getXSDDatasetInfoFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/info/dataSetInfo.xsd'; } public static function getXSDInstrumentInfoFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/info/instrumentInfo.xsd'; } public static function getXSDMissionInfoFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/info/missionInfo.xsd'; } public static function getXSDLocalBaseFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/localbase/base.xsd'; } public static function getXSDSpiceKernelConfigFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/spicekernel/config.xsd'; } public static function getXSDFunctionsFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/parser/functions.xsd'; } public static function getXSDFunctionsArgsListFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/parser/functionsArgsList.xsd'; } public static function getXSDConstantsFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/parser/constants.xsd'; } public static function getXSDParamTemplatesFilePath() { return AMDA_KERNEL_DIR.'/config/xsd/parser/paramtemplates.xml'; } public static function getDatasetInfoPath() { return DataSetInfo; } public static function getInstrumentInfoPath() { return InstrumentInfo; } public static function getMissionInfoPath() { return MissionInfo; } public static function getCommonLibPath() { return CommonLib; } public static function getKernelBinPath() { return AMDA_KERNEL_BUILD_DIR.'/'.self::$binDir; } public static function getExecEnvVarArray() { return array ( "DDPATH" => KERNEL_CONFIG_DIR, "MY_GXX_HOME" => GCC_BASE_DIR, "PATH" => self::getKernelBinPath().":".COTS_BASE_DIR."/bin:".GCC_BASE_DIR."/bin:".getenv("PATH"), "LD_LIBRARY_PATH" => COTS_BASE_DIR."/lib:".GCC_BASE_DIR."/lib64:".GCC_BASE_DIR."/lib:".getenv("LD_LIBRARY_PATH"), ); } public static function setTimeToBatchMode($timeToBatchMode) { self::$timeToBatchMode = $timeToBatchMode; } public static function getTimeToBatchMode() { return self::$timeToBatchMode; } public static function getNbMaxProcessByUser() { return self::$nbMaxProcessByUser; } public static function getNbMaxProcessGlobal() { return self::$nbMaxProcessGlobal; } public static function write($working_dir, $compilation_path = "", $localbase_path = "", $functionsfile_path = "", $constantsfile_path = "", $paramtemplatesfile_path = "", $functionsargslistfile_path = "") { //create app.properties file $appProperties = array(); $appProperties["app.log4cxx.configfile"] = KERNEL_CONFIG_DIR."/log4cxx.config"; $appProperties["app.param.path"] = self::getRequestParamsPath($working_dir); $appProperties["app.parameter.xsd"] = self::getXSDParameterFilePath(); $appProperties["app.request.xsd"] = self::getXSDRequestFilePath(); $appProperties["app.paramInfo.xsd"] = self::getXSDParamInfoFilePath(); $appProperties["app.dataSetInfo.path"] = self::getDatasetInfoPath(); $appProperties["app.dataSetInfo.xsd"] = self::getXSDDatasetInfoFilePath(); $appProperties["app.instrumentInfo.path"] = self::getInstrumentInfoPath(); $appProperties["app.instrumentInfo.xsd"] = self::getXSDInstrumentInfoFilePath(); $appProperties["app.missionInfo.path"] = self::getMissionInfoPath(); $appProperties["app.missionInfo.xsd"] = self::getXSDMissionInfoFilePath(); $appProperties["app.localbase.path"] = $localbase_path; $appProperties["app.localbase.xsd"] = self::getXSDLocalBaseFilePath(); $appProperties["app.spicekernel.configxsd"] = self::getXSDSpiceKernelConfigFilePath(); $appProperties["app.spicekernel.configfile"] = KERNEL_CONFIG_DIR.'/spiceKernelConfig.xml'; $appProperties["app.ihmConstants.xsd"] = self::getXSDConstantsFilePath(); $appProperties["app.ihmConstants.xml"] = $constantsfile_path; $appProperties["app.ihmFunctions.xsd"] = self::getXSDFunctionsFilePath(); $appProperties["app.ihmFunctions.xml"] = $functionsfile_path; $appProperties["app.ihmTemplateParams.xsd"] = self::getXSDParamTemplatesFilePath(); $appProperties["app.ihmTemplateParams.xml"] = $paramtemplatesfile_path; $appProperties["app.ihmFunctionsArgsList.xsd"] = self::getXSDFunctionsArgsListFilePath(); $appProperties["app.ihmFunctionsArgsList.xml"] = $functionsargslistfile_path; $appProperties["app.plugin"] = AMDA_KERNEL_BUILD_DIR.'/'.self::$pluginDir; $appProperties["app.process.src"] = $compilation_path.self::$userSrcDir; $appProperties["app.process.lib"] = self::getCommonLibPath(); $appProperties["app.process.userlib"] = $compilation_path.self::$userLibDir; $appProperties["app.process.CXX_COMPILER"] = self::$cxxCompiler; $appProperties["app.process.CMAKE_CXX_FLAGS"] = self::$cmakeFlags; $appProperties["app.process.INCLUDE"] = ""; foreach (self::$includeArray as $inc) $appProperties["app.process.INCLUDE"] .= ("-I".AMDA_KERNEL_SRC_DIR."/".$inc." "); $appProperties["app.process.INCLUDE"] .= "-I".COTS_BASE_DIR."/include"." -I".BOOST_BASE_DIR."/include -I".COTS_BASE_DIR."/include/log4cxx"; $appProperties["app.process.LIB"] = "-L".AMDA_KERNEL_BUILD_DIR.'/'.self::$libDir." "; foreach (self::$libArray as $lib) $appProperties["app.process.LIB"] .= ("-l".$lib." "); $appProperties["app.process.DYNAMIC_LOADING"] = "false"; $appProperties["app.process.plugins.xml"] = KERNEL_CONFIG_DIR.'/plugins.xml'; $appProperties["app.process.plugins.xsd"] = AMDA_KERNEL_DIR.'/config/xsd/parser/plugins.xsd'; $appProperties["app.plot.configfile"] = KERNEL_CONFIG_DIR.'/'.self::$plotConfigFile; $appProperties["app.param.gapthreshold"] = self::$defaultGapThreshold; if (self::$userHost != "") $appProperties["app.user.host"] = self::$userHost; if (self::$userName != "") $appProperties["app.user.name"] = self::$userName; $fp = fopen($working_dir.self::$propFile, 'w'); foreach ($appProperties as $key => $value) fwrite($fp, $key."=".$value.PHP_EOL); fclose($fp); //copy amda.properties file copy(KERNEL_CONFIG_DIR.'/amda.properties', $working_dir.'/amda.properties'); } } ?>