daitem Properties
(To be removed) Configure OPC daitem
object
Support for the OPC Data Access (DA) standard will be removed in a future release. Instead use OPC Unified Architecture (UA). See Version History.
Use the properties of the daitem
object to examine item values,
quality, timestamps, types, and so on.
General Settings
AccessRights
— Inherent nature of access to item
'read'
| 'read/write'
| 'write'
This property is read-only.
AccessRights
represents the server’s ability to access a single
OPC data item. The property value can be 'read'
,
'write'
, or 'read/write'
, with the following
effects:
'read'
— You can read the server item's value.'write'
— You can write values to the server item.'read/write'
— You can read and change the server item's value. If you attempt a read or write operation on an item that does not have the required access rights, the server might return an error.
The value is set by the server when an item is created.
Example:
'read'
Data Types: char
CanonicalDataType
— Server's data type for item
char
This property is read-only.
CanonicalDataType
indicates the data type of the item as stored
on the OPC server. The MATLAB® supported data types are indicated in the DataType property.
You can specify that the item's value is stored in the daitem
object using a data type that differs from the canonical data type by setting the
DataType property of the item to a value
different from CanonicalDataType
. Translation between the
CanonicalDataType
and the DataType
is
automatic.
Refer to the DataType property reference for a listing of the COM Variant data types and their equivalent MATLAB data types.
Data Types: char
DataType
— OPC client item's data type
char
DataType
indicates the data type of the item as stored in the
daitem
object in the MATLAB workspace. You can specify the data type when the item is created using
the additem
function. If you do not specify a
data type, or if the requested data type is rejected by the server, the canonical
(native) data type is used. If the client associated with the item is not connected, the
data type is set to until the client is connected.
The OPC server uses this data type to store the item value. The CanonicalDataType property of a daitem
object provides
information on the canonical data type of that item on the server.
OPC communication uses COM Variant data types to send information between the server
and client. These are automatically translated to an equivalent MATLAB data type for the COM Variant types defined below. Any data type not
included in this list is returned as 'unknown'
.
OPC Data Type | COM Data Type | MATLAB Data Type |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Empty array ( |
Example:
'double'
Data Types: char
ItemID
— Fully qualified ID on OPC server
char
ItemID
is the fully qualified ID of the data item on the OPC
server. The server uses the ItemID
to return the appropriate data
from the server's cache, or to read and send data to a specific device or
location.
You obtain valid ItemID
values for a particular server by
querying that server's name space using the getnamespace
or serveritems
functions.
Data Types: char
Parent
— OPC object that contains this daitem
object
OPC DA group object
This property is read-only.
For daitem
objects, Parent
indicates the
dagroup
object that contains the daitem
object.
Data Types: DA group object
Quality
— Quality of data value
Bad
(default) | Good
| Uncertain
This property is read-only.
Quality
indicates the quality of the daitem
object’s Value property as a character vector. You
can use the Quality
property to determine if a value is useful or
not.
The Quality
is made up of a major quality, a substatus, and an
optional limit status, arranged as a character vector in the format 'Major:
Substatus: Limit status'
. The limit status part is omitted if the value is
not limited. The major quality can be one of the following values:
Value | Description |
---|---|
| The value is not useful for reasons indicated by the substatus. The default value is |
| The value is of good quality. |
| The quality of the value is uncertain for reasons indicated by the Substatus. |
For a list of substatus and limit status values and their interpretations, see OPC Quality.
Quality
is updated when you perform a read operation using
read
or readasync
, or when a subscription callback occurs.
Quality
is also returned during a synchronous read
operation.
Example: 'Bad: Out of Service'
Data Types: char
QualityID
— Quality of data value as 16-bit integer
28
(default) | integer from 0
to 65535
This property is read-only.
QualityID
is a numeric indication of the quality of the
daitem
object's data value.
QualityID
is a number ranging from 0
to
65535
, made up of four parts. The high 8 bits of the
QualityID
represent the vendor-specific quality information. The
low 8 bits are arranged as QQSSSSLL
, where QQ
represents the major quality, SSSS
represents the quality substatus,
and LL
represents the limit status.
You use the opcqparts
function to extract the four
quality fields from the QualityID
value. Alternatively, you can use
the bit-wise functions to extract the fields you are interested in. For example, to
extract the major quality, you can bit-wise AND the QualityID
with
192
(the decimal equivalent of binary 11000000
)
using the bitand
function, and shift the result 6
bits to the right using the bitshift
function.
You use the opcqstr
function to obtain the four quality
fields from the QualityID
value.
For more information, see OPC Quality.
QualityID
is updated when you perform a read operation using
read
or readasync
, or when a subscription callback occurs.
Example: 28
Data Types: double
ScanRate
— Fastest possible data update rate
double
ScanRate
describes the fastest possible rate at which a server
can update an item. The default value is 0
, which indicates that the
scan rate is not known. Note that the scan rate might not be attainable by the server
due to network load, server load, and other factors.
The value is initially set by the server when a daitem
object is
created or when you connect to the server.
Data Types: double
Tag
— Label to associate with OPC object
char
You configure Tag
to be a character vector value that uniquely
identifies an OPC object.
Tag
is particularly useful when constructing programs that would
otherwise need to define the toolbox object as a global variable, or pass the object as
an argument between callback routines. You can return a toolbox object with the
opcfind
function by specifying the
Tag
property value.
Data Types: char
TimeStamp
— Time when item was last read
date vector
This property is read-only.
TimeStamp
indicates the time when the Value and Quality properties were obtained by the
device (if this is available) or the time the server updated or validated
Value
and Quality
in its cache.
TimeStamp
is updated when you perform an asynchronous or
synchronous read operation or when a subscription callback occurs.
TimeStamp
is stored as a MATLAB date vector. You can convert date vectors to date character vectors with
the datestr
function, and to MATLAB date numbers with the datenum
function.
Data Types: date vector
Type
— OPC object type
char
This property is read-only.
Type
indicates the type of the object. The OPC object types are
'opcda'
, 'dagroup'
, and
'daitem'
. Once an object is created, the value of
Type
is automatically defined, and cannot be changed.
You can identify OPC objects of a given type using the opcfind
function and the Type
value.
Example:
'daitem'
Data Types: char
UserData
— Data to associate with OPC object
any type
You can configure UserData
to store data that you want to
associate with an OPC object. The object does not use this data directly, but you can
access it using the get
function.
Value
— Item value
any MATLAB data type
This property is read-only.
Value
indicates the value that was last obtained from the OPC
server for the item defined by the ItemID property. The data type of the value is given by the DataType property.
The value returned from the server may be different from the value of the device to
which the ItemID
refers, if the DeadbandPercent for the daitem
object's parent group is
not zero. The value is also updated only periodically, based on the parent group's
Active and UpdateRate properties.
You determine the validity of Value
by checking the Quality property for the item.
Value
is updated when you perform an asynchronous or synchronous
read operation or when a subscription callback occurs.
Subscription and Logging Settings
Active
— Item activation state
'on'
(default) | 'off'
Active
can be 'on'
or
'off'
. If Active
is 'on'
, the
OPC server will return data for the group or item when requested by the read
function or when the corresponding data items change (subscriptions).
If Active
is 'off'
, the OPC server will not return
information about the group or item.
By default, Active
is set to 'on'
when you
create the daitem
object. Set Active
to
'off'
when you are temporarily not interested in that
daitem
object's values. You configure Active
for both dagroup
and daitem
objects. Changing the
state of the group does not change the state of the items.
The activation state of a dagroup
or daitem
object affects reads and subscriptions, and depends on whether the data is obtained from
the cache or from the device. The active state of a group or item affects operations as
follows.
Operation | Source | Active State |
---|---|---|
Cache | Both group and items must be active. Inactive items in active groups, and all items in inactive groups, return bad quality. | |
Device | Active is ignored. | |
N/A | Active is ignored. | |
| N/A | Both group and items must be active. Inactive items in active groups, and all items in inactive groups, return bad quality. |
N/A | Active is ignored. |
A transition from 'off'
to 'on'
results in a
change in quality, and causes a subscription callback for the item or items affected.
Changing the Active
state from 'on'
to
'off'
will cause a change in quality but will not cause a callback
since by definition callbacks do not occur for inactive items.
You enable subscription callbacks with the Subscription property. Use the DataChangeFcn property to specify a callback function file to execute when a data change event occurs.
Example:
'on'
Data Types: char
Version History
Introduced before R2006aR2024a: Warns
Support for the OPC Data Access (DA) standard will be removed in a future release. This function issues a warning that it will be removed.
To access live OPC data, use the OPC Unified Architecture (UA) standard instead. See Unified Architecture.
R2023b: To Be Removed
Support for the OPC Data Access (DA) standard will be removed in a future release. This function runs without warning.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)