pub trait AsResourceManager: AsRawSs {
// Provided methods
fn find_res_list(&self, expr: &VisaString) -> Result<ResList, Error> { ... }
fn find_res(&self, expr: &VisaString) -> Result<VisaString, Error> { ... }
fn parse_res(
&self,
res: &VisaString,
) -> Result<(AttrIntfType, AttrIntfNum), Error> { ... }
fn parse_res_ex(
&self,
res: &VisaString,
) -> Result<(AttrIntfType, AttrIntfNum, VisaString, VisaString, VisaString), Error> { ... }
fn open(
&self,
res_name: &VisaString,
access_mode: AccessMode,
open_timeout: Duration,
) -> Result<Instrument, Error> { ... }
fn close_all(&self) { ... }
}Expand description
Ability as the Default Resource Manager for VISA
Provided Methods§
Sourcefn find_res_list(&self, expr: &VisaString) -> Result<ResList, Error>
fn find_res_list(&self, expr: &VisaString) -> Result<ResList, Error>
Queries a VISA system to locate the resources associated with a specified interface.
The viFindRsrc() operation matches the value specified in the expr parameter with the resources available for a particular interface. A regular expression is a string consisting of ordinary characters as well as special characters. You use a regular expression to specify patterns to match in a given string; in other words, it is a search criterion. The viFindRsrc() operation uses a case-insensitive compare feature when matching resource names against the regular expression specified in expr. For example, calling viFindRsrc() with “VXI?*INSTR” would return the same resources as invoking it with “vxi?*instr”.
All resource strings returned by viFindRsrc() will always be recognized by viOpen(). However, viFindRsrc() will not necessarily return all strings that you can pass to viParseRsrc() or viOpen(). This is especially true for network and TCPIP resources.
The search criteria specified in the expr parameter has two parts: a regular expression over a resource string, and an optional logical expression over attribute values. The regular expression is matched against the resource strings of resources known to the VISA Resource Manager. If the resource string matches the regular expression, the attribute values of the resource are then matched against the expression over attribute values. If the match is successful, the resource has met the search criteria and gets added to the list of resources found.
| Special Characters and Operators | Meaning |
|---|---|
| ? | Matches any one character. |
| \ | Makes the character that follows it an ordinary character instead of special character. For example, when a question mark follows a backslash (?), it matches the ? character instead of any one character. |
| [list] | Matches any one character from the enclosed list. You can use a hyphen to match a range of characters. |
| [^list] | Matches any character not in the enclosed list. You can use a hyphen to match a range of characters. |
| * | Matches 0 or more occurrences of the preceding character or expression. |
| + | Matches 1 or more occurrences of the preceding character or expression. |
| Exp|exp | Matches either the preceding or following expression. The or operator |
| (exp) | Grouping characters or expressions. |
| Regular Expression | Sample Matches |
|---|---|
| GPIB?*INSTR | GPIB0::2::INSTR, and GPIB1::1::1::INSTR. |
| GPIB[0-9]*::?*INSTR | GPIB0::2::INSTR and GPIB1::1::1::INSTR. |
| GPIB[^0]::?*INSTR | GPIB1::1::1::INSTR but not GPIB0::2::INSTR or GPIB12::8::INSTR. |
| VXI?*INSTR | VXI0::1::INSTR. |
| ?*VXI[0-9]*::?*INSTR | VXI0::1::INSTR. |
| ASRL[0-9]*::?*INSTR | ASRL1::INSTR but not VXI0::5::INSTR. |
| ASRL1+::INSTR | ASRL1::INSTR and ASRL11::INSTR but not ASRL2::INSTR. |
| (GPIB|VXI)?*INSTR | GPIB1::5::INSTR and VXI0::3::INSTR but not ASRL2::INSTR. |
| (GPIB0|VXI0)::1::INSTR | GPIB0::1::INSTR and VXI0::1::INSTR. |
| ?*INSTR | all INSTR (device) resources. |
| ?*VXI[0-9]*::?*MEMACC | VXI0::MEMACC. |
| VXI0::?* | VXI0::1::INSTR, VXI0::2::INSTR, and VXI0::MEMACC. |
| ?* | all resources. |
| visa://hostname/?* | all resources on the specified remote system. The hostname can be represented as either an IP address (dot-notation) or network machine name. This remote system need not be a configured remote system. |
| /?* | all resources on the local machine. Configured remote systems are not queried. |
| visa:/ASRL?*INSTR | all ASRL resources on the local machine and returns them in URL format (for example, visa:/ASRL1::INSTR). |
see also official doc
Sourcefn find_res(&self, expr: &VisaString) -> Result<VisaString, Error>
fn find_res(&self, expr: &VisaString) -> Result<VisaString, Error>
Queries a VISA system to locate the resources associated with a specified interface, return the first resource matched
Sourcefn parse_res(
&self,
res: &VisaString,
) -> Result<(AttrIntfType, AttrIntfNum), Error>
fn parse_res( &self, res: &VisaString, ) -> Result<(AttrIntfType, AttrIntfNum), Error>
Parse a resource string to get the interface information.
Sourcefn parse_res_ex(
&self,
res: &VisaString,
) -> Result<(AttrIntfType, AttrIntfNum, VisaString, VisaString, VisaString), Error>
fn parse_res_ex( &self, res: &VisaString, ) -> Result<(AttrIntfType, AttrIntfNum, VisaString, VisaString, VisaString), Error>
Parse a resource string to get extended interface information.
the returned three VisaStrings are:
-
Specifies the resource class (for example, “INSTR”) of the given resource string.
-
This is the expanded version of the given resource string. The format should be similar to the VISA-defined canonical resource name.
-
Specifies the user-defined alias for the given resource string.
Sourcefn open(
&self,
res_name: &VisaString,
access_mode: AccessMode,
open_timeout: Duration,
) -> Result<Instrument, Error>
fn open( &self, res_name: &VisaString, access_mode: AccessMode, open_timeout: Duration, ) -> Result<Instrument, Error>
Opens a session to the specified resource.
For the parameter accessMode, either VI_EXCLUSIVE_LOCK (1) or VI_SHARED_LOCK (2).
VI_EXCLUSIVE_LOCK (1) is used to acquire an exclusive lock immediately upon opening a session; if a lock cannot be acquired, the session is closed and an error is returned.
VI_LOAD_CONFIG (4) is used to configure attributes to values specified by some external configuration utility. Multiple access modes can be used simultaneously by specifying a bit-wise OR of the values other than VI_NULL.
NI-VISA currently supports VI_LOAD_CONFIG only on Serial INSTR sessions.