instrnotify

Define notification for instrument events

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, string, 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 string 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('keithley', 0, 5);
set(g, 'Name', 'mygpib');
fopen(g);
fclose(g);
instrnotify('PropertyChangedPostSet',@instrcallback,'-remove');

More About

expand all

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.

Was this topic helpful?