-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcept.txt
101 lines (72 loc) · 1.88 KB
/
concept.txt
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
public class MainActivity {
CameraImplementation mCamera;
AlarmImplementation mAlarm;
EdgeImplementation mServer;
public void onCreate() {
Network = Framework.getNetwork();
mCamera = Network.getCamera();
mAlarm = Network.getAlarm();
mServer = Network.getServer();
Framework.initialize(mCamera, mAlarm, mServer);
}
}
---
@EdgeNetwork()
public class Network extends EdgeNetwork {
public abstract CameraImplementation getCamera();
public abstract AlarmImplementation getAlarm();
public abstract ServerImplementation getServer();
}
---
@AutoConnect(true)
@MobileEntity(id = 1, implementation = CameraImplementation.class)
public interface CameraEntity {
}
public class CameraImplementation implements CameraEntity {
private EdgeEntity mServer;
void onStart() {
mServer = Framework.getNetwork().getServer();
while(true) {
if (movementDetected()) {
Bitmap picture = takePicture();
mServer.processPicture(picture)
}
}
}
Bitmap takePicture() {
// ...
}
}
---
@AutoConnect(true)
@MobileEntity(id = 2, class = AlarmImplementation.class)
public interface AlarmEntity {
@NetworkMessage(retry = 3, backoff = Backoff.Exponential)
void activateAlarm();
@NetworkMessage(retry = 3, backoff = Backoff.Exponential)
void deactivateAlarm();
}
public class AlarmImplementation implements AlarmEntity {
public void activateAlarm() {
// ...
}
public void deactivateAlarm() {
// ...
}
}
---
@AutoConnect(true)
@EdgeEntity(id = 3, class = ServerImplementation.class)
public interface ServerEntity {
@NetworkMessage(retry = 3, backoff = Backoff.Exponential)
void processPicture(Bitmap bitmap);
}
public class ServerImplementation implements ServerEntity {
private AlarmEntity mAlarm;
void processPicture(Bitmap bitmap) {
mAlarm = Framework.getNetwork().getAlarm();
if (FaceRecognition.recognize(bitmap) == null) {
mAlarm.activateAlarm();
}
}
}