Blame view

src/Request/Config/KernelConfigClass.php 8.72 KB
22521f1c   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
<?php

/**
 * @class KernelConfigClass
 * @brief Class that's contain all specific configuration of the AMDA_Kernel module
 * @details
 */
class KernelConfigClass
{
22521f1c   Benjamin Renard   First commit
10
11
	private static $propFile         = "app.properties";

22521f1c   Benjamin Renard   First commit
12
13
14
	private static $cxxCompiler      = "g++";
	private static $cmakeFlags       = "-g -std=c++0x -fPIC -Wall -ggdb -DLINUX -Dlinux -D_REENTRANT -malign-double -pthread";

22521f1c   Benjamin Renard   First commit
15
	private static $plotConfigFile   = "plotConfig.xml";
063337d8   Benjamin Renard   Add frames transf...
16
17
	
	private static $spiceKernelConfigFile = "spiceKernelConfig.xml";
22521f1c   Benjamin Renard   First commit
18
19
20
21
22
23
24
25
26

	private static $binDir           = "bin/";
	private static $pluginDir        = "plugin/";
	private static $libDir           = "lib/";

	private static $requestParamsDir = "params/";
	private static $userSrcDir       = "src/";
	private static $userLibDir       = "lib/";
	
22521f1c   Benjamin Renard   First commit
27
28
	private static $defaultGapThreshold = "5";

1d67748e   Benjamin Renard   Limit number of p...
29
30
31
	private static $nbMaxProcessByUser = 10;
	private static $nbMaxProcessGlobal = 100;

058077b0   Benjamin Renard   Add flag for debu...
32
33
	private static $isDebugMode    = FALSE;

87a28122   Elena.Budnik   create app.user.n...
34

a928f9d3   Benjamin Renard   New parser integr...
35
36
37
	private static $userHost       = "";
	private static $userName       = "";
	private static $forceParamsDir = "";
91c2a59a   Elena.Budnik   added setTimeToBa...
38
39
	
	private static $timeToBatchMode = 10; // secs : interval after which batch mode is launched
87a28122   Elena.Budnik   create app.user.n...
40

22521f1c   Benjamin Renard   First commit
41
42
43
44
45
46
47
48
49
50
51
52
53
	private static $includeArray     = array(
			"InternLib",
			"Common",
			"Parameters",
			"DD_Client_Lib",
			"helpers",
			"TimeTableCatalog"
	);

	public static $libArray = array(
			"Parameters"
	);

87a28122   Elena.Budnik   create app.user.n...
54

058077b0   Benjamin Renard   Add flag for debu...
55
56
57
58
59
	public static function isDebugMode()
	{
		return self::$isDebugMode;
	}

87a28122   Elena.Budnik   create app.user.n...
60
61
62
63
64
65
66
67
68
	public static function setUserHost($userHost)
	{
		self::$userHost = $userHost;
	}
	
	public static function setUserName($user)
	{
		self::$userName = $user;
	}
8ade06fe   Benjamin Renard   Improve config load
69

a928f9d3   Benjamin Renard   New parser integr...
70
71
72
73
74
	public static function setForceParamsDir($paramsDir)
	{
		self::$forceParamsDir = $paramsDir;
	}

22521f1c   Benjamin Renard   First commit
75
76
	public static function getRequestParamsPath($working_dir)
	{
a928f9d3   Benjamin Renard   New parser integr...
77
		$paramsPath = empty(self::$forceParamsDir) ? $working_dir.self::$requestParamsDir : self::$forceParamsDir;
22521f1c   Benjamin Renard   First commit
78
79
80
81
82
83
84
85
86

		if (!is_dir($paramsPath))
			mkdir($paramsPath);
			
		return $paramsPath;
	}

	public static function getXSDParameterFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
87
		return AMDA_KERNEL_DIR.'/config/xsd/parameter/all.xsd';
22521f1c   Benjamin Renard   First commit
88
89
90
91
	}

	public static function getXSDRequestFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
92
		return AMDA_KERNEL_DIR.'/config/xsd/request/all.xsd';
