-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEV.java
More file actions
93 lines (64 loc) · 1.34 KB
/
EV.java
File metadata and controls
93 lines (64 loc) · 1.34 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
package src;
public class EV {
int arr_time;
int delay;
int leave_time;
int ttl;
int flowId;
int id;
double capacity;
double ini_eng;
double req_eng;
double fin_eng;
double current_eng;
double p_max;
double current_cp; //changring power
double[] cv;
public EV(int time, int id,double p){
arr_time = time;
flowId = id;
delay = id;
leave_time = arr_time + delay;
ttl = id;
ini_eng=0;
req_eng=0;
fin_eng=0;
current_eng=ini_eng;
p_max = p;
current_cp=0;
cv = new double[20];
id =0;
}
public void updateTtl(){
if(ttl>0)
ttl=ttl-1;
}
/*
* set curent charing power,
* and update current_eng;
*/
public void charging(double cp,double interval, int time){
double charging = cp*interval;
if(cp>=0){
if(current_eng+charging>fin_eng){
current_cp = fin_eng-current_eng;
current_eng = fin_eng;
}else{
current_cp = charging;
current_eng = current_eng+ current_cp;
}
}
if(cp<0){
if(current_eng+charging<0){
current_cp = -current_eng;
current_eng =0;
}else{
current_cp = charging;
current_eng = current_eng+current_cp;
}
}
cv[time-arr_time] = current_cp;
if(current_cp <0)
System.out.println("bingo");
}
}