advancedSE-luca #2

Merged
paul merged 6 commits from advancedSE-luca into advancedSE 2025-05-25 19:06:30 +02:00
28 changed files with 115 additions and 487 deletions
Showing only changes of commit 4310011f0e - Show all commits

View File

@ -559,6 +559,7 @@ public class Commands extends PICComponent implements CommandInterface {
@Override @Override
public void initialize(PICComponents picComponents) { public void initialize(PICComponents picComponents) {
System.out.println("Commands");
super.initialize(picComponents);
} }
} }

View File

@ -37,12 +37,12 @@ import java.util.Set;
import static java.lang.Math.max; 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 [] prog;
private int [][] read; private int [][] read;
private int [] ind; private int [] ind;
private PICComponents picComponents;
private double executionTimeMultiplier = 1; private double executionTimeMultiplier = 1;
@ -83,30 +83,10 @@ public class Controller_Frontend implements FrontendControllerInterface {
private static volatile boolean isAutoRunActive = false; private static volatile boolean isAutoRunActive = false;
private static volatile boolean isSleeping = 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() {
public Controller_Frontend(CommandInterface commands, WatchdogTimerInterface watchdogTimer, super();
ProgramStackInterface programStack, WindowManagement createWindow, TableInterface table, System.out.println(this);
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;
} }
@ -258,8 +238,8 @@ public class Controller_Frontend implements FrontendControllerInterface {
commands.decode(0); commands.decode(0);
} }
watchdogTimer.testAndTrigger(); watchdogTimer.testAndTrigger();
table.refresh(); Table.refresh();
createWindow.refreshTable(); CreateWindow.refreshTable();
ioPorts.refreshUI(getTRISbuttons(), getPORTbuttons()); ioPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
updateStack(); updateStack();
updateWatchdog(); updateWatchdog();
@ -303,6 +283,8 @@ public class Controller_Frontend implements FrontendControllerInterface {
stopAutoRun(null); stopAutoRun(null);
if(selectedFile != null){ if(selectedFile != null){
String fileAddress = selectedFile.getAbsolutePath(); String fileAddress = selectedFile.getAbsolutePath();
System.out.println(dataRegister);
if (null == dataRegister) dataRegister = (DataRegisterInterface) picComponents.getComponent(DataRegisterInterface.class);
dataRegister.initDataRegister(); dataRegister.initDataRegister();
dataRegister.resetPC(); dataRegister.resetPC();
toggleLEDs(null); toggleLEDs(null);
@ -322,7 +304,7 @@ public class Controller_Frontend implements FrontendControllerInterface {
commands.resetTotalExecutionTime(); commands.resetTotalExecutionTime();
watchdogTimer.reset(); watchdogTimer.reset();
wdtCheck.setSelected(false); wdtCheck.setSelected(false);
table.refresh(); Table.refresh();
read = ParseFile.parseDatei(fileAddress); read = ParseFile.parseDatei(fileAddress);
prog = read [0]; prog = read [0];
ind = read[1]; ind = read[1];
@ -491,8 +473,8 @@ public class Controller_Frontend implements FrontendControllerInterface {
allPORTButtons[i].getToggles().get(0).setSelected(true); allPORTButtons[i].getToggles().get(0).setSelected(true);
allTRISButtons[i].getToggles().get(1).setSelected(false); allTRISButtons[i].getToggles().get(1).setSelected(false);
allPORTButtons[i].getToggles().get(1).setSelected(false); allPORTButtons[i].getToggles().get(1).setSelected(false);
toggleButtonExt.get().addAlwaysOneSelectedSupport(allTRISButtons[i]); toggleButtonExt.addAlwaysOneSelectedSupport(allTRISButtons[i]);
toggleButtonExt.get().addAlwaysOneSelectedSupport(allPORTButtons[i]); toggleButtonExt.addAlwaysOneSelectedSupport(allPORTButtons[i]);
} }
ledCheckA.setSelected(false); ledCheckA.setSelected(false);
@ -601,7 +583,9 @@ public class Controller_Frontend implements FrontendControllerInterface {
@Override @Override
public void initialize(PICComponents picComponents) { public void initialize(PICComponents picComponents) {
super.initialize(picComponents);
this.picComponents = picComponents;
System.out.println("Frontend");
} }
} }

View File

@ -1,11 +1,14 @@
package fabrik.simulator.pic16f84; package fabrik.simulator.pic16f84;
import fabrik.simulator.pic16f84.interfaces.*;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -14,18 +17,30 @@ import java.io.IOException;
import java.util.Objects; import java.util.Objects;
public class CreateWindow extends Application { public class CreateWindow extends Application {
private PICComponents picComponents = new PICComponents(); // Subjekt
private static VBox table;
public static GridPane grid = new GridPane(); public static GridPane grid = new GridPane();
private static VBox table;
@Override @Override
public void start(Stage primaryStage) throws IOException { public void start(Stage primaryStage) throws IOException {
//DataRegister.initDataRegister(); picComponents.registerComponent(CommandInterface.class, new Commands());
//table = Table.refresh(); picComponents.registerComponent(ToggleButtonInterface.class, new ToggleButtonGroupExt());
FXMLLoader codewindow = new FXMLLoader(CreateWindow.class.getResource("frontend.fxml")); picComponents.registerComponent(FrontendControllerInterface.class, new Controller_Frontend());
Parent code = codewindow.load(); 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(table, 1, 1);
grid.add(code, 0, 1); grid.add(code, 0, 1);
@ -44,7 +59,7 @@ public class CreateWindow extends Application {
public static void refreshTable() { public static void refreshTable() {
grid.getChildren().remove(table); grid.getChildren().remove(table);
//table= Table.refresh(); table= Table.refresh();
grid.add(table, 1, 1); grid.add(table, 1, 1);
} }
} }

View File

@ -1,8 +1,6 @@
package fabrik.simulator.pic16f84; package fabrik.simulator.pic16f84;
import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface; import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
import fabrik.simulator.pic16f84.interfaces.EEPROMInterface;
import fabrik.simulator.pic16f84.interfaces.IOPortInterface;
import java.util.Arrays; import java.util.Arrays;
@ -62,7 +60,7 @@ public class DataRegister extends PICComponent implements DataRegisterInterface
carryFlag = 0; carryFlag = 0;
zeroFlag = 0; zeroFlag = 0;
digitCarryFlag = 0; digitCarryFlag = 0;
super.ioPorts.resetTRIS(); ioPorts.resetTRIS();
System.out.println(Arrays.toString(dataRegister)); System.out.println(Arrays.toString(dataRegister));
} }

View File

@ -14,7 +14,7 @@ import java.nio.file.Paths;
import fabrik.simulator.pic16f84.interfaces.*; 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 EEDATA = 0x08;
private final int EEADR = 0x09; private final int EEADR = 0x09;
private final int EECON1 = 0x88; private final int EECON1 = 0x88;
@ -29,14 +29,10 @@ public class EEPROM implements EEPROMInterface {
private boolean writeControl = false; private boolean writeControl = false;
private boolean [] eecon2stages = {false, false}; private boolean [] eecon2stages = {false, false};
private final DataRegisterInterface dataRegister;
private final CommandInterface commands;
private double startTime; private double startTime;
public EEPROM (DataRegisterInterface dataRegister, CommandInterface commands){ public EEPROM (){
this.dataRegister = dataRegister;
this.commands = commands;
} }
public long read (int address) { public long read (int address) {
@ -176,6 +172,7 @@ public class EEPROM implements EEPROMInterface {
@Override @Override
public void initialize(PICComponents picComponents) { public void initialize(PICComponents picComponents) {
System.out.println("EEPROM");
super.initialize(picComponents);
} }
} }

View File

@ -192,8 +192,8 @@ public class IOPorts extends PICComponent implements IOPortInterface {
} }
public void refreshTable(ToggleButtonGroup parent) { public void refreshTable(ToggleButtonGroup parent) {
table.refresh(); Table.refresh();
createWindow.refreshTable(); CreateWindow.refreshTable();
} }
private int[] getToggleParams(ToggleButtonGroup parent) { private int[] getToggleParams(ToggleButtonGroup parent) {

View File

@ -6,7 +6,7 @@ import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
import fabrik.simulator.pic16f84.interfaces.FrontendControllerInterface; import fabrik.simulator.pic16f84.interfaces.FrontendControllerInterface;
import fabrik.simulator.pic16f84.interfaces.InterruptInterface; 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 INTCON = 0xB;
private final int T0IF = 0x2; private final int T0IF = 0x2;
private final int ISR = 0x4; private final int ISR = 0x4;
@ -19,14 +19,8 @@ public class Interrupts implements InterruptInterface {
private final int INTE = 0x4; private final int INTE = 0x4;
private final int INTF = 0x1; 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) { public Interrupts () {
this.dataRegister = dataRegister;
this.commands = commands;
this.frontendController = frontendController;
} }
public void triggerTMR0(boolean manual) { public void triggerTMR0(boolean manual) {
@ -73,6 +67,6 @@ public class Interrupts implements InterruptInterface {
@Override @Override
public void initialize(PICComponents picComponents) { public void initialize(PICComponents picComponents) {
super.initialize(picComponents);
} }
} }

View File

@ -9,16 +9,27 @@ public abstract class PICComponent {
IOPortInterface ioPorts; IOPortInterface ioPorts;
TimerInterface timer; TimerInterface timer;
InterruptInterface interrupts; InterruptInterface interrupts;
TableInterface table; //TableInterface table;
WindowManagement createWindow; //WindowManagement createWindow;
FrontendControllerInterface frontendController; FrontendControllerInterface frontendController;
WatchdogTimerInterface watchdogTimer; WatchdogTimerInterface watchdogTimer;
ProgramStackInterface programStack; ProgramStackInterface programStack;
CommandInterface commands;
ToggleButtonInterface toggleButtonExt;
void initialize(PICComponents picComponents) { void initialize(PICComponents picComponents) {
toggleButtonExt = (ToggleButtonInterface) picComponents.getComponent(ToggleButtonInterface.class);
dataRegister = (DataRegisterInterface) picComponents.getComponent(DataRegisterInterface.class); dataRegister = (DataRegisterInterface) picComponents.getComponent(DataRegisterInterface.class);
eeprom = (EEPROMInterface) picComponents.getComponent(EEPROMInterface.class); eeprom = (EEPROMInterface) picComponents.getComponent(EEPROMInterface.class);
ioPorts = (IOPortInterface) picComponents.getComponent(IOPortInterface.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);
} }
} }

View File

@ -21,9 +21,7 @@ public class PICComponents {
} }
public void initAll() { public void initAll() {
for (PICComponentInterface component : componentCatalogue.values()) { for (PICComponentInterface component : componentCatalogue.values()) component.initialize(this);
component.initialize(this);
}
} }
} }

View File

@ -2,46 +2,49 @@ package fabrik.simulator.pic16f84;
import fabrik.simulator.pic16f84.interfaces.*; 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 PSA = 0x3;
private final int OPTION = 0x81; private final int OPTION = 0x81;
private final TimerInterface timer;
private int scaler; private int scaler;
public PreScaler (DataRegisterInterface dataRegister, TimerInterface timer) { public PreScaler () {
super(); super();
scaler = 0b111; scaler = 0b111;
this.dataRegister = dataRegister;
this.timer = timer;
} }
public boolean isPrescalerOnTimer (){ @Override
public boolean isPrescalerOnTimer(){
return dataRegister.getDirectBit(OPTION, PSA) == 0; return dataRegister.getDirectBit(OPTION, PSA) == 0;
} }
@Override
public int getScaler() { public int getScaler() {
return scaler; return scaler;
} }
public int getFactor () { @Override
public int getFactor() {
int scale = dataRegister.getDirectRegister(OPTION) & 0b111; int scale = dataRegister.getDirectRegister(OPTION) & 0b111;
int timer = isPrescalerOnTimer() ? 1 : 0; int timer = isPrescalerOnTimer() ? 1 : 0;
return (int) Math.pow (2, scale+timer); return (int) Math.pow (2, scale+timer);
} }
public void reset (){ @Override
public void reset(){
dataRegister.setDirectBit(OPTION, 0, 0); dataRegister.setDirectBit(OPTION, 0, 0);
dataRegister.setDirectBit(OPTION, 1, 0); dataRegister.setDirectBit(OPTION, 1, 0);
dataRegister.setDirectBit(OPTION, 2, 0); dataRegister.setDirectBit(OPTION, 2, 0);
} }
@Override
public void resetFromRegister() { public void resetFromRegister() {
scaler = getFactor(); scaler = getFactor();
} }
@Override
public void decrement(boolean manual) { public void decrement(boolean manual) {
scaler--; scaler--;
if (scaler == 0) { if (scaler == 0) {
@ -52,6 +55,6 @@ public class PreScaler extends PICComponent implements PICComponentInterface {
@Override @Override
public void initialize(PICComponents picComponents) { public void initialize(PICComponents picComponents) {
super.initialize(picComponents);
} }
} }

View File

@ -5,7 +5,7 @@ import fabrik.simulator.pic16f84.interfaces.ProgramStackInterface;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ProgramStack implements ProgramStackInterface { public class ProgramStack extends PICComponent implements ProgramStackInterface {
private List<Integer> returnStack = new ArrayList<>(8); private List<Integer> returnStack = new ArrayList<>(8);
private int stackIndex = 0; private int stackIndex = 0;
@ -49,6 +49,6 @@ public class ProgramStack implements ProgramStackInterface {
@Override @Override
public void initialize(PICComponents picComponents) { public void initialize(PICComponents picComponents) {
super.initialize(picComponents);
} }
} }

View File

@ -1,12 +1,10 @@
package fabrik.simulator.pic16f84; package fabrik.simulator.pic16f84;
import fabrik.simulator.pic16f84.interfaces.CommandInterface; import fabrik.simulator.pic16f84.interfaces.*;
import fabrik.simulator.pic16f84.interfaces.WindowManagement;
import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
import fabrik.simulator.pic16f84.interfaces.IOPortInterface;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.scene.chart.PieChart;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn;
@ -23,26 +21,14 @@ public class Table {
//Hier wird die Tabelle aktualisiert //Hier wird die Tabelle aktualisiert
//Tabelle aktualisieren //Tabelle aktualisieren
private static DataRegisterInterface dataRegister;
private final WindowManagement createWindow; private static CommandInterface commands;
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;
}
private static final int NUM_COLUMNS = 8; // Anzahl der Spalten 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_WIDTH = 425; // Breite der TableView
private static final double TABLE_HEIGHT = 600; // Höhe 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) { private static String formatHex(String s) {
return (s.length() == 1) ? "0" + s : s; return (s.length() == 1) ? "0" + s : s;
@ -60,9 +46,17 @@ public class Table {
return s; 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(){ public static VBox refresh() {
// Erstelle eine Instanz der DataRegister-Klasse
// Erstelle eine Instanz der dataRegister-Klasse
// Erstelle eine TableView für die Datenanzeige // Erstelle eine TableView für die Datenanzeige
@ -108,7 +102,7 @@ public class Table {
Label spacing = new Label(" "); Label spacing = new Label(" ");
Label spacing2 = 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 cLabel = new Label("Carry-Flag: " + dataRegister.getCarryFlag());
Label dcLabel = new Label("DigitCarry-Flag: " + dataRegister.getDigitCarryFlag()); Label dcLabel = new Label("DigitCarry-Flag: " + dataRegister.getDigitCarryFlag());
Label zLabel = new Label("Zero-Flag: " + dataRegister.getZeroFlag()); Label zLabel = new Label("Zero-Flag: " + dataRegister.getZeroFlag());
@ -147,7 +141,7 @@ public class Table {
} }
private void triggerReset() { private static void triggerReset() {
dataRegister.initDataRegister(); dataRegister.initDataRegister();
ioPorts.refreshUI(Controller_Frontend.getTRISbuttons(), Controller_Frontend.getPORTbuttons()); ioPorts.refreshUI(Controller_Frontend.getTRISbuttons(), Controller_Frontend.getPORTbuttons());
CreateWindow.refreshTable(); CreateWindow.refreshTable();
@ -158,7 +152,7 @@ public class Table {
} }
// Hilfsklasse für die Datenanzeige in der TableView // Hilfsklasse für die Datenanzeige in der TableView
public class DataEntry { public static class DataEntry {
private final String address; private final String address;
private final String value; private final String value;

View File

@ -5,7 +5,7 @@ import fabrik.simulator.pic16f84.interfaces.FrontendControllerInterface;
import fabrik.simulator.pic16f84.interfaces.InterruptInterface; import fabrik.simulator.pic16f84.interfaces.InterruptInterface;
import fabrik.simulator.pic16f84.interfaces.TimerInterface; 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 TIMERREG = 0x1;
private final int T0SE = 0x4; private final int T0SE = 0x4;
private final int T0CS = 0x5; private final int T0CS = 0x5;
@ -13,16 +13,7 @@ public class Timer implements TimerInterface {
private int oldpin = 0; private int oldpin = 0;
private final DataRegisterInterface dataRegister; public Timer (){
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 void cycles(int cycles){ public void cycles(int cycles){
@ -77,6 +68,6 @@ public class Timer implements TimerInterface {
@Override @Override
public void initialize(PICComponents picComponents) { public void initialize(PICComponents picComponents) {
super.initialize(picComponents);
} }
} }

View File

@ -2,6 +2,7 @@ package fabrik.simulator.pic16f84;
import com.gluonhq.charm.glisten.control.ToggleButtonGroup; import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
import fabrik.simulator.pic16f84.interfaces.IOPortInterface; import fabrik.simulator.pic16f84.interfaces.IOPortInterface;
import fabrik.simulator.pic16f84.interfaces.ToggleButtonInterface;
import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.scene.control.Toggle; import javafx.scene.control.Toggle;
@ -10,21 +11,12 @@ import javafx.scene.input.MouseEvent;
import java.io.IOException; import java.io.IOException;
public class ToggleButtonGroupExt { public class ToggleButtonGroupExt extends PICComponent implements ToggleButtonInterface {
private IOPortInterface ioPorts;
private static ToggleButtonGroupExt me; private static ToggleButtonGroupExt me;
public ToggleButtonGroupExt(IOPortInterface ioPorts) { public ToggleButtonGroupExt() {
this.ioPorts = ioPorts;
}
public static ToggleButtonGroupExt get(IOPortInterface ioPorts) {
if (me == null) {
me = new ToggleButtonGroupExt(ioPorts);
}
return me;
} }
@ -65,4 +57,10 @@ public class ToggleButtonGroupExt {
mouseEvent.consume(); mouseEvent.consume();
} }
}; };
@Override
public void initialize(PICComponents picComponents) {
System.out.println("ToggleButtonGroupExt");
super.initialize(picComponents);
}
} }

View File

@ -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();
}
}

View File

@ -2,29 +2,14 @@ package fabrik.simulator.pic16f84;
import fabrik.simulator.pic16f84.interfaces.*; import fabrik.simulator.pic16f84.interfaces.*;
public class WatchdogTimer implements WatchdogTimerInterface { public class WatchdogTimer extends PICComponent implements WatchdogTimerInterface {
private long watchdogTime; private long watchdogTime;
private double lastReset = 0; private double lastReset = 0;
private boolean enabled = false; private boolean enabled = false;
private long rawtimer = 0; private long rawtimer = 0;
private long realtimer = 0; private long realtimer = 0;
public WatchdogTimer(){
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;
} }
private long getTimeFromRegister() { private long getTimeFromRegister() {
@ -36,7 +21,7 @@ public class WatchdogTimer implements WatchdogTimerInterface {
if (enabled) { if (enabled) {
if (realtimer >= (watchdogTime + lastReset - 1)) { if (realtimer >= (watchdogTime + lastReset - 1)) {
dataRegister.clearBit(3, 4); dataRegister.clearBit(3, 4);
lastReset = command.getTotalExecutionTime(); lastReset = commands.getTotalExecutionTime();
frontendController.stopRunFromBackend("Watchdog Timer"); frontendController.stopRunFromBackend("Watchdog Timer");
} }
else { else {
@ -47,7 +32,7 @@ public class WatchdogTimer implements WatchdogTimerInterface {
} }
public void reset (){ public void reset (){
lastReset = command.getTotalExecutionTime(); lastReset = commands.getTotalExecutionTime();
rawtimer = 0; rawtimer = 0;
realtimer = 0; realtimer = 0;
preScaler.reset(); preScaler.reset();
@ -69,6 +54,6 @@ public class WatchdogTimer implements WatchdogTimerInterface {
@Override @Override
public void initialize(PICComponents picComponents) { public void initialize(PICComponents picComponents) {
super.initialize(picComponents);
} }
} }

View File

@ -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);
}

View File

@ -1,5 +1,7 @@
package fabrik.simulator.pic16f84.interfaces; package fabrik.simulator.pic16f84.interfaces;
import javafx.scene.layout.VBox;
public interface TableInterface extends PICComponentInterface { public interface TableInterface extends PICComponentInterface {
void refresh(); VBox refresh();
} }

View File

@ -1,7 +1,7 @@
package fabrik.simulator.pic16f84.interfaces; package fabrik.simulator.pic16f84.interfaces;
import fabrik.simulator.pic16f84.ToggleButtonGroupExt; import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
public interface ToggleButtonInterface extends PICComponentInterface { public interface ToggleButtonInterface extends PICComponentInterface {
ToggleButtonGroupExt get(); void addAlwaysOneSelectedSupport(ToggleButtonGroup allTRISButton);
} }

View File

@ -11,7 +11,7 @@
<?import javafx.scene.shape.*?> <?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<AnchorPane stylesheets="@styles.css" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fabrik.simulator.pic16f84.Controller_Frontend"> <AnchorPane stylesheets="@styles.css" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<ListView fx:id="lstContentListView" layoutY="31.0" prefHeight="645.0" prefWidth="600.0"> <ListView fx:id="lstContentListView" layoutY="31.0" prefHeight="645.0" prefWidth="600.0">