diff --git a/bin/Control/MyControlModel.class b/bin/Control/MyControlModel.class index 67e29b1..829a535 100644 Binary files a/bin/Control/MyControlModel.class and b/bin/Control/MyControlModel.class differ diff --git a/bin/Control/MyControlView.class b/bin/Control/MyControlView.class index 963c3ef..e2e9bbc 100644 Binary files a/bin/Control/MyControlView.class and b/bin/Control/MyControlView.class differ diff --git a/bin/Model/Microcontroller/EEPROM.class b/bin/Model/Microcontroller/EEPROM.class new file mode 100644 index 0000000..4c93019 Binary files /dev/null and b/bin/Model/Microcontroller/EEPROM.class differ diff --git a/bin/Model/Microcontroller/RAM.class b/bin/Model/Microcontroller/RAM.class index fb53747..7b66774 100644 Binary files a/bin/Model/Microcontroller/RAM.class and b/bin/Model/Microcontroller/RAM.class differ diff --git a/bin/Model/EepromLoader/ReadProgramFile.class b/bin/Model/ProgramLoader/ReadProgramFile.class similarity index 91% rename from bin/Model/EepromLoader/ReadProgramFile.class rename to bin/Model/ProgramLoader/ReadProgramFile.class index 5391973..05917d2 100644 Binary files a/bin/Model/EepromLoader/ReadProgramFile.class and b/bin/Model/ProgramLoader/ReadProgramFile.class differ diff --git a/bin/Runtime/TODO.class b/bin/Runtime/TODO.class deleted file mode 100644 index 274e38d..0000000 Binary files a/bin/Runtime/TODO.class and /dev/null differ diff --git a/bin/View/GUIMenuBar.class b/bin/View/GUIMenuBar.class index e76feb3..f05cf62 100644 Binary files a/bin/View/GUIMenuBar.class and b/bin/View/GUIMenuBar.class differ diff --git a/src/Control/MyControlModel.java b/src/Control/MyControlModel.java index e30eb8e..c039fe5 100644 --- a/src/Control/MyControlModel.java +++ b/src/Control/MyControlModel.java @@ -1,8 +1,8 @@ package Control; import Model.MyModelData; -import Model.EepromLoader.ReadProgramFile; import Model.Microcontroller.PIC; +import Model.ProgramLoader.ReadProgramFile; import View.GUIAbout; import View.GUIHelp; import View.MyView; diff --git a/src/Control/MyControlView.java b/src/Control/MyControlView.java index 3915abf..86059b1 100644 --- a/src/Control/MyControlView.java +++ b/src/Control/MyControlView.java @@ -222,28 +222,28 @@ public class MyControlView { public void showTimer0InterruptPrompt() { if (oPIC.getRam().get_GIE() && oPIC.getRam().get_T0IE() && oPIC.getRam().get_T0IF()) { Object[] options = {"Ok"}; - JOptionPane.showOptionDialog(new JFrame(), asPromptDialogs[0][oMyView.getLanguage()], asPromptTitle[0][oMyView.getLanguage()], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]); + JOptionPane.showOptionDialog(new JFrame(), asPromptDialogs[oMyView.getLanguage()][0], asPromptTitle[oMyView.getLanguage()][0], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); } } public void showEEInterruptPrompt() { if (oPIC.getRam().get_GIE() && oPIC.getRam().get_EEIE() && oPIC.getRam().get_EEIF()) { Object[] options = {"Ok"}; - JOptionPane.showOptionDialog(new JFrame(),asPromptDialogs[1][oMyView.getLanguage()], asPromptTitle[1][oMyView.getLanguage()], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]); + JOptionPane.showOptionDialog(new JFrame(),asPromptDialogs[oMyView.getLanguage()][1], asPromptTitle[oMyView.getLanguage()][1], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); } } public void showPORTBInterruptPrompt() { if (oPIC.getRam().get_GIE() && oPIC.getRam().get_RBIE() && oPIC.getRam().get_RBIF()) { Object[] options = {"Ok"}; - JOptionPane.showOptionDialog(new JFrame(),asPromptDialogs[2][oMyView.getLanguage()], asPromptTitle[2][oMyView.getLanguage()], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]); + JOptionPane.showOptionDialog(new JFrame(),asPromptDialogs[oMyView.getLanguage()][2], asPromptTitle[oMyView.getLanguage()][2], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); } } public void showRB0InterruptPrompt() { if (oPIC.getRam().get_GIE() && oPIC.getRam().get_INTE() && oPIC.getRam().get_INTF()) { Object[] options = {"Ok"}; - JOptionPane.showOptionDialog(new JFrame(),asPromptDialogs[3][oMyView.getLanguage()], asPromptTitle[3][oMyView.getLanguage()], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]); + JOptionPane.showOptionDialog(new JFrame(),asPromptDialogs[oMyView.getLanguage()][3], asPromptTitle[oMyView.getLanguage()][3], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); } } diff --git a/src/Model/Microcontroller/EEPROM.java b/src/Model/Microcontroller/EEPROM.java new file mode 100644 index 0000000..6c77176 --- /dev/null +++ b/src/Model/Microcontroller/EEPROM.java @@ -0,0 +1,72 @@ +package Model.Microcontroller; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; + +public class EEPROM { + + private int[] aiEeprom; + private File oFile; + + public EEPROM() { + aiEeprom = new int[64]; + oFile = new File("./eeprom.dat"); + } + + public void changeEepromLocation(String sLocation) { + oFile = new File(sLocation + "eeprom.dat"); + } + + public boolean writeToFile() { + boolean bSuccess = false; + try { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + FileWriter fw = new FileWriter(oFile); + BufferedWriter bw = new BufferedWriter(fw); + String sLine; + for (int i = 0; i < aiEeprom.length; i++) { + sLine = i + " " + aiEeprom[i] + "\n"; + bw.write(sLine); + } + bw.close(); + bSuccess = true; + } catch (IOException e) { + e.printStackTrace(); + bSuccess = false; + } + return bSuccess; + } + + public boolean readFromFile() { + boolean bSuccess = false; + try { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } + FileReader fr = new FileReader(oFile); + BufferedReader br = new BufferedReader(fr); + String sLine; + while ((sLine = br.readLine()) != null) { + int i = Integer.parseInt(sLine.substring(0, 1)); + int iValue = Integer.parseInt(sLine.substring(2, 5)); + aiEeprom[i] = iValue; + } + br.close(); + bSuccess = true; + } catch (IOException e) { + e.printStackTrace(); + bSuccess = false; + } + return bSuccess; + } +} \ No newline at end of file diff --git a/src/Model/Microcontroller/RAM.java b/src/Model/Microcontroller/RAM.java index 49e924d..5dcb300 100755 --- a/src/Model/Microcontroller/RAM.java +++ b/src/Model/Microcontroller/RAM.java @@ -227,7 +227,6 @@ public class RAM { set_T0IF(true); set_TMR0((iValTMR0 + 1) & 255); } else { - //set_T0IF(false); set_TMR0(iValTMR0 + 1); } //Prescaler assigned to TMR0, increment TMR0 if prescaled TMR0 equals TMR0 prescaler-rate. @@ -241,7 +240,6 @@ public class RAM { set_T0IF(true); set_TMR0((iValTMR0 + 1) & 255); } else { - //set_T0IF(false); set_TMR0(iValTMR0 + 1); } } diff --git a/src/Model/EepromLoader/ReadProgramFile.java b/src/Model/ProgramLoader/ReadProgramFile.java similarity index 99% rename from src/Model/EepromLoader/ReadProgramFile.java rename to src/Model/ProgramLoader/ReadProgramFile.java index 87cbc10..de6af33 100644 --- a/src/Model/EepromLoader/ReadProgramFile.java +++ b/src/Model/ProgramLoader/ReadProgramFile.java @@ -1,4 +1,4 @@ -package Model.EepromLoader; +package Model.ProgramLoader; import java.io.BufferedReader; import java.io.File; diff --git a/src/Runtime/TODO.java b/src/Runtime/TODO.java deleted file mode 100755 index cb3639a..0000000 --- a/src/Runtime/TODO.java +++ /dev/null @@ -1,98 +0,0 @@ -package Runtime; - -public class TODO { - - /** - * Returns the actual line which represents the actual programstep. - * @return - - public static int iGetLine() - { - int iActualLine = 1; - - if (sLoadedSimulationFile != ("Uninitialized")) - { - String[] asDataLines = {}; - try - { - //Filereader reads data out of destination. - FileReader fR = new FileReader(new File(sLoadedSimulationFile)); - - //Creates String-array with whole data. - asDataLines = getData(fR); - } - catch (Exception e) {} - - for (int i = 0; i < asDataLines.length; i++) - { - //Substring 0-4 from hex to dec. after that dec value has to be equal to progcounter minus 1 and at substring 20-25 is line. - - String substringHexStep = "0000"; - int hexStepAsInt = 0; - - try - { - if (!((asDataLines[i].substring(0, 4)).equals(" "))) - { - substringHexStep = asDataLines[i].substring(0, 4); - hexStepAsInt = Integer.parseInt(substringHexStep, 16); - } - }catch(NullPointerException npe){} - - if (hexStepAsInt == (oPIC.getRam().get_Programcounter())) - { - iActualLine = i+1; - } - } - } - - return iActualLine; - } - - - * Returns the last line which represents the last programstep. - * @return - - public static int getLastLine() - { - int actualLine = 1; - - if (sLoadedSimulationFile != ("Uninitialized")) - { - String[] dataLines = {}; - try - { - //Filereader reads data out of destination. - FileReader fR = new FileReader(new File(sLoadedSimulationFile)); - - //Creates String-array with whole data. - dataLines = getData(fR); - } - catch (Exception e) {} - - for (int i = 0; i < dataLines.length; i++) - { - //Substring 0-4 from hex to dec. after that dec value has to be equal to progcounter minus 1 and at substring 20-25 is line. - - String substringHexStep = "0000"; - int hexStepAsInt = 0; - - try - { - if (!((dataLines[i].substring(0, 4)).equals(" "))) - { - substringHexStep = dataLines[i].substring(0, 4); - hexStepAsInt = Integer.parseInt(substringHexStep, 16); - } - }catch(NullPointerException npe){} - - if (hexStepAsInt == (oPIC.getRam().get_LastProgramcounter())) - { - actualLine = i+1; - } - } - } - - return actualLine; - }*/ -} diff --git a/src/View/GUIMenuBar.java b/src/View/GUIMenuBar.java index b91c3e2..3e5b35c 100644 --- a/src/View/GUIMenuBar.java +++ b/src/View/GUIMenuBar.java @@ -11,7 +11,7 @@ import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; -import Model.EepromLoader.ReadProgramFile; +import Model.ProgramLoader.ReadProgramFile; public class GUIMenuBar extends JMenuBar {