Main Content

instrnotify

(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 Compatibility 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'

The type of event: ObjectCreated, ObjectDeleted, or PropertyChangedPostSet

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 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({'P1', 'P2', ...}, 'Type', callback) evaluates the MATLAB expression, callback, in the MATLAB workspace when any of the specified properties, P1, P2, ... are configured. Type can be only PropertyChangedPostSet.

instrnotify(obj, 'Type', callback) evaluates the MATLAB expression, 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, {'P1', 'P2', ...}, 'Type', callback) evaluates the MATLAB expression, callback, in the MATLAB workspace when any of the specified properties, P1, P2, are configured on object obj.

instrnotify('Type', callback, '-remove') removes the specified callback of type Type.

instrnotify(obj, 'Type', callback, '-remove') removes the specified 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.

Version History

Introduced before R2006a

expand all

R2022b: Warns

This function returns a warning that it will be removed in a future release.

This function is used by the serial, Bluetooth, tcpip, udp, visa, gpib and i2c interfaces. These interfaces will also be removed in a future release, as previously announced. Use the following interfaces instead.

The recommended interfaces have additional capabilities and improved performance. For more information about the recommended interfaces, see Interface-Based Instrument Communication.