advancedSE-paul #3
@ -566,6 +566,7 @@ public class Controller_Frontend extends PICComponent implements FrontendControl
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(PICComponentLocator locator) {
|
public void initialize(PICComponentLocator locator) {
|
||||||
super.initialize(locator);
|
super.initialize(locator);
|
||||||
|
executionTime.registerObserver(this);
|
||||||
this.picComponents = locator;
|
this.picComponents = locator;
|
||||||
System.out.println("Frontend");
|
System.out.println("Frontend");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,6 +174,7 @@ public class EEPROM extends PICComponent implements EEPROMInterface, ExecutionTi
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(PICComponentLocator locator) {
|
public void initialize(PICComponentLocator locator) {
|
||||||
super.initialize(locator);
|
super.initialize(locator);
|
||||||
|
executionTime.registerObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -24,29 +24,8 @@ public abstract class ExecutionTimeSubject extends PICComponent implements PICCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void notifyObservers(){
|
protected void notifyObservers(){
|
||||||
for (final ExecutionTimeObserver each : observers){
|
observers.forEach(o -> o.executionTimeChanged());
|
||||||
notify(each);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void notify(final ExecutionTimeObserver observer) {
|
|
||||||
createNotifierFor(observer).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected Thread createNotifierFor(ExecutionTimeObserver observer) {
|
|
||||||
return new Thread(){
|
|
||||||
public void run(){
|
|
||||||
try {
|
|
||||||
observer.executionTimeChanged();
|
|
||||||
} catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
ExecutionTimeSubject.this.observers.remove(observer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public double getTotalExecutionTime(){
|
public double getTotalExecutionTime(){
|
||||||
throw new UnsupportedOperationException("No class implements ExecutionTimeSubject correctly!");
|
throw new UnsupportedOperationException("No class implements ExecutionTimeSubject correctly!");
|
||||||
|
|||||||
@ -67,6 +67,7 @@ public class Timer extends PICComponent implements TimerInterface, ExecutionTime
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(PICComponentLocator locator) {
|
public void initialize(PICComponentLocator locator) {
|
||||||
super.initialize(locator);
|
super.initialize(locator);
|
||||||
|
executionTime.registerObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user