Main Content

hydraulicToIsothermalLiquidPostProcess

Restore original file names and links after upgrading hydraulic block diagram systems to use isothermal liquid blocks

Description

example

finalfiles = hydraulicToIsothermalLiquidPostProcess(convertedfiles) takes a list of converted files, convertedfiles, and removes the _converted suffix from the file names and from the links between the files. The links between the files can include links to custom Simulink® libraries, model references, and subsystem references. Use this function after you convert a list of files, or all files in a folder, by using the hydraulicToIsothermalLiquid conversion tool, to restore the original file names while preserving the links between the files.

The hydraulicToIsothermalLiquidPostProcess function overwrites the original files containing hydraulic blocks from the Foundation and Fluids libraries, after issuing a warning. It is recommended that you verify the conversion results and save a backup copy of the original files before running hydraulicToIsothermalLiquidPostProcess.

When you have reviewed the list of files in the Command window and are ready to proceed, click OK in the Warning dialog box. If you close the dialog box without clicking OK, hydraulicToIsothermalLiquidPostProcess does not process the files and returns an empty cell array.

example

finalfiles = hydraulicToIsothermalLiquidPostProcess(toppath) removes the _converted suffix from all the file names in toppath folder and its subfolders that are on the MATLAB® path, as well as from the links between these files. Use this syntax after you convert all files in a folder, by using the hydraulicToIsothermalLiquid conversion tool, to restore the original file names while preserving the links between the files.

Examples

collapse all

When you convert a list of files, or all files with hydraulic blocks in a folder, the conversion tool updates all the custom Simulink library links, model references, and subsystem references in these files to point to the _converted versions of these files and returns the list of converted files. Once satisfied that the converted systems behave as expected, you can use this list as the input argument to the hydraulicToIsothermalLiquidPostProcess function to restore the original file names.

Consider a model, for the purposes of this example named modelWithLink, that contains some hydraulic blocks and a referenced model, referenceModel, which also contains hydraulic blocks. To preserve the link, convert the modelWithLink model together with the referenced model, by specifying their names in a file list:

convertedFiles = hydraulicToIsothermalLiquid({'modelWithLink' 'referenceModel'})
convertedFiles =

  2×1 cell array

    {'modelWithLink_converted' }
    {'referenceModel_converted'}

For more details on the conversion process, see Convert a List of Files.

Review the HTML report and compare the simulation results of the converted models to the original models to ensure that the results are as expected. It is also recommended that you save back-up copies of your original hydraulic models before restoring the original file names, because the post-processing function overwrites the original files.

Restore the original file names:

finalFiles = hydraulicToIsothermalLiquidPostProcess(convertedFiles)

The function issues a warning:

Warning: Existing files will be overwritten. Press OK in dialog box to proceed:
C:\Work\HtoIL\modelWithLink.slx
C:\Work\HtoIL\Reference Systems\referenceModel.slx 
> In hydraulicToIsothermalLiquidPostProcess_private
In hydraulicToIsothermalLiquidPostProcess (line 30) 

Review the file list, make sure you have backup copies, and click OK.

The function renames the files and the link between them and returns the list of modified files:

finalFiles =

  2×1 cell array

    {'C:\Work\HtoIL\modelWithLink.slx'                   }
    {'C:\Work\HtoIL\Reference Systems\referenceModel.slx'} 

These files now have their original names, but they contain isothermal liquid blocks instead of hydraulic blocks.

When you convert all files in a folder and its subfolders, the conversion tool updates all the library links, model references, and subsystem references in these files to point to the _converted versions of these files. Once satisfied that the converted systems behave as expected, you can restore the original file names by supplying the name and path to the top folder used during the conversion as the input argument to the hydraulicToIsothermalLiquidPostProcess function.

Consider a folder, named in this example topFolder for clarity, that contains subfolders with custom Simulink libraries, referenced models and subsystems, and models, some with hydraulic blocks and some without.

