mirror of
https://github.com/nasa/trick.git
synced 2025-02-06 02:49:20 +00:00
Cleaned non-feature related changes from branch
This commit is contained in:
parent
c6010829d4
commit
bfbc907a8c
1
test/SIM_gui_testing/.gitignore
vendored
1
test/SIM_gui_testing/.gitignore
vendored
@ -1 +0,0 @@
|
||||
socket_info
|
@ -1,7 +0,0 @@
|
||||
|
||||
trick.real_time_enable()
|
||||
trick.exec_set_software_frame(0.1)
|
||||
trick.itimer_enable()
|
||||
|
||||
trick.exec_set_enable_freeze(True)
|
||||
trick.exec_set_freeze_command(True)
|
File diff suppressed because it is too large
Load Diff
@ -1,10 +0,0 @@
|
||||
exec(open("./Modified_Data/realtime.py").read())
|
||||
|
||||
# Save the Connection Info <host,port> to a file
|
||||
host = trick.var_server_get_hostname()
|
||||
port = trick.var_server_get_port()
|
||||
|
||||
f = open("socket_info", "w")
|
||||
f.write(str(host) + ":" + str(port))
|
||||
f.close()
|
||||
|
@ -1,6 +0,0 @@
|
||||
exec(open("./Modified_Data/realtime.py").read())
|
||||
|
||||
# Open the SimControlPanel
|
||||
simControlPanel = trick.SimControlPanel()
|
||||
trick.add_external_application(simControlPanel)
|
||||
|
@ -1,27 +0,0 @@
|
||||
/************************************************************
|
||||
PURPOSE:
|
||||
( Provide a basic simulation for testing GUI )
|
||||
LIBRARY DEPENDENCIES:
|
||||
((Basic/src/Basic.cc))
|
||||
*************************************************************/
|
||||
#include "sim_objects/default_trick_sys.sm"
|
||||
##include "Basic/include/Basic.hh"
|
||||
|
||||
class BasicSimObject : public Trick::SimObject {
|
||||
public:
|
||||
Basic basic;
|
||||
|
||||
BasicSimObject() {
|
||||
("default_data") basic.default_data() ;
|
||||
("initialization") basic.state_init() ;
|
||||
(0.1, "scheduled") basic.state_increment() ;
|
||||
("integration") trick_ret = basic.state_integ() ;
|
||||
}
|
||||
};
|
||||
|
||||
BasicSimObject dyn;
|
||||
IntegLoop dyn_integloop(0.1) dyn;
|
||||
|
||||
void create_connections() {
|
||||
dyn_integloop.getIntegrator(Runge_Kutta_4, 4);
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
TRICK_CFLAGS += -Imodels
|
||||
TRICK_CXXFLAGS += -Imodels
|
@ -1,20 +0,0 @@
|
||||
/************************************************************************
|
||||
PURPOSE: (Provide a basic simulation for testing GUI)
|
||||
LIBRARY DEPENDENCIES:
|
||||
((Basic/src/Basic.o))
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef BASIC_HH
|
||||
#define BASIC_HH
|
||||
|
||||
class Basic {
|
||||
public:
|
||||
int counter; /* -- Just a counter variable */
|
||||
|
||||
int default_data();
|
||||
int state_init();
|
||||
int state_increment();
|
||||
int state_integ();
|
||||
};
|
||||
|
||||
#endif
|
@ -1,26 +0,0 @@
|
||||
/************************************************************************
|
||||
PURPOSE: (Provide a basic simulation for testing GUI)
|
||||
LIBRARY DEPENDENCIES:
|
||||
((Basic.o))
|
||||
**************************************************************************/
|
||||
|
||||
#include "Basic/include/Basic.hh"
|
||||
|
||||
int Basic::default_data() {
|
||||
counter = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Basic::state_init() {
|
||||
counter = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Basic::state_increment() {
|
||||
counter += 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Basic::state_integ() {
|
||||
return 0;
|
||||
}
|
@ -467,7 +467,6 @@ public abstract class TrickApplication extends SingleFrameApplication implements
|
||||
button.setVerticalTextPosition(JButton.BOTTOM);
|
||||
button.setHorizontalTextPosition(JButton.CENTER);
|
||||
button.setAction(getAction(actionName));
|
||||
button.setName(actionName + "Button");
|
||||
button.setFocusable(false);
|
||||
if (!showText) {
|
||||
button.setText(null);
|
||||
|
@ -231,15 +231,57 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
|
||||
//for Java 7, the type of elements of JComboBox needs to be specified to avoid the warning and it's not supported in Java 6
|
||||
@SuppressWarnings("unchecked")
|
||||
private void buildGUI(Frame parent) {
|
||||
JPanel selectionPanel = buildSelectionPanel(),
|
||||
samplePanel = buildSamplePanel(),
|
||||
buttonPanel = buildButtonPanel();
|
||||
JPanel selectionPanel = new JPanel();
|
||||
fontList = new JList(fonts);
|
||||
fontList.getSelectionModel().addListSelectionListener(this);
|
||||
sizeList = new JList(sizes);
|
||||
sizeList.getSelectionModel().addListSelectionListener(this);
|
||||
JPanel fontPanel = getListPanel("Font", fontList);
|
||||
selectionPanel.add(fontPanel);
|
||||
JPanel sizePanel = getListPanel("Size", sizeList);
|
||||
selectionPanel.add(sizePanel);
|
||||
JPanel stylePanel = new JPanel();
|
||||
stylePanel.setLayout(new BoxLayout(stylePanel, BoxLayout.Y_AXIS));
|
||||
JLabel styleLabel = new JLabel("Style");
|
||||
boldBox = new JCheckBox(BOLD_OPTION);
|
||||
boldBox.addActionListener(this);
|
||||
italicBox = new JCheckBox(ITALIC_OPTION);
|
||||
italicBox.addActionListener(this);
|
||||
stylePanel.add(styleLabel);
|
||||
stylePanel.add(Box.createRigidArea(new Dimension(0,5)));
|
||||
stylePanel.add(boldBox);
|
||||
stylePanel.add(italicBox);
|
||||
stylePanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
|
||||
stylePanel.setPreferredSize(new Dimension(stylePanel.getPreferredSize().width, fontPanel.getPreferredSize().height));
|
||||
selectionPanel.add(stylePanel);
|
||||
selectionPanel.setMinimumSize(selectionPanel.getPreferredSize());
|
||||
|
||||
JPanel samplePanel = new JPanel(new BorderLayout());
|
||||
samplePanel.setBorder(new TitledBorder(new EtchedBorder(), "Preview"));
|
||||
|
||||
sampleLabel = new JLabel("", JLabel.CENTER);
|
||||
sampleLabel.setBackground(Color.white);
|
||||
sampleLabel.setBorder(new LineBorder(Color.black));
|
||||
sampleLabel.setOpaque(true);
|
||||
sampleLabel.setPreferredSize(new Dimension(120, 60));
|
||||
|
||||
samplePanel.add(sampleLabel, BorderLayout.CENTER);
|
||||
|
||||
JPanel buttonPanel = new JPanel();
|
||||
okButton = new JButton(OK_OPTION);
|
||||
okButton.addActionListener(this);
|
||||
cancelButton = new JButton(CANCEL_OPTION);
|
||||
cancelButton.addActionListener(this);
|
||||
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
|
||||
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
buttonPanel.add(Box.createHorizontalStrut(30));
|
||||
buttonPanel.add(okButton);
|
||||
buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||
buttonPanel.add(cancelButton);
|
||||
|
||||
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
|
||||
|
||||
getContentPane().add(selectionPanel);
|
||||
getContentPane().add(Box.createVerticalStrut(15));
|
||||
|
||||
getContentPane().add(samplePanel);
|
||||
getContentPane().add(buttonPanel);
|
||||
getContentPane().add(Box.createVerticalStrut(5));
|
||||
@ -255,7 +297,6 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
|
||||
*/
|
||||
private JPanel getListPanel(String labelText, JList list) {
|
||||
JPanel ret = new JPanel();
|
||||
ret.setName(labelText);
|
||||
list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||
JScrollPane listScroller = new JScrollPane(list);
|
||||
listScroller.setAlignmentX(LEFT_ALIGNMENT);
|
||||
@ -271,112 +312,6 @@ public class FontChooser extends JDialog implements ActionListener, ListSelectio
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the font selection panel.
|
||||
*
|
||||
* @return the built panel
|
||||
*/
|
||||
private JPanel buildSelectionPanel() {
|
||||
JPanel selectionPanel = new JPanel();
|
||||
|
||||
fontList = new JList(fonts);
|
||||
fontList.getSelectionModel().addListSelectionListener(this);
|
||||
sizeList = new JList(sizes);
|
||||
sizeList.getSelectionModel().addListSelectionListener(this);
|
||||
|
||||
JPanel fontPanel = getListPanel("Font", fontList),
|
||||
sizePanel = getListPanel("Size", sizeList),
|
||||
stylePanel = buildStylePanel(fontPanel.getPreferredSize().height);
|
||||
|
||||
selectionPanel.add(fontPanel);
|
||||
selectionPanel.add(sizePanel);
|
||||
selectionPanel.add(stylePanel);
|
||||
|
||||
// selectionPanel.setMinimumSize(selectionPanel.getPreferredSize());
|
||||
|
||||
return selectionPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the style selection panel.
|
||||
*
|
||||
* @param height the preferred height of the built style panel.
|
||||
* Should be the preferred height of the font panel.
|
||||
* @return the built panel
|
||||
*/
|
||||
private JPanel buildStylePanel(int height) {
|
||||
JPanel stylePanel = new JPanel();
|
||||
stylePanel.setLayout(new BoxLayout(stylePanel, BoxLayout.Y_AXIS));
|
||||
|
||||
String name = "Style";
|
||||
JLabel styleLabel = new JLabel(name);
|
||||
|
||||
boldBox = new JCheckBox(BOLD_OPTION);
|
||||
boldBox.setName("BoldCheck");
|
||||
boldBox.addActionListener(this);
|
||||
|
||||
italicBox = new JCheckBox(ITALIC_OPTION);
|
||||
italicBox.setName("ItalicCheck");
|
||||
italicBox.addActionListener(this);
|
||||
|
||||
stylePanel.add(styleLabel);
|
||||
stylePanel.add(Box.createRigidArea(new Dimension(0,5)));
|
||||
stylePanel.add(boldBox);
|
||||
stylePanel.add(italicBox);
|
||||
stylePanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
|
||||
stylePanel.setPreferredSize(new Dimension(stylePanel.getPreferredSize().width, height));
|
||||
stylePanel.setName(name);
|
||||
|
||||
return stylePanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the font preview panel.
|
||||
*
|
||||
* @return the built panel
|
||||
*/
|
||||
private JPanel buildSamplePanel() {
|
||||
JPanel samplePanel = new JPanel(new BorderLayout());
|
||||
String title = "Preview";
|
||||
samplePanel.setName(title);
|
||||
samplePanel.setBorder(new TitledBorder(new EtchedBorder(), title));
|
||||
|
||||
sampleLabel = new JLabel("", JLabel.CENTER);
|
||||
sampleLabel.setBackground(Color.white);
|
||||
sampleLabel.setBorder(new LineBorder(Color.black));
|
||||
sampleLabel.setOpaque(true);
|
||||
sampleLabel.setPreferredSize(new Dimension(120, 60));
|
||||
|
||||
samplePanel.add(sampleLabel, BorderLayout.CENTER);
|
||||
|
||||
return samplePanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the button panel to accept the new font or cancel the operation.
|
||||
*
|
||||
* @return the built panel
|
||||
*/
|
||||
private JPanel buildButtonPanel() {
|
||||
JPanel buttonPanel = new JPanel();
|
||||
|
||||
okButton = new JButton(OK_OPTION);
|
||||
okButton.addActionListener(this);
|
||||
cancelButton = new JButton(CANCEL_OPTION);
|
||||
cancelButton.addActionListener(this);
|
||||
|
||||
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
|
||||
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
buttonPanel.setName("Buttons");
|
||||
|
||||
buttonPanel.add(Box.createHorizontalStrut(30));
|
||||
buttonPanel.add(okButton);
|
||||
buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||
buttonPanel.add(cancelButton);
|
||||
|
||||
return buttonPanel;
|
||||
}
|
||||
|
||||
|
||||
//========================================
|
||||
// Inner Classes
|
||||
|
@ -9,7 +9,6 @@ package trick.simcontrol;
|
||||
//========================================
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
@ -109,10 +108,6 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
//========================================
|
||||
// Protected data
|
||||
//========================================
|
||||
protected static String host;
|
||||
protected static int port = -1;
|
||||
protected static boolean isRestartOptionOn;
|
||||
protected static boolean isAutoExitOn; /** whether automatically exit when sim is done/killed. */
|
||||
|
||||
|
||||
//========================================
|
||||
@ -124,6 +119,9 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
private int overrun_present ;
|
||||
private int message_present ;
|
||||
private int message_port ;
|
||||
|
||||
/** whether automatically exit when sim is done/killed. */
|
||||
private static boolean isAutoExitOn;
|
||||
|
||||
// The panel that displays the current sim state description as well as progress.
|
||||
private JXTitledPanel runtimeStatePanel;
|
||||
@ -159,7 +157,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
/*
|
||||
* The action controller that performs actions for such as clicking button, selection a menu item and etc.
|
||||
*/
|
||||
protected SimControlActionController actionController;
|
||||
private SimControlActionController actionController;
|
||||
|
||||
// The animation image player panel
|
||||
private AnimationPlayer logoImagePanel;
|
||||
@ -173,6 +171,9 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
private SocketChannel healthStatusSocketChannel ;
|
||||
|
||||
private JComboBox runningSimList;
|
||||
private static String host;
|
||||
private static int port = -1;
|
||||
private static boolean isRestartOptionOn;
|
||||
//True if an error was encountered during the attempt to connect to Variable Server during intialize()
|
||||
private boolean errOnInitConnect = false;
|
||||
//Time out when attempting to establish connection with Variable Server in milliseconds
|
||||
@ -187,8 +188,8 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
|
||||
final private static String LOCALHOST = "localhost";
|
||||
|
||||
final public static Dimension FULL_SIZE = new Dimension(680, 640);
|
||||
final public static Dimension LITE_SIZE = new Dimension(340, 360);
|
||||
final private Dimension FULL_SIZE = new Dimension(680, 640);
|
||||
final private Dimension LITE_SIZE = new Dimension(340, 360);
|
||||
|
||||
//========================================
|
||||
// Actions
|
||||
@ -347,53 +348,8 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
*/
|
||||
@Action
|
||||
public void connect() {
|
||||
parseHostPortFromInput(); // get host and port from running sim list
|
||||
getInitializationPacket(); // init variable server connection
|
||||
if (commandSimcom == null) {
|
||||
String errMsg = "Sorry, can't connect. Please make sure the availability of both server and port!";
|
||||
printErrorMessage(errMsg);
|
||||
return;
|
||||
}
|
||||
setEnabledAllActions(true); // enable all actions
|
||||
scheduleGetSimState(); // set up the sim status variables
|
||||
startStatusMonitors(); // start monitors for sim and health status
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method for starting monitors for sim status as well as health status.
|
||||
*/
|
||||
protected void startStatusMonitors() {
|
||||
MonitorSimStatusTask monitorSimStatusTask = new MonitorSimStatusTask(this);
|
||||
monitorSimStatusTask.addPropertyChangeListener(this);
|
||||
getContext().getTaskService().execute(monitorSimStatusTask);
|
||||
|
||||
// For receiving hs messages.
|
||||
getContext().getTaskService().execute(new MonitorHealthStatusTask(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all actions as either enabled or disabled
|
||||
* @param isEnabled the state to set each action as
|
||||
*/
|
||||
protected void setEnabledAllActions(boolean isEnabled) {
|
||||
if(actionMap == null)
|
||||
return;
|
||||
|
||||
Object[] keys = actionMap.allKeys();
|
||||
// If there is a server connection established, enable all actions.
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
String theKey = (String)keys[i];
|
||||
getAction(theKey).setEnabled(isEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the host and port from the runningSimList object
|
||||
*/
|
||||
protected void parseHostPortFromInput() {
|
||||
|
||||
if (runningSimList != null && runningSimList.getSelectedItem() != null) {
|
||||
// get host and port for selected sim
|
||||
if (runningSimList != null && runningSimList.getSelectedItem() != null) {
|
||||
String selectedStr = runningSimList.getSelectedItem().toString();
|
||||
// remove the run info if it is shown
|
||||
int leftPre = selectedStr.indexOf("(");
|
||||
@ -410,17 +366,51 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
if (elements == null || elements.length < 2) {
|
||||
String errMsg = "Can't connect! Please provide valid host name and port number separated by : or whitespace!";
|
||||
printErrorMessage(errMsg);
|
||||
} else {
|
||||
host = elements[0].trim();
|
||||
try { port = Integer.parseInt(elements[1].trim()); }
|
||||
catch (NumberFormatException nfe) {
|
||||
String errMsg = elements[1] + " is not a valid port number!";
|
||||
printErrorMessage(errMsg);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
host = elements[0].trim();
|
||||
try {
|
||||
port = Integer.parseInt(elements[1].trim());
|
||||
} catch (NumberFormatException nfe) {
|
||||
String errMsg = elements[1] + " is not a valid port number!";
|
||||
printErrorMessage(errMsg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
getInitializationPacket();
|
||||
|
||||
if (commandSimcom == null) {
|
||||
String errMsg = "Sorry, can't connect. Please make sure the availability of both server and port!";
|
||||
printErrorMessage(errMsg);
|
||||
return;
|
||||
} else {
|
||||
Object[] keys = actionMap.allKeys();
|
||||
// If there is a server connection established, enable all actions.
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
String theKey = (String)keys[i];
|
||||
getAction(theKey).setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scheduleGetSimState();
|
||||
|
||||
startStatusMonitors();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method for starting monitors for sim status as well as health status.
|
||||
*/
|
||||
private void startStatusMonitors() {
|
||||
MonitorSimStatusTask monitorSimStatusTask = new MonitorSimStatusTask(this);
|
||||
monitorSimStatusTask.addPropertyChangeListener(this);
|
||||
getContext().getTaskService().execute(monitorSimStatusTask);
|
||||
|
||||
// For receiving hs messages.
|
||||
getContext().getTaskService().execute(new MonitorHealthStatusTask(this));
|
||||
}
|
||||
|
||||
//========================================
|
||||
// Set/Get methods
|
||||
//========================================
|
||||
@ -465,7 +455,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
(new RetrieveHostPortTask()).execute();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
actionController.setVariableServerConnection(commandSimcom);
|
||||
|
||||
simState = new SimState();
|
||||
@ -575,24 +565,6 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
}
|
||||
}
|
||||
|
||||
public static void setHostPort(String hostname, int portNum) {
|
||||
host = hostname;
|
||||
port = portNum;
|
||||
}
|
||||
|
||||
// Getting specific values from GUI
|
||||
public double getExecTime() { return simState.getExecOutTime(); }
|
||||
|
||||
// Passing components as read-only to inheriting classes
|
||||
protected final JComboBox getRunningSimList() { return runningSimList; }
|
||||
protected final JXEditorPane getEditorPane() { return statusMsgPane; }
|
||||
protected final JToggleButton getDataRecButton() { return dataRecButton; }
|
||||
protected final JToggleButton getRealTimeButton() { return realtimeButton; }
|
||||
protected final JTextField getSimRunDirField() { return getSimRunDirField(0); }
|
||||
protected final JTextField getSimRunDirField(int index) {
|
||||
return (index < simRunDirField.length) ? simRunDirField[index] : null;
|
||||
}
|
||||
|
||||
|
||||
//========================================
|
||||
// Methods
|
||||
@ -868,8 +840,9 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
statusSimcom.put(status_vars) ;
|
||||
|
||||
statusSimcom.put("trick.var_cycle(0.25)\n");
|
||||
setActionsEnabled("connect", false);
|
||||
setGUIEnabled(runningSimList, false);
|
||||
|
||||
getAction("connect").setEnabled(false);
|
||||
runningSimList.setEnabled(false);
|
||||
}
|
||||
catch (NumberFormatException nfe) {
|
||||
|
||||
@ -884,14 +857,6 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
}
|
||||
}
|
||||
|
||||
private void setGUIEnabled(Component gui, boolean flag) {
|
||||
if(gui != null) gui.setEnabled(flag);
|
||||
}
|
||||
|
||||
private void setGUIEnabled(Component[] guis, boolean flag) {
|
||||
for(Component gui : guis) setGUIEnabled(gui, flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient method for setting the state of specified actions.
|
||||
*
|
||||
@ -1298,7 +1263,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
/**
|
||||
* Updates the GUI as needed if SIM states are changed.
|
||||
*/
|
||||
protected void updateGUI() {
|
||||
private void updateGUI() {
|
||||
String newStatusDesc = SimState.SIM_MODE_DESCRIPTION[simState.getMode()];
|
||||
|
||||
recTime.setText(simState.getTwoFractionFormatted(simState.getExecOutTime()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user