22521f1c   Benjamin Renard   First commit
93
94
	}
	
87a28122   Elena.Budnik   create app.user.n...
95
96
	public static function getXSDParamInfoFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
97
		return AMDA_KERNEL_DIR.'/config/xsd/info/paramInfo.xsd';
22521f1c   Benjamin Renard   First commit
98
99
	}
	
87a28122   Elena.Budnik   create app.user.n...
100
101
	public static function getXSDDatasetInfoFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
102
		return AMDA_KERNEL_DIR.'/config/xsd/info/dataSetInfo.xsd';
22521f1c   Benjamin Renard   First commit
103
104
	}
	
87a28122   Elena.Budnik   create app.user.n...
105
106
	public static function getXSDInstrumentInfoFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
107
		return AMDA_KERNEL_DIR.'/config/xsd/info/instrumentInfo.xsd';
22521f1c   Benjamin Renard   First commit
108
109
	}
	
87a28122   Elena.Budnik   create app.user.n...
110
111
	public static function getXSDMissionInfoFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
112
		return AMDA_KERNEL_DIR.'/config/xsd/info/missionInfo.xsd';
22521f1c   Benjamin Renard   First commit
113
114
	}
	
944199fe   Benjamin Renard   Use table definit...
115
116
	public static function getXSDLocalBaseFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
117
		return AMDA_KERNEL_DIR.'/config/xsd/localbase/base.xsd';
944199fe   Benjamin Renard   Use table definit...
118
119
	}
	
063337d8   Benjamin Renard   Add frames transf...
120
121
	public static function getXSDSpiceKernelConfigFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
122
		return AMDA_KERNEL_DIR.'/config/xsd/spicekernel/config.xsd';
063337d8   Benjamin Renard   Add frames transf...
123
	}
a928f9d3   Benjamin Renard   New parser integr...
124
125
126
127
128
129

	public static function getXSDFunctionsFilePath()
	{
		return AMDA_KERNEL_DIR.'/config/xsd/parser/functions.xsd';
	}

8cf39be4   Benjamin Renard   Add functions arg...
130
131
132
133
134
	public static function getXSDFunctionsArgsListFilePath()
	{
		return AMDA_KERNEL_DIR.'/config/xsd/parser/functionsArgsList.xsd';
	}

a928f9d3   Benjamin Renard   New parser integr...
135
136
137
138
	public static function getXSDConstantsFilePath()
	{
		return AMDA_KERNEL_DIR.'/config/xsd/parser/constants.xsd';
	}
65912bc8   Benjamin Renard   Templated paramet...
139
140
141
142
143

	public static function getXSDParamTemplatesFilePath()
	{
		return AMDA_KERNEL_DIR.'/config/xsd/parser/paramtemplates.xml';
	}
063337d8   Benjamin Renard   Add frames transf...
144
145
	
	
22521f1c   Benjamin Renard   First commit
146
147
	public static function getDatasetInfoPath()
	{
8ade06fe   Benjamin Renard   Improve config load
148
		return DataSetInfo;
22521f1c   Benjamin Renard   First commit
149
150
	}
	
87a28122   Elena.Budnik   create app.user.n...
151
152
	public static function getInstrumentInfoPath()
	{
8ade06fe   Benjamin Renard   Improve config load
153
		return InstrumentInfo;
22521f1c   Benjamin Renard   First commit
154
155
	}
	
87a28122   Elena.Budnik   create app.user.n...
156
157
	public static function getMissionInfoPath()
	{
8ade06fe   Benjamin Renard   Improve config load
158
		return MissionInfo;
22521f1c   Benjamin Renard   First commit
159
	}
a04159d9   Benjamin Renard   Define common lib...
160
161
162
163
164

	public static function getCommonLibPath()
	{
		return CommonLib;
	}
944199fe   Benjamin Renard   Use table definit...
165
	
