Begin gemaakt met devices die events kunnen sturen naar applications via main opdat actions worden uitgevoerd.
This commit is contained in:
@@ -1,27 +1,45 @@
|
||||
package pm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import pm.applicatie.voorbeeld.Voorbeeld;
|
||||
import pm.application.Application;
|
||||
import pm.device.Device;
|
||||
import pm.device.Features;
|
||||
import pm.device.exampledevice.ExampleDevice;
|
||||
import pm.device.example.Example;
|
||||
import pm.event.Event;
|
||||
|
||||
public class Main {
|
||||
ArrayList<Application> applicationList;
|
||||
ArrayList<Device> deviceList;
|
||||
Queue<Event> eventQueue;
|
||||
|
||||
public Main() {
|
||||
applicationList = new ArrayList<Application>();
|
||||
deviceList = new ArrayList<Device>();
|
||||
eventQueue = new ConcurrentLinkedQueue<Event>();
|
||||
}
|
||||
|
||||
public void addApplication(Application application) {
|
||||
applicationList.add(application);
|
||||
}
|
||||
|
||||
public boolean removeApplication(Application application) {
|
||||
return applicationList.remove(application);
|
||||
}
|
||||
|
||||
public void addDevice(Device device) {
|
||||
deviceList.add(device);
|
||||
if (device.hasFeature(Features.RESTART)) {
|
||||
device.start();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeDevie(Device device) {
|
||||
return deviceList.remove(device);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
addDevice(new ExampleDevice());
|
||||
addDevice(new Example(eventQueue));
|
||||
addApplication(new Voorbeeld());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user