Before converting the files, make sure that topFolder and all its subfolders are on the MATLAB path:

addpath(genpath('topFolder'))

Convert all the files in topFolder and its subfolders:

convertedFiles = hydraulicToIsothermalLiquid('topFolder')
convertedFiles =

  5×1 cell array

    {'model_converted'             }
    {'custom_Library1_converted'   }
    {'custom_Library2_converted'   }
    {'referenceModel_converted'    }
    {'referenceSubsystem_converted'}

The conversion tool forms the new model name by appending _converted to the name of the original model and saves each converted model in the same folder as the original one.

Note that the tool did not generate a _converted file for modelWithoutHydraulicBlocks and did not return its name in the convertedFiles cell array, because this model does not contain hydraulic blocks.

Review the HTML report and compare the simulation results of the converted models to the original models to ensure that the results are as expected. It is also recommended that you save back-up copies of your original hydraulic models before restoring the original file names, because the post-processing function overwrites the original files.

Restore the original file names:

finalFiles = hydraulicToIsothermalLiquidPostProcess('topFolder')

The function issues a warning:

Warning: Existing files will be overwritten. Press OK in dialog box to proceed:
C:\Work\HtoIL\topFolder\model.slx
C:\Work\HtoIL\topFolder\Libraries\custom_Library1.slx
C:\Work\HtoIL\topFolder\Libraries\custom_Library2.slx
C:\Work\HtoIL\topFolder\Reference Systems\referenceModel.slx
C:\Work\HtoIL\topFolder\Reference Systems\referenceSubsystem.slx 
> In hydraulicToIsothermalLiquidPostProcess_private
In hydraulicToIsothermalLiquidPostProcess (line 30)

Review the file list, make sure you have backup copies, and click OK.

The function renames the files and the links between them and returns the list of modified files:

finalFiles =

  5×1 cell array

    {'C:\Work\HtoIL\topFolder\model.slx'                               }
    {'C:\Work\HtoIL\topFolder\Libraries\custom_Library1.slx'           }
    {'C:\Work\HtoIL\topFolder\Libraries\custom_Library2.slx'           }
    {'C:\Work\HtoIL\topFolder\Reference Systems\referenceModel.slx'    }
    {'C:\Work\HtoIL\topFolder\Reference Systems\referenceSubsystem.slx'} 

This is how the file structure in topFolder looks after post-processing:

All the custom Simulink libraries, referenced models and subsystems, and models that were modified during the conversion now have their original names, but they contain isothermal liquid blocks instead of hydraulic blocks.

Input Arguments

collapse all

Names of the converted models, subsystems, or libraries, specified as a one-dimensional column cell array of file names. File names can include absolute or relative path names. In most cases, this input argument is the list of converted files returned by the hydraulicToIsothermalLiquid function. The conversion tool appends _converted to the name of the original file. hydraulicToIsothermalLiquidPostProcess removes the _converted suffix from the file names and from the library links, model references, and subsystem references within the converted files that point to the other converted files in the list.

Example: {'HydraulicActuatorLibrary_converted';'PumpLibrary_converted'}

Example: {'PumpLibrary_converted';'C:\Work\MyPump_converted.slx'}

Path name of the top folder containing converted block diagram systems, specified as an absolute or relative path name. The top folder must be on the MATLAB path. The top folder can contain subfolders that also contain block diagram systems and are also on the MATLAB path. hydraulicToIsothermalLiquidPostProcess removes the _converted suffix from the all the file names in the top-level folder and its subfolders, as well as from the library links, model references, and subsystem references within the converted files that point to the other converted files in the folder and its subfolders.

Example: 'C:\Work\MyLibraries'

Output Arguments

collapse all

Names of the models, subsystems, or libraries modified by removing the _converted suffix from file names, library links, model references, and subsystem references, returned as a one-dimensional column cell array of file names, including full path or extension.

Introduced in R2021a