Skip to content

Commit 160b722

Browse files
author
neil.hamilton
committed
Create PS6000aSetConfig.m function
1 parent 6b5b9cf commit 160b722

File tree

1 file changed

+186
-0
lines changed

1 file changed

+186
-0
lines changed

PS6000aSetConfig.m

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
function [ps6000aStructs, ps6000aEnuminfo] = PS6000aSetConfig()
2+
%% PS6000AConfig Configure path information
3+
% Configures paths according to platforms and loads information from
4+
% prototype files for PicoScope 6000 Series Oscilloscopes. The folder
5+
% that this file is located in must be added to the MATLAB path.
6+
%
7+
% Platform Specific Information:-
8+
%
9+
% Microsoft Windows: Download the Software Development Kit installer from
10+
% the <a href="matlab: web('https://www.picotech.com/downloads')">Pico Technology Download software and manuals for oscilloscopes and data loggers</a> page.
11+
%
12+
% Linux: Follow the instructions to install the libps6000a and libpswrappers
13+
% packages from the <a href="matlab:
14+
% web('https://www.picotech.com/downloads/linux')">Pico Technology Linux Software & Drivers for Oscilloscopes and Data Loggers</a> page.
15+
%
16+
% Apple Mac OS X: Follow the instructions to install the PicoScope 6
17+
% application from the <a href="matlab: web('https://www.picotech.com/downloads')">Pico Technology Download software and manuals for oscilloscopes and data loggers</a> page.
18+
% Optionally, create a 'maci64' folder in the same directory as this file
19+
% and copy the following files into it:
20+
%
21+
% * libps6000a.dylib and any other libps6000a library files
22+
% * libps6000aWrap.dylib and any other libps6000aWrap library files
23+
% * libpicoipp.dylib and any other libpicoipp library files
24+
% * libiomp5.dylib
25+
%
26+
% Contact our Technical Support team via the <a href="matlab: web('https://www.picotech.com/tech-support/')">Technical Enquiries form</a> for further assistance.
27+
%
28+
% Run this script in the MATLAB environment prior to connecting to the
29+
% device.
30+
%
31+
% This file can be edited to suit application requirements.
32+
33+
%% Set Path to Shared Libraries
34+
% Set paths to shared library files according to the operating system and
35+
% architecture.
36+
37+
% Identify working directory
38+
ps6000aConfigInfo.workingDir = pwd;
39+
40+
% Find file name
41+
ps6000aConfigInfo.configFileName = mfilename('fullpath');
42+
43+
% Only require the path to the config file
44+
[ps6000aConfigInfo.pathStr] = fileparts(ps6000aConfigInfo.configFileName);
45+
46+
% Identify architecture e.g. 'win64'
47+
ps6000aConfigInfo.archStr = computer('arch');
48+
49+
try
50+
51+
addpath(fullfile(ps6000aConfigInfo.pathStr, ps6000aConfigInfo.archStr));
52+
53+
catch err
54+
55+
error('PS6000AConfig:OperatingSystemNotSupported', 'Operating system not supported - please contact [email protected]');
56+
57+
end
58+
59+
% Set the path according to operating system.
60+
61+
if(ismac())
62+
63+
% Libraries (including wrapper libraries) are stored in the PicoScope
64+
% 6 App folder. Add locations of library files to environment variable.
65+
66+
setenv('DYLD_LIBRARY_PATH', '/Applications/PicoScope6.app/Contents/Resources/lib');
67+
68+
if(strfind(getenv('DYLD_LIBRARY_PATH'), '/Applications/PicoScope6.app/Contents/Resources/lib'))
69+
70+
addpath('/Applications/PicoScope6.app/Contents/Resources/lib');
71+
72+
else
73+
74+
warning('PS6000AConfig:LibraryPathNotFound','Locations of libraries not found in DYLD_LIBRARY_PATH');
75+
76+
end
77+
78+
elseif(isunix())
79+
80+
% Edit to specify location of .so files or place .so files in same directory
81+
addpath('/opt/picoscope/lib/');
82+
83+
elseif(ispc())
84+
85+
% Microsoft Windows operating system
86+
87+
% Set path to dll files if the Pico Technology SDK Installer has been
88+
% used or place dll files in the folder corresponding to the
89+
% architecture. Detect if 32-bit version of MATLAB on 64-bit Microsoft
90+
% Windows.
91+
92+
ps6000aConfigInfo.winSDKInstallPath = '';
93+
94+
if(strcmp(ps6000aConfigInfo.archStr, 'win32') && exist('C:\Program Files (x86)\', 'dir') == 7)
95+
96+
try
97+
98+
addpath('C:\Program Files (x86)\Pico Technology\SDK\lib\');
99+
ps6000aConfigInfo.winSDKInstallPath = 'C:\Program Files (x86)\Pico Technology\SDK';
100+
101+
catch err
102+
103+
warning('PS6000AConfig:DirectoryNotFound', ['Folder C:\Program Files (x86)\Pico Technology\SDK\lib\ not found. '...
104+
'Please ensure that the location of the library files are on the MATLAB path.']);
105+
106+
end
107+
108+
else
109+
110+
% 32-bit MATLAB on 32-bit Windows or 64-bit MATLAB on 64-bit
111+
% Windows operating systems
112+
try
113+
114+
addpath('C:\Program Files\Pico Technology\SDK\lib\');
115+
ps6000aConfigInfo.winSDKInstallPath = 'C:\Program Files\Pico Technology\SDK';
116+
117+
catch err
118+
119+
warning('PS6000AConfig:DirectoryNotFound', ['Folder C:\Program Files\Pico Technology\SDK\lib\ not found. '...
120+
'Please ensure that the location of the library files are on the MATLAB path.']);
121+
122+
end
123+
124+
end
125+
126+
else
127+
128+
error('PS6000AConfig:OperatingSystemNotSupported', 'Operating system not supported - please contact [email protected]');
129+
130+
end
131+
132+
%% Set Path for PicoScope Support Toolbox Files if Not Installed
133+
% Set MATLAB Path to include location of PicoScope Support Toolbox
134+
% Functions and Classes if the Toolbox has not been installed. Installation
135+
% of the toolbox is only supported in MATLAB 2014b and later versions.
136+
137+
% Check if PicoScope Support Toolbox is installed - using code based on
138+
% <http://stackoverflow.com/questions/6926021/how-to-check-if-matlab-toolbox-installed-in-matlab How to check if matlab toolbox installed in matlab>
139+
140+
ps6000aConfigInfo.psTbxName = 'PicoScope Support Toolbox';
141+
ps6000aConfigInfo.v = ver; % Find installed toolbox information
142+
143+
if(~any(strcmp(ps6000aConfigInfo.psTbxName, {ps6000aConfigInfo.v.Name})))
144+
145+
warning('PS6000AConfig:PSTbxNotFound', 'PicoScope Support Toolbox not found, searching for folder.');
146+
147+
% If the PicoScope Support Toolbox has not been installed, check to see
148+
% if the folder is on the MATLAB path, having been downloaded via zip
149+
% file or copied from the Microsoft Windows Pico SDK installer
150+
% directory.
151+
152+
ps6000aConfigInfo.psTbxFound = strfind(path, ps6000aConfigInfo.psTbxName);
153+
154+
if(isempty(ps6000aConfigInfo.psTbxFound) && ispc())
155+
156+
% Check if the folder is present in the relevant SDK installation
157+
% directory on Windows platforms (if the SDK installer has been
158+
% used).
159+
160+
% Obtain the folder name
161+
ps6000aConfigInfo.psTbxFolderName = fullfile(ps6000aConfigInfo.winSDKInstallPath, 'MATLAB' , ps6000aConfigInfo.psTbxName);
162+
163+
% If it is present in the SDK directory, add the PicoScope Support
164+
% Toolbox folder and sub-folders to the MATLAB path.
165+
if(exist(ps6000aConfigInfo.psTbxFolderName, 'dir') == 7)
166+
167+
addpath(genpath(ps6000aConfigInfo.psTbxFolderName));
168+
169+
end
170+
171+
else
172+
173+
warning('PS6000AConfig:PSTbxDirNotFound', 'PicoScope Support Toolbox directory not found.');
174+
175+
end
176+
177+
end
178+
179+
% Change back to the folder where the script was called from.
180+
cd(ps6000aConfigInfo.workingDir);
181+
182+
%% Load Enums and Structures
183+
184+
% Load in enumerations and structure information - DO NOT EDIT THIS SECTION
185+
[ps6000aMethodinfo, ps6000aStructs, ps6000aEnuminfo, ps6000aThunkLibName] = ps6000aMFile;
186+

0 commit comments

Comments
 (0)