KernelConfigClass.php
6.7 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
210
211
212
<?php
/**
* @class KernelConfigClass
* @brief Class that's contain all specific configuration of the AMDA_Kernel module
* @details
*/
class KernelConfigClass
{
private static $xsdRequestDir = "request/";
private static $xsdParameterDir = "parameter/";
private static $xsdInfoDir = "info/";
private static $xsdLocalBaseDir = "localbase/";
private static $propFile = "app.properties";
private static $amdaPropFile = "amda.properties";
private static $cxxCompiler = "g++";
private static $cmakeFlags = "-g -std=c++0x -fPIC -Wall -ggdb -DLINUX -Dlinux -D_REENTRANT -malign-double -pthread";
private static $logConfigFile = "log4cxx.config";
private static $plotConfigFile = "plotConfig.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 $datasetInfoDir = "DataSetInfo/";
private static $instrumentInfoDir= "InstrumentInfo/";
private static $missionInfoDir = "MissionInfo/";
private static $localInclude = "/opt/local/include/";
private static $boostInclude = "/opt/tools/gcc/4.7.2/boost/include/";
private static $log4cxxInclude = "/opt/local/include/log4cxx/";
private static $gccDir = "/opt/tools/gcc/4.7.2/rtf/";
private static $defaultGapThreshold = "5";
private static $userHost = "";
private static $kernelAbout = "Created by CDPP/AMDA(c)";
private static $kernelAcknow = "CDPP/AMDA Team";
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 getRequestParamsPath($working_dir)
{
$paramsPath = $working_dir.self::$requestParamsDir;
if (!is_dir($paramsPath))
mkdir($paramsPath);
return $paramsPath;
}
public static function getXSDParameterFilePath()
{
return NEWKERNEL_XSD_DIR.self::$xsdParameterDir.'all.xsd';
}
public static function getXSDRequestFilePath()
{
return NEWKERNEL_XSD_DIR.self::$xsdRequestDir.'all.xsd';
}
public static function getXSDParamInfoFilePath()
{
return NEWKERNEL_XSD_DIR.self::$xsdInfoDir.'paramInfo.xsd';
}
public static function getXSDDatasetInfoFilePath()
{
return NEWKERNEL_XSD_DIR.self::$xsdInfoDir.'dataSetInfo.xsd';
}
public static function getXSDInstrumentInfoFilePath()
{
return NEWKERNEL_XSD_DIR.self::$xsdInfoDir.'instrumentInfo.xsd';
}
public static function getXSDMissionInfoFilePath()
{
return NEWKERNEL_XSD_DIR.self::$xsdInfoDir.'missionInfo.xsd';
}
public static function getXSDLocalBaseFilePath()
{
return NEWKERNEL_XSD_DIR.self::$xsdLocalBaseDir.'base.xsd';
}
public static function getDatasetInfoPath()
{
return NEWKERNEL_INFO_DIR.self::$datasetInfoDir;
}
public static function getInstrumentInfoPath()
{
return NEWKERNEL_INFO_DIR.self::$instrumentInfoDir;
}
public static function getMissionInfoPath()
{
return NEWKERNEL_INFO_DIR.self::$missionInfoDir;
}
public static function getKernelBinPath()
{
return NEWKERNEL_INSTALL_DIR.self::$binDir;
}
public static function getExecEnvVarArray()
{
return array (
"DDPATH" => DDRES_DIR,
"MY_GXX_HOME" => self::$gccDir,
"PATH" => self::getKernelBinPath().":".self::$gccDir."bin/:".getenv("PATH"),
"LD_LIBRARY_PATH" => self::$gccDir."lib64:".self::$gccDir."lib:".getenv("LD_LIBRARY_PATH")
);
}
public static function getTimeToBatchMode()
{
return 10;
}
public static function write($working_dir, $compilation_path, $localbase_path)
{
//create app.properties file
$appProperties = array();
$appProperties["app.log4cxx.configfile"] = NEWKERNEL_CONFIG_DIR.self::$logConfigFile;
$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.plugin"] = NEWKERNEL_INSTALL_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".NEWKERNEL_SRC_DIR.$inc." ");
$appProperties["app.process.INCLUDE"] .= "-I".self::$localInclude." -I".self::$boostInclude." -I".self::$log4cxxInclude;
$appProperties["app.process.LIB"] = "-L".NEWKERNEL_INSTALL_DIR.self::$libDir." ";
foreach (self::$libArray as $lib)
$appProperties["app.process.LIB"] .= ("-l".$lib." ");
$appProperties["app.plot.configfile"] = INTEGRATION_SRC_DIR.'../config/'.self::$plotConfigFile;
$appProperties["app.param.gapthreshold"] = self::$defaultGapThreshold;
if (self::$userHost != "")
$appProperties["app.user.host"] = self::$userHost;
$fp = fopen($working_dir.self::$propFile, 'w');
foreach ($appProperties as $key => $value)
fwrite($fp, $key."=".$value.PHP_EOL);
fclose($fp);
//create amda.properties file
$amdaPropertiesArray = array();
$amdaPropertiesArray["createdby"] = self::$kernelAbout;
$amdaPropertiesArray["acknowledgement"] = self::$kernelAcknow;
$fp = fopen($working_dir.self::$amdaPropFile, 'w');
foreach ($amdaPropertiesArray as $key => $value)
fwrite($fp, $key."=".$value.PHP_EOL);
fclose($fp);
}
}
?>