Products & Services Solutions Academia Support User Community Company

Learn more about OPC Toolbox   

Configuring OPC Toolbox Object Properties

Purpose of Object Properties

All OPC Toolbox objects support properties that enable you to control characteristics of the object:

For all three toolbox objects, you can use the same toolbox functions to

Viewing the Values of Object Properties

To view all the properties of an OPC Toolbox object, with their current values, use the get function.

If you do not specify a return value, the get function displays the object properties in categories that group similar properties together. You use the display form of the get function to view the value of all properties for the toolbox object.

This example uses the get function to display a list of all the properties of the OPC dagroup object grp.

get(grp)

  General Settings:
    DeadbandPercent = 0
    GroupType = private
    Item = []
    Name = group1
    Parent = [1x1 opcda]
    Tag = 
    TimeBias = 0
    Type = dagroup
    UpdateRate = 0.5000
    UserData = []

  Callback Function Settings:
    CancelAsyncFcn = @opccallback
    DataChangeFcn = []
    ReadAsyncFcn = @opccallback
    RecordsAcquiredFcn = []
    RecordsAcquiredFcnCount = 20
    StartFcn = []
    StopFcn = []
    WriteAsyncFcn = @opccallback

  Subscription and Logging Settings:
    Active = on
    LogFileName = opcdatalog.olf
    Logging = off
    LoggingMode = memory
    LogToDiskMode = index
    RecordsAcquired = 0
    RecordsAvailable = 0
    RecordsToAcquire = 120
    Subscription = on

Viewing the Value of a Particular Property

To view the value of a particular property of an OPC Toolbox object, use the get function, specifying the name of the property as an argument. You can also access the value of the property as you would a field in a MATLAB structure.

This example uses the get function to retrieve the value of the Subscription property for the dagroup object.

get(grp,'Subscription')

ans =

on

This example illustrates how to access the same property by referencing the object as if it were a MATLAB structure.

grp.Subscription

ans =

on

Getting Information About Object Properties

To get information about a particular property, you can view the reference page for the property in Functions — Alphabetical List. You can also get information about a particular property at the command line by using the propinfo or opchelp functions.

The propinfo function returns a structure that contains information about the property, such as its data type, default value, and a list of all possible values if the property supports such a list. This example uses propinfo to get information about the LoggingMode property.

propinfo(grp,'LoggingMode')

ans = 

               Type: 'string'
         Constraint: 'enum'
    ConstraintValue: {'memory'  'disk'  'disk&memory'}
       DefaultValue: 'memory'
           ReadOnly: 'whileLogging'

The opchelp function returns reference information about the property with a complete description. This example uses opchelp to get information about the LoggingMode property.

opchelp(grp,'LoggingMode')

Setting the Value of an Object Property

To set the value of a particular property of an OPC Toolbox object, use the set function, specifying the name of the property as an argument. You can also assign the value to the property as you would a field in a MATLAB structure.

This example uses the set function to set the value of the LoggingMode property.

set(grp,'LoggingMode','disk&memory')

To verify the new value of the property, use the get function.

get(grp,'LoggingMode')

ans =

disk&memory

This example sets the value of a property by assigning the value to the object as if it were a MATLAB structure.

grp.LoggingMode = 'disk';
grp.LoggingMode

ans =

disk

Viewing a List of All Settable Object Properties

To view a list of all the properties of a toolbox object that can be set, use the set function.

set(grp)
    General Settings:
    DeadbandPercent
    Name
    Tag
    TimeBias
    UpdateRate
    UserData

  Callback Function Settings:
    CancelAsyncFcn: string -or- function handle -or- cell array
    DataChangeFcn: string -or- function handle -or- cell array
    ReadAsyncFcn: string -or- function handle -or- cell array
    RecordsAcquiredFcn: string -or- function handle -or- cell array
    RecordsAcquiredFcnCount
    StartFcn: string -or- function handle -or- cell array
    StopFcn: string -or- function handle -or- cell array
    WriteAsyncFcn: string -or- function handle -or- cell array

  Subscription and Logging Settings:
    Active: [ {on} | off ]
    LogFileName
    LoggingMode: [ {memory} | disk | disk&memory ]
    LogToDiskMode: [ {index} | append | overwrite ]
    RecordsToAcquire
    Subscription: [ {on} | off ]

When using the set function to display a list of settable properties, all properties that have a predefined set of acceptable values list those values after the property. The default value is enclosed in curly braces ({}). For example, from the display shown above, you can set the Subscription property for a dagroup object to 'on' or 'off', with the default value being 'on'. You can set the LogFileName property to any value.

Special Read-Only Modes

Some OPC Toolbox object properties change their read-only status, depending on the state of an object (defined by another property of that object, or the parent of that object). The toolbox uses two special read-only modes:

To determine if a property has a modifiable read-only state, use the propinfo function.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS