Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

tharbprobjwriteprofilename(tharBPRObj, profileName, profile)
function tharbprobjwriteprofilename(tharBPRObj, profileName, profile)
% THARBPROBJWRITEPROFILENAME writes the profileName to a Thar BPR
% tharbprobjwriteprofilename(tharBPRObj, profileName, profile) writes the profileName to a profile in
% a Thar BPR. tharBPRObj is the BPR serial object (generated by tharbproj),
% and profile is either 'A' or 'B'.  If the profile is not supplied, the
% set pressure is applied to the current profile. profileName is a string
% using the 32-127 ASCII character set.  It can be no longer than 7
% characters and must be at least one character.

% e.g. tharbprobjwriteprofilename(tharbprobj(5), 'P1') - sets the
% profileName of the current profile to 'P1' on the Thar BPR attached to
% COM5

% Range:

% tharBPRObj = valid serial port object

% profileName = string (see above for details)

% profile = 'A', 'B' or omitted


% error handling
if nargin < 2
    % errors
    error('Insufficient arguments')
elseif ~ischar(profileName) || isempty(profileName) || length(profileName) > 7 || any(profileName > 126) || any(profileName < 32)
    % errors
    error('profileName must be a string no longer than 7 characters only using printable characters with ASCII codes less than 127.')
end

% more error handling
if nargin < 3
    % gets the current profile
    profile = tharbprobjreadcurrentprofile(tharBPRObj);
elseif numel(profile) ~= 1 || ~any(strcmp(profile, {'A', 'B'}))
    % errors
    error('Profile must be either A or B.')
else
    % navigates to the display menu
    tharbprobjdisplaymenu(tharBPRObj);
end

% presses F5 then the profile name to get to the correct screen, enters the
% name, presses enter five times, then 'y' to save the changes - it takes
% around 4 seconds before the BPR starts sending screen updates out again
% (no idea why)
tharbprobjcomm('writesave', tharBPRObj, [char(21), profile, profileName, char([13, 13, 13, 13, 13]), 'Y'])

Contact us