Blame view

src/Request/Config/KernelConfigClass.php 6.42 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";

87a28122   Elena.Budnik   create app.user.n...
29
30
31

	private static $userHost = "";
	private static $userName = "";
91c2a59a   Elena.Budnik   added setTimeToBa...
32
33
	
	private static $timeToBatchMode = 10; // secs : interval after which batch mode is launched
87a28122   Elena.Budnik   create app.user.n...
34

22521f1c   Benjamin Renard   First commit
35
36
37
38
39
40
41
42
43
44
45
46
47
	private static $includeArray     = array(
			"InternLib",
			"Common",
			"Parameters",
			"DD_Client_Lib",
			"helpers",
			"TimeTableCatalog"
	);

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

87a28122   Elena.Budnik   create app.user.n...
48
49
50
51
52
53
54
55
56
57

	public static function setUserHost($userHost)
	{
		self::$userHost = $userHost;
	}
	
	public static function setUserName($user)
	{
		self::$userName = $user;
	}
8ade06fe   Benjamin Renard   Improve config load
58

22521f1c   Benjamin Renard   First commit
59
60
61
62
63
64
65
66
67
68
69
70
	public static function getRequestParamsPath($working_dir)
	{
		$paramsPath = $working_dir.self::$requestParamsDir;

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

	public static function getXSDParameterFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
71
		return AMDA_KERNEL_DIR.'/config/xsd/parameter/all.xsd';
22521f1c   Benjamin Renard   First commit
72
73
74
75
	}

	public static function getXSDRequestFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
76
		return AMDA_KERNEL_DIR.'/config/xsd/request/all.xsd';
22521f1c   Benjamin Renard   First commit
77
78
	}
	
87a28122   Elena.Budnik   create app.user.n...
79
80
	public static function getXSDParamInfoFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
81
		return AMDA_KERNEL_DIR.'/config/xsd/info/paramInfo.xsd';
22521f1c   Benjamin Renard   First commit
82
83
	}
	
87a28122   Elena.Budnik   create app.user.n...
84
85
	public static function getXSDDatasetInfoFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
86
		return AMDA_KERNEL_DIR.'/config/xsd/info/dataSetInfo.xsd';
22521f1c   Benjamin Renard   First commit
87
88
	}
	
87a28122   Elena.Budnik   create app.user.n...
89
90
	public static function getXSDInstrumentInfoFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
91
		return AMDA_KERNEL_DIR.'/config/xsd/info/instrumentInfo.xsd';
22521f1c   Benjamin Renard   First commit
92
93
	}
	
87a28122   Elena.Budnik   create app.user.n...
94
95
	public static function getXSDMissionInfoFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
96
		return AMDA_KERNEL_DIR.'/config/xsd/info/missionInfo.xsd';
22521f1c   Benjamin Renard   First commit
97
98
	}
	
944199fe   Benjamin Renard   Use table definit...
99
100
	public static function getXSDLocalBaseFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
101
		return AMDA_KERNEL_DIR.'/config/xsd/localbase/base.xsd';
944199fe   Benjamin Renard   Use table definit...
102
103
	}
	
063337d8   Benjamin Renard   Add frames transf...
104
105
	public static function getXSDSpiceKernelConfigFilePath()
	{
8ade06fe   Benjamin Renard   Improve config load
106
		return AMDA_KERNEL_DIR.'/config/xsd/spicekernel/config.xsd';
063337d8   Benjamin Renard   Add frames transf...
107
108
109
	}
	
	
22521f1c   Benjamin Renard   First commit
110
111
	public static function getDatasetInfoPath()
	{
8ade06fe   Benjamin Renard   Improve config load
112
		return DataSetInfo;
22521f1c   Benjamin Renard   First commit
113
114
	}
	
87a28122   Elena.Budnik   create app.user.n...
115
116
	public static function getInstrumentInfoPath()
	{
8ade06fe   Benjamin Renard   Improve config load
117
		return InstrumentInfo;
22521f1c   Benjamin Renard   First commit
118
119
	}
	
87a28122   Elena.Budnik   create app.user.n...
120
121
	public static function getMissionInfoPath()
	{
8ade06fe   Benjamin Renard   Improve config load
122
		return MissionInfo;
22521f1c   Benjamin Renard   First commit
123
	}
