-
Notifications
You must be signed in to change notification settings - Fork 0
/
slx_LabJackTSeries.m
63 lines (54 loc) · 2.08 KB
/
slx_LabJackTSeries.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
%SLX_LABJACKTSERIES Mask initialization for LabJack T-Series block
%
% slx_LabJackTSeries.m
% Julian Bell, JTEC Energy
% 2024-01-04 (actually earlier, but this is when I'm adding these notes
%
% This class definition configures & initializes the mask for the
% LabJack T-Series block in slx_LJM
%
% Relevant references:
% - XXX
%
% TODO:
% - XXX
classdef slx_LabJackTSeries
properties
ljHandle double
ljID string
end
methods(Static)
% Following properties of 'maskInitContext' are available to use:
% - BlockHandle
% - MaskObject
% - MaskWorkspace: Use get/set APIs to work with mask workspace.
function MaskInitialization(maskInitContext)
ljmAsm = NET.addAssembly('LabJack.LJM');
% Create mask contexts
bh = maskInitContext.BlockHandle;
mo = maskInitContext.MaskObject;
mw = maskInitContext.MaskWorkspace;
% Creating an object to nested class LabJack.LJM.CONSTANTS
t = ljmAsm.AssemblyHandle.GetType('LabJack.LJM+CONSTANTS');
LJM_CONSTANTS = System.Activator.CreateInstance(t);
ljHandle = 0;
ljID = get_param(bh,'ljIdentifier');
ljID = strip(ljID,"'"); % Need to strip off leading and trailing single quotes
assignin('base','id',ljID);
% Connect to devices & configure inputs
try
[ljmError, ljHandle] = LabJack.LJM.OpenS('ANY', 'USB', ljID, ljHandle); % Example - need to change this to T4 for different device
showDeviceInfo(ljHandle);
disp(['Handle = ',num2str(ljHandle)]);
set_param(bh,'ljHandle',num2str(ljHandle));
mw.set('ljHandle',ljHandle);
disp(['Set ljHandle for block to ',num2str(ljHandle)]);
catch ljConnectErr
showErrorMessage(ljConnectErr);
disp(ljConnectErr)
LabJack.LJM.CloseAll();
end
end
% Use the code browser on the left to add the callbacks.
end
end