-
Notifications
You must be signed in to change notification settings - Fork 2
/
IoT_class_plantuml.txt
405 lines (344 loc) · 12.6 KB
/
IoT_class_plantuml.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
@startuml
title Internet Of Things -- Class Diagram
package IOT {
package IOTServer as IOTServerPackage {
interface IOTServerInterface {
+ public void receiveServiceOffering(InetAddress sourceAddress, String data)
+ public void subscribeRequestHandler(String destinationIP, int destinationPort)
+ public void incomingNotificationHandler(IOTMessage message)
}
class IOTServer {
- private SubscriberList subscribers
- private IOTClientInterface client
- private IOTApplicationInterface application
+ public IOTServer(SubscriberList pSubscribers, IOTClientInterface pClient, IOTApplicationInterface pApplication)
}
class HTTPServerConnector {
- private IOTServerInterface server
+ public HTTPServerConnector()
# protected void doGet(HttpServletRequest request, HttpServletResponse response)
# protected void doPost(HttpServletRequest request, HttpServletResponse response)
}
package UDPListener {
interface UDPListenerInterface {
+ public void run()
+ public void terminate()
}
class UDPListener {
- private Integer port
- private DatagramSocket socket
- private Boolean running
- private IOTServerInterface receiverServer
+ public UDPListener (@NotNull Integer port, @NotNull IOTServerInterface receiverServer)
+ public Integer getPort()
+ public boolean isRunning()
+ public String toString()
+ {static} public static void main(String[] args)
}
}
}
package IOTClient as IOTClientPackage {
package UDPBroadcastService {
interface UDPBroadcastServiceInterface {
+ public void run()
+ public void terminate()
}
class UDPBroadcastService {
+ {static} public static final int BROADCAST_MESSAGE_INTERVAL = 10000
- private Integer port
- private Boolean running
- private DatagramSocket socket
- private String message
+ public UDPBroadcastService (Integer port, String message)
+ public String toString()
+ {static} public static void main(String[] args)
}
}
interface IOTClientInterface {
+ public void notifySubscribers(IOTMessage message)
+ public void createSubscriptionRequest(String destinationIP, int destinationPort)
}
class IOTClient {
- private SubscriberList subscribers
- private String serviceDescription
+ public public IOTClient (SubscriberList pSubscribers, String serviceDescription)
- private String createUrl(String ipAddress, int port)
+ public void createNewPostRequest(String urlString)
+ public String getServiceDescription()
+ public void setServiceDescription(String serviceDescription)
}
}
package IOTApplication as IOTApplicationPackage {
package alarmclock as alarmclockPackage {
class AlarmClockGUI {
{static} - private static final long serialVersionUID = 1L
+ public AlarmClockGUI()
# protected void doGet(HttpServletRequest request, HttpServletResponse response)
# protected void doPost(HttpServletRequest request, HttpServletResponse response)
}
class AlarmClockService {
- private Timer timer
- private List<Alarm> alarms
- private IOTClientInterface client
- final private String servDesc = "ACS101"
- final private String persFileName = servDesc
- private IOTFilePersistenceManager<Alarm> fileManager
- private final String[] compatDevice = { "ACS", "CMS", "LBCS" }
+ {static} public static final int EC_ALARM_ALREADY_EXISTS = -1
+ {static} public static final int EC_ALARM_DOESNT_EXIST = -2
+ {static} public static final int EC_ALARM_RUNNING = -3
+ {static} public static final int EC_ALARM_IN_PAST = -4
+ {static} public static final int EC_ALARM_NOT_CANCELLED = -5
+ public AlarmClockService(IOTClientInterface newClient)
+ public int setAlarm(Calendar date)
- private int containsKey(long msDate)
+ public ArrayList<Long> getAlarms()
+ public HashMap<Long, Boolean> getAlarm(Calendar date)
+ public int startAlarm(Calendar date)
+ public int cancelAlarm(Calendar date)
+ public int remAlarm(Calendar date)
+ public boolean isActive(Calendar date)
}
class PiezoPlayer {
- private final int PIEZO_PIN = 0
{static} com.pi4j.wiringpi.Gpio.wiringPiSetup()
- private final int[][] MARIO_THEME = {too long for display}
+ public void playTune(int melody)
}
class Alarm {
- {static} private static final long serialVersionUID = 4399487403808161276L
- private Long id
- private Long time
- private transient TimerTask task
+ public Alarm(Long newTime, TimerTask newTask)
+ public Long getTime()
+ public TimerTask getTask()
+ public void setTime(Long time)
+ public void setTask(TimerTask task)
+ public Long getId()
+ public void setId(Long id)
}
class ACRestService {
- private AlarmClockService acs
+ public ACRestService(AlarmClockService newAcs)
+ public Response getAllElements()
+ public Response getElement(String msDate)
+ public Response postElement(String msDate)
+ public Response delElement(String msDate)
}
}
package coffeemachine as coffeemachinepackage {
class CoffeeMachineService {
- private Timer timer = new Timer()
- private ArrayList<Long> coffeeTimes
- private IOTClientInterface client
- final private String servDesc = "CMS"
- final private String persFilename = servDesc + ".txt"
- private IOTFilePersistenceManager<Long> fileManager
- private final String[] compatDevice = {"ACS", "CMS"}
+ {static} public static final int ERROR_CMS_DEVICE_UNAVAILABLE = -1
+ {static} public static final int ERROR_CMS_INVALID_TIME = -2
+ public CoffeeMachineService(IOTClientInterface client)
+ public int addCoffeeTime(long time)
+ public synchronized int makeCoffee()
}
class CoffeeMaker {
- private final int COFFEE_PIN = 0
- private final long ONE_MIN_MS = 60000
- private final long FIVE_MIN_MS = 300000
- private final long FIFTEEN_MIN_MS = 900000
# {static} com.pi4j.wiringpi.Gpio.wiringPiSetup()
+ public void turnOn()
}
}
package testcases as testcasesPackage {
class AlarmTest {
- {static} static private AlarmClockService service
- {static} static private long alarmDelay = 5000
- {static} static private long timeInMs
- private void setUpAlarm()
+ public void testStartAlarm()
+ public void testCancelAlarm()
+ public void testRemoveAlarm()
}
class CoffeeTest {
- private CoffeeMachineService coffeeMachineService = new CoffeeMachineService(null)
- {static} static private final int COFFEE_DELAY = 5000
+ public void testAddCoffeetime()
+ public void testDuplicateCoffetime()
+ public void testPastCoffeetime()
}
class IOTFilePersistenceTest {
+ public void test() throws Exception
}
}
class IOTApplicationInterface {
+ public void handleIncomingNotification(IOTMessage message)
+ public String getServiceDescription()
+ public boolean isInterested(String broadcast)
}
class IOTMessage {
- private final String servDesc
- private final String messageType
- private final String message
+ public IOTMessage(String newMessageType, String newMessage)
+ public String getMessageType()
+ public String getMessage()
}
interface IOTPersistenceManager {
+ public abstract class Predicate<T>
+ List<T> findAll()
+ List<T> find(Predicate<T> predicate)
+ List<T> find(T element)
+ T findFirst(Predicate<T> predicate)
+ T findFirst(T element)
+ void add(T element)
+ void delete(T element)
+ void delete(Predicate<T> predicate)
}
class IOTFilePersistenceManager {
- private String filename
- private ArrayList<T> data
+ public void open()
+ public void createNewDatastore(String filename)
+ public void createNewDatastore()
}
}
class DeviceDetection {
- private boolean isWin
- private boolean isMac
- private boolean isLin
- private boolean isRasp
+ public DeviceDetection()
+ public boolean isWin()
+ public boolean isMac()
+ public boolean isLin()
+ public boolean isRasp()
}
class IOTRunner {
- private IOTClient client
- private AlarmClockService alarmClock
- private IOTServer server
- private UDPListenerInterface udpListener
- private UDPBroadcastService udpBroadcastService
- private Thread listenerThread
- private Thread broadcasterThread
- private SubscriberList subscriberList
- private IACSoapService acSoapService
+ {static} public static final int UDP_SERVICE_PORT = 29902
+ {static} public static final int REST_SERVICE_PORT = 9000
+ {static} public static final int SOAP_SERVICE_PORT = 9090
+ public IOTRunner ()
}
class Subscriber {
- final private String ipAddress
- final private int port
+ public Subscriber(String pIpAddress, int pPort)
+ public String getIpAddress()
+ public int getPort()
}
class SubscriberList {
- private ArrayList<Subscriber> list
+ public void addSubscriber(Subscriber newSubscriber)
+ public ArrayList<Subscriber> getSubscribers()
}
package IOT_SOAP {
interface IACSoapService {
+ public public ArrayList<Long> getAlarms()
+ public HashMap<Long, String> getAlarm(String msDate)
+ public int postAlarm(String msDate)
+ public int delAlarm(String msDate)
}
class ACSoapService {
- private AlarmClockService alarmClockService
+ public ACSoapService ()
+ public void setAlarmClockService(AlarmClockService alarmClockService)
+ {static} public static void main(String[] args)
}
class LongBooleanHashmap {
# ArrayList<LongBooleanEntry> entries
public ArrayList<LongBooleanEntry> getEntries()
{static} static class LongBooleanEntry
}
class LongBooleanEntry {
# Long msTime
# Boolean msTimeBool
+ public Long getMsTime()
+ public void setMsTime(Long msTime)
+ public Boolean getMsTimeBool()
+ public void setMsTimeBool(Boolean msTimeBool)
}
class LongBooleanHashmapAdapter {
+ public HashMap<Long, Boolean> unmarshal(LongBooleanHashmap v)
+ public LongBooleanHashmap marshal(HashMap<Long, Boolean> v)
}
package testcases as TestCasesPackagex {
class AcSoapServiceTest {
- {static} static private AlarmClockService alarmClockService
- {static} long alarmDelay = 5000
- {static} long timeInMs
- {static} static public String serviceUrl = "http://localhost:8080/ACSoapService"
- private IACSoapService soapService
- {static} static private boolean endpointsReady = false
- private ArrayList<Long> alarms
+ public AcSoapServiceTest()
+ public void startClient()
+ public void startServer()
}
}
}
}
interface ServletContextListener {
+ public void contextInitialized(ServletContextEvent servletContextEvent)
+ public void contextDestroyed(ServletContextEvent servletContextEvent)
}
note left of IOTServerPackage : shared server library (same codebase across all devices)
note left of IOTClientPackage : shared client library (same codebase across all devices)
note left of IOTApplicationPackage : code dependent on underlying device
HTTPServlet <|-- AlarmClockGUI
HTTPServlet <|-- HTTPServerConnector
IOTClientInterface <|.. IOTClient
IOTServerInterface <|.. IOTServer
IOTApplicationInterface <|.. AlarmClockService
IOTApplicationInterface <|.. CoffeeMachineService
Runnable <|-- UDPListenerInterface
Runnable <|-- UDPBroadcastServiceInterface
UDPListenerInterface <|.. UDPListener
UDPBroadcastServiceInterface <|.. UDPBroadcastService
ServletContextListener <|.. IOTRunner
IACSoapService <|.. ACSoapService
SubscriberList --> "*" Subscriber
HTTPServerConnector --> "1" IOTServerInterface
IOTServer --> "1" SubscriberList
IOTServer --> "1" IOTClientInterface
IOTServer --> "1" IOTApplicationInterface
IOTClientInterface --> IOTMessage : uses
IOTClient --> "1" SubscriberList
UDPListener --> "1" IOTServerInterface
AlarmClockService --> "1" IOTClientInterface
AlarmClockService --> DeviceDetection : uses
AlarmClockService --> IOTMessage : uses
AlarmClockService --> "1" IOTFilePersistenceManager
CoffeeMachineService --> "1" IOTClientInterface
CoffeeMachineService --> DeviceDetection : uses
CoffeeMachineService --> IOTMessage: uses
CoffeeMachineService --> "1" IOTFilePersistenceManager
AlarmTest --> AlarmClockService : tests
CoffeeTest --> CoffeeMachineService : tests
IOTFilePersistenceTest --> IOTFilePersistenceManager : tests
AcSoapServiceTest --> IACSoapService : tests
LongBooleanHashmap --> LongBooleanEntry : contains
LongBooleanHashmapAdapter --> LongBooleanHashmap : uses
IACSoapService --> LongBooleanHashmapAdapter : requires
ACSoapService --> "1" AlarmClockService : depends on functionality
AcSoapServiceTest --> "1" AlarmClockService : tests
ACRestService --> "1" AlarmClockService : depends on functionality
IOTRunner --> "1" IOTClient
IOTRunner --> "1" IOTApplicationInterface
IOTRunner --> "1" IOTServer
IOTRunner --> "1" UDPListenerInterface
IOTRunner --> "1" UDPBroadcastService
IOTRunner --> "1" SubscriberList
IOTRunner --> "1" ACRestService
IOTRunner --> "1" IACSoapService
@enduml