Import/Timer sleep
This commit is contained in:
@ -9,6 +9,20 @@ public class Commands {
|
||||
return wRegister;
|
||||
}
|
||||
|
||||
public static void addExecutionTime(int i) {
|
||||
totalExecutionTime += i;
|
||||
Timer.cycles(i);
|
||||
EEPROM.registerTime(false);
|
||||
}
|
||||
|
||||
public static long getTotalExecutionTime() {
|
||||
return totalExecutionTime;
|
||||
}
|
||||
|
||||
public static void resetTotalExecutionTime() {
|
||||
totalExecutionTime = 0;
|
||||
}
|
||||
|
||||
public static void decode(int instruction){
|
||||
final int jumpaddr = 0x7FF;
|
||||
final int fileregaddr = 0x7F;
|
||||
@ -255,16 +269,6 @@ public class Commands {
|
||||
addExecutionTime(1);
|
||||
}
|
||||
|
||||
public static void addExecutionTime(int i) {
|
||||
totalExecutionTime += i;
|
||||
Timer.cycles(i);
|
||||
EEPROM.registerTime(false);
|
||||
}
|
||||
|
||||
public static long getTotalExecutionTime() {
|
||||
return totalExecutionTime;
|
||||
}
|
||||
|
||||
public static void MOVWF(int file) {
|
||||
DataRegister.setRegister(file, wRegister);
|
||||
}
|
||||
|
||||
@ -25,16 +25,11 @@ import java.io.FileReader;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextArea;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import static fabrik.simulator.pic16f84.Commands.totalExecutionTime;
|
||||
|
||||
|
||||
public class Controller_Frontend {
|
||||
|
||||
@ -83,9 +78,13 @@ public class Controller_Frontend {
|
||||
@FXML
|
||||
private CheckBox wdtCheck;
|
||||
|
||||
private static volatile boolean isAutoRunActive = true;
|
||||
private static volatile boolean isAutoRunActive = false;
|
||||
private static volatile boolean isSleeping = false;
|
||||
|
||||
public static boolean isSleeping (){
|
||||
return isSleeping;
|
||||
}
|
||||
|
||||
public static void stopRunFromBackend(String message){
|
||||
isAutoRunActive = false;
|
||||
if (isSleeping)
|
||||
@ -130,7 +129,6 @@ public class Controller_Frontend {
|
||||
Platform.runLater(() -> {
|
||||
try {
|
||||
stepintoButton(null);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -172,18 +170,8 @@ public class Controller_Frontend {
|
||||
selectedRowStyle = "-fx-background-color: red; -fx-text-fill: white;";
|
||||
else
|
||||
selectedRowStyle = "-fx-background-color: teal; -fx-text-fill: white;";
|
||||
lstContentListView.setCellFactory(column -> new ListCell<String>() {
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
setText(item);
|
||||
if (getIndex() == currentIndex) {
|
||||
setStyle(selectedRowStyle);
|
||||
} else {
|
||||
setStyle("");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
markSelectedRow(currentIndex, selectedRowStyle);
|
||||
|
||||
// Befehle ausführen
|
||||
if (!isSleeping) {
|
||||
@ -202,17 +190,51 @@ public class Controller_Frontend {
|
||||
totalExecutionTimeLabel.setText("Total Execution Time: " + Commands.getTotalExecutionTime() + "µs");
|
||||
}
|
||||
|
||||
private void markSelectedRow(int currentIndex, String selectedRowStyle){
|
||||
lstContentListView.setCellFactory(column -> new ListCell<String>() {
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
setText(item);
|
||||
if (getIndex() == currentIndex) {
|
||||
setStyle(selectedRowStyle);
|
||||
} else {
|
||||
setStyle("");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
protected void selectFileLST(ActionEvent event){
|
||||
protected void selectFileLST(ActionEvent event) throws IOException {
|
||||
File selectedFile = chooseLSTFile();
|
||||
stopAutoRun(null);
|
||||
if(selectedFile != null){
|
||||
DataRegister.initDataRegister();
|
||||
DataRegister.resetPC();
|
||||
initialize();
|
||||
toggleLEDs(null);
|
||||
IOPorts.reset();
|
||||
for (ToggleButtonGroup toggleButtonGroup : allPORTbuttons) {
|
||||
try {
|
||||
toggleButtonGroup.getToggles().get(0).setSelected(true);
|
||||
toggleButtonGroup.getToggles().get(1).setSelected(false);
|
||||
IOPorts.setPORTfromUI(toggleButtonGroup);
|
||||
} catch (NullPointerException ignored) {}
|
||||
}
|
||||
IOPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
|
||||
Commands.resetTotalExecutionTime();
|
||||
WatchdogTimer.reset();
|
||||
wdtCheck.setSelected(false);
|
||||
Table.refresh();
|
||||
read = ParseFile.parseDatei(selectedFile.getAbsolutePath());
|
||||
prog = read [0];
|
||||
ind = read[1];
|
||||
System.out.println(Arrays.toString(Arrays.stream(prog).toArray()));
|
||||
displayLSTFileContent(selectedFile);
|
||||
}
|
||||
markSelectedRow(0, "-fx-background-color: red; -fx-text-fill: white;");
|
||||
}
|
||||
}
|
||||
|
||||
private File chooseLSTFile() {
|
||||
@ -311,9 +333,15 @@ public class Controller_Frontend {
|
||||
Circle[] allLEDsA = {ledA0, ledA1, ledA2, ledA3, ledA4};
|
||||
Circle[] allLEDsB = {ledB0, ledB1, ledB2, ledB3, ledB4, ledB5, ledB6, ledB7};
|
||||
for (int i = 0; i<allPORTButtons.length; i++) {
|
||||
allTRISButtons[i].getToggles().get(0).setSelected(true);
|
||||
allPORTButtons[i].getToggles().get(0).setSelected(true);
|
||||
allTRISButtons[i].getToggles().get(1).setSelected(false);
|
||||
allPORTButtons[i].getToggles().get(1).setSelected(false);
|
||||
ToggleButtonGroupExt.get().addAlwaysOneSelectedSupport(allTRISButtons[i]);
|
||||
ToggleButtonGroupExt.get().addAlwaysOneSelectedSupport(allPORTButtons[i]);
|
||||
}
|
||||
ledCheckA.setSelected(false);
|
||||
ledCheckB.setSelected(false);
|
||||
setTRISbuttons(allTRISButtons);
|
||||
setPORTbuttons(allPORTButtons);
|
||||
IOPorts.setLEDs(allLEDsA, allLEDsB);
|
||||
|
||||
@ -201,4 +201,10 @@ public class IOPorts {
|
||||
int value = (toggles.get(0).isSelected()) ? 1 : 0;
|
||||
return new int[]{fileAddress, bit, value};
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
trisLatch = new int[]{0xFF, 0xFF};
|
||||
dataLatch = new int[2];
|
||||
refreshPorts();
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,8 @@ public class Table {
|
||||
//Tabelle aktualisieren
|
||||
|
||||
private static final int NUM_COLUMNS = 8; // Anzahl der Spalten
|
||||
private static final double TABLE_WIDTH = 310; // Breite der TableView
|
||||
private static final double TABLE_WIDTH = 400; // Breite der TableView
|
||||
private static final double TABLE_HEIGHT = 650; // Höhe der TableView
|
||||
|
||||
|
||||
|
||||
@ -33,6 +34,7 @@ public class Table {
|
||||
// Erstelle eine TableView für die Datenanzeige
|
||||
TableView<DataEntry[]> tableView = new TableView<>();
|
||||
tableView.setPrefWidth(TABLE_WIDTH);
|
||||
tableView.setPrefHeight(TABLE_HEIGHT);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ public class Timer {
|
||||
}
|
||||
|
||||
public static void incrementFromPin (int register){
|
||||
if (DataRegister.getDirectBit(OPTION, T0CS) == 1){
|
||||
if ((DataRegister.getDirectBit(OPTION, T0CS) == 1) && !Controller_Frontend.isSleeping()){
|
||||
int newpin = (register >> 4) & 1;
|
||||
if (newpin != oldpin) {
|
||||
System.out.println(newpin + " " + oldpin);
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
<AnchorPane stylesheets="@styles.css" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fabrik.simulator.pic16f84.Controller_Frontend">
|
||||
|
||||
<children>
|
||||
<ListView fx:id="lstContentListView" layoutY="31.0" prefHeight="645.0" prefWidth="600.0" />
|
||||
<HBox layoutY="688.0" prefHeight="24.0" prefWidth="600.0">
|
||||
<ListView fx:id="lstContentListView" layoutY="31.0" prefHeight="645.0" prefWidth="550.0" />
|
||||
<HBox layoutY="688.0" prefHeight="24.0" prefWidth="550.0">
|
||||
<children>
|
||||
<Button fx:id="stepintoButton" mnemonicParsing="false" onAction="#stepintoButton" text="Step IN">
|
||||
<opaqueInsets>
|
||||
|
||||
Reference in New Issue
Block a user