qc_start_model qc_kill_model navigation bar

Table of Contents

qc_stop_model

Stops a model in normal simulation or external mode.

Syntax

result = qc_stop_model(model, name)      % Stop model NAME on the target associated with MODEL
result = qc_stop_model(config_set, name) % Stop model NAME on the target associated with the configuration set
result = qc_stop_model(target_uri, name) % Stop model NAME on the target specified by the target URI
result = qc_stop_model(name)             % Stop model NAME
result = qc_stop_model                   % Stop current model
    

Description

Stops a model. If MODEL is specified, then the target URI associated with the active configuration set of that model is used to identify the target. If a configuration set is specified then its associated target URI is used. If a target URI is specified then it is used directly to access the target. In any of the above cases, qc_stop_model always accesses the target to stop the model and ignores the state of the Simulink diagram.

If only a model NAME is specified, then the action of qc_stop_model depends on the state of the Simulink diagram for the model. If the model is running a normal simulation, then the simulation is stopped. Otherwise, it connects to the associated target and stops the model on the target. The target is identified by the settings for the active configuration for the model. The model will also disconnect.

If NAME is a cell array of model names, then each model in the cell array is stopped. This functionality may be used with the qc_get_loaded_models function to stop all the models running on the target.

If no model is specified then it behaves as if the currently selected model, as returned by bdroot, was passed as a single input argument.

Note that this function will stop the model on the target even if the model is not currently connected in external mode.

Note that qc_stop_model does not update the Simulink diagram graphics when it stops the model directly on the target. Hence, the Simulink diagram toolbar may still indicate that the model is running, even though it is not and the plots have stopped. To update the Simulink diagram graphics, execute the drawnow command or just move the mouse over the Simulink diagram for the model.

Also, if the model is loaded but has not been started then on some targets the model will have to be started before it receives the stop signal.

Limitations

Closing a model after stopping it

Warning The Simulink external mode interface is not fully functional when a MATLAB script is running. Hence, it is not possible to close a model using close_system immediately after invoking qc_stop_model because the model will not be able to disconnect fully from the real-time code until the MATLAB script completes. If designing a GUI that stops and closes the Simulink model, use a separate Stop button and Close button which invoke qc_stop_model and close_system respectively so that control can return to Simulink after the Stop button is pressed. Otherwise an error will be reported in the MATLAB Command Window indicating that the model cannot be closed because it is still connected.

Parameters

model

A string indicating the name of the model from which to identify the target eg. 'q_a_lpbk'.

name

A string indicating the name of the model to stop eg. 'test_model'.

config_set

A Simulink.ConfigSet configuration set from which to identify the target (see getConfigSet).

target_uri

A string containing the URI used for communicating with the QUARC Target Manager on the target.

Outputs

result

Returns 0 on success and a negative error code on failure. See qc_error and qc_get_error_message for handling error codes. If no result output is assigned it issues an error on failure.

Examples

result = qc_stop_model('q_a_lpbk'); % Stops the 'q_a_lpbk' model
    

See Also

 

navigation bar