Removed useless envorinment class, 1 step closer to mvc-arch
This commit is contained in:
Binary file not shown.
BIN
bin/Control/MyControlModelPIC.class
Normal file
BIN
bin/Control/MyControlModelPIC.class
Normal file
Binary file not shown.
BIN
bin/Control/MyControlModelRuntime.class
Normal file
BIN
bin/Control/MyControlModelRuntime.class
Normal file
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/View/MyColors.class
Normal file
BIN
bin/View/MyColors.class
Normal file
Binary file not shown.
Binary file not shown.
@@ -5,13 +5,13 @@ import java.util.ArrayList;
|
||||
import Model.MyModel;
|
||||
import View.MyView;
|
||||
|
||||
public class MyControlModel {
|
||||
public class MyControlModelPIC {
|
||||
|
||||
MyModel oModel;
|
||||
MyView oView;
|
||||
//put Objects to manipulate here
|
||||
|
||||
public MyControlModel(MyModel model, MyView view) {
|
||||
public MyControlModelPIC(MyModel model, MyView view) {
|
||||
oModel = model;
|
||||
oView = view;
|
||||
}
|
||||
@@ -73,28 +73,7 @@ public class MyControlModel {
|
||||
public void setRamModel(int[][] aiiRam) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void startProgramModel() {
|
||||
|
||||
}
|
||||
|
||||
public void stepProgramModel() {
|
||||
|
||||
}
|
||||
|
||||
public void pauseProgramModel() {
|
||||
|
||||
}
|
||||
|
||||
public void resetProgramModel() {
|
||||
|
||||
}
|
||||
|
||||
public void controlWDTModel(boolean bEnabled) {
|
||||
|
||||
}
|
||||
|
||||
public void setQuarzModel(int iElement) {
|
||||
|
||||
85
src/Control/MyControlModelRuntime.java
Normal file
85
src/Control/MyControlModelRuntime.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package Control;
|
||||
|
||||
import Model.MyModel;
|
||||
import View.MyView;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
|
||||
public class MyControlModelRuntime implements ActionListener {
|
||||
|
||||
MyModel oMyModel;
|
||||
|
||||
ArrayList<JCheckBox> oBreakpoints;
|
||||
ArrayList<JButton> oControlButtons;
|
||||
|
||||
public MyControlModelRuntime(MyModel model, MyView view) {
|
||||
oMyModel = model;
|
||||
oControlButtons = view.getGUIMCMenu().getControlButtons();
|
||||
oBreakpoints = view.getGUITestFileTable().getCheckboxes();
|
||||
addActionListeners();
|
||||
}
|
||||
|
||||
private void startProgramEnvironment() {
|
||||
oMyModel.start();
|
||||
}
|
||||
|
||||
private void stepProgramEnvironment() {
|
||||
oMyModel.step();
|
||||
}
|
||||
|
||||
private void pauseProgramEnvironment() {
|
||||
oMyModel.pause();
|
||||
}
|
||||
|
||||
private void resetProgramEnvironment() {
|
||||
|
||||
}
|
||||
|
||||
public void controlWDTEnvironment(boolean bEnabled) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int i = 0;
|
||||
for (JCheckBox oBreakpoint : oBreakpoints) {
|
||||
if (e.getSource() == oBreakpoint) {
|
||||
oMyModel.controlBreakpoint(i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (e.getSource() == oControlButtons.get(0)) {
|
||||
//startProgramEnvironment();
|
||||
System.out.println("Test");
|
||||
}
|
||||
if (e.getSource() == oControlButtons.get(1)) {
|
||||
|
||||
}
|
||||
if (e.getSource() == oControlButtons.get(2)) {
|
||||
|
||||
}
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void addActionListeners() {
|
||||
if (oBreakpoints != null) {
|
||||
for (JCheckBox oBreakpoint : oBreakpoints) {
|
||||
oBreakpoint.addActionListener(this);
|
||||
}
|
||||
}
|
||||
if (oControlButtons != null) {
|
||||
for (JButton oButton : oControlButtons) {
|
||||
oButton.addActionListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public class MyControlView {
|
||||
MyView oMyView;
|
||||
MyModel oMyModel;
|
||||
|
||||
public MyControlView(MyView view, MyModel model) {
|
||||
public MyControlView(MyModel model, MyView view) {
|
||||
oMyView = view;
|
||||
oMyModel = model;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,160 @@
|
||||
package Model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import Model.Microcontroller.Bitmask;
|
||||
import Model.Microcontroller.PIC;
|
||||
import Model.Runtime.Environment;
|
||||
import Model.Microcontroller.WATCHDOG;
|
||||
import View.GUIMainFrame;
|
||||
|
||||
public class MyModel {
|
||||
PIC oPIC;
|
||||
Environment oEnvironment;
|
||||
|
||||
public MyModel(PIC pic, Environment env) {
|
||||
oPIC = pic;
|
||||
oEnvironment = env;
|
||||
private PIC oPIC;
|
||||
|
||||
private int iModelState = 3;
|
||||
private int iActualLine;
|
||||
private int iLastLine;
|
||||
|
||||
private ArrayList<Integer> listBreakpoints = new ArrayList<Integer>();
|
||||
|
||||
private long liRuntimeRun;
|
||||
private long liRuntimeStep;
|
||||
|
||||
private boolean[] bBreakpoints;
|
||||
|
||||
private WATCHDOG watchdog;
|
||||
GUIMainFrame oMainFrame;
|
||||
|
||||
public MyModel() {
|
||||
oPIC = new PIC();
|
||||
}
|
||||
|
||||
public PIC getPIC() {
|
||||
return this.oPIC;
|
||||
}
|
||||
|
||||
public Environment getEnvironment() {
|
||||
return this.oEnvironment;
|
||||
private int getModelState() {
|
||||
return iModelState;
|
||||
}
|
||||
|
||||
/**
|
||||
* -1 == ERROR, 0 == END, 1 == START, 2 == PAUSE, 3 == RESET
|
||||
* @param i
|
||||
*/
|
||||
public void setModelState(int i) {
|
||||
iModelState = i;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getBreakpointsList() {
|
||||
return listBreakpoints;
|
||||
}
|
||||
|
||||
public void setBreakpointsList(ArrayList<Integer> liBreakpoints) {
|
||||
listBreakpoints = liBreakpoints;
|
||||
bBreakpoints = new boolean[listBreakpoints.size()];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getActualLine() {
|
||||
return iActualLine;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getLastLine() {
|
||||
return iLastLine;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getRuntimeRun() {
|
||||
return liRuntimeRun;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getRuntimeStep() {
|
||||
return liRuntimeStep;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WATCHDOG getWatchdog() {
|
||||
return watchdog;
|
||||
}
|
||||
|
||||
public void step() {
|
||||
//Check if step valid
|
||||
if (oPIC.getRam().get_Programcounter() < (oPIC.getEeprom().getLengthEEPROM() - 1)) {
|
||||
final long timeStart = System.nanoTime();
|
||||
|
||||
//Makes one step through the eeprom.
|
||||
Bitmask oBitmask = new Bitmask();
|
||||
oBitmask.bitMaskDecoderAndExecuteCommand(oPIC.getEeprom().getElement(oPIC.getRam().get_Programcounter()), oPIC);
|
||||
|
||||
final long timeEnd = System.nanoTime();
|
||||
|
||||
liRuntimeStep += (timeEnd - timeStart);
|
||||
|
||||
} else {
|
||||
System.out.println("Step invalid, end of file reached!");
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (getModelState() != 2) { //Do not start again if paused, instead call start to unpause only.
|
||||
final long timeStart = System.nanoTime();
|
||||
|
||||
//workWithWatchdog(1, 1);
|
||||
//Check if set breakpoint reached or program was stopped or interrupt
|
||||
|
||||
while (getModelState() != 0) {
|
||||
switch (iModelState) {
|
||||
|
||||
case 1: { //START
|
||||
step();
|
||||
//
|
||||
//workWithWatchdog(1, 2);
|
||||
final long timeEnd = System.nanoTime();
|
||||
liRuntimeRun += timeEnd - timeStart;
|
||||
oMainFrame.updateWindow();
|
||||
}break;
|
||||
|
||||
case 2: { //PAUSE resume() has to be called to continue
|
||||
while (iModelState == 2) {}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
} else { //Unpause
|
||||
iModelState = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
if (getModelState() != 1) {
|
||||
oPIC.resetPIC();
|
||||
iModelState = 3; //RESET
|
||||
}
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
iModelState = 2;
|
||||
}
|
||||
|
||||
public void controlBreakpoint(int iBreakpoint) {
|
||||
if (bBreakpoints != null) {
|
||||
bBreakpoints[iBreakpoint] = !bBreakpoints[iBreakpoint];
|
||||
System.out.println("Breakpoint " + iBreakpoint + " was set to " + bBreakpoints[iBreakpoint]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 21.02.2022
|
||||
* @lastchange 21.02.2022
|
||||
*/
|
||||
|
||||
package Model.Runtime;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import Model.Microcontroller.WATCHDOG;
|
||||
import Model.Microcontroller.PIC;
|
||||
import View.GUIMainFrame;
|
||||
|
||||
public class Environment {
|
||||
|
||||
private PIC oPIC;
|
||||
|
||||
private String sEepromDataFile;
|
||||
private String sActualCommand;
|
||||
|
||||
private int iEnvironmentState;
|
||||
private int iActualLine;
|
||||
private int iLastLine;
|
||||
|
||||
private ArrayList<Integer> listBreakpoints = new ArrayList<Integer>();
|
||||
|
||||
private long liRuntime;
|
||||
|
||||
private WATCHDOG watchdog;
|
||||
|
||||
public Environment() {
|
||||
|
||||
oPIC = new PIC();
|
||||
|
||||
GUIMainFrame oMainFrame = new GUIMainFrame(this);
|
||||
|
||||
watchdog = new WATCHDOG();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sEepromDataFile = "";
|
||||
sActualCommand = "";
|
||||
|
||||
iEnvironmentState = 0;
|
||||
|
||||
while (iEnvironmentState > -1) {
|
||||
|
||||
// loadfile command readEepromFile.readFileAndWriteToEEPROM(new File(sEepromDataFile), oPIC);
|
||||
}
|
||||
}
|
||||
|
||||
public PIC getPIC() {
|
||||
return oPIC;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getBreakpoints() {
|
||||
return listBreakpoints;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iBreakpoint
|
||||
* @param bState
|
||||
*/
|
||||
public void changeListBreakpoints(int iBreakpoint, boolean bState) {
|
||||
if (iBreakpoint > -1) {
|
||||
if (bState) {
|
||||
//add new breakpoint to list
|
||||
boolean bExists = false;
|
||||
for (int i = 0; i < listBreakpoints.size(); i++) {
|
||||
if (listBreakpoints.get(i) == iBreakpoint)
|
||||
bExists = true;
|
||||
}
|
||||
if (!bExists) {
|
||||
listBreakpoints.add(iBreakpoint);
|
||||
}
|
||||
} else {
|
||||
//remove breakpoint from list
|
||||
int iIndex = -1;
|
||||
for (int i = 0; i < listBreakpoints.size(); i++) {
|
||||
if (listBreakpoints.get(i) == iBreakpoint) {
|
||||
iIndex = i;
|
||||
i = listBreakpoints.size();
|
||||
}
|
||||
}
|
||||
if (iIndex > -1) {
|
||||
listBreakpoints.remove(iIndex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//remove all breakpoints from list
|
||||
while (listBreakpoints.size() > 0) {
|
||||
listBreakpoints.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getActualLine() {
|
||||
return iActualLine;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getLastLine() {
|
||||
return iLastLine;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getRuntime() {
|
||||
return liRuntime;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WATCHDOG getWatchdog() {
|
||||
return watchdog;
|
||||
}
|
||||
|
||||
public void step() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
package Model.Runtime;
|
||||
|
||||
import Control.MyControlModelPIC;
|
||||
import Control.MyControlModelRuntime;
|
||||
import Control.MyControlView;
|
||||
import Model.MyModel;
|
||||
import View.MyView;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Environment env = new Environment();
|
||||
MyModel oModel = new MyModel();
|
||||
MyView oView = new MyView(oModel);
|
||||
MyControlView oControlView = new MyControlView(oModel, oView);
|
||||
MyControlModelRuntime oControlModelRuntime = new MyControlModelRuntime(oModel, oView);
|
||||
MyControlModelPIC oControlModelPIC = new MyControlModelPIC(oModel, oView);
|
||||
}
|
||||
}
|
||||
@@ -10,42 +10,8 @@ import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import Control.MyControlModel;
|
||||
import Control.MyControlView;
|
||||
import Model.MyModel;
|
||||
import Model.Runtime.Environment;
|
||||
|
||||
public class GUIMainFrame extends JFrame {
|
||||
|
||||
/**
|
||||
* Color oWhite = new Color(255, 253, 250);
|
||||
* Color oDarkGray = new Color(76, 78, 82);
|
||||
* Color oDarkGrayB = new Color(47, 47, 47);
|
||||
* Color oLightBlue = new Color(173, 216, 230);
|
||||
* Color oOrangeDM = new Color(255, 170, 0);
|
||||
* Color oLightBlueDM = new Color(0, 213, 255);
|
||||
* Color oOrangeDMB = new Color(255, 85, 0);
|
||||
* First Color == TextColor
|
||||
* Second Color == BackgroundColor
|
||||
* Third Color == BorderColor
|
||||
* Fourth Color == TextColor Marked
|
||||
* Fifth Color == BackgroundColor Marked
|
||||
* Sixth Color == BorderColor Marked
|
||||
*/
|
||||
Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82), new Color(47, 47, 47), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
|
||||
Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250), new Color(173, 216, 230), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
|
||||
|
||||
//Components of gui-main-frame
|
||||
GUITestFileTable oGUITestFileTable = new GUITestFileTable();
|
||||
GUIMenuBar oGUIMenuBar;
|
||||
GUIRegister oGUIRegister = new GUIRegister();
|
||||
GUIRegistersDetailed oGUIRegistersDetailed = new GUIRegistersDetailed();
|
||||
GUIRamTable oGUIRamTable = new GUIRamTable();
|
||||
GUIPorts oGUIPorts = new GUIPorts();
|
||||
GUIStack oGUIStack = new GUIStack();
|
||||
GUIMCMenu oGUIMCMenu = new GUIMCMenu();
|
||||
GUITime oGUITime = new GUITime();
|
||||
|
||||
//Panels of gui-main-frame
|
||||
JPanel oMainPanel = new JPanel();
|
||||
JPanel oPanel0 = new JPanel();
|
||||
@@ -53,27 +19,31 @@ public class GUIMainFrame extends JFrame {
|
||||
JPanel oPanel2 = new JPanel();
|
||||
JPanel oPanel3 = new JPanel();
|
||||
|
||||
ArrayList<JPanel> oPanels = new ArrayList<JPanel>();
|
||||
|
||||
/**
|
||||
* Object for storing all components, will be overhanded to menubar, to set theme.
|
||||
*
|
||||
*/
|
||||
MyView oMyView;
|
||||
|
||||
MyModel oMyModel;
|
||||
|
||||
MyControlView mcv;
|
||||
|
||||
ArrayList<JPanel> oPanels = new ArrayList<JPanel>();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public GUIMainFrame(Environment oEnvironment) {
|
||||
public GUIMainFrame(GUIMenuBar oGUIMenuBar, MyView view) {
|
||||
oMyView = view;
|
||||
|
||||
// sets title of frame
|
||||
this.setTitle("PIC-Simulator GUI");
|
||||
|
||||
// if x is pressed, exit application (HIDE_ON_CLOSE-hides application, DO_NOTHING_ON_CLOSE-prevents user from closing application)
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
//prevent frame from beeing resized
|
||||
this.setResizable(false);
|
||||
|
||||
//sets x and y dimension of frame
|
||||
this.setSize(1400, 800);
|
||||
|
||||
this.setTitle("PIC-Simulator GUI"); // sets title of frame
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // if x is pressed, exit application (HIDE_ON_CLOSE-hides application, DO_NOTHING_ON_CLOSE-prevents user from closing application)
|
||||
this.setResizable(false); // prevent frame from beeing resized
|
||||
this.setSize(1400, 800); //sets x and y dimension of frame
|
||||
//Set Icon
|
||||
ImageIcon guiLogo = new ImageIcon("./pictures/gui_logo.png"); // create an ImageIcon
|
||||
this.setIconImage(guiLogo.getImage()); // change icon of frame
|
||||
@@ -81,19 +51,16 @@ public class GUIMainFrame extends JFrame {
|
||||
//Adds components to frame, sets layouts,...
|
||||
buildGUIMainFrame();
|
||||
|
||||
//Init view object with components of main frame.
|
||||
oMyView = new MyView(this, oGUIMCMenu, oGUIPorts, oGUIRamTable, oGUIRegister, oGUIRegistersDetailed, oGUIStack, oGUITestFileTable, oGUITime, oMainPanel, oEnvironment);
|
||||
|
||||
//Set menubar
|
||||
oGUIMenuBar = new GUIMenuBar(oMyModel, oMyView);
|
||||
this.setJMenuBar(oGUIMenuBar);
|
||||
|
||||
setTheme(0);
|
||||
updateWindow();
|
||||
this.setVisible(true); //make frame visible
|
||||
oMyModel = new MyModel(oEnvironment.getPIC(), oEnvironment);
|
||||
mcv = new MyControlView(oMyView, oMyModel);
|
||||
mcv.updateView();
|
||||
updateWindow();
|
||||
}
|
||||
|
||||
public JPanel getMainPanel() {
|
||||
return oMainPanel;
|
||||
}
|
||||
|
||||
private void buildGUIMainFrame() {
|
||||
@@ -114,30 +81,30 @@ public class GUIMainFrame extends JFrame {
|
||||
oConstraints.gridx = 0;
|
||||
oConstraints.gridy = 0;
|
||||
oConstraints.insets = new Insets(10,10,0,0);
|
||||
oPanel0.add(oGUITestFileTable, oConstraints);
|
||||
oPanel0.add(oMyView.getGUITestFileTable(), oConstraints);
|
||||
|
||||
//Build 2nd Panel from left
|
||||
oConstraints.gridx = 0;
|
||||
oConstraints.gridy = 0;
|
||||
oConstraints.insets = new Insets(10,10,0,0);
|
||||
oPanel1.add(oGUIRegister, oConstraints);
|
||||
oPanel1.add(oMyView.getGUIRegister(), oConstraints);
|
||||
oConstraints.gridy = 1;
|
||||
oConstraints.insets = new Insets(36,10,0,0);
|
||||
oPanel1.add(oGUIRegistersDetailed, oConstraints);
|
||||
oPanel1.add(oMyView.getGUIRegistersDetailed(), oConstraints);
|
||||
oConstraints.gridy = 2;
|
||||
oConstraints.insets = new Insets(47,10,0,0);
|
||||
oPanel1.add(oGUIRamTable, oConstraints);
|
||||
oPanel1.add(oMyView.getGUIRamTable(), oConstraints);
|
||||
|
||||
//Build 3rd Panel from left
|
||||
oConstraints.gridx = 0;
|
||||
oConstraints.gridy = 0;
|
||||
oConstraints.insets = new Insets(10,10,0,0);
|
||||
oPanel2.add(oGUIPorts, oConstraints);
|
||||
oPanel2.add(oMyView.getGUIPorts(), oConstraints);
|
||||
oConstraints.gridy = 1;
|
||||
oPanel2.add(oPanel3, oConstraints);
|
||||
oConstraints.gridy = 2;
|
||||
oConstraints.insets = new Insets(45,90,0,0);
|
||||
oPanel2.add(oGUIMCMenu, oConstraints);
|
||||
oPanel2.add(oMyView.getGUIMCMenu(), oConstraints);
|
||||
|
||||
//Build lower panel of 3rd panel
|
||||
oConstraints.gridx = 0;
|
||||
@@ -145,10 +112,10 @@ public class GUIMainFrame extends JFrame {
|
||||
oConstraints.insets = new Insets(0,0,0,0);
|
||||
oConstraints.weightx = 1;
|
||||
oConstraints.weighty = 1;
|
||||
oPanel3.add(oGUIStack, oConstraints);
|
||||
oPanel3.add(oMyView.getGUIStack(), oConstraints);
|
||||
oConstraints.insets = new Insets(0,40,0,0);
|
||||
oConstraints.gridx = 1;
|
||||
oPanel3.add(oGUITime, oConstraints);
|
||||
oPanel3.add(oMyView.getGUITime(), oConstraints);
|
||||
|
||||
//Build MainPanel
|
||||
oConstraints.gridx = 0;
|
||||
@@ -181,30 +148,22 @@ public class GUIMainFrame extends JFrame {
|
||||
public void setTheme(int iThemeNr) {
|
||||
switch (iThemeNr) {
|
||||
case 0: {
|
||||
Color[] aoLightTheme = MyColors.getTheme(0);
|
||||
for (JPanel oPanel : oPanels) {
|
||||
oPanel.setForeground(aoLightTheme[0]);
|
||||
oPanel.setBackground(aoLightTheme[1]);
|
||||
}
|
||||
this.setForeground(aoLightTheme[0]);
|
||||
this.setBackground(aoLightTheme[1]);
|
||||
oGUIMCMenu.setTheme(0);
|
||||
oGUIStack.setTheme(0);
|
||||
oGUIPorts.setTheme(0);
|
||||
oGUIRamTable.setTheme(0);
|
||||
oGUITime.setTheme(0);
|
||||
}break;
|
||||
case 1: {
|
||||
Color[] aoDarkTheme = MyColors.getTheme(1);
|
||||
for (JPanel oPanel : oPanels) {
|
||||
oPanel.setForeground(aoDarkTheme[0]);
|
||||
oPanel.setBackground(aoDarkTheme[1]);
|
||||
}
|
||||
this.setForeground(aoDarkTheme[0]);
|
||||
this.setBackground(aoDarkTheme[1]);
|
||||
oGUIMCMenu.setTheme(1);
|
||||
oGUIStack.setTheme(1);
|
||||
oGUIPorts.setTheme(1);
|
||||
oGUIRamTable.setTheme(1);
|
||||
oGUITime.setTheme(1);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,38 +15,21 @@ import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import Control.MyControlModel;
|
||||
import Model.Backend.MyModel;
|
||||
import Model.Backend.EepromLoader.ReadEepromFile;
|
||||
import Model.MyModel;
|
||||
import Model.EepromLoader.ReadEepromFile;
|
||||
|
||||
public class GUIMenuBar extends JMenuBar implements ActionListener {
|
||||
/**
|
||||
* Color oWhite = new Color(255, 253, 250);
|
||||
* Color oDarkGray = new Color(76, 78, 82);
|
||||
* Color oDarkGrayB = new Color(47, 47, 47);
|
||||
* Color oLightBlue = new Color(173, 216, 230);
|
||||
* Color oOrangeDM = new Color(255, 170, 0);
|
||||
* Color oLightBlueDM = new Color(0, 213, 255);
|
||||
* Color oOrangeDMB = new Color(255, 85, 0);
|
||||
* First Color == TextColor
|
||||
* Second Color == BackgroundColor
|
||||
* Third Color == BorderColor
|
||||
* Fourth Color == TextColor Marked
|
||||
* Fifth Color == BackgroundColor Marked
|
||||
* Sixth Color == BorderColor Marked
|
||||
*/
|
||||
Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82), new Color(47, 47, 47), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
|
||||
Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250), new Color(173, 216, 230), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
|
||||
|
||||
MyView oMyView;
|
||||
|
||||
MyControlModel oMyControl;
|
||||
MyModel oMyModel;
|
||||
|
||||
ArrayList<JCheckBox> oBreakpoints;
|
||||
ReadEepromFile oRef;
|
||||
boolean[] bBreakpointSet;
|
||||
int iTestFileLoaded = 0;
|
||||
|
||||
ArrayList<JMenuItem> oMenuItems = new ArrayList<JMenuItem>();
|
||||
//Custom separators because addSeparator(default) looks not nice.
|
||||
JMenuItem oSeparator0;
|
||||
JMenuItem oSeparator1;
|
||||
@@ -123,7 +106,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
|
||||
//Referrence to change different parts of gui for theme.
|
||||
oMyView = view;
|
||||
|
||||
oMyControl = new MyControlModel(model, view);
|
||||
oMyModel = model;
|
||||
|
||||
//File
|
||||
oFileMenu = new JMenu(sGermanLang[0]);
|
||||
@@ -157,6 +140,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
|
||||
oManual = new JMenuItem(sGermanLang[22]);
|
||||
oAbout = new JMenuItem(sGermanLang[23]);
|
||||
|
||||
fillList();
|
||||
setActionListeners();
|
||||
setGerMnemonics();
|
||||
buildMenubar();
|
||||
@@ -394,7 +378,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
|
||||
System.out.println("oResetProg"); //TODO
|
||||
}
|
||||
if (e.getSource() == oStepProg) {
|
||||
oMyView.getEnvironment().step();
|
||||
System.out.println("oStepProg"); //TODO
|
||||
}
|
||||
if (e.getSource() == oIntervalASAP) {
|
||||
System.out.println("oIntervalASAP"); //TODO
|
||||
@@ -411,11 +395,13 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
|
||||
if (e.getSource() == oGerLangItem) {
|
||||
changeLangMenuBar(sGermanLang);
|
||||
setGerMnemonics();
|
||||
oMyView.setLanguage(0);
|
||||
//TODO rest of gui
|
||||
}
|
||||
if (e.getSource() == oEngLangItem) {
|
||||
changeLangMenuBar(sEnglishLang);
|
||||
setEngMnemonics();
|
||||
oMyView.setLanguage(1);
|
||||
//TODO rest of gui
|
||||
}
|
||||
//Show manual
|
||||
@@ -430,9 +416,31 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
|
||||
controlBreakpoints(e);
|
||||
}
|
||||
|
||||
private void fillList() {
|
||||
//Fill list oMenuitems
|
||||
oMenuItems.add(oLoadTestFile);
|
||||
oMenuItems.add(oLoadProgStateItem);
|
||||
oMenuItems.add(oSaveProgStateItem);
|
||||
oMenuItems.add(oExitItem);
|
||||
oMenuItems.add(oDarkTheme);
|
||||
oMenuItems.add(oLightTheme);
|
||||
oMenuItems.add(oStartProg);
|
||||
oMenuItems.add(oPauseProg);
|
||||
oMenuItems.add(oResetProg);
|
||||
oMenuItems.add(oStepProg);
|
||||
oMenuItems.add(oIntervalASAP);
|
||||
oMenuItems.add(oInterval1Sec);
|
||||
oMenuItems.add(oInterval2Sec);
|
||||
oMenuItems.add(oGerLangItem);
|
||||
oMenuItems.add(oEngLangItem);
|
||||
oMenuItems.add(oManual);
|
||||
oMenuItems.add(oAbout);
|
||||
}
|
||||
|
||||
public void setTheme(int iThemeNr) {
|
||||
switch (iThemeNr) {
|
||||
case 0: {
|
||||
Color[] aoLightTheme = MyColors.getTheme(0);
|
||||
this.setBackground(aoLightTheme[1]);
|
||||
this.setBorder(BorderFactory.createLineBorder(aoLightTheme[1], 2));
|
||||
this.setOpaque(true);
|
||||
@@ -531,6 +539,7 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
|
||||
oSeparator3.setBorder(BorderFactory.createLineBorder(oColorSeparators, 2));
|
||||
}break;
|
||||
case 1: {
|
||||
Color[] aoDarkTheme = MyColors.getTheme(1);
|
||||
this.setBackground(aoDarkTheme[1]);
|
||||
this.setBorder(BorderFactory.createLineBorder(aoDarkTheme[1], 2));
|
||||
this.setOpaque(true);
|
||||
@@ -644,36 +653,40 @@ public class GUIMenuBar extends JMenuBar implements ActionListener {
|
||||
oRef.setOPCode(oRef.getData());
|
||||
oMyView.getGUITestFileTable().setData(oRef.getData());
|
||||
|
||||
|
||||
ArrayList<String> data = oRef.getData();
|
||||
int iDataSize = data.size();
|
||||
ArrayList<String> opcode = oRef.getOPCode();
|
||||
|
||||
int iOPCodeSize = opcode.size();
|
||||
//If testfile was loaded before, reset all checkboxes
|
||||
if (iTestFileLoaded > 0) {
|
||||
oBreakpoints = oMyView.getGUITestFileTable().getCheckboxes();
|
||||
for (int i = 0; i < iDataSize; i++) {
|
||||
oBreakpoints.get(i).setEnabled(false);
|
||||
}
|
||||
}
|
||||
//Enable only checkboxes which belong to real code
|
||||
for (int i = 0; i < iDataSize; i++) {
|
||||
for (int j = 0; j < iOPCodeSize; j++) {
|
||||
if (data.get(i).equals(opcode.get(j))) {
|
||||
oBreakpoints = oMyView.getGUITestFileTable().getCheckboxes();
|
||||
oBreakpoints.get(i).setEnabled(true);
|
||||
oBreakpoints.get(i).addActionListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
bBreakpointSet = new boolean[iOPCodeSize];
|
||||
oRef.readFileAndWriteToEEPROM(oMyView.getEnvironment().getPIC());
|
||||
setBreakpointsActionListeners();
|
||||
|
||||
oRef.readFileAndWriteToEEPROM(oMyModel.getPIC());
|
||||
oMyView.getGUIMainFrame().updateWindow();
|
||||
iTestFileLoaded = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void setBreakpointsActionListeners() {
|
||||
ArrayList<String> data = oRef.getData();
|
||||
int iDataSize = data.size();
|
||||
ArrayList<String> opcode = oRef.getOPCode();
|
||||
|
||||
int iOPCodeSize = opcode.size();
|
||||
//If testfile was loaded before, reset all checkboxes
|
||||
if (iTestFileLoaded > 0) {
|
||||
oBreakpoints = oMyView.getGUITestFileTable().getCheckboxes();
|
||||
for (int i = 0; i < iDataSize; i++) {
|
||||
oBreakpoints.get(i).setEnabled(false);
|
||||
}
|
||||
}
|
||||
//Enable only checkboxes which belong to real code
|
||||
for (int i = 0; i < iDataSize; i++) {
|
||||
for (int j = 0; j < iOPCodeSize; j++) {
|
||||
if (data.get(i).equals(opcode.get(j))) {
|
||||
oBreakpoints = oMyView.getGUITestFileTable().getCheckboxes();
|
||||
oBreakpoints.get(i).setEnabled(true);
|
||||
oBreakpoints.get(i).addActionListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
bBreakpointSet = new boolean[iOPCodeSize];
|
||||
}
|
||||
|
||||
private void controlBreakpoints(ActionEvent e) {
|
||||
if (oRef != null) {
|
||||
int iOPCode = oRef.getOPCode().size();
|
||||
|
||||
@@ -64,6 +64,7 @@ public class GUIRegister extends JPanel {
|
||||
buildGUIRegister();
|
||||
setWidth();
|
||||
setTheme(0);
|
||||
setLanguage(0);
|
||||
}
|
||||
|
||||
private void addComponents() {
|
||||
@@ -151,6 +152,18 @@ public class GUIRegister extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public void setLanguage(int iLangNr) {
|
||||
switch (iLangNr) {
|
||||
case 0: {
|
||||
oSFRRegisters.setValueAt("Vorteiler", 3, 2);
|
||||
}break;
|
||||
case 1: {
|
||||
oSFRRegisters.setValueAt("Prescaler", 3, 2);
|
||||
}break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setTheme(int iThemeNr) {
|
||||
switch (iThemeNr) {
|
||||
case 0: {
|
||||
|
||||
@@ -22,6 +22,7 @@ public class GUITestFileTable extends JScrollPane {
|
||||
JPanel oTable = new JPanel();
|
||||
int iTheme = 0;
|
||||
boolean bFileLoaded = false;
|
||||
JTextField oFill;
|
||||
|
||||
/**
|
||||
* Color oWhite = new Color(255, 253, 250);
|
||||
@@ -46,7 +47,7 @@ public class GUITestFileTable extends JScrollPane {
|
||||
*/
|
||||
public GUITestFileTable() {
|
||||
|
||||
JTextField oFill = new JTextField("Please load testfile!");
|
||||
oFill = new JTextField();
|
||||
oFill.setEditable(false);
|
||||
oLineInformation.add(oFill);
|
||||
|
||||
@@ -57,6 +58,7 @@ public class GUITestFileTable extends JScrollPane {
|
||||
this.setPreferredSize(new Dimension(600, 700));
|
||||
this.setViewportView(oTestPanel);
|
||||
setTheme(0);
|
||||
setLanguage(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,6 +214,17 @@ public class GUITestFileTable extends JScrollPane {
|
||||
}
|
||||
}
|
||||
|
||||
public void setLanguage(int iLangNr) {
|
||||
switch (iLangNr) {
|
||||
case 0: {
|
||||
oFill.setText("Bitte Testdatei laden!");
|
||||
}break;
|
||||
case 1: {
|
||||
oFill.setText("Please load testfile!");
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Color to set for testfiletable
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,8 @@ public class GUITime extends JPanel {
|
||||
JLabel oLabelWDT = new JLabel("Watchdog Timer");
|
||||
JCheckBox oEnableWDT = new JCheckBox("WDT");
|
||||
|
||||
JLabel oLabelRuntime = new JLabel("Runtime: 0");
|
||||
int iRuntime = 0;
|
||||
JLabel oLabelRuntime = new JLabel("Runtime: " + iRuntime);
|
||||
|
||||
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"};
|
||||
@@ -41,6 +42,7 @@ public class GUITime extends JPanel {
|
||||
|
||||
public GUITime() {
|
||||
buildGUITime();
|
||||
setLanguage(0);
|
||||
}
|
||||
|
||||
private void buildGUITime() {
|
||||
@@ -67,6 +69,27 @@ public class GUITime extends JPanel {
|
||||
this.add(oIntervals, oConstraints);
|
||||
}
|
||||
|
||||
public void setLanguage(int iLangNr) {
|
||||
switch (iLangNr) {
|
||||
case 0: {
|
||||
oLabelRuntime.setText("Laufzeit: " + iRuntime);
|
||||
oLabelQuarz.setText("Quarzfrequenz");
|
||||
}break;
|
||||
case 1: {
|
||||
oLabelRuntime.setText("Runtime: " + iRuntime);
|
||||
oLabelQuarz.setText("Quarzfrequency");
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRuntime(int iRuntime) {
|
||||
this.iRuntime = iRuntime;
|
||||
}
|
||||
|
||||
public int getRuntime() {
|
||||
return iRuntime;
|
||||
}
|
||||
|
||||
public void setTheme(int iThemeNr) {
|
||||
switch (iThemeNr) {
|
||||
case 0: {
|
||||
|
||||
42
src/View/MyColors.java
Normal file
42
src/View/MyColors.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package View;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class MyColors {
|
||||
|
||||
/**
|
||||
* Color oWhite = new Color(255, 253, 250);
|
||||
* Color oDarkGray = new Color(76, 78, 82);
|
||||
* Color oDarkGrayB = new Color(47, 47, 47);
|
||||
* Color oLightBlue = new Color(173, 216, 230);
|
||||
* Color oOrangeDM = new Color(255, 170, 0);
|
||||
* Color oLightBlueDM = new Color(0, 213, 255);
|
||||
* Color oOrangeDMB = new Color(255, 85, 0);
|
||||
* First Color == TextColor
|
||||
* Second Color == BackgroundColor
|
||||
* Third Color == BorderColor
|
||||
* Fourth Color == TextColor Marked
|
||||
* Fifth Color == BackgroundColor Marked
|
||||
* Sixth Color == BorderColor Marked
|
||||
*/
|
||||
static Color[] aoDarkTheme = {new Color(255, 253, 250), new Color(76, 78, 82), new Color(47, 47, 47), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
|
||||
static Color[] aoLightTheme = {new Color(76, 78, 82), new Color(255, 253, 250), new Color(173, 216, 230), new Color(0, 213, 255), new Color(255, 170, 0), new Color(255, 85, 0)};
|
||||
|
||||
public static Color[] getTheme(int iThemeNr) {
|
||||
Color[] oTheme;
|
||||
switch (iThemeNr) {
|
||||
case 0: {
|
||||
oTheme = aoLightTheme;
|
||||
}break;
|
||||
|
||||
case 1: {
|
||||
oTheme = aoDarkTheme;
|
||||
}break;
|
||||
|
||||
default: {
|
||||
oTheme = null;
|
||||
}break;
|
||||
}
|
||||
return oTheme;
|
||||
}
|
||||
}
|
||||
@@ -2,36 +2,36 @@ package View;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import Model.Backend.Runtime.Environment;
|
||||
import Model.MyModel;
|
||||
|
||||
public class MyView implements IMyView {
|
||||
|
||||
GUIMainFrame oGUIMainFrame;
|
||||
GUIMCMenu oGUIMCMenu;
|
||||
GUIPorts oGUIPorts;
|
||||
GUIRamTable oGUIRamTable;
|
||||
GUIRegister oGUIRegister;
|
||||
GUIRegistersDetailed oGUIRegistersDetailed;
|
||||
GUIStack oGUIStack;
|
||||
GUITestFileTable oGUITestFileTable;
|
||||
GUITime oGUITime;
|
||||
private GUIMainFrame oGUIMainFrame;
|
||||
private GUIMCMenu oGUIMCMenu;
|
||||
private GUIPorts oGUIPorts;
|
||||
private GUIRamTable oGUIRamTable;
|
||||
private GUIRegister oGUIRegister;
|
||||
private GUIRegistersDetailed oGUIRegistersDetailed;
|
||||
private GUIStack oGUIStack;
|
||||
private GUITestFileTable oGUITestFileTable;
|
||||
private GUITime oGUITime;
|
||||
private GUIMenuBar oGUIMenuBar;
|
||||
|
||||
JPanel oGUIMainPanel;
|
||||
private JPanel oGUIMainPanel;
|
||||
|
||||
Environment oEnvironment;
|
||||
|
||||
public MyView(GUIMainFrame oGUIMainFrame, GUIMCMenu oGUIMCMenu, GUIPorts oGUIPorts, GUIRamTable oGUIRamTable, GUIRegister oGUIRegister, GUIRegistersDetailed oGUIRegistersDetailed, GUIStack oGUIStack, GUITestFileTable oGUITestFileTable, GUITime oGUITime, JPanel oGUIMainPanel, Environment oEnvironment) {
|
||||
this.oGUIMainFrame = oGUIMainFrame;
|
||||
this.oGUIMCMenu = oGUIMCMenu;
|
||||
this.oGUIPorts = oGUIPorts;
|
||||
this.oGUIRamTable = oGUIRamTable;
|
||||
this.oGUIRegister = oGUIRegister;
|
||||
this.oGUIRegistersDetailed = oGUIRegistersDetailed;
|
||||
this.oGUIStack = oGUIStack;
|
||||
this.oGUITestFileTable = oGUITestFileTable;
|
||||
this.oGUITime = oGUITime;
|
||||
this.oGUIMainPanel = oGUIMainPanel;
|
||||
this.oEnvironment = oEnvironment;
|
||||
public MyView(MyModel model) {
|
||||
oGUIMenuBar = new GUIMenuBar(model, this);
|
||||
oGUIMCMenu = new GUIMCMenu();
|
||||
oGUIPorts = new GUIPorts();
|
||||
oGUIRamTable = new GUIRamTable();
|
||||
oGUIRegister = new GUIRegister();
|
||||
oGUIRegistersDetailed = new GUIRegistersDetailed();
|
||||
oGUIStack = new GUIStack();
|
||||
oGUITestFileTable = new GUITestFileTable();
|
||||
oGUITime = new GUITime();
|
||||
oGUIMainFrame = new GUIMainFrame(oGUIMenuBar, this);
|
||||
oGUIMainPanel = oGUIMainFrame.getMainPanel();
|
||||
setTheme(0);
|
||||
}
|
||||
|
||||
public void setTheme(int iThemeNr) {
|
||||
@@ -44,6 +44,14 @@ public class MyView implements IMyView {
|
||||
oGUIStack.setTheme(iThemeNr);
|
||||
oGUITestFileTable.setTheme(iThemeNr);
|
||||
oGUITime.setTheme(iThemeNr);
|
||||
oGUIMenuBar.setTheme(iThemeNr);
|
||||
}
|
||||
|
||||
public void setLanguage(int iLangNr) {
|
||||
oGUIMCMenu.setLanguage(iLangNr);
|
||||
oGUIRegister.setLanguage(iLangNr);
|
||||
oGUITestFileTable.setLanguage(iLangNr);
|
||||
oGUITime.setLanguage(iLangNr);
|
||||
}
|
||||
|
||||
public GUIMainFrame getGUIMainFrame() {
|
||||
@@ -74,6 +82,10 @@ public class MyView implements IMyView {
|
||||
return this.oGUIStack;
|
||||
}
|
||||
|
||||
public GUITime getGUITime() {
|
||||
return this.oGUITime;
|
||||
}
|
||||
|
||||
public GUITestFileTable getGUITestFileTable() {
|
||||
return this.oGUITestFileTable;
|
||||
}
|
||||
@@ -81,8 +93,4 @@ public class MyView implements IMyView {
|
||||
public JPanel getGUIMainPanel() {
|
||||
return this.oGUIMainPanel;
|
||||
}
|
||||
|
||||
public Environment getEnvironment() {
|
||||
return this.oEnvironment;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user