Skip to content

Commit aa13d01

Browse files
committed
LVD: Added ability to reset an extremum value in the middle of a mission, allowing the same extremum to be used multiple times.
1 parent 584f85f commit aa13d01

6 files changed

Lines changed: 250 additions & 1 deletion

File tree

helper_methods/ksptot_ma/launch_vehicle_designer/classes/Events/actions/@EventActionEnum/EventActionEnum.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
SetAeroLiftProps('Set Lift Aero Properties','SetLiftAeroPropertiesAction');
1717
SetStopwatchRunningState('Set Stopwatch Running State','SetStopwatchRunningStateAction');
1818
SetExtremumRecordingState('Set Extremum Recording State','SetExtremumRecordingStateAction');
19+
ResetExtremumValueAction('Reset Extremum Value','ResetExtremumValueAction');
1920
end
2021

2122
properties
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
classdef ResetExtremumValueAction < AbstractEventAction
2+
%ResetExtremumValueAction Summary of this class goes here
3+
% Detailed explanation goes here
4+
5+
properties
6+
extremum LaunchVehicleExtrema
7+
end
8+
9+
methods
10+
function obj = ResetExtremumValueAction(extremum)
11+
if(nargin > 0)
12+
obj.extremum = extremum;
13+
end
14+
15+
obj.id = rand();
16+
end
17+
18+
function newStateLogEntry = executeAction(obj, stateLogEntry)
19+
newStateLogEntry = stateLogEntry;
20+
21+
if(not(isempty(obj.extremum)))
22+
extremaState = newStateLogEntry.extremaStates([newStateLogEntry.extremaStates.extrema] == obj.extremum);
23+
extremaState.value = NaN;
24+
end
25+
end
26+
27+
function initAction(obj, initialStateLogEntry)
28+
%nothing
29+
end
30+
31+
function name = getName(obj)
32+
if(not(isempty(obj.extremum)))
33+
nameStr = obj.extremum.getNameStr();
34+
else
35+
nameStr = '<No Extremum Selected>';
36+
end
37+
38+
name = sprintf('Reset Extremum Value (%s)', nameStr);
39+
end
40+
41+
function tf = usesStage(obj, stage)
42+
tf = false;
43+
end
44+
45+
function tf = usesEngine(obj, engine)
46+
tf = false;
47+
end
48+
49+
function tf = usesTank(obj, tank)
50+
tf = false;
51+
end
52+
53+
function tf = usesEngineToTankConn(obj, engineToTank)
54+
tf = false;
55+
end
56+
57+
function tf = usesStopwatch(obj, stopwatch)
58+
tf = false;
59+
end
60+
61+
function tf = usesExtremum(obj, extremum)
62+
tf = [obj.extremum] == extremum;
63+
end
64+
65+
function tf = usesTankToTankConn(obj, tankToTank)
66+
tf = false;
67+
end
68+
69+
function [tf, vars] = hasActiveOptimVar(obj)
70+
tf = false;
71+
vars = AbstractOptimizationVariable.empty(0,1);
72+
end
73+
end
74+
75+
methods(Static)
76+
function addActionTf = openEditActionUI(action, lv)
77+
addActionTf = lvd_EditActionResetExtremumValueGUI(action, lv);
78+
end
79+
end
80+
end

helper_methods/ksptot_ma/launch_vehicle_designer/classes/Events/actions/@SetExtremumRecordingStateAction/SetExtremumRecordingStateAction.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
methods
1111
function obj = SetExtremumRecordingStateAction(extremum, runningStateToSet)
1212
if(nargin > 0)
13-
obj.stopwatch = extremum;
13+
obj.extremum = extremum;
1414
obj.runningStateToSet = runningStateToSet;
1515
end
1616

