-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPower.java
More file actions
133 lines (118 loc) · 3.54 KB
/
Power.java
File metadata and controls
133 lines (118 loc) · 3.54 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
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
public class Power {
String name = "";
String cnt_in_effect;
String triggered;
String activated;
String expired;
String power_suspended;
String cnt_suspended;
String terminated;
String exerted;
String power_resumed;
String cnt_resumed;
String antecedent;
String pow;
Map<String, String> events = new HashMap<>();
Map<String, String> defines = new HashMap<>();
Power(String name) {
this.name = name;
cnt_in_effect = "";
triggered = "";
activated = "";
expired = "";
power_suspended = "";
cnt_suspended = "";
terminated = "";
exerted = "";
power_resumed = "";
cnt_resumed = "";
antecedent = "";
}
public void generate() {
if (cnt_in_effect.trim().length() == 0) {
cnt_in_effect = "TRUE";
}
if (triggered.trim().length() == 0) {
events.put(this.name + "_triggered", "Event(" + cnt_in_effect + ");");
triggered = this.name + "_triggered._happened";
}
if (activated.trim().length() == 0) {
events.put(this.name + "_activated", "Event(" + this.name + ".state=create);");
activated = this.name + "_activated._happened";
}
if (expired.trim().length() == 0) {
events.put(this.name + "_expired", "Event(" + this.name + ".state=create);");
expired = this.name + "_expired._happened";
}
if (power_suspended.trim().length() == 0) {
// TODO
// events.put(this.name+"_power_suspended",
// "Event("+this.name+".state=inEffect);");
// power_suspended = this.name+"_power_suspended._happened";
power_suspended = "FALSE";
}
if (cnt_suspended.trim().length() == 0) {
// TODO
// events.put(this.name+"_cnt_suspended",
// "Event("+this.name+".state=inEffect);");
// cnt_suspended = this.name+"_cnt_suspended._happened";
cnt_suspended = "FALSE";
}
if (terminated.trim().length() == 0) {
// TODO
// events.put(this.name+"_terminated", "Event("+this.name+".state=inEffect);");
// terminated = this.name+"_terminated._happened";
terminated = "FALSE";
}
if (exerted.trim().length() == 0) {
events.put(this.name + "_exerted", "Event(" + this.name + ".state=inEffect);");
exerted = this.name + "_exerted._happened";
}
if (power_resumed.trim().length() == 0) {
// TODO
// events.put(this.name+"_power_resumed",
// "Event("+this.name+".state=suspension);");
// power_resumed = this.name+"_power_resumed._happened";
power_resumed = "FALSE";
}
if (cnt_resumed.trim().length() == 0) {
// TODO
// events.put(this.name+"_cnt_resumed",
// "Event("+this.name+".state=suspension);");
// cnt_resumed = this.name+"_cnt_resumed._happened";
cnt_resumed = "FALSE";
}
if (antecedent.trim().length() == 0) {
antecedent = "TRUE";
}
}
public void set_antecedent(String ant) {
antecedent = ant;
}
public void set_cnt_ineffect(String inef) {
cnt_in_effect = inef;
}
public void set_trigger(String trg) {
triggered = trg;
}
public String get() {
pow = "Power(" + cnt_in_effect + "," + triggered + "," + activated + ",\r\n\t\t\t" +
expired + "," + power_suspended + "," + cnt_suspended + "," + terminated + ",\r\n\t\t\t" +
exerted + "," + power_resumed + "," + cnt_resumed + "," + antecedent + ");\n";
return "\t\t" + name + "\t:\t" + pow;
}
public String export_events() {
String list = "";
Iterator<Entry<String, String>> itr = events.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry<String, String> event = itr.next();
list += "\t\t" + event.getKey() + "\t:\t" + event.getValue() + "\n";
}
;
return list;
}
}