22521f1c   Benjamin Renard   First commit
166
167
	public static function getKernelBinPath()
	{
8ade06fe   Benjamin Renard   Improve config load
168
		return AMDA_KERNEL_BUILD_DIR.'/'.self::$binDir;
22521f1c   Benjamin Renard   First commit
169
170
171
172
173
	}

	public static function getExecEnvVarArray()
	{
		return array (
8ade06fe   Benjamin Renard   Improve config load
174
175
176
				"DDPATH" => KERNEL_CONFIG_DIR,
				"MY_GXX_HOME" => GCC_BASE_DIR,
				"PATH" => self::getKernelBinPath().":".COTS_BASE_DIR."/bin:".GCC_BASE_DIR."/bin:".getenv("PATH"),
058077b0   Benjamin Renard   Add flag for debu...
177
				"LD_LIBRARY_PATH" => COTS_BASE_DIR."/lib:".COTS_BASE_DIR."/lib64:".GCC_BASE_DIR."/lib64:".GCC_BASE_DIR."/lib:".getenv("LD_LIBRARY_PATH"),
22521f1c   Benjamin Renard   First commit
178
179
		);
	}
91c2a59a   Elena.Budnik   added setTimeToBa...
180
181
182
183
184
185
	
	public static function setTimeToBatchMode($timeToBatchMode)
	{
		self::$timeToBatchMode = $timeToBatchMode;
	}
	
22521f1c   Benjamin Renard   First commit
186
187
	public static function getTimeToBatchMode()
	{
91c2a59a   Elena.Budnik   added setTimeToBa...
188
		return self::$timeToBatchMode;
22521f1c   Benjamin Renard   First commit
189
190
	}

1d67748e   Benjamin Renard   Limit number of p...
191
192
193
194
195
196
197
198
199
200
	public static function getNbMaxProcessByUser()
	{
		return self::$nbMaxProcessByUser;
	}

	public static function getNbMaxProcessGlobal()
	{
		return self::$nbMaxProcessGlobal;
	}

8cf39be4   Benjamin Renard   Add functions arg...
201
	public static function write($working_dir, $compilation_path = "", $localbase_path = "", $functionsfile_path = "", $constantsfile_path = "", $paramtemplatesfile_path = "", $functionsargslistfile_path = "")
