-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadRXAlog.java
More file actions
127 lines (78 loc) · 3.31 KB
/
Copy pathreadRXAlog.java
File metadata and controls
127 lines (78 loc) · 3.31 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
package sample.control;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.util.Scanner;
import java.util.Set;
public class readRXAlog {
String optim_time ;
String optim_time_ATS = "skip";
String optim_init = "skip";
String premature = "NO";
String rescale = "1.0";
String type = "ATP";
String optim_method = "From Segments";
public double time_s_d(String time_s) {
double time_d;
String[] date_sl = time_s.split(" ");
String[] time_sl = date_sl[3].split(":");
time_d = Double.parseDouble(time_sl[2]) +
Double.parseDouble(time_sl[1]) * 60. +
Double.parseDouble(time_sl[0])* 3600. ;
return time_d;
}
public readRXAlog(File file) {
// TODO Auto-generated constructor stub
try {
Scanner scanner = new Scanner(file);
double ref_time = -1;
double latest_time = -1;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if(line.contains("<Time>")) {
String time_s = line.substring(line.indexOf("<Time>")+6, line.indexOf("/Time")-1);
// System.out.println(time_s+"\n");
latest_time = time_s_d(time_s);
if(ref_time == -1)
ref_time = latest_time;
}
if(line.contains("seconds for optimization.")) {
optim_time = String.format("%.1f", (latest_time - ref_time)/60.);
optim_time_ATS = line.substring(line.indexOf("<Message>")+9, line.indexOf("seconds")-1);
type = "ATS";
}
if( line.contains("Warm-Start Optimization Completed") )
optim_time = String.format("%.1f", (latest_time - ref_time)/60.);
if( line.contains("Computing beamlet doses") )
optim_method = "From Fluence";
if(line.contains("seconds for optimization init"))
optim_init = line.substring(line.indexOf("<Message>")+9, line.indexOf("seconds")-1);
// if(line.contains("optimization init"))
// optim_init = String.format("%.1f", Double.parseDouble(line.substring(line.indexOf("<Message>")+9, line.indexOf("seconds")-1))/60.);
// else
// optim_time = String.format("%.1f", Double.parseDouble(line.substring(line.indexOf("<Message>")+9, line.indexOf("seconds")-1))/60.);
if(line.contains("prematurely"))
premature="YES";
if(line.contains("Rescale:"))
rescale = line.substring(line.indexOf("Rescale:")+8, line.indexOf("</Message>")-1);
}
// if( ! optim_init.contentEquals("skip") && ! optim_time_ATS.contentEquals("skip") )
// optim_time = String.format("%.1f", ( Double.parseDouble(optim_init) + Double.parseDouble(optim_time_ATS) )/60.);
if(type.contentEquals("ATP")) {
if(optim_method.contentEquals("From Fluence")) {
optim_method = "Shapes";
} else {
optim_method = "Weights";
}
}
}catch(FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}