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 gilsonpumpobjdisconnect(serialObject)
% GILSONPUMPOBJDISCONNECT terminates communication with Gilson pumps
% gilsonpumpobjdisconnect(serialObject) terminates communication with
% Gilson pumps, given serialObject as a valid pump serial object
% (generated by gilsonpumpobj).

% e.g. gilsonpumpobjdisconnect(gilsonpumpobj(6)) - terminates communication
% with the pump attached to COM6, then deletes and clears the serial object

% Range:

% serialObject = valid serial port object

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

% error handling
if ~isserial(serialObject) || (~isfield(serialObject.UserData, 'realTermHandle') && ~isrunning(serialObject))
    % errors if the realterm handle isn't there, and the serial object is
    % closed
    error('serial must be a valid open serial object.')
elseif isfield(serialObject.UserData, 'realTermHandle') && ~isrunning(serialObject.UserData.realTermHandle)
    % errors
    error('The realterm application must be connected.')
elseif isfield(serialObject.UserData, 'realTermHandle') && (~isfield(serialObject.UserData, 'captureFileID') || ~isfid(serialObject.UserData.captureFileID))
    % if using realterm, the capture file ID must be there
    error('If using Realterm, the capture file handle must be in the serial object''s UserData.')

% device ID
deviceID = 1;

% tries to leave the instrument in the best possible condition -
% unfortunately one of these causes the pump display to misbehave
    % release the keypad
    %gilsonpumpobjcomm('write', serialObject, deviceID, 'K')

    % reconnect both lines to the display
    %gilsonpumpobjcomm('write', serialObject, deviceID, 'W')

    % unlocks the keypad
    % displays a warning
    warning('gilson:disconnectionTidy', 'Did not correctly disconnect.')

% if the real term handle is there, do a different sequence of events
if isfield(serialObject.UserData, 'realTermHandle')
    % run the real term closer
    realtermfclose(serialObject.UserData.realTermHandle, serialObject.UserData.captureFileID)

    % closes communication conventionally

% deletes it afterwards

Contact us