944199fe   Benjamin Renard   Use table definit...
124
	
22521f1c   Benjamin Renard   First commit
125
126
	public static function getKernelBinPath()
	{
8ade06fe   Benjamin Renard   Improve config load
127
		return AMDA_KERNEL_BUILD_DIR.'/'.self::$binDir;
22521f1c   Benjamin Renard   First commit
128
129
130
131
132
	}

	public static function getExecEnvVarArray()
	{
		return array (
8ade06fe   Benjamin Renard   Improve config load
133
134
135
136
				"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"),
22521f1c   Benjamin Renard   First commit
137
138
		);
	}
91c2a59a   Elena.Budnik   added setTimeToBa...
139
140
141
142
143
144
	
	public static function setTimeToBatchMode($timeToBatchMode)
	{
		self::$timeToBatchMode = $timeToBatchMode;
	}
	
22521f1c   Benjamin Renard   First commit
145
146
	public static function getTimeToBatchMode()
	{
91c2a59a   Elena.Budnik   added setTimeToBa...
147
		return self::$timeToBatchMode;
22521f1c   Benjamin Renard   First commit
148
149
	}

944199fe   Benjamin Renard   Use table definit...
150
	public static function write($working_dir, $compilation_path, $localbase_path)
22521f1c   Benjamin Renard   First commit
151
152
153
154
	{
		//create app.properties file
		$appProperties = array();

8ade06fe   Benjamin Renard   Improve config load
155
		$appProperties["app.log4cxx.configfile"]      = KERNEL_CONFIG_DIR."/log4cxx.config";
22521f1c   Benjamin Renard   First commit
156
157
158
159
160
161
		$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...
162
		$appProperties["app.dataSetInfo.xsd"]         = self::getXSDDatasetInfoFilePath();
22521f1c   Benjamin Renard   First commit
163
		$appProperties["app.instrumentInfo.path"]     = self::getInstrumentInfoPath();
87a28122   Elena.Budnik   create app.user.n...
164
		$appProperties["app.instrumentInfo.xsd"]      = self::getXSDInstrumentInfoFilePath();
22521f1c   Benjamin Renard   First commit
165
		$appProperties["app.missionInfo.path"]        = self::getMissionInfoPath();
944199fe   Benjamin Renard   Use table definit...
166
		$appProperties["app.missionInfo.xsd"]         = self::getXSDMissionInfoFilePath();
22521f1c   Benjamin Renard   First commit
167
		
944199fe   Benjamin Renard   Use table definit...
168
169
		$appProperties["app.localbase.path"]          = $localbase_path;
		$appProperties["app.localbase.xsd"]           = self::getXSDLocalBaseFilePath();
22521f1c   Benjamin Renard   First commit
170
		
063337d8   Benjamin Renard   Add frames transf...
171
		$appProperties["app.spicekernel.configxsd"]   = self::getXSDSpiceKernelConfigFilePath();
8ade06fe   Benjamin Renard   Improve config load
172
		$appProperties["app.spicekernel.configfile"]  = KERNEL_CONFIG_DIR.'/spiceKernelConfig.xml';
063337d8   Benjamin Renard   Add frames transf...
173
		
8ade06fe   Benjamin Renard   Improve config load
174
		$appProperties["app.plugin"]                  = AMDA_KERNEL_BUILD_DIR.'/'.self::$pluginDir;
22521f1c   Benjamin Renard   First commit
175
176
177
178
179
180
181
		$appProperties["app.process.src"]             = $compilation_path.self::$userSrcDir;
		$appProperties["app.process.lib"]             = $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)
8ade06fe   Benjamin Renard   Improve config load
182
183
			$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
184

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

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

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

87a28122   Elena.Budnik   create app.user.n...
193
194
195
196
197
198
		if (self::$userHost != "")
			$appProperties["app.user.host"] = self::$userHost;

		if (self::$userName != "")
			$appProperties["app.user.name"] = self::$userName;
			
22521f1c   Benjamin Renard   First commit
199
200
201
202
203
		$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
204
205
		//copy amda.properties file
		copy(KERNEL_CONFIG_DIR.'/amda.properties', $working_dir.'/amda.properties');
22521f1c   Benjamin Renard   First commit
206
207
208
209
	}
}

?>