Main Content

instrnotify

(To be removed) Define notification for instrument events

This function that usesserial,Bluetooth,tcpip,udp,visa, orgpibwill be removed in a future release. Useserialport,bluetooth,tcpclient,tcpserver,udpport, orvisadevinstead. 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

'Type'

事件的类型:ObjectCreated,ObjectDeleted, orPropertyChangedPostSet

callback

Function handle, character vector, or cell array to evaluate.

'P1',P2', ...

Any number of object property names.

obj

Instrument object or device group object.

'-remove'

Argument to remove specified callback.

Description

instrnotify('Type', callback)evaluates the MATLAB®expression,callback, in the MATLAB workspace when an event of typeTypeis generated.Typecan beObjectCreated,ObjectDeleted, orPropertyChangedPostSet.

IfTypeisObjectCreated,callbackis evaluated each time an instrument object or a device group object is created. IfTypeisObjectDeleted,callbackis evaluated each time an instrument object or a device group object is deleted. IfTypeisPropertyChangedPostSet,callbackis evaluated each time an instrument object or device group object property is configured withset.

callbackcan 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

Thecallbackfunction is invoked with

function(obj, event, [arg1, arg2,...])

whereobjis the instrument object or device group object generating the event.eventis a structure containing information on the event generated. IfTypeisObjectCreatedorObjectDeleted,eventcontains the type of event. IfTypeisPropertyChangedPostSet,eventcontains the type of event, the property being configured, and the new property value.

instrnotify({'P1', 'P2', ...}, 'Type', callback)evaluates the MATLAB expression,callback, in the MATLAB workspace when any of the specified properties,P1,P2, ... are configured.Typecan be onlyPropertyChangedPostSet.

instrnotify(obj, 'Type', callback)evaluates the MATLAB expression,callback, in the MATLAB workspace when an event of typeTypefor objectobj, is generated.objcan be an array of instrument objects or device group objects.

instrnotify(obj, {'P1', 'P2', ...}, 'Type', callback)evaluates the MATLAB expression,callback, in the MATLAB workspace when any of the specified properties,P1,P2, are configured on objectobj.

instrnotify('Type', callback, '-remove')removes the specifiedcallbackof typeType.

instrnotify(obj, 'Type', callback, '-remove')removes the specifiedcallbackof typeTypefor objectobj.

Examples

instrnotify('PropertyChangedPostSet', @instrcallback); g = gpib('mcc', 0, 5); set(g, 'Name', 'mygpib'); fopen(g); fclose(g); instrnotify('PropertyChangedPostSet',@instrcallback,'-remove');

Tips

PropertyChangedPostSetevents 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'sTagproperty is configured to'myobject', aPropertyChangedPostSetevent will not be generated if the object'sTagproperty is currently set to'myobject'. APropertyChangedPostSetevent will be generated if the object'sTagproperty is set to'myGPIBObject'.

Ifobjis specified and the callbackTypeisObjectCreated, the callback will not be generated becauseobjhas already been created.

IfTypeisObjectDeleted, the invalid objectobjis not passed as the first input argument to thecallbackfunction. 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.

版本历史

Introduced before R2006a

expand all

Not recommended starting in R2022a