Watchdog Label

This commit is contained in:
2024-06-03 01:02:08 +02:00
parent ea6cacfa70
commit 6aab534dad
4 changed files with 86 additions and 51 deletions

View File

@ -30,6 +30,7 @@ import javafx.util.Callback;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static java.lang.Math.max;
@ -121,20 +122,20 @@ public class Controller_Frontend {
wakeUpFromSleep();
else
DataRegister.resetPC();
// Stage stoppedStage = new Stage();
// stoppedStage.setTitle("Programm unterbrochen!");
// VBox vbox = new VBox();
// vbox.setAlignment(javafx.geometry.Pos.CENTER);
// Label grundlabel = new Label("Grund: " + message);
// grundlabel.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;");
// Label ueberlabel = new Label("Programm unterbrochen!");
// vbox.getChildren().add(ueberlabel);
// vbox.getChildren().add(grundlabel);
// VBox.setMargin(grundlabel, new javafx.geometry.Insets(10, 10, 10, 10));
// Scene scene = new Scene(vbox, 300, 90);
// stoppedStage.setAlwaysOnTop(true);
// stoppedStage.setScene(scene);
// stoppedStage.show();
Stage stoppedStage = new Stage();
stoppedStage.setTitle("Programm unterbrochen!");
VBox vbox = new VBox();
vbox.setAlignment(javafx.geometry.Pos.CENTER);
Label grundlabel = new Label("Grund: " + message);
grundlabel.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;");
Label ueberlabel = new Label("Programm unterbrochen!");
vbox.getChildren().add(ueberlabel);
vbox.getChildren().add(grundlabel);
VBox.setMargin(grundlabel, new javafx.geometry.Insets(10, 10, 10, 10));
Scene scene = new Scene(vbox, 300, 90);
stoppedStage.setAlwaysOnTop(true);
stoppedStage.setScene(scene);
stoppedStage.show();
}
public static void sleep() {
@ -263,8 +264,8 @@ public class Controller_Frontend {
Stage stage = (Stage) stepintoButton.getScene().getWindow();
CreateWindow.refreshTable(stage);
IOPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
updateStack();
updateWatchdog();
long totalExecutionTime = Commands.getTotalExecutionTime();
totalExecutionTimeLabel.setText("Total Execution Time: " + totalExecutionTime + "µs");
}
@ -317,6 +318,7 @@ public class Controller_Frontend {
IOPorts.setPORTfromUI(toggleButtonGroup);
} catch (NullPointerException ignored) {}
}
wakeUpFromSleep();
breakpoints.clear();
IOPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
Commands.resetTotalExecutionTime();
@ -326,6 +328,7 @@ public class Controller_Frontend {
read = ParseFile.parseDatei(fileAddress);
prog = read [0];
ind = read[1];
updateStack();
System.out.println(Arrays.toString(Arrays.stream(prog).toArray()));
displayLSTFileContent(selectedFile);
markSelectedRow(0, "-fx-background-color: red; -fx-text-fill: white;");
@ -577,6 +580,31 @@ public class Controller_Frontend {
public void toggleLEDs (ActionEvent actionEvent) {
IOPorts.setLEDs(new boolean[]{ledCheckA.isSelected(), ledCheckB.isSelected()});
}
@FXML
private Label stackIndex;
@FXML
private ListView<String> stackVisual;
private static String format (String s) {
return (s.length() == 1) ? "0" + s : s;
}
private void updateStack (){
stackIndex.setText("Stack-Pointer: " + ProgramStack.getStackPointer());
ObservableList<String> observedList = FXCollections.observableArrayList();
List<Integer> stackList = ProgramStack.getStack();
for (Integer integer : stackList) {
observedList.add("0x" + format(Integer.toHexString(integer).toUpperCase()));
}
stackVisual.setItems(observedList);
}
private void updateWatchdog (){
wdtCheck.setText("Watchdog-Timer: " + WatchdogTimer.get() + "µs");
}
}

View File

@ -79,9 +79,9 @@ public class Table {
Label fsrLabel = new Label("FSR: 0x" + format(Integer.toHexString(DataRegister.getRegister(DataRegister.getFSR())).toUpperCase()));
Label pclathLabel = new Label("PCLATH: 0x" + format(Integer.toHexString(DataRegister.getRegister(DataRegister.getPCLATH())).toUpperCase()));
Label intconLabel = new Label("INTCON: 0x" + format(Integer.toHexString(DataRegister.getRegister(DataRegister.getINTCON())).toUpperCase()));
Label wRegisterLabel = new Label("W Register: 0x" + format(Integer.toHexString(Commands.get_wRegister()).toUpperCase()));
Label wRegisterLabel = new Label("W-Register: 0x" + format(Integer.toHexString(Commands.get_wRegister()).toUpperCase()));
Label PCLabel = new Label("PC: 0x" + format(Integer.toHexString(DataRegister.getPC()).toUpperCase()));
Label Prescaler = new Label("Prescaler: " + format(Integer.toHexString(PreScaler.getScaler())).toUpperCase());
Label Prescaler = new Label("Prescaler: 0x" + format(Integer.toHexString(PreScaler.getScaler())).toUpperCase());

View File

@ -4,6 +4,8 @@ public class WatchdogTimer {
private static long watchdogTime;
private static long lastReset = 0;
private static boolean enabled = false;
private static long rawtimer = 0;
private static long realtimer = 0;
private static long getTimeFromRegister() {
return (PreScaler.isPrescalerOnTimer()) ? 18L : PreScaler.getFactor() * 18L;
@ -12,16 +14,22 @@ public class WatchdogTimer {
public static void testAndTrigger() {
watchdogTime = getTimeFromRegister() * 1000;
if (enabled) {
if (Commands.getTotalExecutionTime() >= (watchdogTime + lastReset - 1)) {
if (realtimer >= (watchdogTime + lastReset - 1)) {
DataRegister.clearBit(3, 4);
lastReset = Commands.getTotalExecutionTime();
Controller_Frontend.stopRunFromBackend("Watchdog Timer");
}
else {
rawtimer++;
realtimer = (long) (rawtimer * Controller_Frontend.getExecutionTimeMultiplier());
}
}
}
public static void reset (){
lastReset = Commands.getTotalExecutionTime();
rawtimer = 0;
realtimer = 0;
PreScaler.reset();
DataRegister.setBit(3, 3);
DataRegister.setBit(3, 4);
@ -34,4 +42,8 @@ public class WatchdogTimer {
public static void disable() {
enabled = false;
}
public static long get (){
return realtimer;
}
}

View File

@ -1,34 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import com.gluonhq.charm.glisten.control.ToggleButtonGroup?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.effect.Blend?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.paint.Color?>
<?import javafx.scene.paint.RadialGradient?>
<?import javafx.scene.paint.Stop?>
<?import javafx.scene.shape.Circle?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<?import com.gluonhq.charm.glisten.control.*?>
<?import java.lang.*?>
<?import javafx.collections.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import javafx.collections.FXCollections?>
<?import javafx.scene.control.ComboBox?>
<?import java.lang.String?>
<AnchorPane stylesheets="@styles.css" xmlns="http://javafx.com/javafx/21" 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" fx:controller="fabrik.simulator.pic16f84.Controller_Frontend">
<children>
<ListView fx:id="lstContentListView" layoutY="31.0" prefHeight="645.0" prefWidth="550.0">
@ -66,7 +49,7 @@
</ComboBox>
<Label fx:id="totalExecutionTimeLabel" text="Total Execution Time: 0µs" />
<CheckBox fx:id="wdtCheck" mnemonicParsing="false" onAction="#toggleWatchdog" text="Watchdog-Timer">
<CheckBox fx:id="wdtCheck" mnemonicParsing="false" onAction="#toggleWatchdog" text="Watchdog-Timer: 0µs">
<Label fx:id="watchdogStatusLabel"/>
<VBox.margin>
<Insets top="10.0" />
@ -74,8 +57,13 @@
</CheckBox>
</children>
</VBox>
<Text layoutX="659.0" layoutY="97.0" strokeType="OUTSIDE" strokeWidth="0.0" text="IO-Ports">
<font>
<Font name="System Bold" size="19.0" />
</font>
</Text>
<HBox layoutX="659.0" layoutY="53.0" prefHeight="293.0" prefWidth="701.0">
<HBox layoutX="659.0" layoutY="111.0" prefHeight="293.0" prefWidth="701.0">
<children>
<GridPane alignment="CENTER" gridLinesVisible="true" prefHeight="273.0" prefWidth="687.0">
<columnConstraints>
@ -751,7 +739,7 @@
</VBox>
<VBox alignment="CENTER" layoutX="10.0" layoutY="124.0" GridPane.rowIndex="7">
<children>
<CheckBox fx:id="ledCheckB" mnemonicParsing="false" onAction="#toggleLEDs"/>
<CheckBox fx:id="ledCheckB" mnemonicParsing="false" onAction="#toggleLEDs" />
</children>
</VBox>
<VBox alignment="CENTER" GridPane.columnIndex="1" GridPane.rowIndex="7">
@ -1022,7 +1010,14 @@
</GridPane>
</children>
</HBox>
<MenuBar prefHeight="31.0" prefWidth="1400.0" AnchorPane.bottomAnchor="1400.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<Text layoutX="659.0" layoutY="459.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Stack">
<font>
<Font name="System Bold" size="19.0" />
</font>
</Text>
<Label fx:id="stackIndex" layoutX="659.0" layoutY="458.0" prefHeight="30.0" prefWidth="111.0" text="Stack-Pointer: 0" />
<ListView fx:id="stackVisual" layoutX="659.0" layoutY="489.0" prefHeight="187.0" prefWidth="92.0" />
<MenuBar prefHeight="31.0" prefWidth="1400.0" AnchorPane.bottomAnchor="1400.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>