forked from gaopu/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsulinPump.java
More file actions
59 lines (49 loc) · 1.43 KB
/
InsulinPump.java
File metadata and controls
59 lines (49 loc) · 1.43 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
import java.util.Timer;
import java.util.TimerTask;
class InsulinPump extends Thread{
private double insulinQuantity;//胰岛素的量
private double battery;//电池电量
private double bloodSugar;//血糖值
private double weight;//根据体重计算注射的胰岛素量
public InsulinPump (double weight) {
insulinQuantity = 1000;
battery = 100;
bloodSugar = 5;//正常情况:3.9--6.1 mmol/L
this.weight = weight;
}
/**
* 启动胰岛素泵,开启检测
*/
public void run() {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
battery -= 0.1;
}
},1000,1000);//10秒减少1个电
}
public double getInsulinQuantity() {
return insulinQuantity;
}
public void setInsulinQuantity(double insulinQuantity) {
this.insulinQuantity = insulinQuantity;
}
public double getBattery() {
return battery;
}
public void setBattery(int battery) {
this.battery = battery;
}
public double getBloodSugar() {
return bloodSugar;
}
public void setBloodSugar(double bloodSugar) {
this.bloodSugar = bloodSugar;
}
//调整胰岛素的量
public double adjust() {
double quantity = (bloodSugar * 18 - 100) * weight * 6 / 2000;
insulinQuantity -= quantity;
return quantity;
}
}