instrnotify
R2026b(To be removed) Define notification for instrument events
This function that uses serial, Bluetooth,
tcpip, udp, visa,
gpib, or i2c will be removed in a future release.
Use serialport, bluetooth,
tcpclient,
tcpserver,
udpport,
visadev,
aardvark/device, or
ni845x/device
instead. For more information on updating your code, see Version History.
Syntax
instrnotify('Type',
callback)
instrnotify({'P1',
'P2', ...}, 'Type',
callback)
instrnotify(obj, 'Type',
callback)
instrnotify(obj, {'P1',
'P2', ...}, 'Type',
callback)
instrnotify('Type',
callback, '-remove')
instrnotify(obj, 'Type',
callback, '-remove')
Arguments
| The type of event: |
| Function handle, character vector, or cell array to evaluate. |
| Any number of object property names. |
| Instrument object or device group object. |
| Argument to remove specified callback. |
Description
instrnotify('
evaluates the MATLAB® expression, Type',
callback)callback, in the MATLAB workspace when an event of type Type is
generated. Type can be ObjectCreated,
ObjectDeleted, or PropertyChangedPostSet.
If Type is ObjectCreated,
callback is evaluated each time an instrument object or a
device group object is created. If Type is
ObjectDeleted, callback is evaluated each
time an instrument object or a device group object is deleted. If
Type is PropertyChangedPostSet,
callback is evaluated each time an instrument object or
device group object property is configured with set.
callback can be
A function handle
A character vector to be evaluated
A cell array containing the function to evaluate in the first cell (function handle or name of function) and extra arguments to pass to the function in subsequent cells
The callback function is invoked with
function(obj, event, [arg1, arg2,...])
where obj is the instrument object or device group object
generating the event. event is a structure containing information
on the event generated. If Type is
ObjectCreated or ObjectDeleted,
event contains the type of event. If
Type is PropertyChangedPostSet,
event contains the type of event, the property being
configured, and the new property value.
instrnotify({'
evaluates the MATLAB expression, P1',
'P2', ...}, 'Type',
callback)callback, in the MATLAB workspace when any of the specified properties,
P1, P2, ... are
configured. Type can be only
PropertyChangedPostSet.
instrnotify(obj, '
evaluates the MATLAB expression, Type',
callback)callback, in the MATLAB workspace when an event of type Type for
object obj, is generated. obj can be an array
of instrument objects or device group objects.
instrnotify(obj, {'
evaluates the MATLAB expression, P1',
'P2', ...}, 'Type',
callback)callback, in the MATLAB workspace when any of the specified properties,
P1, P2, are configured on
object obj.
instrnotify('
removes the specified Type',
callback, '-remove')callback of type
Type.
instrnotify(obj, '
removes the specified Type',
callback, '-remove')callback of type
Type for object obj.
Examples
instrnotify('PropertyChangedPostSet', @instrcallback);
g = gpib('mcc', 0, 5);
set(g, 'Name', 'mygpib');
fopen(g);
fclose(g);
instrnotify('PropertyChangedPostSet',@instrcallback,'-remove');Tips
PropertyChangedPostSet events are generated only when the
property is configured to a different value than what the property is currently
configured to. For example, if a GPIB object's Tag property is
configured to 'myobject', a
PropertyChangedPostSet event will not be generated if the
object's Tag property is currently set to
'myobject'. A PropertyChangedPostSet event
will be generated if the object's Tag property is set to
'myGPIBObject'.
If obj is specified and the callback
Type is ObjectCreated, the
callback will not be generated because obj has already been
created.
If Type is ObjectDeleted, the
invalid object obj is not passed as the first input argument to
the callback function. Instead, an empty matrix is passed as
the first input argument.
Note
To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.