22521f1c   Benjamin Renard   First commit
202
203
204
205
	{
		//create app.properties file
		$appProperties = array();

8ade06fe   Benjamin Renard   Improve config load
206
		$appProperties["app.log4cxx.configfile"]      = KERNEL_CONFIG_DIR."/log4cxx.config";
22521f1c   Benjamin Renard   First commit
207
208
209
210
211
212
		$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();
87a28122   Elena.Budnik   create app.user.n...
213
		$appProperties["app.dataSetInfo.xsd"]         = self::getXSDDatasetInfoFilePath();
22521f1c   Benjamin Renard   First commit
214
		$appProperties["app.instrumentInfo.path"]     = self::getInstrumentInfoPath();
87a28122   Elena.Budnik   create app.user.n...
215
		$appProperties["app.instrumentInfo.xsd"]      = self::getXSDInstrumentInfoFilePath();
22521f1c   Benjamin Renard   First commit
216
		$appProperties["app.missionInfo.path"]        = self::getMissionInfoPath();
944199fe   Benjamin Renard   Use table definit...
217
		$appProperties["app.missionInfo.xsd"]         = self::getXSDMissionInfoFilePath();
22521f1c   Benjamin Renard   First commit
218
		
944199fe   Benjamin Renard   Use table definit...
219
220
		$appProperties["app.localbase.path"]          = $localbase_path;
		$appProperties["app.localbase.xsd"]           = self::getXSDLocalBaseFilePath();
22521f1c   Benjamin Renard   First commit
221
		
063337d8   Benjamin Renard   Add frames transf...
222
		$appProperties["app.spicekernel.configxsd"]   = self::getXSDSpiceKernelConfigFilePath();
8ade06fe   Benjamin Renard   Improve config load
223
		$appProperties["app.spicekernel.configfile"]  = KERNEL_CONFIG_DIR.'/spiceKernelConfig.xml';
a928f9d3   Benjamin Renard   New parser integr...
224
225
226
227
228

		$appProperties["app.ihmConstants.xsd"]        = self::getXSDConstantsFilePath();
		$appProperties["app.ihmConstants.xml"]        = $constantsfile_path;
		$appProperties["app.ihmFunctions.xsd"]        = self::getXSDFunctionsFilePath();
		$appProperties["app.ihmFunctions.xml"]        = $functionsfile_path;
65912bc8   Benjamin Renard   Templated paramet...
229
230
		$appProperties["app.ihmTemplateParams.xsd"]   = self::getXSDParamTemplatesFilePath();
		$appProperties["app.ihmTemplateParams.xml"]   = $paramtemplatesfile_path;
8cf39be4   Benjamin Renard   Add functions arg...
231
232
		$appProperties["app.ihmFunctionsArgsList.xsd"] = self::getXSDFunctionsArgsListFilePath();
		$appProperties["app.ihmFunctionsArgsList.xml"] = $functionsargslistfile_path;
063337d8   Benjamin Renard   Add frames transf...
233
		
8ade06fe   Benjamin Renard   Improve config load
234
		$appProperties["app.plugin"]                  = AMDA_KERNEL_BUILD_DIR.'/'.self::$pluginDir;
22521f1c   Benjamin Renard   First commit
235
		$appProperties["app.process.src"]             = $compilation_path.self::$userSrcDir;
a04159d9   Benjamin Renard   Define common lib...
236
237
		$appProperties["app.process.lib"]             = self::getCommonLibPath();
		$appProperties["app.process.userlib"]         = $compilation_path.self::$userLibDir;
22521f1c   Benjamin Renard   First commit
238
239
240
241
242
		$appProperties["app.process.CXX_COMPILER"]    = self::$cxxCompiler;
		$appProperties["app.process.CMAKE_CXX_FLAGS"] = self::$cmakeFlags;

		$appProperties["app.process.INCLUDE"]         = "";
		foreach (self::$includeArray as $inc)
8ade06fe   Benjamin Renard   Improve config load
243
244
			$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";
22521f1c   Benjamin Renard   First commit
245

8ade06fe   Benjamin Renard   Improve config load
246
		$appProperties["app.process.LIB"]             = "-L".AMDA_KERNEL_BUILD_DIR.'/'.self::$libDir." ";
22521f1c   Benjamin Renard   First commit
247
248
249
		foreach (self::$libArray as $lib)
			$appProperties["app.process.LIB"] .= ("-l".$lib." ");

b302ab2c   Benjamin Renard   Fix for dynamical...
250
251
252
		$appProperties["app.process.DYNAMIC_LOADING"] = "false";
		$appProperties["app.process.plugins.xml"]     = KERNEL_CONFIG_DIR.'/plugins.xml';

7cf7bfe2   Hacene SI HADJ MOHAND   adding plugins xs...
253
254
                $appProperties["app.process.plugins.xsd"]     = AMDA_KERNEL_DIR.'/config/xsd/parser/plugins.xsd'; 

8ade06fe   Benjamin Renard   Improve config load
255
		$appProperties["app.plot.configfile"]         = KERNEL_CONFIG_DIR.'/'.self::$plotConfigFile;
22521f1c   Benjamin Renard   First commit
256
257

		$appProperties["app.param.gapthreshold"] = self::$defaultGapThreshold;
22521f1c   Benjamin Renard   First commit
258

87a28122   Elena.Budnik   create app.user.n...
259
260
261
262
263
264
		if (self::$userHost != "")
			$appProperties["app.user.host"] = self::$userHost;

		if (self::$userName != "")
			$appProperties["app.user.name"] = self::$userName;
			
22521f1c   Benjamin Renard   First commit
265
266
267
268
269
		$fp = fopen($working_dir.self::$propFile, 'w');
		foreach ($appProperties as $key => $value)
			fwrite($fp, $key."=".$value.PHP_EOL);
		fclose($fp);

8ade06fe   Benjamin Renard   Improve config load
270
271
		//copy amda.properties file
		copy(KERNEL_CONFIG_DIR.'/amda.properties', $working_dir.'/amda.properties');
22521f1c   Benjamin Renard   First commit
272
273
274
275
	}
}

?>