Introduce ExecutionTimeSubject

This commit is contained in:
2025-05-26 15:32:36 +02:00
parent 06e9348016
commit 85bc6e9eba
14 changed files with 131 additions and 40 deletions

View File

@ -1,7 +1,8 @@
package fabrik.simulator.pic16f84;
import fabrik.simulator.pic16f84.interfaces.*;
public class Commands extends PICComponent implements CommandInterface {
public class Commands extends ExecutionTimeSubject implements CommandInterface {
private int wRegister;
private long totalExecutionTime;
private double executionTimeMultiplier = 1;
@ -18,16 +19,17 @@ public class Commands extends PICComponent implements CommandInterface {
public void addExecutionTime(int i) {
totalExecutionTime += i;
timer.cycles(i);
eeprom.registerTime(false);
super.notifyObservers();
}
@Override
public double getTotalExecutionTime() {
return (totalExecutionTime * getExecutionTimeMultiplier());
}
public void resetTotalExecutionTime() {
totalExecutionTime = 0;
super.notifyObservers();
}
@ -556,10 +558,12 @@ public class Commands extends PICComponent implements CommandInterface {
}
}
@Override
public double getExecutionTimeMultiplier(){
return executionTimeMultiplier;
}
@Override
public void setExecutionTimeMultiplier(String option){
switch (option) {
case "8 MHZ":
@ -584,11 +588,6 @@ public class Commands extends PICComponent implements CommandInterface {
executionTimeMultiplier = 125;
break;
}
}
@Override
public void initialize(PICComponentLocator locator) {
super.initialize(locator);
super.notifyObservers();
}
}