Table of Contents > QUARC > User's Guide > QUARC Targets > Communicating with the Target
Using Default URIs
While QUARC provides the flexibility of specifying both a target and a model URI, it would be inconvenient to have to specify these URIs for every model. Thankfully, QUARC allows default URIs to be assigned so that it is rarely necessary to specify a target or model URI when creating a new model.
Default Target URI
The default target URI is used whenever a target URI has not been specified for a model. QUARC maintains a separate default target URI for each communication protocol. At first, the use of separate default target URIs for each communication protocol would seem to make matters much more complicated than necessary, but actually it makes things much easier. In reality, it means that you almost never have to specify a target URI! In fact, you almost never have to specify a default target URI, because QUARC provides appropriate defaults. Go to the Default Model URI section if you wish to skip the discussion of the default target URI.
The default target URI is used as a template to derive the target URI for the model from the model URI. For example, suppose the model URI is tcpip://mytargetbox:17001, indicating that the real-time code for the model will be running on the system called "mytargetbox" and that QUARC will communicate with the model using the TCP/IP protocol on port 17001. Now, if QUARC is communicating with the model using TCP/IP, it would make sense that it should communicate with the QUARC Target Manager using TCP/IP as well. Furthermore, the QUARC Target Manager is clearly going to be running on the same machine as the real-time code, the "mytargetbox" machine. Hence, the only difference between the target URI and the model URI is going to be the TCP/IP port number! The port typically used by the QUARC Target Manager is port 17000. Hence, the target URI is going to be tcpip://mytargetbox:17000.
In order to derive this target URI from the model URI of tcpip://mytargetbox:17001,
the default URI for the TCP/IP protocol is set to tcpip://%h:17000. The "%h
"
is one of the format specifiers that may be specified within a default target URI. It is replaced with the hostname
from the model URI. In this case, the "%h
" is replaced with "mytargetbox". Hence, the target URI
is formed from the model URI by using the hostname from the model URI and changing the port to 17000.
Refer to the qc_get_target_uri function reference page for a complete list of the format specifiers that may be used in a default target URI.
Remember that there is a separate default target URI for each communication protocol. Thus, a different substitution mechanism can be used for each communication protocol. Consider another example. Suppose the model URI for model "mymodel" is shmem://mymodel:5. In this case, the host and target PC are the same PC. The shared memory protocol, shmem, is being used for communicating with the model, and the name of the shared memory is derived from the name of the model itself, "mymodel". The shared memory "port" is 5. Port numbers other than 1 are rarely used for shared memory but port 5 was used in this example to differentiate it from the port used for the target URI.
There are two ways to specify the default target URI for a particular communications protocol in MATLAB:
For details on specifying the default target URI for Windows Explorer refer to Using Windows Explorer to Manage Models. To change the URIs used by the QUARC Target Manager use the qc_add_target_uri and qc_remove_target_uri commands in MATLAB.
Default Model URI
The default model URI is used whenever a URI has not been specified for a model. QUARC maintains a separate default model URI for each target type. Typically, the default model URI is only changed for remote targets for which the hostname or IP address of the remote machine must be specified. However, in this case the default model URI usually only has to be specified once and from henceforth all models assigned to that target type will automatically be directed to the remote target machine.
For example, suppose a model is configured to use the QUARC Windows target. Initially, the default model URI
for the Windows target is set to shmem://%m:1. The "%m
" is a format specifier that
may be used in default model URIs that is replaced with the name of the model. Hence, if the model is called
"mymodel
" then the model URI will be assigned to shmem://mymodel:1, if no
other URI is specified. Thus, the shared memory protocol will be used and the base name of the shared memory
will be "mymodel". In this case, there is no reason to modify the default model URI if the model's real-time
code will be run on the same computer.
Now suppose a second configuration is added to the model that is set up to use the QUARC Linux target. Since the target is run on a second computer/device, the default model URI for the target should be set to point to the target computer/device. For example, let the default model URI for the target be set to tcpip://mytargetbox:17001. Then whenever the target is activated for a model, the code for the model will be downloaded and run on the "mytargetbox" computer. Any new models set up to use the target will also run on the "mytargetbox" computer/device unless a model URI is explicitly specified or the default model URI for target is changed.
By making a separate default model URI for each target type it is possible to switch between different target types without ever having to specify a model URI. For example, it is possible to switch between the Windows target and an embedded Linux target for a model simply by activating one configuration or the other. For information on defining multiple configurations for a model, refer to Defining Multiple Configurations.
There are two ways to specify the default model URI for a particular target type in MATLAB:
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.