-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pm_callback.m
69 lines (61 loc) · 1.85 KB
/
Pm_callback.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function Pm_callback(obj, event, varargin)
%IMAQCALLBACK Display event information for the event.
%
% IMAQCALLBACK(OBJ, EVENT) displays a message which contains the
% type of the event, the time of the event and the name of the
% object which caused the event to occur.
%
% If an error event occurs, the error message is also displayed.
%
% IMAQCALLBACK is an example callback function. Use this callback
% function as a template for writing your own callback function.
%
% Example:
% obj = videoinput('winvideo', 1);
% set(obj, 'StartFcn', {'imaqcallback'});
% start(obj);
% wait(obj);
% delete(obj);
%
% See also IMAQHELP.
%
% CP 10-01-02
% Copyright 2001-2010 The MathWorks, Inc.
% Define error identifiers.
errID = 'imaq:imaqcallback:invalidSyntax';
errID2 = 'imaq:imaqcallback:zeroInputs';
switch nargin
case 0
error(message(errID2));
case 1
error(message(errID));
case 2
if ~isa(obj, 'imaqdevice') || ~isa(event, 'struct')
error(message(errID));
end
if ~(isfield(event, 'Type') && isfield(event, 'Data'))
error(message(errID));
end
end
% Determine the type of event.
EventType = event.Type;
% Determine the time of the error event.
EventData = event.Data;
EventDataTime = EventData.AbsTime;
% Create a display indicating the type of event, the time of the event and
% the name of the object.
name = get(obj, 'Name');
fprintf('%s event occurred at %s for video input object: %s.\n', ...
EventType, datestr(EventDataTime,13), name);
% Display the error string.
if strcmpi(EventType, 'error')
fprintf('%s\n', EventData.Message);
end
switch EventType
case 'Start'
Pm_startCallback(obj);
% case 'FramesAcquired'
% localFramesAcquiredCallback(obj)
% case 'Stop'
% localStopCallback(obj)
end