SuperModel > CAE File Management > File Manager Customization
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
File Manager Customization
Overview
MSC SuperModel provides additional customization capabilities in the File Manager. Users may now develop PCL functions that are called by the File Manger during certain file operations. The customized actions can be defined to occur before or after the File Manager has completed its specified task. In addition, customized error handling functions may be added that are invoked if File Manager has difficulty performing its intended operation. This allows users to perform any necessary clean up operations if the failure affects their customized tasks.
Details
File Manager has been extended to allow user-defined functions to be a regular part of performed file operations; similar to the "user_db_open" and "user_db_close" functions of MSC Patran. These can be used to perform tasks such as enabling and disabling custom PCL menus. MSC SuperModel now provides a method for custom operations in addition to the normal File Manager tasks. MSC SuperModel does not limit the number of users that can customize a feature; it provides opportunities for custom operations before or after File Manager completes its task and allows for custom error handling.
Functions That Support Customization
The following File Manager functions now support user customization:
NEW
OPEN
SAVE
SAVE_AS
CLOSE
ABORT
RECOVER
RELEASE
UNRELEASE
QUIT
 
Sequence of Custom Function Calls
File Manager can be instructed to invoke a user-supplied function either:
Prior to executing the standard File Manager task (designated as "PRE"),
After successfully completing the standard File Manager task (designated as "POST"), or
In the event an error occurs while attempting the standard operation (designated as "ERROR").
Together, this collection of functions allows users the ability to interact with File Manager operations robustly and cleanly.
Supporting Multiple Customization
MSC SuperModel allows multiple users to "register" their own function names with a particular File Manager operation. During registration, the operation sequence of functions is specified -- “PRE”, “POST”, or “ERROR”.
There is no limit to the number of functions that can be registered. The File Manager calls all registered functions at the appropriate operation sequence.
Custom Function Return Status and Process Interruption
User functions that operate prior to File Manager’s own operation (i.e., those registered as “PRE” tasks) are allowed to terminate the file operation. This is accomplished by returning a non-zero value in the status argument of any custom function. After File Manager receives a non-zero status, all subsequent operations are terminated, including additional custom functions that are yet to be invoked, File Manager standard process functions, and any registered “POST” or “ERROR” functions. An error message is posted for the user and all file states remain as is prior to the operation.
There is no limit to the number of functions that can be registered. The File Manager calls all registered functions at the appropriate operation sequence.
Registering Custom Functions
The following PCL is required to register custom functions with the File Manager:
smdl_fm_customize.register(<my_function>, <FM_OPERATION>, <FM_SEQUENCE>)
where,
<my_function> is the name of a custom PCL function which are executed as part of the File Manager's operation.
<FM_OPERATION> is a string constant which designates the operation which will invoke `my_function'. Acceptable values are: “NEW”, “OPEN”, “SAVE”, “SAVE_AS”, “ABORT”, “RECOVER”, “CLOSE”, “QUIT”, “RELEASE”, and “UNRELEASE”.
<FM_SEQUENCE> is a string constant which designates the operation sequence for the custom function. Acceptable values are: “PRE”,” POST”, and “ERROR”.
Both stand-alone and class-method functions are supported. The user is responsible for ensuring the argument compatibility of the registered functions with the data to be passed by File Manager (see "Shared Information from File Manager" below).
For example, the following lines would tell the File Manager to execute two custom functions. The first is called after the File Manager has finished an Open file operation and is a stand-alone (or globally defined) function. The second is called if File Manager encounters an error while performing a Close file operation.
smdl_fm_customize.register("my_open_post", "OPEN", "POST")
smdl_fm_customize.register("my_custom_class.close_error", "CLOSE", "ERROR")
These calls should be placed in the p3smdl_epilog.pcl file that is automatically loaded by MSC SuperModel during initialization. This file is similar to the MSC Patran p3epilog.pcl file that is assumed to reside:
Current directory
User’s home directory
P3HOME directory
Sharing Information With the File Manager
To allow custom functions to properly operate with the File Manager, a predefined set of arguments are passed to any registered function. This intentionally limits the user’s knowledge of the file system to maintain data security and integrity.
In addition, each function is expected to return a status as an integer value. This status is always the last argument present. “PRE” functions may use the status to terminate the file operation (see Custom Functions Return Status and Process Termination).
The information passed to any given function depends on the associated standard File Manager operation, as shown in the table below.
 
Function
ID
Description
Hierarchy
Type
Access
Status
New
1+
2+
3+
4+
 
5*
Open
1*
2*
3*
4*
5+
6*
Save
*
 
 
 
 
2*
Save As
1, 2@
3+
4+
 
 
5*
Close
1*
 
 
 
 
2*
Quit
 
 
 
 
 
*
Release
1*
 
 
 
 
2*
Unrelease
1*
 
 
 
 
2*
Abort
 
 
 
 
 
*
Recover
1+
2+
3+
4+
5+
6*
where
ID = Unique integer that the system uses to identify a file
Description = String which identifies a file
Hierarchy = String array of branch names where the file resides
Type = String label which designates the file's type.
Access = String which denotes the ability of the user to modify the contents of a file
# - Designates the order of the arguments passed (1,2,3,4,5)
* - Argument is valid for PRE, POST & ERROR calls
+ - Argument is valid for POST calls only
[blank] - Argument NOT passed
@ - SAVE AS receives two file ids; for the original and copy (the copy is only valid for the “POST” task)
Example
A custom function for handling SAVE_AS operations would have the form:
my_custom.save_as(orig_file_id, save_file_id, save_desc, save_hier)