Skip to content

Commit

Permalink
Added warning for start-up error and made console invisible.
Browse files Browse the repository at this point in the history
  • Loading branch information
newpomax committed May 21, 2021
1 parent 3abaf0f commit dcd25e6
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 10 deletions.
32 changes: 32 additions & 0 deletions F_thrust_RASAERO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; Name diameter(mm) Length(mm) delay propellant_weight(kg) mass(kg)
O10400-I 143 2438 P 6.07 18.01 SSI
0.010 10.129
0.370 1675.048
0.730 1649.453
1.090 1622.081
1.450 1590.739
1.810 1558.013
2.170 1524.492
2.530 1493.891
2.890 1462.492
3.250 1431.987
3.610 1400.609
3.970 1371.720
4.330 1343.713
4.690 1316.055
5.050 1288.726
5.410 1262.746
5.770 1235.414
6.130 1208.810
6.490 1182.573
6.850 1156.720
7.210 414.400
7.570 316.530
7.930 241.952
8.290 182.485
8.650 134.944
9.010 97.016
9.370 66.594
9.730 46.179
10.090 39.194
10.445 0.000
32 changes: 32 additions & 0 deletions Outputs/F_thrust_RASAERO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; Name diameter(mm) Length(mm) delay propellant_weight(kg) mass(kg)
O18000-I 143 2438 P 9.81 21.75 SSI
0.005 393.864
0.425 1762.134
0.845 1741.508
1.265 1720.709
1.680 1698.403
2.100 1675.962
2.520 1654.852
2.940 1633.081
3.360 1611.461
3.780 1590.006
4.200 1568.623
4.615 1547.330
5.035 1527.943
5.455 1508.611
5.875 1488.873
6.295 1469.723
6.715 1449.460
7.135 1430.134
7.555 1411.474
7.970 1393.661
8.390 1375.512
8.810 1357.409
9.230 1338.986
9.650 1322.025
10.070 1304.232
10.490 1285.500
10.905 1267.145
11.325 1249.772
11.745 1231.826
12.162 0.000
32 changes: 32 additions & 0 deletions Outputs/IMPULSE_17,25_kNs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; Name diameter(mm) Length(mm) delay propellant_weight(kg) mass(kg)
O18000-I 143 2438 P 9.89 21.83 SSI
0.005 216.251
0.360 2091.647
0.710 2067.483
1.065 2042.841
1.420 2016.018
1.770 1989.652
2.125 1964.546
2.480 1938.635
2.830 1913.214
3.185 1887.638
3.540 1862.152
3.890 1836.824
4.245 1813.667
4.600 1790.645
4.950 1767.411
5.305 1744.595
5.655 1720.835
6.010 1697.667
6.365 1675.390
6.715 1654.212
7.070 1632.593
7.425 1610.976
7.775 1589.276
8.130 1568.964
8.485 1547.847
8.835 1525.778
9.190 1503.802
9.545 1483.087
9.895 1461.786
10.245 0.000
5 changes: 0 additions & 5 deletions PropSim.py

This file was deleted.

17 changes: 17 additions & 0 deletions PropSim.pyw
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import tkinter as tk
from tkinter import messagebox as msgbox # for writing errors during set-up

if __name__ == '__main__':
try:
from PythonLib.MainWindow import MainWindow
mainwindow = MainWindow() # construct the MainWindow
except Exception as err:
# Create a tk root to base the pop-up off of
root = tk.Tk()
root.overrideredirect(1)
root.withdraw()
err_msg = "Encountered error during start-up:\n{0} \n\nPlease contact PropSim help: \nMax Newport, newpomax@alumni.stanford.edu".format(err)
response = msgbox.showerror(title="Start-up Error", message = err_msg) # if encountered an error during start-up, show in pop-up
root.destroy()

mainwindow.run() # run the MainWindow
5 changes: 4 additions & 1 deletion PythonLib/CmdPane.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def __init__(self, parent, matlabeng):
def get(self):
return self.var.get()

def put(self, msg):
self.var.set(str(msg))

