forked from adChong/gbEplus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RunTool.java
86 lines (68 loc) · 3.01 KB
/
RunTool.java
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
package main.java.ui;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Logger;
import org.apache.commons.io.FilenameUtils;
import org.jdom2.Document;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import main.java.model.gbXML.ReverseTranslator;
import main.java.plugins.ashraeassumptions.ASHRAEConstructions;
import main.java.plugins.ashraeassumptions.ASHRAELightData;
import main.java.plugins.ashraeassumptions.ASHRAEOAData;
import main.java.plugins.ashraeassumptions.DOEReferenceEquipmentData;
import main.java.plugins.ashraebaseline.ASHRAEHVAC;
/**
* Test code
* @author weilixu
*
*/
public class RunTool {
public static Logger logger = Logger.getLogger(RunTool.class.getName());
public static StringBuilder logMsg = new StringBuilder();
public static String TEST_XML_STRING = null;
public static int PRETTY_PRINT_INDENT_FACTOR = 4;
public static void main(String[] args) {
// String gbXMLfilepath = args[0];
// String OutputFilepath = args[1];
String gbXMLfilepath = "./resource/test2.xml";
String OutputFilepath = "./output";
System.out.println("translating gbXML to IDF.....");
Path p = Paths.get(gbXMLfilepath);
String OutputFileName = FilenameUtils.getBaseName(p.getFileName().toString());
exportIDF(gbXMLfilepath, OutputFilepath, OutputFileName);
}
public static void captureLog(String msg) {
logMsg.append(System.getProperty("line.separator"));
logMsg.append(msg);
}
public static int exportIDF(String gbxmlfilepath, String idfOutputpath, String outputfilename) {
SAXBuilder builder = new SAXBuilder();
try {
File xmlFile = new File(gbxmlfilepath);
Document doc;
doc = (Document) builder.build(xmlFile);
ReverseTranslator trans = new ReverseTranslator(doc, "8.6");
//register construction
trans.registerDataPlugins(new ASHRAEConstructions());
trans.registerDataPlugins(new ASHRAELightData("./resource/Sep_test_internalloads.xml"));
trans.registerDataPlugins(new ASHRAEOAData("./resource/Sep_test_internalloads.xml"));
trans.registerDataPlugins(new DOEReferenceEquipmentData("./resource/Sep_test_internalloads.xml"));
// trans.registerDataPlugins(new ASHRAEHVAC());
trans.convert();
trans.exportFile(idfOutputpath, outputfilename);
System.out.println("exported IDF to " + idfOutputpath + outputfilename + ".idf" );
} catch (JDOMException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// System.out.println(¡°Severe : ¡± + e.toString());
} catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// System.out.println(¡°Severe : ¡± + e.toString());
}
return 0;
}
}