Working Component Management
This commit is contained in:
@ -559,6 +559,7 @@ public class Commands extends PICComponent implements CommandInterface {
|
||||
|
||||
@Override
|
||||
public void initialize(PICComponents picComponents) {
|
||||
|
||||
System.out.println("Commands");
|
||||
super.initialize(picComponents);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,12 +37,12 @@ import java.util.Set;
|
||||
|
||||
import static java.lang.Math.max;
|
||||
|
||||
public class Controller_Frontend implements FrontendControllerInterface {
|
||||
public class Controller_Frontend extends PICComponent implements FrontendControllerInterface {
|
||||
|
||||
private int [] prog;
|
||||
private int [][] read;
|
||||
private int [] ind;
|
||||
|
||||
private PICComponents picComponents;
|
||||
private double executionTimeMultiplier = 1;
|
||||
|
||||
|
||||
@ -83,30 +83,10 @@ public class Controller_Frontend implements FrontendControllerInterface {
|
||||
private static volatile boolean isAutoRunActive = false;
|
||||
private static volatile boolean isSleeping = false;
|
||||
|
||||
private final CommandInterface commands;
|
||||
private final WatchdogTimerInterface watchdogTimer;
|
||||
private final ProgramStackInterface programStack;
|
||||
private final WindowManagement createWindow;
|
||||
private final TableInterface table;
|
||||
private final DataRegisterInterface dataRegister;
|
||||
private final IOPortInterface ioPorts;
|
||||
private final ToggleButtonInterface toggleButtonExt;
|
||||
private final ParseFile fileParser;
|
||||
|
||||
|
||||
public Controller_Frontend(CommandInterface commands, WatchdogTimerInterface watchdogTimer,
|
||||
ProgramStackInterface programStack, WindowManagement createWindow, TableInterface table,
|
||||
DataRegisterInterface dataRegister, IOPortInterface ioPorts, ToggleButtonInterface toggleButtons,
|
||||
ParseFile fileParser) {
|
||||
this.commands = commands;
|
||||
this.watchdogTimer = watchdogTimer;
|
||||
this.programStack = programStack;
|
||||
this.createWindow = createWindow;
|
||||
this.table = table;
|
||||
this.dataRegister = dataRegister;
|
||||
this.ioPorts = ioPorts;
|
||||
this.toggleButtonExt = toggleButtons;
|
||||
this.fileParser = fileParser;
|
||||
public Controller_Frontend() {
|
||||
super();
|
||||
System.out.println(this);
|
||||
}
|
||||
|
||||
|
||||
@ -258,8 +238,8 @@ public class Controller_Frontend implements FrontendControllerInterface {
|
||||
commands.decode(0);
|
||||
}
|
||||
watchdogTimer.testAndTrigger();
|
||||
table.refresh();
|
||||
createWindow.refreshTable();
|
||||
Table.refresh();
|
||||
CreateWindow.refreshTable();
|
||||
ioPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
|
||||
updateStack();
|
||||
updateWatchdog();
|
||||
@ -303,6 +283,8 @@ public class Controller_Frontend implements FrontendControllerInterface {
|
||||
stopAutoRun(null);
|
||||
if(selectedFile != null){
|
||||
String fileAddress = selectedFile.getAbsolutePath();
|
||||
System.out.println(dataRegister);
|
||||
if (null == dataRegister) dataRegister = (DataRegisterInterface) picComponents.getComponent(DataRegisterInterface.class);
|
||||
dataRegister.initDataRegister();
|
||||
dataRegister.resetPC();
|
||||
toggleLEDs(null);
|
||||
@ -322,7 +304,7 @@ public class Controller_Frontend implements FrontendControllerInterface {
|
||||
commands.resetTotalExecutionTime();
|
||||
watchdogTimer.reset();
|
||||
wdtCheck.setSelected(false);
|
||||
table.refresh();
|
||||
Table.refresh();
|
||||
read = ParseFile.parseDatei(fileAddress);
|
||||
prog = read [0];
|
||||
ind = read[1];
|
||||
@ -491,8 +473,8 @@ public class Controller_Frontend implements FrontendControllerInterface {
|
||||
allPORTButtons[i].getToggles().get(0).setSelected(true);
|
||||
allTRISButtons[i].getToggles().get(1).setSelected(false);
|
||||
allPORTButtons[i].getToggles().get(1).setSelected(false);
|
||||
toggleButtonExt.get().addAlwaysOneSelectedSupport(allTRISButtons[i]);
|
||||
toggleButtonExt.get().addAlwaysOneSelectedSupport(allPORTButtons[i]);
|
||||
toggleButtonExt.addAlwaysOneSelectedSupport(allTRISButtons[i]);
|
||||
toggleButtonExt.addAlwaysOneSelectedSupport(allPORTButtons[i]);
|
||||
}
|
||||
|
||||
ledCheckA.setSelected(false);
|
||||
@ -601,7 +583,9 @@ public class Controller_Frontend implements FrontendControllerInterface {
|
||||
|
||||
@Override
|
||||
public void initialize(PICComponents picComponents) {
|
||||
|
||||
super.initialize(picComponents);
|
||||
this.picComponents = picComponents;
|
||||
System.out.println("Frontend");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package fabrik.simulator.pic16f84;
|
||||
|
||||
import fabrik.simulator.pic16f84.interfaces.*;
|
||||
import javafx.application.Application;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
@ -14,18 +17,30 @@ import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CreateWindow extends Application {
|
||||
|
||||
private static VBox table;
|
||||
private PICComponents picComponents = new PICComponents(); // Subjekt
|
||||
public static GridPane grid = new GridPane();
|
||||
private static VBox table;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException {
|
||||
|
||||
//DataRegister.initDataRegister();
|
||||
//table = Table.refresh();
|
||||
FXMLLoader codewindow = new FXMLLoader(CreateWindow.class.getResource("frontend.fxml"));
|
||||
Parent code = codewindow.load();
|
||||
picComponents.registerComponent(CommandInterface.class, new Commands());
|
||||
picComponents.registerComponent(ToggleButtonInterface.class, new ToggleButtonGroupExt());
|
||||
picComponents.registerComponent(FrontendControllerInterface.class, new Controller_Frontend());
|
||||
picComponents.registerComponent(DataRegisterInterface.class, new DataRegister());
|
||||
picComponents.registerComponent(EEPROMInterface.class, new EEPROM());
|
||||
picComponents.registerComponent(InterruptInterface.class, new Interrupts());
|
||||
picComponents.registerComponent(IOPortInterface.class, new IOPorts());
|
||||
picComponents.registerComponent(PreScalerInterface.class, new PreScaler());
|
||||
picComponents.registerComponent(ProgramStackInterface.class, new ProgramStack());
|
||||
picComponents.registerComponent(TimerInterface.class, new Timer());
|
||||
picComponents.registerComponent(WatchdogTimerInterface.class, new WatchdogTimer());
|
||||
picComponents.initAll();
|
||||
|
||||
FXMLLoader codewindow = new FXMLLoader(CreateWindow.class.getResource("frontend.fxml"));
|
||||
codewindow.setController(picComponents.getComponent(FrontendControllerInterface.class));
|
||||
Parent code = codewindow.load();
|
||||
table = Table.init(picComponents);
|
||||
grid.add(table, 1, 1);
|
||||
grid.add(code, 0, 1);
|
||||
|
||||
@ -44,7 +59,7 @@ public class CreateWindow extends Application {
|
||||
|
||||
public static void refreshTable() {
|
||||
grid.getChildren().remove(table);
|
||||
//table= Table.refresh();
|
||||
table= Table.refresh();
|
||||
grid.add(table, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package fabrik.simulator.pic16f84;
|
||||
|
||||
import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.EEPROMInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.IOPortInterface;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -62,7 +60,7 @@ public class DataRegister extends PICComponent implements DataRegisterInterface
|
||||
carryFlag = 0;
|
||||
zeroFlag = 0;
|
||||
digitCarryFlag = 0;
|
||||
super.ioPorts.resetTRIS();
|
||||
ioPorts.resetTRIS();
|
||||
System.out.println(Arrays.toString(dataRegister));
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ import java.nio.file.Paths;
|
||||
|
||||
import fabrik.simulator.pic16f84.interfaces.*;
|
||||
|
||||
public class EEPROM implements EEPROMInterface {
|
||||
public class EEPROM extends PICComponent implements EEPROMInterface {
|
||||
private final int EEDATA = 0x08;
|
||||
private final int EEADR = 0x09;
|
||||
private final int EECON1 = 0x88;
|
||||
@ -28,15 +28,11 @@ public class EEPROM implements EEPROMInterface {
|
||||
private boolean readControl = false;
|
||||
private boolean writeControl = false;
|
||||
private boolean [] eecon2stages = {false, false};
|
||||
|
||||
private final DataRegisterInterface dataRegister;
|
||||
private final CommandInterface commands;
|
||||
|
||||
|
||||
private double startTime;
|
||||
|
||||
public EEPROM (DataRegisterInterface dataRegister, CommandInterface commands){
|
||||
this.dataRegister = dataRegister;
|
||||
this.commands = commands;
|
||||
public EEPROM (){
|
||||
}
|
||||
|
||||
public long read (int address) {
|
||||
@ -176,6 +172,7 @@ public class EEPROM implements EEPROMInterface {
|
||||
|
||||
@Override
|
||||
public void initialize(PICComponents picComponents) {
|
||||
|
||||
System.out.println("EEPROM");
|
||||
super.initialize(picComponents);
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,8 +192,8 @@ public class IOPorts extends PICComponent implements IOPortInterface {
|
||||
}
|
||||
|
||||
public void refreshTable(ToggleButtonGroup parent) {
|
||||
table.refresh();
|
||||
createWindow.refreshTable();
|
||||
Table.refresh();
|
||||
CreateWindow.refreshTable();
|
||||
}
|
||||
|
||||
private int[] getToggleParams(ToggleButtonGroup parent) {
|
||||
|
||||
@ -6,7 +6,7 @@ import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.FrontendControllerInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.InterruptInterface;
|
||||
|
||||
public class Interrupts implements InterruptInterface {
|
||||
public class Interrupts extends PICComponent implements InterruptInterface {
|
||||
private final int INTCON = 0xB;
|
||||
private final int T0IF = 0x2;
|
||||
private final int ISR = 0x4;
|
||||
@ -19,14 +19,8 @@ public class Interrupts implements InterruptInterface {
|
||||
private final int INTE = 0x4;
|
||||
private final int INTF = 0x1;
|
||||
|
||||
private final DataRegisterInterface dataRegister;
|
||||
private final CommandInterface commands;
|
||||
private final FrontendControllerInterface frontendController;
|
||||
|
||||
public Interrupts (DataRegisterInterface dataRegister, CommandInterface commands, FrontendControllerInterface frontendController) {
|
||||
this.dataRegister = dataRegister;
|
||||
this.commands = commands;
|
||||
this.frontendController = frontendController;
|
||||
public Interrupts () {
|
||||
}
|
||||
|
||||
public void triggerTMR0(boolean manual) {
|
||||
@ -73,6 +67,6 @@ public class Interrupts implements InterruptInterface {
|
||||
|
||||
@Override
|
||||
public void initialize(PICComponents picComponents) {
|
||||
|
||||
super.initialize(picComponents);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,16 +9,27 @@ public abstract class PICComponent {
|
||||
IOPortInterface ioPorts;
|
||||
TimerInterface timer;
|
||||
InterruptInterface interrupts;
|
||||
TableInterface table;
|
||||
WindowManagement createWindow;
|
||||
//TableInterface table;
|
||||
//WindowManagement createWindow;
|
||||
FrontendControllerInterface frontendController;
|
||||
WatchdogTimerInterface watchdogTimer;
|
||||
ProgramStackInterface programStack;
|
||||
CommandInterface commands;
|
||||
ToggleButtonInterface toggleButtonExt;
|
||||
|
||||
void initialize(PICComponents picComponents) {
|
||||
toggleButtonExt = (ToggleButtonInterface) picComponents.getComponent(ToggleButtonInterface.class);
|
||||
dataRegister = (DataRegisterInterface) picComponents.getComponent(DataRegisterInterface.class);
|
||||
eeprom = (EEPROMInterface) picComponents.getComponent(EEPROMInterface.class);
|
||||
ioPorts = (IOPortInterface) picComponents.getComponent(IOPortInterface.class);
|
||||
System.out.print("Initializing PIC Component ");
|
||||
preScaler = (PreScaler) picComponents.getComponent(PreScalerInterface.class);
|
||||
timer = (TimerInterface) picComponents.getComponent(TimerInterface.class);
|
||||
interrupts = (InterruptInterface) picComponents.getComponent(InterruptInterface.class);
|
||||
//table = (TableInterface) picComponents.getComponent(TableInterface.class);
|
||||
//createWindow = (WindowManagement) picComponents.getComponent(WindowManagement.class);
|
||||
frontendController = (FrontendControllerInterface) picComponents.getComponent(FrontendControllerInterface.class);
|
||||
watchdogTimer = (WatchdogTimerInterface) picComponents.getComponent(WatchdogTimerInterface.class);
|
||||
programStack = (ProgramStackInterface) picComponents.getComponent(ProgramStackInterface.class);
|
||||
commands = (CommandInterface) picComponents.getComponent(CommandInterface.class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,9 +21,7 @@ public class PICComponents {
|
||||
}
|
||||
|
||||
public void initAll() {
|
||||
for (PICComponentInterface component : componentCatalogue.values()) {
|
||||
component.initialize(this);
|
||||
}
|
||||
for (PICComponentInterface component : componentCatalogue.values()) component.initialize(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,46 +2,49 @@ package fabrik.simulator.pic16f84;
|
||||
|
||||
import fabrik.simulator.pic16f84.interfaces.*;
|
||||
|
||||
public class PreScaler extends PICComponent implements PICComponentInterface {
|
||||
public class PreScaler extends PICComponent implements PreScalerInterface {
|
||||
|
||||
private final int PSA = 0x3;
|
||||
private final int OPTION = 0x81;
|
||||
private final TimerInterface timer;
|
||||
private int scaler;
|
||||
|
||||
public PreScaler (DataRegisterInterface dataRegister, TimerInterface timer) {
|
||||
public PreScaler () {
|
||||
super();
|
||||
scaler = 0b111;
|
||||
this.dataRegister = dataRegister;
|
||||
this.timer = timer;
|
||||
}
|
||||
|
||||
public boolean isPrescalerOnTimer (){
|
||||
@Override
|
||||
public boolean isPrescalerOnTimer(){
|
||||
return dataRegister.getDirectBit(OPTION, PSA) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getScaler() {
|
||||
return scaler;
|
||||
}
|
||||
|
||||
public int getFactor () {
|
||||
@Override
|
||||
public int getFactor() {
|
||||
int scale = dataRegister.getDirectRegister(OPTION) & 0b111;
|
||||
int timer = isPrescalerOnTimer() ? 1 : 0;
|
||||
return (int) Math.pow (2, scale+timer);
|
||||
}
|
||||
|
||||
public void reset (){
|
||||
@Override
|
||||
public void reset(){
|
||||
dataRegister.setDirectBit(OPTION, 0, 0);
|
||||
dataRegister.setDirectBit(OPTION, 1, 0);
|
||||
dataRegister.setDirectBit(OPTION, 2, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetFromRegister() {
|
||||
scaler = getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decrement(boolean manual) {
|
||||
scaler--;
|
||||
if (scaler == 0) {
|
||||
@ -52,6 +55,6 @@ public class PreScaler extends PICComponent implements PICComponentInterface {
|
||||
|
||||
@Override
|
||||
public void initialize(PICComponents picComponents) {
|
||||
|
||||
super.initialize(picComponents);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import fabrik.simulator.pic16f84.interfaces.ProgramStackInterface;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProgramStack implements ProgramStackInterface {
|
||||
public class ProgramStack extends PICComponent implements ProgramStackInterface {
|
||||
private List<Integer> returnStack = new ArrayList<>(8);
|
||||
private int stackIndex = 0;
|
||||
|
||||
@ -49,6 +49,6 @@ public class ProgramStack implements ProgramStackInterface {
|
||||
|
||||
@Override
|
||||
public void initialize(PICComponents picComponents) {
|
||||
|
||||
super.initialize(picComponents);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
package fabrik.simulator.pic16f84;
|
||||
|
||||
import fabrik.simulator.pic16f84.interfaces.CommandInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.WindowManagement;
|
||||
import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.IOPortInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.*;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.geometry.Insets;
|
||||
|
||||
import javafx.scene.chart.PieChart;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableColumn;
|
||||
@ -21,28 +19,16 @@ import static javafx.application.Application.launch;
|
||||
public class Table {
|
||||
|
||||
|
||||
//Hier wird die Tabelle aktualisiert
|
||||
//Tabelle aktualisieren
|
||||
|
||||
private final WindowManagement createWindow;
|
||||
private final DataRegisterInterface dataRegister;
|
||||
private final CommandInterface command;
|
||||
private final PreScaler preScaler;
|
||||
private final IOPortInterface ioPorts;
|
||||
|
||||
|
||||
public Table (DataRegisterInterface dataRegister, WindowManagement createWindow, CommandInterface command, PreScaler preScaler, IOPortInterface ioPorts){
|
||||
|
||||
this.dataRegister = dataRegister;
|
||||
this.createWindow = createWindow;
|
||||
this.command = command;
|
||||
this.preScaler = preScaler;
|
||||
this.ioPorts = ioPorts;
|
||||
}
|
||||
//Hier wird die Tabelle aktualisiert
|
||||
//Tabelle aktualisieren
|
||||
private static DataRegisterInterface dataRegister;
|
||||
private static CommandInterface commands;
|
||||
|
||||
private static final int NUM_COLUMNS = 8; // Anzahl der Spalten
|
||||
private static final double TABLE_WIDTH = 425; // Breite der TableView
|
||||
private static final double TABLE_HEIGHT = 600; // Höhe der TableView
|
||||
private static IOPortInterface ioPorts;
|
||||
private static PreScalerInterface preScaler;
|
||||
|
||||
private static String formatHex(String s) {
|
||||
return (s.length() == 1) ? "0" + s : s;
|
||||
@ -60,9 +46,17 @@ public class Table {
|
||||
return s;
|
||||
}
|
||||
|
||||
public static VBox init(PICComponents picComponents){
|
||||
dataRegister = (DataRegisterInterface) picComponents.getComponent(DataRegisterInterface.class);
|
||||
commands = (CommandInterface) picComponents.getComponent(CommandInterface.class);
|
||||
ioPorts = (IOPortInterface) picComponents.getComponent(IOPortInterface.class);
|
||||
preScaler = (PreScalerInterface) picComponents.getComponent(PreScalerInterface.class);
|
||||
return refresh();
|
||||
}
|
||||
|
||||
public VBox refresh(){
|
||||
// Erstelle eine Instanz der DataRegister-Klasse
|
||||
public static VBox refresh() {
|
||||
|
||||
// Erstelle eine Instanz der dataRegister-Klasse
|
||||
|
||||
|
||||
// Erstelle eine TableView für die Datenanzeige
|
||||
@ -108,7 +102,7 @@ public class Table {
|
||||
|
||||
Label spacing = new Label(" ");
|
||||
Label spacing2 = new Label(" ");
|
||||
Label wRegisterLabel = new Label("W-Register: 0x" + formatHex(Integer.toHexString(command.get_wRegister()).toUpperCase()));
|
||||
Label wRegisterLabel = new Label("W-Register: 0x" + formatHex(Integer.toHexString(commands.get_wRegister()).toUpperCase()));
|
||||
Label cLabel = new Label("Carry-Flag: " + dataRegister.getCarryFlag());
|
||||
Label dcLabel = new Label("DigitCarry-Flag: " + dataRegister.getDigitCarryFlag());
|
||||
Label zLabel = new Label("Zero-Flag: " + dataRegister.getZeroFlag());
|
||||
@ -147,7 +141,7 @@ public class Table {
|
||||
|
||||
}
|
||||
|
||||
private void triggerReset() {
|
||||
private static void triggerReset() {
|
||||
dataRegister.initDataRegister();
|
||||
ioPorts.refreshUI(Controller_Frontend.getTRISbuttons(), Controller_Frontend.getPORTbuttons());
|
||||
CreateWindow.refreshTable();
|
||||
@ -158,7 +152,7 @@ public class Table {
|
||||
}
|
||||
|
||||
// Hilfsklasse für die Datenanzeige in der TableView
|
||||
public class DataEntry {
|
||||
public static class DataEntry {
|
||||
private final String address;
|
||||
private final String value;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import fabrik.simulator.pic16f84.interfaces.FrontendControllerInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.InterruptInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.TimerInterface;
|
||||
|
||||
public class Timer implements TimerInterface {
|
||||
public class Timer extends PICComponent implements TimerInterface {
|
||||
private final int TIMERREG = 0x1;
|
||||
private final int T0SE = 0x4;
|
||||
private final int T0CS = 0x5;
|
||||
@ -13,16 +13,7 @@ public class Timer implements TimerInterface {
|
||||
|
||||
private int oldpin = 0;
|
||||
|
||||
private final DataRegisterInterface dataRegister;
|
||||
private final InterruptInterface interrupts;
|
||||
private final PreScaler preScaler;
|
||||
private final FrontendControllerInterface frontendController;
|
||||
|
||||
public Timer (DataRegisterInterface dataRegister, InterruptInterface interrupts, PreScaler preScaler, FrontendControllerInterface frontendController){
|
||||
this.dataRegister = dataRegister;
|
||||
this.interrupts = interrupts;
|
||||
this.preScaler = preScaler;
|
||||
this.frontendController = frontendController;
|
||||
public Timer (){
|
||||
}
|
||||
|
||||
public void cycles(int cycles){
|
||||
@ -77,6 +68,6 @@ public class Timer implements TimerInterface {
|
||||
|
||||
@Override
|
||||
public void initialize(PICComponents picComponents) {
|
||||
|
||||
super.initialize(picComponents);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package fabrik.simulator.pic16f84;
|
||||
|
||||
import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
|
||||
import fabrik.simulator.pic16f84.interfaces.IOPortInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.ToggleButtonInterface;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.control.Toggle;
|
||||
@ -10,21 +11,12 @@ import javafx.scene.input.MouseEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ToggleButtonGroupExt {
|
||||
public class ToggleButtonGroupExt extends PICComponent implements ToggleButtonInterface {
|
||||
|
||||
private IOPortInterface ioPorts;
|
||||
|
||||
private static ToggleButtonGroupExt me;
|
||||
|
||||
public ToggleButtonGroupExt(IOPortInterface ioPorts) {
|
||||
this.ioPorts = ioPorts;
|
||||
}
|
||||
|
||||
public static ToggleButtonGroupExt get(IOPortInterface ioPorts) {
|
||||
if (me == null) {
|
||||
me = new ToggleButtonGroupExt(ioPorts);
|
||||
}
|
||||
return me;
|
||||
public ToggleButtonGroupExt() {
|
||||
}
|
||||
|
||||
|
||||
@ -65,4 +57,10 @@ public class ToggleButtonGroupExt {
|
||||
mouseEvent.consume();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void initialize(PICComponents picComponents) {
|
||||
System.out.println("ToggleButtonGroupExt");
|
||||
super.initialize(picComponents);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
package fabrik.simulator.pic16f84;
|
||||
|
||||
import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
|
||||
import fabrik.simulator.pic16f84.interfaces.IOPortInterface;
|
||||
|
||||
public class TryComponentManagement {
|
||||
public static void main(String[] args) {
|
||||
DataRegisterInterface dataRegister = new DataRegister();
|
||||
IOPortInterface ioPorts = new IOPorts();
|
||||
|
||||
PICComponents picComponents = new PICComponents(); // Subjekt
|
||||
|
||||
picComponents.registerComponent(DataRegisterInterface.class, dataRegister);
|
||||
picComponents.registerComponent(IOPortInterface.class, ioPorts);
|
||||
|
||||
picComponents.initAll();
|
||||
}
|
||||
}
|
||||
@ -2,29 +2,14 @@ package fabrik.simulator.pic16f84;
|
||||
|
||||
import fabrik.simulator.pic16f84.interfaces.*;
|
||||
|
||||
public class WatchdogTimer implements WatchdogTimerInterface {
|
||||
public class WatchdogTimer extends PICComponent implements WatchdogTimerInterface {
|
||||
private long watchdogTime;
|
||||
private double lastReset = 0;
|
||||
private boolean enabled = false;
|
||||
private long rawtimer = 0;
|
||||
private long realtimer = 0;
|
||||
|
||||
|
||||
private final DataRegisterInterface dataRegister;
|
||||
private final ProgramStackInterface programStack;
|
||||
private final FrontendControllerInterface frontendController;
|
||||
private final PreScaler preScaler;
|
||||
private final CommandInterface command;
|
||||
|
||||
|
||||
public WatchdogTimer( DataRegisterInterface dataRegister, ProgramStackInterface programStack, FrontendControllerInterface frontendController,PreScaler preScaler, CommandInterface command){
|
||||
|
||||
this.dataRegister = dataRegister;
|
||||
this.programStack = programStack;
|
||||
this.preScaler = preScaler;
|
||||
this.command = command;
|
||||
this.frontendController = frontendController;
|
||||
|
||||
public WatchdogTimer(){
|
||||
}
|
||||
|
||||
private long getTimeFromRegister() {
|
||||
@ -36,7 +21,7 @@ public class WatchdogTimer implements WatchdogTimerInterface {
|
||||
if (enabled) {
|
||||
if (realtimer >= (watchdogTime + lastReset - 1)) {
|
||||
dataRegister.clearBit(3, 4);
|
||||
lastReset = command.getTotalExecutionTime();
|
||||
lastReset = commands.getTotalExecutionTime();
|
||||
frontendController.stopRunFromBackend("Watchdog Timer");
|
||||
}
|
||||
else {
|
||||
@ -47,7 +32,7 @@ public class WatchdogTimer implements WatchdogTimerInterface {
|
||||
}
|
||||
|
||||
public void reset (){
|
||||
lastReset = command.getTotalExecutionTime();
|
||||
lastReset = commands.getTotalExecutionTime();
|
||||
rawtimer = 0;
|
||||
realtimer = 0;
|
||||
preScaler.reset();
|
||||
@ -69,6 +54,6 @@ public class WatchdogTimer implements WatchdogTimerInterface {
|
||||
|
||||
@Override
|
||||
public void initialize(PICComponents picComponents) {
|
||||
|
||||
super.initialize(picComponents);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package fabrik.simulator.pic16f84.interfaces;
|
||||
|
||||
public interface PreScalerInterface extends PICComponentInterface{
|
||||
boolean isPrescalerOnTimer();
|
||||
|
||||
int getScaler();
|
||||
|
||||
int getFactor();
|
||||
|
||||
void reset();
|
||||
|
||||
void resetFromRegister();
|
||||
|
||||
void decrement(boolean manual);
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package fabrik.simulator.pic16f84.interfaces;
|
||||
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
public interface TableInterface extends PICComponentInterface {
|
||||
void refresh();
|
||||
VBox refresh();
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package fabrik.simulator.pic16f84.interfaces;
|
||||
|
||||
import fabrik.simulator.pic16f84.ToggleButtonGroupExt;
|
||||
import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
|
||||
|
||||
public interface ToggleButtonInterface extends PICComponentInterface {
|
||||
ToggleButtonGroupExt get();
|
||||
void addAlwaysOneSelectedSupport(ToggleButtonGroup allTRISButton);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user