function varargout = solar(varargin) % SOLAR M-file for solar.fig % SOLAR, by itself, creates a new SOLAR or raises the existing % singleton*. % % H = SOLAR returns the handle to a new SOLAR or the handle to % the existing singleton*. % % SOLAR('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in SOLAR.M with the given input arguments. % % SOLAR('Property','Value',...) creates a new SOLAR or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before solar_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to solar_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help solar % Last Modified by GUIDE v2.5 18-Dec-2004 18:10:34 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @solar_OpeningFcn, ... 'gui_OutputFcn', @solar_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin & isstr(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before solar is made visible. function solar_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to solar (see VARARGIN) % Choose default command line output for solar handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes solar wait for user response (see UIRESUME) % uiwait(handles.figure1); if nargin == 3, initial_dir = pwd; elseif nargin == 4 & exist(varargin{1},'dir') initial_dir = varargin{1}; else errordlg('Input argument must be a valid directory','Input Argument Error!') return end % Populate the listbox load_listbox(initial_dir,handles) % --- Outputs from this function are returned to the command line. function varargout = solar_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in controladores_pushbuttom. function controladores_pushbuttom_Callback(hObject, eventdata, handles) % hObject handle to controladores_pushbuttom (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.controladores_pushbuttom,'visible','off'); set(handles.salir_pushbutton,'visible','off'); set(handles.ensayo_pushbutton,'visible','off'); set(handles.historico_pushbutton,'visible','off'); set(handles.Volver_pushbuttom,'visible','on'); set(handles.Anadir_pushbutton,'visible','on'); set(handles.Abrir_pushbutton,'visible','on'); set(handles.frame1,'visible','on'); set(handles.frame2,'visible','on'); set(handles.listbox1,'visible','on'); set(handles.text1,'visible','on'); set(handles.text2,'visible','on'); set(handles.edit1,'visible','on'); set(handles.editar_pushbutton,'visible','on'); % --- Executes on button press in salir_pushbutton. function salir_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to salir_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get the current position of the GUI from the handles structure % to pass to the modal dialog. %pos_size = get(handles.figure1,'Position'); % Call modaldlg with the argument 'Position'. user_response = modaldlg('Title','Confirma Cerrar'); switch user_response case 'No' % take no action case 'Si' % Prepare to close GUI application window % . % . % . guidata(hObject, handles); delete(handles.figure1); end % --- Executes on button press in Volver_pushbuttom. function Volver_pushbuttom_Callback(hObject, eventdata, handles) % hObject handle to Volver_pushbuttom (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.controladores_pushbuttom,'visible','on'); set(handles.salir_pushbutton,'visible','on'); set(handles.ensayo_pushbutton,'visible','on'); set(handles.historico_pushbutton,'visible','on'); set(handles.Anadir_pushbutton,'visible','off'); set(handles.Abrir_pushbutton,'visible','off'); set(handles.frame1,'visible','off'); set(handles.frame2,'visible','off'); set(handles.listbox1,'visible','off'); set(handles.text1,'visible','off'); set(handles.text2,'visible','off'); set(handles.edit1,'visible','off'); set(handles.Volver_pushbuttom,'visible','off'); set(handles.editar_pushbutton,'visible','off'); % --- Executes on button press in ensayo_pushbutton. function ensayo_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to ensayo_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) run('programacion_ensayo'); close('solar'); % --- Executes on button press in historico_pushbutton. function historico_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to historico_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) run('historicos'); close('solar'); % --- Executes during object creation, after setting all properties. function listbox1_CreateFcn(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on selection change in listbox1. function listbox1_Callback(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns listbox1 contents as cell array % contents{get(hObject,'Value')} returns selected item from listbox1 if strcmp(get(handles.figure1,'SelectionType'),'open') % If double click index_selected = get(handles.listbox1,'Value'); file_list = get(handles.listbox1,'String'); filename = file_list{index_selected}; % Item selected in list box if handles.is_dir(handles.sorted_index(index_selected)) % If directory cd (filename) load_listbox(pwd,handles) % Load list box with new directory else [path,name,ext,ver] = fileparts(filename); switch ext case '.mdl' set(handles.edit1,'string',name); case '.MDL' set(handles.edit1,'string',name); otherwise errordlg(lasterr,'File Type Error','modal') end end end % --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double % --- Executes on button press in Abrir_pushbutton. function Abrir_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to Abrir_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) nombre_archivo=get(handles.edit1,'string'); if nombre_archivo==' ' errordlg('Debe señalar un fichero simulink','Error de fichero','modal') return; end save nombre_archivo.mat nombre_archivo; run('mimico'); close('solar'); % --- Executes on button press in Anadir_pushbutton. function Anadir_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to Anadir_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) cd c:\matlab6p5\work\solar\archivos ; open('PLANTA_PILOTO_OPC_NUEVO'); function load_listbox(dir_path, handles) %This example creates a subfunction to load items into the list box. %This subfunction accepts the path to a directory and the handles %structure as input arguments. %It performs these steps: %Change to the specified directory so the GUI can navigate up and down %the tree as required. %Use the dir command to get a list of files in the specified directory %and to determine which name is a directory and which is a file. dir %returns a structure (dir_struct) with two fields, %name and isdir, which contain this information. %Sort the file and directory names (sortrows) and save the sorted names %and other information in the handles structure so this information %can be passed to other functions. %The name structure field is passed to sortrows as a cell array, %which is transposed to get one file name per row. %The isdir field and the sorted index values, %sorted_index, are saved as vectors in the handles structure. %Call guidata to save the handles structure. %Set the list box String property to display the file and directory %names and set the Value property to 1. %This is necessary to ensure Value never exceeds the number of items in String, %since MATLAB updates the Value property only when a selection occurs and not when %the contents of String changes. %Displays the current directory in the text box by setting its String property %to the output of the pwd command. %The load_listbox function is called by the opening function of the GUI M-file %as well as by the list box callback. cd (dir_path) dir_struct = dir(dir_path); [sorted_names,sorted_index] = sortrows({dir_struct.name}'); handles.file_names = sorted_names; handles.is_dir = [dir_struct.isdir]; handles.sorted_index = [sorted_index]; guidata(handles.figure1,handles) set(handles.listbox1,'String',handles.file_names,... 'Value',1) set(handles.text1,'String',pwd) % --- Executes on button press in editar_pushbutton. function editar_pushbutton_Callback(hObject, eventdata, handles) % hObject handle to editar_pushbutton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) index_selected = get(handles.listbox1,'Value'); file_list = get(handles.listbox1,'String'); filename = file_list{index_selected}; [path,name,ext,ver] = fileparts(filename); switch ext case '.mdl' open(name); case '.MDL' open(name); otherwise errordlg('Debe señalar un fichero simulink','Error de fichero','modal') end