Parameter Tuning Controlling the Execution Order navigation bar

Table of Contents > QUARC > User's Guide > QUARC Basics for Models

Managing Models on the Target

QUARC supplies a variety of functions that may be used to manage models that are running on local or remote targets, right from the MATLAB Command Prompt or a MATLAB script. These functions can be used to perform tasks such as downloading code to a QUARC target, getting a list of the models currently loaded on the target, or adding and removing target URI's.

QUARC also provides a means of managing models on the target using Windows Explorer. Each time a model is built, a QUARC real-time executable is created. By right-clicking on this executable file, a context menu is opened that includes options such as Run, Run on target, Run at boot and more. For detailed information on how to use this menu please see Using Windows Explorer to Manage Models.

Managing Models on the Target Using QUARC MATLAB Functions

This section describes each of the MATLAB functions supplied by QUARC that may be used to manage models on targets. For more details about each function, please click on the function name.

qc_download_model: This function may be used to download the generated code from a model to a QUARC Target. There are two optional arguments to this function: "model" which is a string containing the name of the model for which you want to download the generated code and "directory" which is a string containing the path to the code generated for the model. If you do not specify any of these arguments the function uses the currently selected model and assumes that the code resides in the current working directory.

qc_get_downloaded_models: This function may be used to retrieve a list of the models that have been downloaded to a target and are ready to be loaded. If you specify a model when using this function, the target URI currently associated with that model will be used i.e., the same target that would be used if you built the model. For example if your model name is "test_model" and you pass this name to the qc_get_downloaded_models function, it will return all the models loaded on the target currently associated with "test_model". Similarly if you specify a configuration set when using this function, the target URI associated with that configuration set will be used. Finally if you specify a target URI, it is used directly to access the target and hence a list of all the models downloaded on the target specified by the target URI is retrieved. If you do not pass any arguments to this function, it will use the target URI associated with the current model to retrieve the list of downloaded models.

qc_remove_downloaded_model: This function may be used to delete a previously downloaded model from a target. If you do not pass any arguments to this function, the real-time code for the current model will be removed from its associated target. If you specify a model name, the real-time code for that specific model will be removed from its associated target. If you would like to remove multiple models at a time, you can use a cell array of strings to indicate the models to be removed. If you specify a model name and a target URI, the target URI is used directly to access the target and the real-time code for the model specified is removed. If you specify a configuration set, the target URI associated with that configuration set will be used to access the target.

qc_load_model: This function may be used to load the generated code for a model on a target. Please note that the code must already be downloaded to the target. You can pass a model name as well as model arguments to this function. If no arguments are specified then the arguments specified in the external mode MEX-file arguments in the Code Generation - Host/Target Interface are used. However if you specify model arguments when using the qc_load_model function, they will override the arguments set in the Code Generation - Host/Target Interface. The Code Generation - Host/Target Interface MEX-file arguments can be viewed and modified as follows:

Open Model Explorer by selecting Model Explorer from the View menu of the diagram, or click on the Launch Model Explorer button on the toolbar.

Under the Model Hierarchy pane, expand the tree view item associated with the model and click on the configuration for which you want to view or modify the MEX-file arguments.

Under the Contents of: pane, click on Code Generation as shown below:

Under the Code Generation pane which opens on the right-hand side of the Model Explorer window, click on the Interface tab. The MEX-file arguments may be found under the Host/Target interface tab as shown below:

For more information about this parameter, please refer to the MEX-File Arguments reference section. If no model name is specified when using the qc_load_model function, the currently selected model will be loaded. The target is identified by the settings for the active configuration of the model. Substitutions on the model arguments are performed as described in the help for the qc_get_model_arguments function.

qc_load_model_at_boot: This function may be used to register a model to run on a QUARC target at boot time. Please note that the code must already be downloaded to the target. You can pass a model name as well as model arguments to this function. If no arguments are specified then the arguments specified in the external mode MEX-file arguments in the Code Generation - Host/Target Interface are used. However if you specify model arguments when using the qc_load_model_at_boot function they will override the arguments set in the Code Generation - Host/Target Interface. The Code Generation - Host/Target Interface MEX-file arguments can be viewed or modified as explained above.

If no model name is specified, the currently selected model will be used. The target is identified by the settings for the active configuration of the model. Substitutions on the model arguments are performed as described in the help for the qc_get_model_arguments function.

qc_get_loaded_models: This function may be used to retrieve a list of the models that are currently loaded on a target. If you pass a model name to this function, the target URI presently associated with that model is used to identify the target i.e., the same target that is used if you build the model. If a configuration set is specified, the target URI associated with that configuration set is used. If a target URI is specified, it is used directly to access the target. Finally if no target URI is specified then the target associated with the currently selected model is employed.

It is possible to retrieve the arguments passed to each model that is loaded in addition to just the model names. Simply pass the string 'command' as an additional argument to this function, and the command line for each model will also be retrieved.

qc_get_models_loaded_at_boot: This function may be used to retrieve a list of all the models that are currently configured to load on the QUARC target when the target boots. If you pass a model name to the function, the target URI currently associated with the model is used i.e., the same target that is used if you build the model. If a configuration set is specified then the target URI associated with that configuration set is used. If a target URI is specified then it is used directly to access the target. If no target URI is specified the target associated with the currently selected model is employed.

