% pref = Prefs
% Creates an object for viewing and chaning stamp's preferences.
% Preferences will be loaded as properties of pref and can be changed
% accordingly.
% MATLAB Support Package for Velleman PCSGU250
% Version 1.0
% Copyright 2011 The MathWorks, Inc.
classdef Prefs < handle
properties(Dependent)
% SDKDir
% The location of the PCSGU250 SDK top level directory (PCSGU250_DLL)
SDKDir
end
methods
function out = get.SDKDir(obj) %#ok<*MANU>
if ispref('vellscope','SDKDir')
out = getpref('vellscope','SDKDir');
else
out = '';
end
end
function set.SDKDir(obj,value)
[isOK,msg] = obj.checkSDKDirectory(value);
if ~isOK
error(msg)
end
try
if ~exist(fullfile(value,'FASTTime32.dll'),'file')
FASTDLLLoc = fullfile(value,'VB_2008_Expless','PCSGU250DLL_Demo','bin','Debug','FASTTime32.dll');
copyfile(FASTDLLLoc,fullfile(value,'FASTTime32.dll'));
end
catch
error('vellscope:CopyFailed',['Unable to copy FASTTime32.dll' char(10)...
'See README.pdf for troubleshooting instructions.'])
end
try
if ~exist(fullfile(value,'lib'),'dir')
mkdir(value,'lib');
end
catch
error('vellscope:MkdirFailed',['Unable to create lib folder' char(10)...
'See README.pdf for troubleshooting instructions.'])
end
if ~ispref('vellscope','SDKDir')
addpref('vellscope','SDKDir',value)
else
setpref('vellscope','SDKDir',value)
end
end
function display(obj)
fprintf(['\n To change preferences, change the relevant property:\n' ...
' ex. pref.SDKDir = ''C:\\MyDir\\PCSGU250_DLL''\n\n']);
disp(obj);
end
end
methods(Static)
function [isOK,msg] = checkSDKDirectory(SDKDir)
requiredFiles = {
'PCSGU250.dll'
'PcLab2000LT.exe'
'mpusbapi.dll'
'pcgu250.bit'
};
isOK = false;
msg = '';
for i=1:numel(requiredFiles)
if ~(exist(fullfile(SDKDir, requiredFiles{i}), 'file') == 2)
msg = sprintf('SDK directory (%s) does not contain %s', SDKDir, requiredFiles{i});
return;
end
end
isOK = true;
end
end
end