Created EEPROM class, implemented write and read to eeprom, implemented changeEepromLocation
This commit is contained in:
Binary file not shown.
Binary file not shown.
BIN
bin/Model/Microcontroller/EEPROM.class
Normal file
BIN
bin/Model/Microcontroller/EEPROM.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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;
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
72
src/Model/Microcontroller/EEPROM.java
Normal file
72
src/Model/Microcontroller/EEPROM.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package Model.EepromLoader;
|
||||
package Model.ProgramLoader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@@ -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;
|
||||
}*/
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user