instrnotify
(To be removed) Define notification for instrument events
This function that usesserial
,Bluetooth
,tcpip
,udp
,visa
, orgpib
will be removed in a future release. Useserialport
,bluetooth
,tcpclient
,tcpserver
,udpport
, orvisadev
instead. For more information on updating your code, seeCompatibility Considerations.
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
|
事件的类型: |
|
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 typeType
is generated.Type
can beObjectCreated
,ObjectDeleted
, orPropertyChangedPostSet
.
IfType
isObjectCreated
,callback
is evaluated each time an instrument object or a device group object is created. IfType
isObjectDeleted
,callback
is evaluated each time an instrument object or a device group object is deleted. IfType
isPropertyChangedPostSet
,callback
is evaluated each time an instrument object or device group object property is configured withset
.
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
Thecallback
function is invoked with
function(obj, event, [arg1, arg2,...])
whereobj
is the instrument object or device group object generating the event.event
is a structure containing information on the event generated. IfType
isObjectCreated
orObjectDeleted
,event
contains the type of event. IfType
isPropertyChangedPostSet
,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 onlyPropertyChangedPostSet
.
instrnotify(obj, '
evaluates the MATLAB expression,Type
', callback)callback
, in the MATLAB workspace when an event of typeType
for objectobj
, 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 objectobj
.
instrnotify('
removes the specifiedType
', callback, '-remove')callback
of typeType
.
instrnotify(obj, '
removes the specifiedType
', callback, '-remove')callback
of typeType
for objectobj
.
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'sTag
property is configured to'myobject'
, aPropertyChangedPostSet
event will not be generated if the object'sTag
property is currently set to'myobject'
. APropertyChangedPostSet
event will be generated if the object'sTag
property is set to'myGPIBObject'
.
Ifobj
is specified and the callbackType
isObjectCreated
, the callback will not be generated becauseobj
has already been created.
IfType
isObjectDeleted
, the invalid objectobj
is not passed as the first input argument to thecallback
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 theTabkey 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, seeUsing Tab Completion for Functions.