def on_return(self):
# Process input
myline = self.var.get()
Expand Down Expand Up @@ -84,7 +87,7 @@ def _cmd_thread(self, cmd):
output = StringIO()
try:
self.entry.unbind("<Return>") # prevent additional commands from being sent
self.matlabeng.eval(cmd, nargout = 0, stdout = output)
self.matlabeng.eval(cmd, nargout = 0, stdout = output, stderr = output)
finally:
results = output.getvalue()
if results == None or results == '':
Expand Down
4 changes: 3 additions & 1 deletion PythonLib/DesignLiquidPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ def postbuild(self, matlabeng):
def run(self, stdout):
input_struct_str = ','.join(self.inputstructs) # input struct

self.matlabeng.eval( 'DesignLiquid(' + input_struct_str + ') ;' , nargout = 0, stdout = stdout)
self.matlabeng.eval( 'DesignLiquid(' + input_struct_str + ') ;' , nargout = 0, stdout = stdout, stderr = stdout)

self.inputPane.mainwindow.cmdPane.put("save('./Data Analysis/SimulateLiquid_fromDesignLiquid.mat', '-struct', 'output');") # put this in the cmd line to prompt for save

def plot(self, plotpane):
''' Plotting! Uses SimulateLiquidPage's defined version with different arguments. '''
SimulateLiquidPage.plot(self, plotpane, is_design = True)
Expand Down
8 changes: 7 additions & 1 deletion PythonLib/EntryVar.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ def validate(self):
if len(splitstr) > 2: # protect against too many arguments before using eval()
self.set_err()
return "Error: Variable " + self.name + " has an unparseable input: " + self.get()
elif len(splitstr) == 1 :
try:
check = float(splitstr[0]) # check if no unit that the input is numeric
except:
self.set_err()
return "Error: Variable " + self.name + " has an unparseable input: " + self.get()

try:
parse_this = splitstr[0].strip()
Expand All @@ -81,7 +87,7 @@ def validate(self):
self.numeric_val = float(eval(parse_this,{"__builtins__":None},{})) # use eval to parse input for numeric expressions, protecting against harmful input
except:
self.set_err()
return "Error: Variable " + self.name + " has an unparseable value: " + self.splitstr[0]
return "Error: Variable " + self.name + " has an unparseable value: " + self.get()
if len(splitstr) > 1 : # if a unit was included
if units.validate_units(splitstr[1].strip(), self.baseunit):
self.parsed_unit = splitstr[1]
Expand Down
1 change: 1 addition & 0 deletions PythonLib/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
class MainWindow(tk.Tk):
def __init__(self):
super().__init__() #use inherited constructor for tk.Tk
self.iconbitmap(default="PythonLib/ssi_logo.ico")

# Build the primary frame that contains all other items.
self.mainframe = ttk.Frame(self)
Expand Down
2 changes: 1 addition & 1 deletion PythonLib/SimulateHybridPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def postbuild(self, matlabeng):
def run(self, stdout):
input_struct_str = ','.join(self.inputstructs)

self.matlabeng.eval( 'PerformanceCode(' + input_struct_str + ') ;' , nargout = 0, stdout = stdout)
self.matlabeng.eval( 'PerformanceCode(' + input_struct_str + ') ;' , nargout = 0, stdout = stdout, stderr = stdout)

def plot(self, plotpane):
''' Plotting! Uses SimulateLiquidPage's defined version with different arguments. '''
Expand Down
2 changes: 1 addition & 1 deletion PythonLib/SimulateLiquidPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def postbuild(self, matlabeng):
def run(self, stdout):
''' Handles running the actual simulation. '''
input_struct_str = ','.join(self.inputstructs)
self.matlabeng.eval( 'PerformanceCode(' + input_struct_str + ') ;' , stdout = stdout, nargout = 0 )
self.matlabeng.eval( 'PerformanceCode(' + input_struct_str + ') ;' , stdout = stdout, stderr = stdout, nargout = 0 )

def plot(self, plotpane, is_liquid = True, is_design = False):
''' Handles plotting. Update here to change how output is graphed. '''
Expand Down
5 changes: 5 additions & 0 deletions PythonLib/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
python <= 3.8 # This depends on your MATLAB type - see: https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/python-compatibility.pdf
mplcursors==0.4 # for plot marking
numpy==1.20.1
matplotlib==3.3.4
matlab==0.1
Binary file added PythonLib/ssi_logo.ico
Binary file not shown.

0 comments on commit dcd25e6

Please sign in to comment.