It is possible to retrieve the arguments passed to each model in addition to just the model names. Simply pass the string 'command' as an additional argument to the function, and the command line for each model will also be retrieved.

qc_remove_model_loaded_at_boot: This function may be used to remove a model from the list of models configured to load on a QUARC target at boot time. If a model is specified when using the function, the target URI currently associated with that model is used to identify the target. If a model name is specified, the specified model will be removed from its associated target. If a configuration set is specified, its associated target URI is used. If a target URI is specified, it is used directly to access the target. If no target URI is specified, the target URI associated with the currently selected model is employed. If you would like to remove multiple models at a time, you can use a cell array of strings to indicate the models to be removed from the list of models loaded at boot.

qc_is_model_loaded: This function may be used to determine whether a model is loaded on a QUARC target. It returns 1 if the model is currently loaded on the target and 0 otherwise. If a model is specified when using this function, the target URI currently associated with that model is used to identify the target. If a configuration set is specified, its associated target URI is used. If a target URI is specified, it is used directly to access the target. Finally if no model is specified, the function behaves as if the currently selected model, as returned by bdroot function, was passed as a single input argument.

Please also note that this function returns the status of the model on the target, regardless of whether Simulink is connected in external mode or not.

qc_stop_model: This function may be used to stop a model in normal simulation or external mode. In external mode it also disconnects from the model. If a model is specified when using this function, the target URI currently associated with that model is used to identify the target. If a configuration set is specified, its associated target URI is used. If a target URI is specified, it is used directly to access the target. In all of the above cases, this function always accesses the target and stops the model. It ignores the state of the Simulink diagram. The only case when the state of the Simulink diagram is not ignored by this function is when a model name is specified. In this case, if the model is running a normal simulation, then the simulation is stopped and if the model is connected in external mode, it is stopped as if the Stop item was selected in the Simulation menu. If you would like to stop multiple models, you can use a cell array of strings to indicate the models to be stopped. Finally if no arguments are passed to the function, it behaves as if the currently selected model as returned by bdroot function was passed as a single input argument.

qc_kill_model: This function can be used to forcefully terminate a model on a QUARC target. It does not wait for the model to shut down cleanly but kills the process immediately.

Warning WARNING: USING THIS FUNCTION IS NOT RECOMMENDED UNLESS ABSOLUTELY NECESSARY. SYSTEM RESOURCES MAY BE LOST ON THE TARGET AS A RESULT OF THIS FUNCTION'S OPERATION.

If a model is specified when using this function, the target URI currently associated with that model is used to identify the target i.e., the same target that is used if the model is built. If a configuration set is specified, its associated target URI is used. If a target URI is specified, it is used directly to access the target. Finally if no arguments are passed to this function, it behaves as if the currently selected model as returned by the bdroot function was passed as a single input argument. Note that this function will kill the model on the target even if the model is not currently connected in external mode. It is recommended that the qc_stop_model function be used instead of this function whenever possible.

qc_model_console: This function may be used to open a QUARC Console to monitor a model's standard input and output, even when the model runs on a remote target. If no model is specified when using this function, it behaves as if the currently selected model as returned by bdroot was passed as a single input argument. If a model's name is specified when using this function, it will open a QUARC Console for the target currently associated with the given model. If the additional argument 'all' is specified then this function opens a QUARC Console that monitors all models running on the target simultaneously.

qc_add_target_uri: This function may be used to cause the QUARC Target Manager to start serving on a particular URI. The QUARC Target manager continues to serve on the other URIs for which it was configured. The new URI is passed as a string to this function. If a model is specified when using this function then the target URI currently associated with that model is used to identify the target. If a configuration set is specified, its associated target URI is used. If a target URI is specified, it is used directly to access the target. This function can be useful for making the target accessible to other systems.

A "key" argument must be passed to this function to associate a key with the new URI. If this key is not unique, the new URI will replace an existing URI in the target's list of URIs. This key is later required if the URI is being removed using the qc_remove_target_uri function.

qc_get_target_uris: This function may be used to retrieve a list of all the URIs that may be used to connect to a QUARC target. The list is returned as a structure array containing two fields:

key: A string containing the key associated with the target URI.
uri: A string containing the full target URI.

If a model is specified when using this function, the target URI currently associated with that model is used to identify the target. If a configuration set is specified, its associated target URI is used. If a target URI is specified, it is used directly to access the target. If no target URI is specified, the target associated with the current model as returned by bdroot is used.

qc_remove_target_uri: This function may be used to stop a QUARC Target Manager from serving on a particular URI.

Warning WARNING: BE VERY CAREFUL WHEN USING THIS FUNCTION. IF ALL THE URIs FOR A TARGET ARE REMOVED THERE WILL NO LONGER BE ANY MEANS OF CONNECTING TO THAT TARGET.

If a model is specified when using the function, the target URI currently associated with that model is used to identify the target. If a configuration set is specified, its associated target URI is used. If a target URI is specified, it is used directly to access the target. If no target URI is specified, the target associated with the current model as returned by bdroot is used.

A "key" argument must be passed to this function. This key must be the one associated with the URI to be removed. Please note that the URI itself does should not be specified. A key is associated with a URI when the URI is first added to the target using the qc_add_target_uri function.

 

navigation bar