Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation



06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

function gilsonpumpobjmainmenu(gilsonPumpObj)
% GILSONPUMPOBJFLOWMENU navigates the back to the main menu of Gilson pumps
% gilsonpumpobjmainmenu(gilsonPumpObj) navigates back to the main menu of
% Gilson pumps, regardless of the current menu position, given a valid
% Gilson device object.  After using this command, you need to reconnect
% the keypad to the software using 'write' 'K'.

% e.g. gilsonpumpobjmainmenu(gilsonPumpObj(6)) - navigates back to the
% flowmenu of the Gilson device on COM6

% Range:

% gilsonPumpObj = valid serial port object

% checks the number of arguments
error(nargchk(1, 1, nargin))

% pre-defines the deviceID for future ease of changing
deviceID = 1;

% reconnects the display to the pump for the bottom line (the important one
% for navigational purposes) - this then makes the next 'W' output for this
% one - saves on the bytes sent versus if the display was read twice
gilsonpumpobjcomm('write', gilsonPumpObj, deviceID, 'W1');

% reads out the bottomm line of the display (which will always be 27
% characters long - 3 for 'W0=', and 24 for the actual text
currentDisplay = gilsonpumpobjcomm('read', gilsonPumpObj, deviceID, 'W');

% Finds the current menu based on the position of key headings above each
% soft key (4 characters maximum in length) - the last key stroke is always
% soft key #4 (when the 'Menu' option is available, so is incorporated into
% the final command for convenience
if strcmp(currentDisplay(24:27), 'Quit')
    % character for soft key #5 (takes you back to the flow menu) then soft
    % key #4 to get to the main menu
    keyStrokes = 'e';
elseif strcmp(currentDisplay(19:22), 'Menu')
    % don't need to do anything
    keyStrokes = '';
elseif strcmp(currentDisplay(24:26), 'End') || strcmp(currentDisplay(24:25), 'No')
    % navigates into the next menu, where 'Quit' is option #5
    keyStrokes = 'ee';
elseif strcmp(currentDisplay(4:7), 'Flow')
    % navigates into the flow menu then back into the main menu
    keyStrokes = 'a';
elseif all(isspace(currentDisplay(4:end)))
    % can be in two places on this basis, so checks the other line
    otherLine = gilsonpumpobjcomm('read', gilsonPumpObj, 1, 'W');
    % if min is in this position, then it is in the programming menu,
    % awaiting selection of a time and a flow rate
    if strcmp(otherLine(10:12), 'min')
        keyStrokes = 'Ee';
        % means it is in a file copy, delete or some other menu when you
        % have no choice but to enter in an option - this set of keystrokes
        % cancels the current item just in case, then enters in 1 as a
        % dummy - it then gives you the option to back out (soft key #5 =
        % 'No'), then leads back into a menu where option #5 is 'Quit' as
        % normal
        keyStrokes = 'C1Eee';
    % gives an error message if neither of the above options are present
    error('Could not navigate back to the main menu - unknown menu position')

% sends the command - purposefully not unlocking the keypad afterwards to
% make sure no other buttons are pressed between navigating back to the
% main menu, and running the next command
gilsonpumpobjcomm('write', gilsonPumpObj, 1, ['K', keyStrokes, 'd']);

Contact us