T3SP-D4MX Operator’s Manual
3.2.5 Matlab
Interfacing the
cDMXU.dll
shared library from Matlab can be achieved by
using the
calllib
function. It allows for calling functions in shared li-
braries. It can be used to wrap these libraries in a Matlab m-file, as shown
in the following example:
function
varargout = mux_example(varargin)
% function varargout = mux_example(varargin)
%
% Examples:
%
mux_example('init');
%
mux_example('release')
%
mux_example('getserialnumber')
%
mux_example('getnumberofchannels')
%
mux_example('setchannel', 1); % starting with 1 (0: ALL OFF)
%
mux_example('getchannel');
if
~
nargin
cmd = 'init';
else
cmd =
lower
(varargin{1});
end
dll = 'cDMXUD';
shrlib = ['C:\YOUR_PATH\' dll '.dll'];
header = 'C:\YOUR_PATH\cDMXU.h';
assert(
exist
(header,'file')>0, 'Unable to locate header file');
if
~libisloaded(dll)
loadlibrary(shrlib,header);
end
is_init = (calllib(dll,'cDMXU_IsInitialized') == 0);
if
~is_init,
err = calllib(dll,'cDMXU_Init','');
assert(err == 0, 'Initialization failed');
18
933407 Rev1