Timer implemented, About and Help Frames added
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/View/GUIAbout.class
Normal file
BIN
bin/View/GUIAbout.class
Normal file
Binary file not shown.
BIN
bin/View/GUIHelp.class
Normal file
BIN
bin/View/GUIHelp.class
Normal file
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
,aaron_moser,aaron-moser-ThinkPad-T430,08.04.2022 11:11,file:///home/aaron_moser/.config/libreoffice/4;
|
||||
Binary file not shown.
@@ -3,6 +3,8 @@ package Control;
|
||||
import Model.MyModelData;
|
||||
import Model.EepromLoader.ReadEepromFile;
|
||||
import Model.Microcontroller.PIC;
|
||||
import View.GUIAbout;
|
||||
import View.GUIHelp;
|
||||
import View.MyView;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -259,9 +261,11 @@ public class MyControlModel implements ActionListener {
|
||||
oMyView.setLanguage(1);
|
||||
}break;
|
||||
case 15: {
|
||||
new GUIHelp();
|
||||
//Show manual
|
||||
}break;
|
||||
case 16: {
|
||||
new GUIAbout();
|
||||
//Show about
|
||||
}break;
|
||||
}
|
||||
@@ -292,5 +296,6 @@ public class MyControlModel implements ActionListener {
|
||||
oMenuItem.addActionListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public class MyControlView {
|
||||
setRegistersDetailed();
|
||||
setStack();
|
||||
setTestFileTable();
|
||||
setMCMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,6 +150,10 @@ public class MyControlView {
|
||||
oMyView.getGUIPorts().enableCheckboxesB(abEnabled);
|
||||
}
|
||||
|
||||
public void setMCMenu() {
|
||||
oMyView.getGUITime().setRuntime(oPIC.getRuntimer().getRuntime());
|
||||
}
|
||||
|
||||
public void setRamView() {
|
||||
int[] aiData;
|
||||
int[] aiBank0 = oPIC.getRam().get_Bank0();
|
||||
|
||||
@@ -17,18 +17,21 @@ public class PIC {
|
||||
private RAM Ram;
|
||||
private STACK Stack;
|
||||
private int WRegister;
|
||||
private RUNTIMER Runtimer;
|
||||
|
||||
public PIC() {
|
||||
//Initialising objects of PIC.
|
||||
Eeprom = new EEPROM();
|
||||
Ram = new RAM();
|
||||
Stack = new STACK();
|
||||
Runtimer = new RUNTIMER(Ram);
|
||||
WRegister = 0;
|
||||
}
|
||||
|
||||
public synchronized void resetPIC() {
|
||||
Ram = new RAM();
|
||||
Stack = new STACK();
|
||||
Runtimer = new RUNTIMER(Ram);
|
||||
WRegister = 0;
|
||||
}
|
||||
|
||||
@@ -78,6 +81,10 @@ public class PIC {
|
||||
return Stack;
|
||||
}
|
||||
|
||||
public synchronized RUNTIMER getRuntimer() {
|
||||
return Runtimer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Datasheet Page 57
|
||||
*
|
||||
@@ -137,6 +144,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PCL and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,6 +182,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,6 +269,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,6 +322,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,6 +352,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,6 +395,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,6 +423,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,6 +462,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,9 +492,10 @@ public class PIC {
|
||||
if (Ram.get_T0CS() == false)
|
||||
Ram.increment_TMR0();
|
||||
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,6 +516,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -512,6 +538,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -537,6 +565,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -583,6 +613,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -632,6 +664,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -679,6 +713,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -701,6 +737,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -749,6 +787,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -805,6 +845,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -838,6 +880,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -879,6 +923,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -899,6 +945,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -937,6 +985,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -955,6 +1005,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -970,6 +1022,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -997,6 +1051,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**OPTION
|
||||
@@ -1012,6 +1068,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
|
||||
@@ -1039,6 +1097,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1061,6 +1121,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1117,6 +1179,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1172,6 +1236,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1195,6 +1261,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1251,6 +1319,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1326,6 +1396,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1363,6 +1435,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1388,6 +1462,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1419,6 +1495,8 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1462,5 +1540,7 @@ public class PIC {
|
||||
|
||||
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
|
||||
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
|
||||
|
||||
Runtimer.incrementRuntime();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,100 @@
|
||||
package Model.Microcontroller;
|
||||
|
||||
public class RUNTIMER {
|
||||
|
||||
}
|
||||
private double dRuntime;
|
||||
private double dMaxWatchdog;
|
||||
private double dRTIncrVal;
|
||||
|
||||
private boolean WDTE = false;
|
||||
|
||||
private RAM oRam;
|
||||
|
||||
public RUNTIMER(RAM oRam) {
|
||||
this.oRam = oRam;
|
||||
}
|
||||
|
||||
public void setMaxWatchdog(double dMaxVal) {
|
||||
dMaxWatchdog = dMaxVal;
|
||||
}
|
||||
|
||||
private void checkWatchdog() {
|
||||
if (WDTE) {
|
||||
if (oRam.get_PSA()) {
|
||||
setMaxWatchdog(18000 * oRam.get_WDT_PrescalerRate());
|
||||
} else {
|
||||
setMaxWatchdog(18000);//18 ms
|
||||
}
|
||||
if ((dMaxWatchdog - dRuntime) <= 0) {
|
||||
System.out.println("WDT Interrupt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getRuntime() {
|
||||
return dRuntime;
|
||||
}
|
||||
|
||||
public void setRuntime(double liVal) {
|
||||
dRuntime = liVal;
|
||||
}
|
||||
|
||||
public void incrementRuntime() {
|
||||
dRuntime += dRTIncrVal;
|
||||
checkWatchdog();
|
||||
}
|
||||
|
||||
public void setQuarzSpeed(int iInterval) {
|
||||
switch (iInterval) {
|
||||
//10 {"32 kHz", "100 kHz", "500 kHz", "1 MHz", "2 MHz", "4 MHz", "8 MHz", "12 MHz", "16 MHz", "20 MHz"}
|
||||
case 0: {
|
||||
//32 kHz => 125 mikrosekunden = 0.125ms
|
||||
dRTIncrVal = 0.001 * (4 / 0.032);
|
||||
}break;
|
||||
|
||||
case 1: {
|
||||
//100kHz => 40 mikrosekunden = 0.040 ms
|
||||
dRTIncrVal = 0.001 * (4 / 0.1);
|
||||
}break;
|
||||
|
||||
case 2: {
|
||||
//500kHz => 8 mikrosekunden = 0.008 ms
|
||||
dRTIncrVal = 0.001 * (4 / 0.5);
|
||||
}break;
|
||||
|
||||
case 3: {
|
||||
//1MHz => 4 mikrosekunden = 0.004 ms
|
||||
dRTIncrVal = 0.001 * (4 / 1);
|
||||
}break;
|
||||
|
||||
case 4: {
|
||||
//2MHz => 2 mikrosekunden = 0.002 ms
|
||||
dRTIncrVal = 0.001 * (4 / 2);
|
||||
}break;
|
||||
|
||||
case 5: {
|
||||
//4MHz => 1 mikrosekunde = 0.001 ms
|
||||
dRTIncrVal = 0.001 * (4 / 4);
|
||||
}break;
|
||||
|
||||
case 6: {
|
||||
//8MHz => 0.5 mikrosekunden = 0.0005 ms
|
||||
dRTIncrVal = 0.001 * (4 / 8);
|
||||
}break;
|
||||
|
||||
case 7: {
|
||||
//12MHz => 0.33 mikrosekunden = 0.0003 ms
|
||||
dRTIncrVal = 0.001 * (4 / 12);
|
||||
}break;
|
||||
|
||||
case 8: {
|
||||
//16MHz => 0.25 mikrosekunden = 0.00025 ms
|
||||
dRTIncrVal = 0.001 * (4 / 16);
|
||||
}break;
|
||||
|
||||
case 9: {
|
||||
//20MHz => 0.20 mikrosekunden = 0.00020 ms
|
||||
dRTIncrVal = 0.001 * (4 / 20);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package Model.Microcontroller;
|
||||
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 23.06.2021
|
||||
* @lastchange 23.06.2021
|
||||
*/
|
||||
|
||||
//Doesn't work correctly, status is changed too fast.
|
||||
public class WATCHDOG extends Thread
|
||||
{
|
||||
private long time;
|
||||
private int watchdogStatus;
|
||||
private long timeStart;
|
||||
private long timeEnd;
|
||||
|
||||
/**
|
||||
* Constructor of watchdog.
|
||||
*/
|
||||
public WATCHDOG()
|
||||
{
|
||||
time = 0;
|
||||
watchdogStatus = 0;
|
||||
timeStart = 0;
|
||||
timeEnd = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return time in microseconds of watchdog.
|
||||
*/
|
||||
public synchronized long getTime()
|
||||
{
|
||||
return this.time / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets time of watchdog.
|
||||
* @param value of new time.
|
||||
*/
|
||||
public synchronized void setTime(long value)
|
||||
{
|
||||
this.time = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Status of watchdog.
|
||||
* 0: Waiting for start
|
||||
* 1: Start Watchdog
|
||||
* 2: GetTime Watchdog
|
||||
* 3: End Watchdog
|
||||
* 4: Stop Watchdog
|
||||
*/
|
||||
public synchronized int getWatchdogStatus()
|
||||
{
|
||||
return this.watchdogStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 0: Waiting for start
|
||||
* 1: Start Watchdog
|
||||
* 2: GetTime Watchdog
|
||||
* 3: End Watchdog
|
||||
* 4: Stop Watchdog
|
||||
* @param value
|
||||
*/
|
||||
public synchronized void setWatchdogStatus(int value)
|
||||
{
|
||||
this.watchdogStatus = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes it possible to create a thread of watchdog.
|
||||
*/
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
//If status is changed to 3, watchdog is stopped.
|
||||
while (this.watchdogStatus != 3)
|
||||
{
|
||||
if (watchdogStatus != 4)
|
||||
{
|
||||
//If status changes to 1, starts to count time and sets status to 4.
|
||||
if (this.watchdogStatus == 1)
|
||||
{
|
||||
this.timeStart = System.nanoTime();
|
||||
if (this.getWatchdogStatus() != 2)
|
||||
{
|
||||
this.setWatchdogStatus(4);
|
||||
}
|
||||
}
|
||||
|
||||
//If status changes to 2, stops count time and sets time to new value, then sets status to 4.
|
||||
if (this.watchdogStatus == 2)
|
||||
{
|
||||
this.timeEnd = System.nanoTime();
|
||||
if (this.getWatchdogStatus() != 1)
|
||||
{
|
||||
this.setWatchdogStatus(4);
|
||||
}
|
||||
this.setTime(this.timeEnd - this.timeStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,66 +113,13 @@ public class MyModel extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
private void setQuarzSpeed(int iInterval) { //TODO Quartz
|
||||
switch (iInterval) {
|
||||
//10 {"32 kHz", "100 kHz", "500 kHz", "1 MHz", "2 MHz", "4 MHz", "8 MHz", "12 MHz", "16 MHz", "20 MHz"}
|
||||
case 0: {
|
||||
//32 kHz =>
|
||||
dRTIncrVal = (4 / 0.032);
|
||||
}break;
|
||||
|
||||
case 1: {
|
||||
//100kHz => 0.000010s
|
||||
dRTIncrVal = (4 / 0.1);
|
||||
}break;
|
||||
|
||||
case 2: {
|
||||
//500kHz => 0.0000020s
|
||||
dRTIncrVal = (4 / 0.5);
|
||||
}break;
|
||||
|
||||
case 3: {
|
||||
//1MHz => 0.0000010s
|
||||
dRTIncrVal = (4 / 1);
|
||||
}break;
|
||||
|
||||
case 4: {
|
||||
//2MHz => 0.0000005s
|
||||
dRTIncrVal = (4 / 2);
|
||||
}break;
|
||||
|
||||
case 5: {
|
||||
//4MHz => 0.00000025s 1 mükrosekunde
|
||||
dRTIncrVal = (4 / 4);
|
||||
}break;
|
||||
|
||||
case 6: {
|
||||
//8MHz => 0.000000125s
|
||||
dRTIncrVal = (4 / 8);
|
||||
}break;
|
||||
|
||||
case 7: {
|
||||
//12MHz => 0.00000008333333
|
||||
dRTIncrVal = (4 / 12);
|
||||
}break;
|
||||
|
||||
case 8: {
|
||||
//16MHz => 0.0000000625
|
||||
dRTIncrVal = (4 / 16);
|
||||
}break;
|
||||
|
||||
case 9: {
|
||||
//20MHz => 0.00000005
|
||||
dRTIncrVal = (4 / 20);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setModel(MyModelData data) {
|
||||
oMyModelData = data;
|
||||
oPIC = oMyModelData.getPIC();
|
||||
abBreakpoints = oMyModelData.getBreakpoints();
|
||||
setQuarzSpeed(oMyModelData.getQuartzInterval());
|
||||
oPIC.getRuntimer().setQuarzSpeed(oMyModelData.getQuartzInterval());
|
||||
iVisualInterval = oMyModelData.getVisualInterval();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ public class Main {
|
||||
MyView oView = new MyView();
|
||||
|
||||
MyControlView oControlView = new MyControlView(oPIC, oView);
|
||||
|
||||
|
||||
new MyControlModel(oView, qCommandsToModel, qDataToModel);
|
||||
|
||||
//Check if model sent a new pic-element through queue and update view.
|
||||
while (qCommandsToModel.peek() > 0) {
|
||||
while (true) {
|
||||
while (!qDataToView.isEmpty()) {
|
||||
PIC pic = qDataToView.poll();
|
||||
oControlView.setPIC(pic);
|
||||
|
||||
53
src/View/GUIAbout.java
Normal file
53
src/View/GUIAbout.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package View;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
|
||||
public class GUIAbout extends JFrame {
|
||||
public GUIAbout() {
|
||||
// sets title of frame
|
||||
this.setTitle("PIC-Simulator GUI - About");
|
||||
|
||||
//prevent frame from beeing resized
|
||||
this.setResizable(false);
|
||||
|
||||
//sets x and y dimension of frame
|
||||
this.setSize(650, 420);
|
||||
|
||||
//Set Icon
|
||||
ImageIcon guiLogo = new ImageIcon("./pictures/gui_logo.png"); // create an ImageIcon
|
||||
this.setIconImage(guiLogo.getImage()); // change icon of frame
|
||||
|
||||
this.setVisible(true);
|
||||
|
||||
JScrollPane oJScrollPane = new JScrollPane();
|
||||
|
||||
JPanel oAboutPanel = new JPanel();
|
||||
|
||||
JTextArea oAboutText = new JTextArea();
|
||||
oAboutText.setLineWrap(true);
|
||||
oAboutText.setPreferredSize(new Dimension(600, 400));
|
||||
oAboutText.setEditable(false);
|
||||
|
||||
oAboutPanel.add(oAboutText);
|
||||
|
||||
oAboutText.setText( "Hochschule Offenburg SS2022\n" +
|
||||
"Projekt Rechnerarchitektur - Simulator Mikroprozessor 16F84\n" +
|
||||
"Entwickler: Aaron Moser\n" +
|
||||
"Programmiersprache: Java\n" +
|
||||
"Entwicklungsumgebung: Visual Studio Code\n");
|
||||
|
||||
oJScrollPane.setViewportView(oAboutPanel);
|
||||
oJScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
oJScrollPane.setWheelScrollingEnabled(true);
|
||||
oJScrollPane.getVerticalScrollBar().setUnitIncrement(16);
|
||||
|
||||
this.add(oJScrollPane);
|
||||
}
|
||||
}
|
||||
54
src/View/GUIHelp.java
Normal file
54
src/View/GUIHelp.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package View;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
|
||||
public class GUIHelp extends JFrame {
|
||||
public GUIHelp() {
|
||||
// sets title of frame
|
||||
this.setTitle("PIC-Simulator GUI - Help");
|
||||
|
||||
//prevent frame from beeing resized
|
||||
this.setResizable(false);
|
||||
|
||||
//sets x and y dimension of frame
|
||||
this.setSize(650, 420);
|
||||
|
||||
//Set Icon
|
||||
ImageIcon guiLogo = new ImageIcon("./pictures/gui_logo.png"); // create an ImageIcon
|
||||
this.setIconImage(guiLogo.getImage()); // change icon of frame
|
||||
|
||||
this.setVisible(true);
|
||||
|
||||
|
||||
JScrollPane oJScrollPane = new JScrollPane();
|
||||
|
||||
JPanel oHelpPanel = new JPanel();
|
||||
|
||||
JTextArea oHelpText = new JTextArea();
|
||||
oHelpText.setLineWrap(true);
|
||||
oHelpText.setPreferredSize(new Dimension(600, 400));
|
||||
oHelpText.setEditable(false);
|
||||
|
||||
oHelpPanel.add(oHelpText);
|
||||
|
||||
oHelpText.setText( "\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n");
|
||||
|
||||
oJScrollPane.setViewportView(oHelpPanel);
|
||||
oJScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
oJScrollPane.setWheelScrollingEnabled(true);
|
||||
oJScrollPane.getVerticalScrollBar().setUnitIncrement(16);
|
||||
|
||||
this.add(oJScrollPane);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package View;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.GridBagConstraints;
|
||||
@@ -33,16 +34,19 @@ public class GUITime extends JPanel {
|
||||
JLabel oLabelWDT = new JLabel("Watchdog Timer");
|
||||
JCheckBox oEnableWDT = new JCheckBox("WDT");
|
||||
|
||||
int iRuntime = 0;
|
||||
JLabel oLabelRuntime = new JLabel("Runtime: " + iRuntime);
|
||||
double dRuntime = 0;
|
||||
JLabel oLabelRuntime = new JLabel("Runtime: " + dRuntime);
|
||||
|
||||
JLabel oLabelQuarz = new JLabel("Quarzfrequency");
|
||||
String[] asIntervals = {"32 kHz", "100 kHz", "500 kHz", "1 MHz", "2 MHz", "4 MHz", "8 MHz", "12 MHz", "16 MHz", "20 MHz"};
|
||||
JComboBox<String> oIntervals = new JComboBox<>(asIntervals);
|
||||
|
||||
int iLanguage;
|
||||
|
||||
public GUITime() {
|
||||
buildGUITime();
|
||||
setLanguage(0);
|
||||
oLabelRuntime.setPreferredSize(new Dimension(150, 20));
|
||||
}
|
||||
|
||||
private void buildGUITime() {
|
||||
@@ -70,13 +74,14 @@ public class GUITime extends JPanel {
|
||||
}
|
||||
|
||||
public void setLanguage(int iLangNr) {
|
||||
iLanguage = iLangNr;
|
||||
switch (iLangNr) {
|
||||
case 0: {
|
||||
oLabelRuntime.setText("Laufzeit: " + iRuntime);
|
||||
oLabelRuntime.setText("Laufzeit: " + dRuntime);
|
||||
oLabelQuarz.setText("Quarzfrequenz");
|
||||
}break;
|
||||
case 1: {
|
||||
oLabelRuntime.setText("Runtime: " + iRuntime);
|
||||
oLabelRuntime.setText("Runtime: " + dRuntime);
|
||||
oLabelQuarz.setText("Quarzfrequency");
|
||||
}break;
|
||||
}
|
||||
@@ -90,12 +95,18 @@ public class GUITime extends JPanel {
|
||||
return oEnableWDT;
|
||||
}
|
||||
|
||||
public void setRuntime(int iRuntime) {
|
||||
this.iRuntime = iRuntime;
|
||||
public void setRuntime(double dRuntime) {
|
||||
this.dRuntime = dRuntime;
|
||||
if (iLanguage == 0) {
|
||||
oLabelRuntime.setText("Laufzeit: " + dRuntime);
|
||||
} else {
|
||||
oLabelRuntime.setText("Runtime: " + dRuntime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getRuntime() {
|
||||
return iRuntime;
|
||||
public double getRuntime() {
|
||||
return dRuntime;
|
||||
}
|
||||
|
||||
public void setTheme(int iThemeNr) {
|
||||
|
||||
Reference in New Issue
Block a user