KernelConfigClass.php
6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?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 $userHost = "";
private static $userName = "";
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 getRequestParamsPath($working_dir)
{
$paramsPath = $working_dir.self::$requestParamsDir;
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 getDatasetInfoPath()
{
return DataSetInfo;
}
public static function getInstrumentInfoPath()
{
return InstrumentInfo;
}
public static function getMissionInfoPath()
{
return MissionInfo;
}
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 write($working_dir, $compilation_path, $localbase_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.plugin"] = AMDA_KERNEL_BUILD_DIR.'/'.self::$pluginDir;
$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)
$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.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');
}
}
?>