function prologix_function_generator_waveform(waveform,frequency,amplitude,offset,ipAddress,port)
%PROLOGIX_FUNCTION_GENERATOR Summary of this function goes here
%   Detailed explanation goes here



%% test for valid input data
    if nargin < 4
        offset = 0;
    end
    switch waveform
        case {1,'s','sin','sinus','sinusoid'}
            waveform = 'sinusoid';
        case {2,'S','sq', 'square'}
            waveform = 'square';
        case {3,'t','triangle'}
            waveform = 'triangle';
        case {4,'r','ramp'}
            waveform = 'ramp';
        otherwise
            error('waveform is not correctly defined');
    end
    
    switch waveform
        case {'square','sinusoid'}
            if (1e-04 > frequency) || (frequency > 1.5e07)
                error(['frequency is out of range for ',waveform,' waveform (100uHz - 15MHz)']);
            end
        case {'triangle','ramp'}
            if (1e-04 > frequency) || (frequency > 1e05)
                error(['frequency is out of range for ',waveform,' waveform (100uHz - 100kHz)']);
            end
    end
    
    
    
%% start connection with prologix
    if nargin < 5
        t = prologix_connect();
    elseif nargin < 6
        t = prologix_connect(ipAddress);
    else
        t = prologix_connect(ipAddress,port);
    end
%%  
    fprintf(t,'++addr 10');
    fprintf(t, ['apply:',waveform,' ',num2str(frequency),',',num2str(amplitude),',',num2str(offset)]);
    prologix_disconnect(t);
end

