Log toegevoegd!
This commit is contained in:
@@ -2,6 +2,9 @@ package pm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import pm.application.ApplicationCycle;
|
||||
import pm.application.example.ExampleApplication;
|
||||
import pm.application.itunes.iTunesApplication;
|
||||
@@ -24,6 +27,8 @@ import pm.exception.device.DeviceInitialiseException;
|
||||
import pm.value.Action;
|
||||
|
||||
public class Main extends EventListener {
|
||||
protected Log log = LogFactory.getLog(Main.class);
|
||||
|
||||
//protected String[] deviceClassArray;
|
||||
protected ApplicationCycle applicationCycle;
|
||||
protected ArrayList<Device> deviceList;
|
||||
@@ -53,6 +58,7 @@ public class Main extends EventListener {
|
||||
try {
|
||||
device.initialise();
|
||||
device.start();
|
||||
log.info("Device started: " + device);
|
||||
} catch (DeviceInitialiseException e) {
|
||||
remove(device);
|
||||
}
|
||||
|
||||
@@ -3,32 +3,43 @@ package pm.event;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import pm.Event;
|
||||
import pm.Listener;
|
||||
import pm.event.task.Continuous;
|
||||
import pm.value.Action;
|
||||
|
||||
public abstract class EventListener extends Listener implements Runnable {
|
||||
protected Queue<Task> taskQueue;
|
||||
protected Queue<Event> eventQueue;
|
||||
|
||||
public EventListener() {
|
||||
taskQueue = new ConcurrentLinkedQueue<Task>();
|
||||
eventQueue = new ConcurrentLinkedQueue<Event>();
|
||||
}
|
||||
|
||||
public final void run() {
|
||||
while (run) {
|
||||
if (taskQueue.isEmpty()) {
|
||||
if (eventQueue.isEmpty()) {
|
||||
sleep();
|
||||
} else {
|
||||
task(taskQueue.poll());
|
||||
event(eventQueue.poll());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Task task) {
|
||||
taskQueue.add(task);
|
||||
public void add(Event event) {
|
||||
eventQueue.add(event);
|
||||
}
|
||||
|
||||
protected void task(Task task) {
|
||||
protected void event(Event event) {
|
||||
if (event instanceof Feedback) {
|
||||
event((Feedback) event);
|
||||
} else if (event instanceof Task) {
|
||||
event((Task) event);
|
||||
}
|
||||
}
|
||||
|
||||
protected void event(Feedback feedback) {}
|
||||
|
||||
protected void event(Task task) {
|
||||
Action action = task.getAction();
|
||||
if (task instanceof Continuous) {
|
||||
Continuous continuous = (Continuous) task;
|
||||
|
||||
@@ -22,6 +22,12 @@ public class EventManager {
|
||||
taskListenerList.add(eventListener);
|
||||
}
|
||||
|
||||
public static void add(Feedback feedback) {
|
||||
for (EventListener eventListener : taskListenerList) {
|
||||
eventListener.add(feedback);
|
||||
}
|
||||
}
|
||||
|
||||
public static void add(EventListener self, Task task) {
|
||||
if (task instanceof Stopper) {
|
||||
Stopper stopper = (Stopper) task;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
TODO
|
||||
------------
|
||||
log bijhouden
|
||||
|
||||
mappings lezen vanuit config bestand
|
||||
|
||||
exeptions en foutmeldingen nakijken/afhandelen/loggen
|
||||
@@ -39,6 +37,10 @@ feedback systeem implementeren, rumble voor zowel wiimote als rumblepad
|
||||
algemene listener parent class / interface maken? die zou standaard thread functies implementeren / vereisen: start, run, stop
|
||||
+hier zijn al enkele aanpassingen aan gemaakt, de main stuurt nu direct de TaskManager aan in plaats van dat het vannuit een Device of Application gebeurd
|
||||
|
||||
log bijhouden
|
||||
+werkt via apache commons logging, nu nog boodschappen toevoegen!
|
||||
|
||||
|
||||
DONE
|
||||
-------------
|
||||
lantextdevice generiek maken met normale textdevice
|
||||
Reference in New Issue
Block a user