Binary file not shown.
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
function varargout = lvd_EditActionResetExtremumValueGUI(varargin)
2+
% LVD_EDITACTIONRESETEXTREMUMVALUEGUI MATLAB code for lvd_EditActionResetExtremumValueGUI.fig
3+
% LVD_EDITACTIONRESETEXTREMUMVALUEGUI, by itself, creates a new LVD_EDITACTIONRESETEXTREMUMVALUEGUI or raises the existing
4+
% singleton*.
5+
%
6+
% H = LVD_EDITACTIONRESETEXTREMUMVALUEGUI returns the handle to a new LVD_EDITACTIONRESETEXTREMUMVALUEGUI or the handle to
7+
% the existing singleton*.
8+
%
9+
% LVD_EDITACTIONRESETEXTREMUMVALUEGUI('CALLBACK',hObject,eventData,handles,...) calls the local
10+
% function named CALLBACK in LVD_EDITACTIONRESETEXTREMUMVALUEGUI.M with the given input arguments.
11+
%
12+
% LVD_EDITACTIONRESETEXTREMUMVALUEGUI('Property','Value',...) creates a new LVD_EDITACTIONRESETEXTREMUMVALUEGUI or raises the
13+
% existing singleton*. Starting from the left, property value pairs are
14+
% applied to the GUI before lvd_EditActionResetExtremumValueGUI_OpeningFcn gets called. An
15+
% unrecognized property name or invalid value makes property application
16+
% stop. All inputs are passed to lvd_EditActionResetExtremumValueGUI_OpeningFcn via varargin.
17+
%
18+
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
19+
% instance to run (singleton)".
20+
%
21+
% See also: GUIDE, GUIDATA, GUIHANDLES
22+
23+
% Edit the above text to modify the response to help lvd_EditActionResetExtremumValueGUI
24+
25+
% Last Modified by GUIDE v2.5 23-Jan-2019 10:00:18
26+
27+
% Begin initialization code - DO NOT EDIT
28+
gui_Singleton = 1;
29+
gui_State = struct('gui_Name', mfilename, ...
30+
'gui_Singleton', gui_Singleton, ...
31+
'gui_OpeningFcn', @lvd_EditActionResetExtremumValueGUI_OpeningFcn, ...
32+
'gui_OutputFcn', @lvd_EditActionResetExtremumValueGUI_OutputFcn, ...
33+
'gui_LayoutFcn', [] , ...
34+
'gui_Callback', []);
35+
if nargin && ischar(varargin{1})
36+
gui_State.gui_Callback = str2func(varargin{1});
37+
end
38+
39+
if nargout
40+
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
41+
else
42+
gui_mainfcn(gui_State, varargin{:});
43+
end
44+
% End initialization code - DO NOT EDIT
45+
46+
47+
% --- Executes just before lvd_EditActionResetExtremumValueGUI is made visible.
48+
function lvd_EditActionResetExtremumValueGUI_OpeningFcn(hObject, eventdata, handles, varargin)
49+
% This function has no output args, see OutputFcn.
50+
% hObject handle to figure
51+
% eventdata reserved - to be defined in a future version of MATLAB
52+
% handles structure with handles and user data (see GUIDATA)
53+
% varargin command line arguments to lvd_EditActionResetExtremumValueGUI (see VARARGIN)
54+
55+
% Choose default command line output for lvd_EditActionResetExtremumValueGUI
56+
handles.output = hObject;
57+
58+
action = varargin{1};
59+
setappdata(hObject,'action',action);
60+
61+
lv = varargin{2};
62+
setappdata(hObject,'lv',lv);
63+
64+
populateGUI(handles, action, lv);
65+
66+
% Update handles structure
67+
guidata(hObject, handles);
68+
69+
% UIWAIT makes lvd_EditActionResetExtremumValueGUI wait for user response (see UIRESUME)
70+
uiwait(handles.lvd_EditActionResetExtremumValueGUI);
71+
72+
function populateGUI(handles, action, lv)
73+
[exListStr, extrema] = lv.getExtremaListBoxStr();
74+
if(not(isempty(exListStr)))
75+
set(handles.refExtremumCombo,'String',exListStr);
76+
else
77+
set(handles.refExtremumCombo,'String',' ');
78+
end
79+
80+
if(not(isempty(action.extremum)))
81+
ind = find(extrema == action.extremum,1,'first');
82+
else
83+
ind = [];
84+
end
85+
86+
if(not(isempty(ind)))
87+
set(handles.refExtremumCombo,'Value',ind);
88+
end
89+
90+
91+
% --- Outputs from this function are returned to the command line.
92+
function varargout = lvd_EditActionResetExtremumValueGUI_OutputFcn(hObject, eventdata, handles)
93+
% varargout cell array for returning output args (see VARARGOUT);
94+
% hObject handle to figure
95+
% eventdata reserved - to be defined in a future version of MATLAB
96+
% handles structure with handles and user data (see GUIDATA)
97+
98+
% Get default command line output from handles structure
99+
if(isempty(handles))
100+
varargout{1} = false;
101+
else
102+
action = getappdata(hObject,'action');
103+
lv = getappdata(hObject,'lv');
104+
105+
[~, extrema] = lv.getExtremaListBoxStr();
106+
if(not(isempty(extrema)))
107+
ind = get(handles.refExtremumCombo,'Value');
108+
action.extremum = extrema(ind);
109+
end
110+
111+
varargout{1} = true;
112+
close(handles.lvd_EditActionResetExtremumValueGUI);
113+
end
114+
115+
116+
% --- Executes on button press in saveAndCloseButton.
117+
function saveAndCloseButton_Callback(hObject, eventdata, handles)
118+
% hObject handle to saveAndCloseButton (see GCBO)
119+
% eventdata reserved - to be defined in a future version of MATLAB
120+
% handles structure with handles and user data (see GUIDATA)
121+
uiresume(handles.lvd_EditActionResetExtremumValueGUI);
122+
123+
% --- Executes on button press in cancelButton.
124+
function cancelButton_Callback(hObject, eventdata, handles)
125+
% hObject handle to cancelButton (see GCBO)
126+
% eventdata reserved - to be defined in a future version of MATLAB
127+
% handles structure with handles and user data (see GUIDATA)
128+
close(handles.lvd_EditActionResetExtremumValueGUI);
129+
130+
% --- Executes on selection change in refExtremumCombo.
131+
function refExtremumCombo_Callback(hObject, eventdata, handles)
132+
% hObject handle to refExtremumCombo (see GCBO)
133+
% eventdata reserved - to be defined in a future version of MATLAB
134+
% handles structure with handles and user data (see GUIDATA)
135+
136+
% Hints: contents = cellstr(get(hObject,'String')) returns refExtremumCombo contents as cell array
137+
% contents{get(hObject,'Value')} returns selected item from refExtremumCombo
138+
139+
140+
% --- Executes during object creation, after setting all properties.
141+
function refExtremumCombo_CreateFcn(hObject, eventdata, handles)
142+
% hObject handle to refExtremumCombo (see GCBO)
143+
% eventdata reserved - to be defined in a future version of MATLAB
144+
% handles empty - handles not created until after all CreateFcns called
145+
146+
% Hint: popupmenu controls usually have a white background on Windows.
147+
% See ISPC and COMPUTER.
148+
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
149+
set(hObject,'BackgroundColor','white');
150+
end
151+
152+
153+
% --- Executes on key press with focus on lvd_EditActionResetExtremumValueGUI or any of its controls.
154+
function lvd_EditActionResetExtremumValueGUI_WindowKeyPressFcn(hObject, eventdata, handles)
155+
% hObject handle to lvd_EditActionResetExtremumValueGUI (see GCBO)
156+
% eventdata structure with the following fields (see MATLAB.UI.FIGURE)
157+
% Key: name of the key that was pressed, in lower case
158+
% Character: character interpretation of the key(s) that was pressed
159+
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
160+
% handles structure with handles and user data (see GUIDATA)
161+
switch(eventdata.Key)
162+
case 'return'
163+
saveAndCloseButton_Callback(handles.saveAndCloseButton, [], handles);
164+
case 'enter'
165+
saveAndCloseButton_Callback(handles.saveAndCloseButton, [], handles);
166+
case 'escape'
167+
close(handles.lvd_EditActionResetExtremumValueGUI);
168+
end
-1.04 KB
Binary file not shown.

0 commit comments

Comments
 (0)