-
Notifications
You must be signed in to change notification settings - Fork 3
/
gpib_instrument.m
executable file
·47 lines (43 loc) · 1.93 KB
/
gpib_instrument.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
classdef gpib_instrument
%gpib_instrument - connect and disconect to GPIB instrument
%
% T. Mandic, University of Zagreb, 2016
properties
address = 28
vendor = 'ni'
handle
buffer_size = 1044480
boardindex = 0;
end
methods
%% Constructor
function this_gpib_instrument = gpib_instrument(inaddress, invendor, inbuffer_size, inboardindex)
if nargin == 4
this_gpib_instrument.address = inaddress;
this_gpib_instrument.vendor = invendor;
this_gpib_instrument.buffer_size = inbuffer_size;
this_gpib_instrument.boardindex = inboardindex;
end
end
%% open gpib port
function this_gpib_instrument = open(this_gpib_instrument)
this_gpib_instrument.handle = gpib(this_gpib_instrument.vendor,this_gpib_instrument.boardindex,this_gpib_instrument.address);
this_gpib_instrument.handle.InputBufferSize = this_gpib_instrument.buffer_size;
fopen(this_gpib_instrument.handle);
if strcmp('open', this_gpib_instrument.handle.status)
disp('gpib_instrument: GPIB port open');
elseif strcmp('closed', this_gpib_instrument.handle.status)
disp('gpib_instrument: Unable to open GPIB port');
end
end
%% close gpib port
function this_gpib_instrument = close(this_gpib_instrument)
fclose(this_gpib_instrument.handle);
if strcmp('open', this_gpib_instrument.handle.status)
disp('gpib_instrument: Unable to close GPIB port');
elseif strcmp('closed', this_gpib_instrument.handle.status)
disp('gpib_instrument: GPIB port closed');
end
end
end
end