Update pid controller demo

Update pid controller demo

// This demo show how to use MicroDAQ macros to access
// MicroDAQ peripherals. This example uses PID algorithm
// to control DC motor. The DC motor is driven by H-bridge
// which is controlled by PWM and DIO.
//
// MicroDAQ DIO15, DIO16 are used to control H-bridge
// enable and direction pins. MicroDAQ PWM is used to
// control H-bridge voltage. DC motor is equipped with
// quadrature encoder. MicroDAQ encoder module is used
// to read DC motor shaft position.

function dc_motor_controller(data_color,command, Kp, Ki, Kd)
mdaqClose();

pwm_module = 1;
pwm_period = 200; // in microseconds
dio_enable = 15;
dio_direction = 16;
enc = 2;
dt = 0.0041;
prev_err = 0;
int_err = 0;
command_data = [0];
response_data = [0];
control_data = [0]
time = [];

// connect to MicroDAQ device, con will be used as a first
// argument for MicroDAQ hardware access macros
con = mdaqOpen();
if con > -1 then
    // disable PWM module 2/3
    mdaqDIOFunc(con, 4, %F);
    mdaqDIOFunc(con, 5, %F);

    // configure MicroDAQ PWM module 1 with period 200us
    // and non-inverted PWM waveform
    mdaqDIOFunc(con, 3, %T);
    mdaqPWMInit(con, pwm_module, pwm_period, %F, 0, 0);

    // initialize MicroDAQ Encoder 2 module with 0 value
    mdaqEncoderInit(con, enc, 0, "quadrature");

    // set initial state of DIO20, DIO20 and PWM module to 0 duty
    mdaqDIOWrite(con, dio_enable, %T)
    mdaqDIOWrite(con, dio_direction, %T);
    mdaqPWMWrite(con, pwm_module, 0, 0);

    // PID control loop
    for i=1:1000
        tic();

        // get position
        position = mdaqEncoderRead(con, enc);

        // calculate PID algorithm
        err = command - position;
        err_diff = (err - prev_err) / dt;
        int_err = int_err + (err * dt);

        p_term = err * Kp;
        i_term = int_err * Ki;
        d_term = err_diff  * Kd;

        control = p_term + i_term + d_term;
        prev_err = err;

        // depending on control value (negative/positive)
        // set DIO22 to %T (for positive) or %F (negative)
        if control > 0 then
            mdaqDIOWrite(con, dio_direction, %T);
            if control > 100 then
                control = 100;
            end
        else
            mdaqDIOWrite(con, dio_direction, %F);
            if control < -100 then
                control = -100;
            end
        end

        // set PWM value (0-100 range)
        mdaqPWMWrite(con, pwm_module, abs(control), abs(control));

        // store experiment data
        control_data = [control_data, control];
        response_data = [response_data, position];
        command_data = [command_data, command];

        // gather loop time for loop time statistics
        time = [time, toc()];
    end

    // calculate time base
    loop_time = mean(time);
    t = 0:loop_time:loop_time*1000;

    mprintf("PID gains:\n\tKp: %f\n\tKi: %f\n\tKd: %f\n", Kp, Ki, Kd);
    mprintf("Loop time (dt) statistics: \n\tMean: %f\n\tMax: %f\n\tMin: %f\n", loop_time, max(time), min(time));

    // set PWM to 0 and close connection with MicroDAQ
    mdaqPWMWrite(con, pwm_module, 0,0)
    mdaqClose(con);

    data_color = data_color + 1;
    plot2d(t, response_data,data_color);
    plot2d(t, control_data,data_color);
    plot2d(t, command_data,1);
end
endfunction

// PID gains
Kp = 0.065;
Ki = 0.04;
Kd = 0.005;

// call dc_motor_controller with different Ki PID gain
dc_motor_controller(1, 3000, Kp, Ki-0.04, Kd)
dc_motor_controller(2, 3000, Kp, Ki-0.02, Kd)
dc_motor_controller(3, 3000, Kp, Ki,      Kd)
dc_motor_controller(4, 3000, Kp, Ki+0.02, Kd)
dc_motor_controller(5, 3000, Kp, Ki+0.04, Kd)

// This demo show how to use MicroDAQ macros to access
// MicroDAQ peripherals. This example uses PID algorithm
// to control DC motor. The DC motor is driven by H-bridge
// which is controlled by PWM and DIO.
//
// MicroDAQ DIO15, DIO16 are used to control H-bridge
// enable and direction pins. MicroDAQ PWM is used to
// control H-bridge voltage. DC motor is equipped with
// quadrature encoder. MicroDAQ encoder module is used
// to read DC motor shaft position.

function dc_motor_controller(data_color,command, Kp, Ki, Kd)
mdaqClose();

pwm_module = 1;
pwm_period = 200; // in microseconds
dio_enable = 15;
dio_direction = 16;
enc = 2;
dt = 0.0041;
prev_err = 0;
int_err = 0;
command_data = [0];
response_data = [0];
control_data = [0]
time = [];

// connect to MicroDAQ device, con will be used as a first
// argument for MicroDAQ hardware access macros
con = mdaqOpen();
if con > -1 then
    // disable PWM module 2/3
    mdaqDIOFunc(con, 4, %F);
    mdaqDIOFunc(con, 5, %F);

    // configure MicroDAQ PWM module 1 with period 200us
    // and non-inverted PWM waveform
    mdaqDIOFunc(con, 3, %T);
    mdaqPWMInit(con, pwm_module, pwm_period, %F, 0, 0);

    // initialize MicroDAQ Encoder 2 module with 0 value
    mdaqEncoderInit(con, enc, 0);

    // set initial state of DIO20, DIO20 and PWM module to 0 duty
    mdaqDIOWrite(con, dio_enable, %T)
    mdaqDIOWrite(con, dio_direction, %T);
    mdaqPWMWrite(con, pwm_module, 0, 0);

    // PID control loop
    for i=1:1000
        tic();

        // get position
        position = mdaqEncoderRead(con, enc);

        // calculate PID algorithm
        err = command - position;
        err_diff = (err - prev_err) / dt;
        int_err = int_err + (err * dt);

        p_term = err * Kp;
        i_term = int_err * Ki;
        d_term = err_diff  * Kd;

        control = p_term + i_term + d_term;
        prev_err = err;

        // depending on control value (negative/positive)
        // set DIO22 to %T (for positive) or %F (negative)
        if control > 0 then
            mdaqDIOWrite(con, dio_direction, %T);
            if control > 100 then
                control = 100;
            end
        else
            mdaqDIOWrite(con, dio_direction, %F);
            if control < -100 then
                control = -100;
            end
        end

        // set PWM value (0-100 range)
        mdaqPWMWrite(con, pwm_module, abs(control), abs(control));

        // store experiment data
        control_data = [control_data, control];
        response_data = [response_data, position];
        command_data = [command_data, command];

        // gather loop time for loop time statistics
        time = [time, toc()];
    end

    // calculate time base
    loop_time = mean(time);
    t = 0:loop_time:loop_time*1000;

    mprintf("PID gains:\n\tKp: %f\n\tKi: %f\n\tKd: %f\n", Kp, Ki, Kd);
    mprintf("Loop time (dt) statistics: \n\tMean: %f\n\tMax: %f\n\tMin: %f\n", loop_time, max(time), min(time));

    // set PWM to 0 and close connection with MicroDAQ
    mdaqPWMWrite(con, pwm_module, 0,0)
    mdaqClose(con);

    data_color = data_color + 1;
    plot2d(t, response_data,data_color);
    plot2d(t, control_data,data_color);
    plot2d(t, command_data,1);
end
endfunction

// PID gains
Kp = 0.065;
Ki = 0.04;
Kd = 0.005;

// call dc_motor_controller with different Ki PID gain
dc_motor_controller(1, 3000, Kp, Ki-0.04, Kd)
dc_motor_controller(2, 3000, Kp, Ki-0.02, Kd)
dc_motor_controller(3, 3000, Kp, Ki,      Kd)
dc_motor_controller(4, 3000, Kp, Ki+0.02, Kd)
dc_motor_controller(5, 3000, Kp, Ki+0.04, Kd)


Create meeting_scilab.sci

Create meeting_scilab.sci


Add relative path

Add relative path

clear(); // Löschen aller Variablen
clearglobal(); // Löschen aller globalen Variablen

//********************************************
//              CONSTANTS
//********************************************

PI = 3.14;

//********************************************
//      READ IN THE FUNCTIONS.SCI FIlE
//  containing numiercal and plotting routines
//********************************************

// not sure what's the cleaner way, but i'll go with getd()
absolute_path = get_absolute_file_path('tracking_treadmill.sce')
getd(absolute_path);
//exec('./functions.sci');

//********************************************
//              DATA-IMPORT
//********************************************

// Öffnendialog starten
//data_path = uigetfile("*.*","","Select CSV data",%t);

data_path = absolute_path + "/../data/aljoscha/5_kmh.mdf"

// Einlesen der Daten
delimiter = " ";                                // Ist klar
regex_ignore = '/(Track).*$/';                  // Löschen aller mit "Track" beginnenden Zeilen
header = 5;                                     // Anzahl an Zeilen im Kopf
data = csvRead(data_path, delimiter, [], [], [], regex_ignore, [], header);

// Meta-Daten der Bilder
numberOfTracks = size(data,1) / max(data(:, 2))           // Number of Tracks
numberOfImages = max(data(:, 2))                          // Number of Images per Track
DELTA_T = 0.02;                                 // 50 FPS
CALIBRATION = 300;                              // Pix per m is correct, get the cal ratio from user via dialog box
Y_RESOLUTION = 576 / 300;                             // Höhe in Pixeln

// Kalibrieren
data = data / CALIBRATION;

// Eingelesenen Datensatz gemäß der Logik beim Tracken in 8 Datensätze unterteilen
// Jeder Datensatz wird logisch in x und y Werte unterteilt
// Gelenk.x und Gelenk.y enthalten jeweils eine 1 spaltige Matrix mit Koordinatenwerten
// Multiplikation mit -1 der y-Werte um "natürliches Koordinatensystem" zu erhalten
for i = 1 : numberOfTracks
    if i == 1 then
        toes.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        toes.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 2 then
        ankle.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        ankle.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 3 then
        knee.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        knee.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 4 then
        hip.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        hip.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 5 then
        shoulder.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        shoulder.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 6 then
        elbow.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        elbow.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 7 then
        hand.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        hand.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 8 then
        neck.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        neck.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    end
end

toes.speed = CalcSpeed(toes)
disp(toes.speed.x)
disp(toes.speed.y)
toes.speed.x = MovingMean(toes.speed.x)
toes.speed.x = MovingMean(toes.speed.y)
disp(toes.speed.x)
disp(toes.speed.y)

plot (toes.x, toes.y, 'or');
plot(toes.speed.x, toes.speed.y);
// plot(knee.x,knee.y,'or'); // Plot x, y, ?

//savetarget = uiputfile("*.txt*");

//fprintfMat(savetarget, UsS); // Speichern fprintfMat(Zielpfad, Daten)

clear(); // Löschen aller Variablen
clearglobal(); // Löschen aller globalen Variablen

//********************************************
//              CONSTANTS
//********************************************

PI = 3.14;

//********************************************
//      READ IN THE FUNCTIONS.SCI FIlE
//  containing numiercal and plotting routines
//********************************************

// not sure what's the cleaner way, but i'll go with getd()
absolute_path = get_absolute_file_path('tracking_treadmill.sce')
getd(absolute_path);
//exec('./functions.sci');

//********************************************
//              DATA-IMPORT
//********************************************

// Öffnendialog starten
data_path = uigetfile("*.*","","Select CSV data",%t);

// Einlesen der Daten
delimiter = " ";                                // Ist klar
regex_ignore = '/(Track).*$/';                  // Löschen aller mit "Track" beginnenden Zeilen
header = 5;                                     // Anzahl an Zeilen im Kopf
data = csvRead(data_path, delimiter, [], [], [], regex_ignore, [], header);

// Meta-Daten der Bilder
numberOfTracks = size(data,1) / max(data(:, 2))           // Number of Tracks
numberOfImages = max(data(:, 2))                          // Number of Images per Track
DELTA_T = 0.02;                                 // 50 FPS
CALIBRATION = 300;                              // Pix per m is correct, get the cal ratio from user via dialog box
Y_RESOLUTION = 576 / 300;                             // Höhe in Pixeln

// Kalibrieren
data = data / CALIBRATION;

// Eingelesenen Datensatz gemäß der Logik beim Tracken in 8 Datensätze unterteilen
// Jeder Datensatz wird logisch in x und y Werte unterteilt
// Gelenk.x und Gelenk.y enthalten jeweils eine 1 spaltige Matrix mit Koordinatenwerten
// Multiplikation mit -1 der y-Werte um "natürliches Koordinatensystem" zu erhalten
for i = 1 : numberOfTracks
    if i == 1 then
        toes.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        toes.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 2 then
        ankle.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        ankle.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 3 then
        knee.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        knee.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 4 then
        hip.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        hip.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 5 then
        shoulder.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        shoulder.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 6 then
        elbow.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        elbow.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 7 then
        hand.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        hand.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 8 then
        neck.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        neck.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    end
end

toes.speed = CalcSpeed(toes)
disp(toes.speed.x)
disp(toes.speed.y)
toes.speed.x = MovingMean(toes.speed.x)
toes.speed.x = MovingMean(toes.speed.y)
disp(toes.speed.x)
disp(toes.speed.y)

plot (toes.x, toes.y, 'or');
plot(toes.speed.x, toes.speed.y);
// plot(knee.x,knee.y,'or'); // Plot x, y, ?

//savetarget = uiputfile("*.txt*");

//fprintfMat(savetarget, UsS); // Speichern fprintfMat(Zielpfad, Daten)


Do not based on name file when building block

function buildmacros()

    global %microdaq;
    %microdaq = struct("model", ["Unknown"],..
        "ip_address", [],..
        "dsp_loaded", %F,..
        "dsp_ext_mode", %T,..
        "dsp_debug_mode", %F,..
        "private", struct(..
        "mlink_link_id", -1000,..
        "userhostlib_link_id", -1000,..
        "connection_id", -1,..
        "has_mdaqBlock", %F,..
        "has_mdaq_param_sim", %F,..
        "mem_write_idx", 0,..
        "mem_read_idx", 0,..
        "to_file_idx", 0,..
        "dac_idx", 0,..
        "adc_idx", 0,..
        "webscope_idx", 0,..
        "udpsend_idx", 0,..
        "mdaq_signal_id", 0,..
        "ao_scan_ch_count", -1,..
        "mdaq_hwid", [])..
    );

    script_path = get_absolute_file_path("buildmacros.sce");
    module_path = part(script_path,1:length(script_path)-length("macros") - 1 )

    tbx_build_macros(TOOLBOX_NAME, script_path + filesep() + "microdaq_blocks");
    tbx_build_macros(TOOLBOX_NAME, script_path + filesep() + "microdaq_macros");
    tbx_build_macros(TOOLBOX_NAME, script_path);

    // check user_blocks beafore build
    if isdir(script_path + filesep() + "user_blocks") == %F then
        mkdir(script_path + filesep() + "user_blocks");
    end

    tbx_build_macros(TOOLBOX_NAME, script_path + filesep() + "user_blocks");

    // Build MicroDAQ blocks
    microdaq_blocks = []
    f = ls(script_path + filesep() + "microdaq_blocks" + filesep() + "*.bin")
    microdaq_blocks = basename(f)

    blocks = [];
    for i=1:size(microdaq_blocks, "*")
        if strstr(microdaq_blocks(i), "_sim") == "" then
            blocks = [blocks, microdaq_blocks(i)];
        end
    end

    tbx_build_blocks(module_path, blocks, "macros" + filesep() + "microdaq_blocks");

    // Build MicroDAQ User blocks
    if isfile(script_path + filesep() + "user_blocks" + filesep() + "names")  == %T then

        microdaq_blocks = []
        f = ls(script_path + filesep() + "user_blocks" + filesep() + "*.bin")
        microdaq_blocks = basename(f)

        blocks = [];
        for i=1:size(microdaq_blocks, "*")
            if strstr(microdaq_blocks(i), "_sim") == "" then
                if isfile(script_path + filesep() + "user_blocks" + filesep() + microdaq_blocks(i) + '.sci')  == %T then
                    blocks = [blocks, microdaq_blocks(i)];
                end
            end
        end

        if blocks <> [] then
            tbx_build_blocks(module_path, blocks, "macros" + filesep() + "user_blocks");
        end
    end

endfunction

buildmacros();
clear buildmacros; // remove buildmacros on stack

function buildmacros()
    // create global microdaq settings struct
    sci_ver_str = getversion('scilab', 'string_info');

    global %microdaq;
    %microdaq = struct("model", ["Unknown"],..
        "ip_address", [],..
        "dsp_loaded", %F,..
        "dsp_ext_mode", %T,..
        "dsp_debug_mode", %F,..
        "private", struct(..
        "mlink_link_id", -1000,..
        "userhostlib_link_id", -1000,..
        "connection_id", -1,..
        "has_mdaqBlock", %F,..
        "has_mdaq_param_sim", %F,..
        "mem_write_idx", 0,..
        "mem_read_idx", 0,..
        "to_file_idx", 0,..
        "dac_idx", 0,..
        "adc_idx", 0,..
        "webscope_idx", 0,..
        "udpsend_idx", 0,..
        "mdaq_signal_id", 0,..
        "ao_scan_ch_count", -1,..
        "mdaq_hwid", [])..
    );

    script_path = get_absolute_file_path("buildmacros.sce");
    module_path = part(script_path,1:length(script_path)-length("macros") - 1 )

    tbx_build_macros(TOOLBOX_NAME, script_path);
    tbx_build_macros(TOOLBOX_NAME, script_path + filesep() + "microdaq_blocks");
    tbx_build_macros(TOOLBOX_NAME, script_path + filesep() + "microdaq_macros");

    // check user_blocks beafore build
    if isdir(script_path + filesep() + "user_blocks") == %F then
        mkdir(script_path + filesep() + "user_blocks");
    end

    tbx_build_macros(TOOLBOX_NAME, script_path + filesep() + "user_blocks");

if sci_ver_str == 'scilab-5.5.2' then
    // Build MicroDAQ blocks
    microdaq_blocks = mgetl( script_path + filesep() + "microdaq_blocks" + filesep() + "names");
    microdaq_blocks = microdaq_blocks';

    blocks = [];
    for i=1:size(microdaq_blocks, "*")
        if strstr(microdaq_blocks(i), "_sim") == ""
            blocks = [blocks, microdaq_blocks(i)];
        end
    end

    tbx_build_blocks(module_path, blocks, "macros" + filesep() + "microdaq_blocks");

    // Build MicroDAQ User blocks
    if isfile(script_path + filesep() + "user_blocks" + filesep() + "names")  == %T then

        microdaq_blocks = mgetl( script_path + filesep() + "user_blocks" + filesep() + "names");
        microdaq_blocks = microdaq_blocks';

        blocks = [];
        for i=1:size(microdaq_blocks, "*")
            if strstr(microdaq_blocks(i), "_sim") == ""
                if isfile(script_path + filesep() + "user_blocks" + filesep() + microdaq_blocks(i) + '.sci')  == %T then
                    blocks = [blocks, microdaq_blocks(i)];
                end
            end
        end

        if blocks <> [] then
            tbx_build_blocks(module_path, blocks, "macros" + filesep() + "user_blocks");
        end
    end
end
endfunction

buildmacros();
clear buildmacros; // remove buildmacros on stack


Change AI task table col description

Change AI task table col description

function  mdaqAITaskInit(arg1, arg2, arg3, arg4, arg5, arg6)
    link_id = -1;

    if argn(2) == 5 then
        channels = arg1;
        aiRange = arg2;
        aiMode = arg3;
        scan_freq = arg4;
        scan_time = arg5;
    end

    if argn(2) == 6 then
        link_id = arg1;
        channels = arg2;
        aiRange = arg3;
        aiMode = arg4;
        scan_freq = arg5;
        scan_time = arg6;

        if link_id < 0 then
            error("Invalid connection ID!")
            return;
        end
    end

    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        adc_info = get_adc_info(%microdaq.private.mdaq_hwid);
        if argn(2) > 6 | argn(2) < 5 then
            mprintf("Description:\n");
            mprintf("\tInitializes analog input task\n");
            mprintf("Usage:\n");
            mprintf("\tmdaqAITaskInit(linkID, channels, range, isDifferential, rate, duration)\n");
			mprintf("\tlinkID - connection id returned by mdaqOpen() (OPTIONAL)\n");
            mprintf("\tchannels - analog input channels to read\n");
            mprintf("\trange - analog input range matrix e.g.\n");
            mprintf("\t        [-10,10] - single range argument applied for all used channels\n");
            mprintf("\t        [-10,10;-5,5] - multi-range argument for two channels\n");
			mprintf("\tisDifferential - scalar or vector with measurement mode settings: %s - differential, %s - single-ended mode\n", "%T", "%F");
            mprintf("\trate - read per second rate for channels in use\n");
            mprintf("\tduration - task duration in seconds (-1 - infinity)\n");
            return;
        end
    else
        error('Unable to detect MicroDAQ configuration. Run mdaqHWInfo() function.');
    end

    ch_count = size(channels, 'c');

    if scan_time < 0 then
        scan_time = -1;
    end

    if size(channels, 'r') > 1 then
        error('Wrong channel - scalar or single row vector expected')
    end

    if size(aiRange, 'c') <> 2 then
        error('Wrong range - matrix range [low,high;low,high;...] expected')
    end

    aiRangeSize = size(aiRange, 'r');
    if aiRangeSize <> 1 & aiRangeSize <> ch_count then
        error('Range vector should match selected AI channels')
    end

    if type(aiMode) == 1 then
        if size(find(aiMode>1), '*') > 0
            error('Wrong mode (isDifferential parameter) - boolean value expected (%T/1, %F/0)')
        end
    end

    if size(aiMode, 'r') > 1 then
        error('Wrong mode (isDifferential parameter) - scalar or single row vector expected')
    end

    aiModeSize = size(aiMode, 'c');
    if aiModeSize <> 1 & aiModeSize <> ch_count then
        error('Mode (isDifferential parameter) vector should match selected AI channels')
    end

    if aiRangeSize == 1 then
        range_tmp = aiRange;
        aiRange = ones(ch_count,2);
        aiRange(:,1) = range_tmp(1);
        aiRange(:,2) = range_tmp(2);
        clear range_tmp;
    end

    aiRange_t = aiRange;
    aiRange = matrix(aiRange', 1, ch_count*2);

    aiMode(find(aiMode==%T))=1;
    if aiModeSize == 1 then
        aiMode = ones(1, ch_count) * aiMode;
    end

    if argn(2) == 5 then
        link_id = mdaqOpen();
        if link_id < 0 then
            error("Unable to connect to MicroDAQ device!");
        end
    end

    result = [];
    real_freq = scan_freq;
    [result real_freq] = call("sci_mlink_ai_scan_init",..
                    link_id, 1, "i",..
                    channels, 2, "i",..
                    ch_count, 3, "i",..
                    aiRange, 4, "d",..
                    aiMode, 5, "i",..
                    scan_freq, 6, "d",..
                    scan_time, 7, "d",..
                "out",..
                    [1, 1], 9, "i",..
                    [1, 1], 8, "d");

    if result < 0 & result <> -88 then
        if argn(2) == 5 then
            mdaqClose(link_id);
        end
        error(mdaq_error2(result), 10000 + abs(result));
    else
        if result == -88 then
            disp("Warninng: AI task interrupted!")
            mdaqAIScanStop()

            // time to terminate TCP connection
            sleep(200);
            [result real_freq] = call("sci_mlink_ai_scan_init",..
                            link_id, 1, "i",..
                            channels, 2, "i",..
                            ch_count, 3, "i",..
                            aiRange, 4, "d",..
                            aiMode, 5, "i",..
                            scan_freq, 6, "d",..
                            scan_time, 7, "d",..
                        "out",..
                            [1, 1], 9, "i",..
                            [1, 1], 8, "d");
        end

        if argn(2) == 5 then
            mdaqClose(link_id);
        end

        if result < 0 then
            error(mdaq_error2(result), 10000 + abs(result));
        end

        if result == 1 then
            limited_cap = %t;
        else
            limited_cap = %f;
        end

        rows = [];
        row = '';

        adc_res = strtod(part(adc_info.resolution, 1:2))
        for j=1:ch_count
            if aiMode(j) == 1 then
                measure_type = "Differential"
            elseif (aiMode(j) == 0)
                measure_type = "Single-ended"
            end
            adc_range = aiRange_t(j, 2) - aiRange_t(j, 1);
            resolution = string((int(adc_range/2^adc_res * 1000000)) / 1000);
            rangeStr="";
            if aiRange_t(j, 1) < 0 then
                rangeStr = "±" + string(aiRange_t(j, 2))+"V";
            else
                rangeStr = "0-" + string(aiRange_t(j, 2))+"V";
            end
            rows = [rows; "AI"+string(channels(j)), measure_type, rangeStr, resolution+"mV"]
        end

        mprintf("\nAnalog input task settings:\n");
        mprintf("\t--------------------------------------------------\n")
        str2table(rows, ["Channel", "Terminal config", "Range", "Resolution"], 3)
        mprintf("\t--------------------------------------------------\n")
        mprintf("\tTask rate:\t\t%.1f scans per second\n", scan_freq);
        mprintf("\tActual task rate:\t%.1f scans per second\n", real_freq);

        if 1 /real_freq > 0.001 then
            mprintf("\tScan period: \t\t%.5f seconds\n", 1 / real_freq);
        end

        if 1 /real_freq <= 0.001 then
            mprintf("\tScan period: \t\t%.5f ms\n", 1 / real_freq * 1000);
        end

        if scan_time < 0
            mprintf("\tNumber of channels:\t%d\n", ch_count)
            mprintf("\tNumber of scans:\tInf\n");
            mprintf("\tDuration:\t\tInf\n");
        else
            mprintf("\tNumber of channels:\t%d\n", ch_count)
            mprintf("\tNumber of scans:\t%d\n", scan_time * scan_freq);
            if scan_time == 1
                mprintf("\tDuration:\t\t%.2f second\n", scan_time);
            else
                mprintf("\tDuration:\t\t%.2f seconds\n", scan_time);
            end
        end
        mprintf("\t--------------------------------------------------\n")
    end
endfunction

function  mdaqAITaskInit(arg1, arg2, arg3, arg4, arg5, arg6)
    link_id = -1;

    if argn(2) == 5 then
        channels = arg1;
        aiRange = arg2;
        aiMode = arg3;
        scan_freq = arg4;
        scan_time = arg5;
    end

    if argn(2) == 6 then
        link_id = arg1;
        channels = arg2;
        aiRange = arg3;
        aiMode = arg4;
        scan_freq = arg5;
        scan_time = arg6;

        if link_id < 0 then
            error("Invalid connection ID!")
            return;
        end
    end

    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        adc_info = get_adc_info(%microdaq.private.mdaq_hwid);
        if argn(2) > 6 | argn(2) < 5 then
            mprintf("Description:\n");
            mprintf("\tInitializes analog input task\n");
            mprintf("Usage:\n");
            mprintf("\tmdaqAITaskInit(linkID, channels, range, isDifferential, rate, duration)\n");
			mprintf("\tlinkID - connection id returned by mdaqOpen() (OPTIONAL)\n");
            mprintf("\tchannels - analog input channels to read\n");
            mprintf("\trange - analog input range matrix e.g.\n");
            mprintf("\t        [-10,10] - single range argument applied for all used channels\n");
            mprintf("\t        [-10,10;-5,5] - multi-range argument for two channels\n");
			mprintf("\tisDifferential - scalar or vector with measurement mode settings: %s - differential, %s - single-ended mode\n", "%T", "%F");
            mprintf("\trate - read per second rate for channels in use\n");
            mprintf("\tduration - task duration in seconds (-1 - infinity)\n");
            return;
        end
    else
        error('Unable to detect MicroDAQ configuration. Run mdaqHWInfo() function.');
    end

    ch_count = size(channels, 'c');

    if scan_time < 0 then
        scan_time = -1;
    end

    if size(channels, 'r') > 1 then
        error('Wrong channel - scalar or single row vector expected')
    end

    if size(aiRange, 'c') <> 2 then
        error('Wrong range - matrix range [low,high;low,high;...] expected')
    end

    aiRangeSize = size(aiRange, 'r');
    if aiRangeSize <> 1 & aiRangeSize <> ch_count then
        error('Range vector should match selected AI channels')
    end

    if type(aiMode) == 1 then
        if size(find(aiMode>1), '*') > 0
            error('Wrong mode (isDifferential parameter) - boolean value expected (%T/1, %F/0)')
        end
    end

    if size(aiMode, 'r') > 1 then
        error('Wrong mode (isDifferential parameter) - scalar or single row vector expected')
    end

    aiModeSize = size(aiMode, 'c');
    if aiModeSize <> 1 & aiModeSize <> ch_count then
        error('Mode (isDifferential parameter) vector should match selected AI channels')
    end

    if aiRangeSize == 1 then
        range_tmp = aiRange;
        aiRange = ones(ch_count,2);
        aiRange(:,1) = range_tmp(1);
        aiRange(:,2) = range_tmp(2);
        clear range_tmp;
    end

    aiRange_t = aiRange;
    aiRange = matrix(aiRange', 1, ch_count*2);

    aiMode(find(aiMode==%T))=1;
    if aiModeSize == 1 then
        aiMode = ones(1, ch_count) * aiMode;
    end

    if argn(2) == 5 then
        link_id = mdaqOpen();
        if link_id < 0 then
            error("Unable to connect to MicroDAQ device!");
        end
    end

    result = [];
    real_freq = scan_freq;
    [result real_freq] = call("sci_mlink_ai_scan_init",..
                    link_id, 1, "i",..
                    channels, 2, "i",..
                    ch_count, 3, "i",..
                    aiRange, 4, "d",..
                    aiMode, 5, "i",..
                    scan_freq, 6, "d",..
                    scan_time, 7, "d",..
                "out",..
                    [1, 1], 9, "i",..
                    [1, 1], 8, "d");

    if result < 0 & result <> -88 then
        if argn(2) == 5 then
            mdaqClose(link_id);
        end
        error(mdaq_error2(result), 10000 + abs(result));
    else
        if result == -88 then
            disp("Warninng: AI task interrupted!")
            mdaqAIScanStop()

            // time to terminate TCP connection
            sleep(200);
            [result real_freq] = call("sci_mlink_ai_scan_init",..
                            link_id, 1, "i",..
                            channels, 2, "i",..
                            ch_count, 3, "i",..
                            aiRange, 4, "d",..
                            aiMode, 5, "i",..
                            scan_freq, 6, "d",..
                            scan_time, 7, "d",..
                        "out",..
                            [1, 1], 9, "i",..
                            [1, 1], 8, "d");
        end

        if argn(2) == 5 then
            mdaqClose(link_id);
        end

        if result < 0 then
            error(mdaq_error2(result), 10000 + abs(result));
        end

        if result == 1 then
            limited_cap = %t;
        else
            limited_cap = %f;
        end

        rows = [];
        row = '';

        adc_res = strtod(part(adc_info.resolution, 1:2))
        for j=1:ch_count
            if aiMode(j) == 1 then
                measure_type = "Differential"
            elseif (aiMode(j) == 0)
                measure_type = "Single-ended"
            end
            adc_range = aiRange_t(j, 2) - aiRange_t(j, 1);
            resolution = string((int(adc_range/2^adc_res * 1000000)) / 1000);
            rangeStr="";
            if aiRange_t(j, 1) < 0 then
                rangeStr = "±" + string(aiRange_t(j, 2))+"V";
            else
                rangeStr = "0-" + string(aiRange_t(j, 2))+"V";
            end
            rows = [rows; "AI"+string(channels(j)), measure_type, rangeStr, resolution+"mV"]
        end

        mprintf("\nAnalog input task settings:\n");
        mprintf("\t--------------------------------------------------\n")
        mprintf("\t--------------------------------------------------\n")
        mprintf("\tTask rate:\t\t%.1f scans per second\n", scan_freq);
        mprintf("\tActual task rate:\t%.1f scans per second\n", real_freq);

        if 1 /real_freq > 0.001 then
            mprintf("\tScan period: \t\t%.5f seconds\n", 1 / real_freq);
        end

        if 1 /real_freq <= 0.001 then
            mprintf("\tScan period: \t\t%.5f ms\n", 1 / real_freq * 1000);
        end

        if scan_time < 0
            mprintf("\tNumber of channels:\t%d\n", ch_count)
            mprintf("\tNumber of scans:\tInf\n");
            mprintf("\tDuration:\t\tInf\n");
        else
            mprintf("\tNumber of channels:\t%d\n", ch_count)
            mprintf("\tNumber of scans:\t%d\n", scan_time * scan_freq);
            if scan_time == 1
                mprintf("\tDuration:\t\t%.2f second\n", scan_time);
            else
                mprintf("\tDuration:\t\t%.2f seconds\n", scan_time);
            end
        end
        mprintf("\t--------------------------------------------------\n")
    end
endfunction


INTEGRATION: CWS mav14 (1.2.330); FILE MERGED 2005/01/11 13:34:24 sw 1.2.330.1: #i36993#

-o sfx.AppDispatchProvider
-o sfx.DocumentTemplates
-o sfx.FrameLoader
-o sfx.SfxMacroLoader
#i36993#-o sfx.StandaloneDocumentInfo

-o sfx.AppDispatchProvider
-o sfx.DocumentTemplates
-o sfx.FrameLoader
-o sfx.SfxMacroLoader
-o sfx.StandaloneDocumentInfo


ITS ALIVE!!!!!!!

ITS ALIVE!!!!!!!

[testsign,Fs,bits]=wavread("D:\Programs\scilab-5.5.2\modules\sound\demos\BART.wav");
//t = [1:1:length(testsign)]*1/Fs;
outputO = 0;
outputE= 0;
for n=1:length(testsign),
    if n <= 50000  then
        outputO = testsign(n);
        testsign(1)= outputO;

    elseif n > 50000 then
         testsign(n)=[testsign(n) + (testsign(n-50000)*0.6 )];
    elseif n > 100000 then

        testsign(n) = [testsign(n) + (testsign(n-50000)*0.6 ) + (testsign(n-100000)*0.7 )];
end,

end
playsnd(testsign,44100);

[testsign,Fs,bits]=wavread("D:\Programs\scilab-5.5.2\modules\sound\demos\chimes.wav");
//t = [1:1:length(testsign)]*1/Fs;
outputO = 0;
outputE= 0;
for n=1:length(testsign),
    if n <= 1000  then
        outputO = testsign(n);
        testsign(1)= outputO;

    elseif n > 1000 then
         testsign(n)=[testsign(n) + (testsign(n-1000)*0.6 )];
    elseif n > 2000 then

        testsign(n) = [testsign(n) + (testsign(n-1000)*0.6 ) + (testsign(n-2000)*0.4 )];
end,

end
playsnd(testsign,12000);


MSC-226 - fix display of PFile path for Input/Output Files on windows

function %PAFile_p(l)
    printf('[%s (%s)]',+l.Path,l.Space);
endfunction

function %PAFile_p(l)
    printf('['+l.Path+' ('+l.Space+')]');
endfunction


Unable to run standard models when toolbox loaded fix

function continueSimulation=pre_xcos_simulate(scs_m, needcompile)
    global %microdaq;
    %microdaq.private.has_mdaqBlock = %F;
    continueSimulation = %T;
    look_for_mdaqBlocks = %T;

    for i = 1:size(scs_m.objs)
        curObj= scs_m.objs(i);

        if (typeof(curObj) == "Block" & curObj.gui == "CLKINV_f")
            messagebox("Starting simulation inside of a superblock is not possible", "Simulation problem", "error");
            continueSimulation = %F;
            return;
        end

        if (typeof(curObj) == "Block" & curObj.gui == "CLOCK_c")
            sTsamp=curObj.model.rpar.objs(2).graphics.exprs(1);
            %microdaq.private.model_tsamp=strtod(sci2exp(eval(sTsamp)));
        end

        if (typeof(curObj) == "Block" & curObj.gui == "mdaq_setup")
            if scs_m.objs(i).model.rpar(1) == (-1) then
                scs_m.props.tf= 1.000D+12;
            else
                scs_m.props.tf=scs_m.objs(i).model.rpar(1);
            end

            // if model has microdaq block set real-time scaling to 1
            tmp = scs_m;

            perform_scan(tmp);
            if %microdaq.private.has_mdaqBlock then
                scs_m.props.tol(5) = 1;
            end

            if %microdaq.dsp_loaded == %T then
                look_for_mdaqBlocks = %F;
                scs_m.props.tol(5) = 0;

                [mdaq_ip_addr, result] = mdaq_get_ip();
                if result < 0 then
                    disp("Unable to get MicroDAQ IP address - run microdaq_setup!");
                    continueSimulation = %F;
                    %microdaq.dsp_loaded = %F;
                    break;
                end

                result = client_connect(mdaq_ip_addr, 4344);
                if result < 0 then
                    con = mdaqOpen();
                    result = mlink_set_obj(con, "ext_mode", 1);
                    mdaqClose(con);
                    if result == -25 then
                        message("ERROR: Unable to connect - your are running model in Standalone mode!");
                    else
                        message("ERROR: Unable to connect to MicroDAQ device!")
                        %microdaq.dsp_loaded = %F;
                    end
                    continueSimulation = %F;
                    break;
                end
                disp('### Starting model in Ext mode...');

                perform_scan(tmp);
                if %microdaq.private.has_mdaq_param_sim then
                    result = mdaqOpen();
                    if result > -1 then
                        %microdaq.private.connection_id = result;
                    else
                        message("ERROR: Unable to connect to MicroDAQ device!");
                        continueSimulation = %F;
                        %microdaq.private.connection_id = -1;
                    end
                end
            end
        end
    end

    if look_for_mdaqBlocks then
        tmp = scs_m;
        perform_scan(tmp);
        if %microdaq.private.has_mdaqBlock then
            disp("### Running model in simulation mode... ")
            close_last_connection();
            result = mdaqOpen();
            if result > -1 then
                %microdaq.private.connection_id = result;
            else
                message("ERROR: Unable to connect to MicroDAQ device!");
                continueSimulation = %F;
                %microdaq.private.connection_id = -1;
            end
        end

        %microdaq.private.mdaq_signal_id = 0;
    end

    scs_m=resume(scs_m)
endfunction

function continueSimulation=pre_xcos_simulate(scs_m, needcompile)
    global %microdaq;
    %microdaq.private.has_mdaqBlock = %F;
    continueSimulation = %T;
    look_for_mdaqBlocks = %T;
    runFromMainScheme = %F;

    for i = 1:size(scs_m.objs)
        curObj= scs_m.objs(i);
        if (typeof(curObj) == "Block" & curObj.gui == "CLOCK_c")
            sTsamp=curObj.model.rpar.objs(2).graphics.exprs(1);
            %microdaq.private.model_tsamp=strtod(sci2exp(eval(sTsamp)));
        end

        if (typeof(curObj) == "Block" & curObj.gui == "mdaq_setup")
            runFromMainScheme = %T;

            if scs_m.objs(i).model.rpar(1) == (-1) then
                scs_m.props.tf= 1.000D+12;
            else
                scs_m.props.tf=scs_m.objs(i).model.rpar(1);
            end

            // if model has microdaq block set real-time scaling to 1
            tmp = scs_m;

            perform_scan(tmp);
            if %microdaq.private.has_mdaqBlock then
                scs_m.props.tol(5) = 1;
            end

            if %microdaq.dsp_loaded == %T then
                look_for_mdaqBlocks = %F;
                scs_m.props.tol(5) = 0;

                [mdaq_ip_addr, result] = mdaq_get_ip();
                if result < 0 then
                    disp("Unable to get MicroDAQ IP address - run microdaq_setup!");
                    continueSimulation = %F;
                    %microdaq.dsp_loaded = %F;
                    break;
                end

                result = client_connect(mdaq_ip_addr, 4344);
                if result < 0 then
                    con = mdaqOpen();
                    result = mlink_set_obj(con, "ext_mode", 1);
                    mdaqClose(con);
                    if result == -25 then
                        message("ERROR: Unable to connect - your are running model in Standalone mode!");
                    else
                        message("ERROR: Unable to connect to MicroDAQ device!")
                        %microdaq.dsp_loaded = %F;
                    end
                    continueSimulation = %F;
                    break;
                end
                disp('### Starting model in Ext mode...');

                perform_scan(tmp);
                if %microdaq.private.has_mdaq_param_sim then
                    result = mdaqOpen();
                    if result > -1 then
                        %microdaq.private.connection_id = result;
                    else
                        message("ERROR: Unable to connect to MicroDAQ device!");
                        continueSimulation = %F;
                        %microdaq.private.connection_id = -1;
                    end
                end
            end
        end
    end

    if runFromMainScheme == %F then
        messagebox("Please start model from root diagram (the one which contains mdaq_setup block).");
        continueSimulation = %F;
        return;
    end

    if look_for_mdaqBlocks then
        tmp = scs_m;
        perform_scan(tmp);
        if %microdaq.private.has_mdaqBlock then
            disp("### Running model in simulation mode... ")
            close_last_connection();
            result = mdaqOpen();
            if result > -1 then
                %microdaq.private.connection_id = result;
            else
                message("ERROR: Unable to connect to MicroDAQ device!");
                continueSimulation = %F;
                %microdaq.private.connection_id = -1;
            end
        end

        %microdaq.private.mdaq_signal_id = 0;
    end

    scs_m=resume(scs_m)
endfunction


Bufix: build -> load model, wrong message ("Model has been started...")

function load_last_dsp_image()
    global %microdaq;
    res = 0;

    if isfile(TMPDIR + filesep() + "last_mdaq_dsp_image") == %t then
        dsp_app_path = mgetl(TMPDIR + filesep() + "last_mdaq_dsp_image");
        if isfile(dsp_app_path) == %t then
            if %microdaq.private.connection_id <> -1 then
                mdaq_close(%microdaq.private.connection_id);
                %microdaq.private.connection_id = -1;
            end

            connection_id = mdaq_open();
            if connection_id < 0 then
                message('Unable to locate MicroDAQ device - check your setup!');
                return;
            end

            res = mlink_dsp_load(connection_id, dsp_app_path, '');
            if res < 0 then
                // try again to load application
                mdaq_close(connection_id);
                connection_id = mdaq_open();
                if connection_id < 0 then
                    message('ERROR: Unable to connect to MicroDAQ device - check your setup!');
                    return;
                end
                res = mlink_dsp_load(connection_id, dsp_app_path, '');
                if res < 0 then
                    message('Unable to load DSP firmware! (' + mdaq_error2(res) + ').');
                    mdaq_close(connection_id);
                    %microdaq.dsp_loaded = %F
                    return;
                end
            end
            disp('### Model has been loaded to MicroDAQ.');

            res_mode = mlink_set_obj(connection_id, "ext_mode", 1);

            res = mlink_dsp_start(connection_id,-1);
            if res < 0 then
                message("Unable to start DSP application!");
                mdaq_close(connection_id);
                %microdaq.dsp_loaded = %F;
                return;
            end

           if res_mode == -25 then
                disp('### Model has been started in Standalone mode.');
           end

            %microdaq.dsp_loaded = %T;
            mdaq_close(connection_id);
        else
            message("Unable to find model, build model and try again!")
        end
    else
        message("Unable to find model, build model and try again!")
    end
endfunction

function load_last_dsp_image()
    global %microdaq;
    res = 0;

    if isfile(TMPDIR + filesep() + "last_mdaq_dsp_image") == %t then
        dsp_app_path = mgetl(TMPDIR + filesep() + "last_mdaq_dsp_image");
        if isfile(dsp_app_path) == %t then
            if %microdaq.private.connection_id <> -1 then
                mdaq_close(%microdaq.private.connection_id);
                %microdaq.private.connection_id = -1;
            end

            connection_id = mdaq_open();
            if connection_id < 0 then
                message('Unable to locate MicroDAQ device - check your setup!');
                return;
            end

            res = mlink_dsp_load(connection_id, dsp_app_path, '');
            if res < 0 then
                // try again to load application
                mdaq_close(connection_id);
                connection_id = mdaq_open();
                if connection_id < 0 then
                    message('ERROR: Unable to connect to MicroDAQ device - check your setup!');
                    return;
                end
                res = mlink_dsp_load(connection_id, dsp_app_path, '');
                if res < 0 then
                    message('Unable to load DSP firmware! (' + mdaq_error2(res) + ').');
                    mdaq_close(connection_id);
                    %microdaq.dsp_loaded = %F
                    return;
                end
            end
            disp('### Model has been loaded to MicroDAQ.');

            res = mlink_set_obj(connection_id, "ext_mode", 1);
//            if res == -25 then
//               disp('### Starting model in Standalone mode...');
//           end

            res = mlink_dsp_start(connection_id,-1);
            if res < 0 then
                message("Unable to start DSP application!");
                mdaq_close(connection_id);
                %microdaq.dsp_loaded = %F;
                return;
            end
            disp('### Model has been started in Standalone mode.');
            %microdaq.dsp_loaded = %T;
            mdaq_close(connection_id);
        else
            message("Unable to find model, build model and try again!")
        end
    else
        message("Unable to find model, build model and try again!")
    end
endfunction


disable two slow java based subsequenttests, fdo#45337

These two tests are not well designed and need 5 and 10 minute just to
check that we really return every row. This is not a good trade-off
between test coverage and execution time.

Enable them again with a better concept.

# i84653 -o sc.ScPageObj
# i84554 -o sc.AccessibleEditableTextPara_PreviewNote
# i88241 -o sc.AccessibleEditableTextPara_HeaderFooter
-o sc.AccessibleEditableTextPara_PreviewCell
-o sc.ScAccessibleCell
# i91044 -o sc.ScAccessibleCsvCell
# i91044 -o sc.ScAccessibleCsvGrid
# i84641 -o sc.ScAccessibleCsvRuler
# i88330 -o sc.ScAccessibleDocument
# i91045 -o sc.ScAccessibleDocumentPagePreview
-o sc.ScAccessiblePageHeader
-o sc.ScAccessiblePageHeaderArea
-o sc.ScAccessiblePreviewCell
-o sc.ScAccessiblePreviewHeaderCell
-o sc.ScAccessiblePreviewTable
# fdo#45337 -o sc.ScAccessibleSpreadsheet
-o sc.ScAnnotationObj
-o sc.ScAnnotationShapeObj
-o sc.ScAnnotationsObj
-o sc.ScAreaLinkObj
-o sc.ScAreaLinksObj
-o sc.ScAutoFormatFieldObj
-o sc.ScAutoFormatObj
-o sc.ScAutoFormatsObj
-o sc.ScCellCursorObj
-o sc.ScCellFieldObj
-o sc.ScCellFieldsObj
-o sc.ScCellFormatsEnumeration
-o sc.ScCellFormatsObj
-o sc.ScCellObj
-o sc.ScCellRangeObj
-o sc.ScCellRangesObj
-o sc.ScCellSearchObj
-o sc.ScCellTextCursor
-o sc.ScCellsEnumeration
-o sc.ScCellsObj
-o sc.ScChartObj
-o sc.ScChartsObj
-o sc.ScConsolidationDescriptor
-o sc.ScDDELinkObj
-o sc.ScDDELinksObj
-o sc.ScDataPilotFieldGroupItemObj
-o sc.ScDataPilotFieldGroupObj
-o sc.ScDataPilotFieldGroupsObj
-o sc.ScDataPilotFieldObj
-o sc.ScDataPilotFieldsObj
-o sc.ScDataPilotItemObj
-o sc.ScDataPilotItemsObj
-o sc.ScDataPilotTableObj
-o sc.ScDataPilotTablesObj
-o sc.ScDatabaseRangeObj
# -o sc.ScDatabaseRangesObj
-o sc.ScDocumentConfiguration
-o sc.ScDrawPageObj
-o sc.ScDrawPagesObj
-o sc.ScFilterDescriptorBase
-o sc.ScFunctionListObj
-o sc.ScHeaderFieldObj
-o sc.ScHeaderFieldsObj
-o sc.ScHeaderFooterContentObj
-o sc.ScHeaderFooterTextCursor
-o sc.ScHeaderFooterTextObj
-o sc.ScIndexEnumeration_CellAnnotationsEnumeration
-o sc.ScIndexEnumeration_CellAreaLinksEnumeration
-o sc.ScIndexEnumeration_DDELinksEnumeration
-o sc.ScIndexEnumeration_DataPilotFieldsEnumeration
-o sc.ScIndexEnumeration_DataPilotItemsEnumeration
-o sc.ScIndexEnumeration_DataPilotTablesEnumeration
-o sc.ScIndexEnumeration_DatabaseRangesEnumeration
-o sc.ScIndexEnumeration_FunctionDescriptionEnumeration
-o sc.ScIndexEnumeration_LabelRangesEnumeration
-o sc.ScIndexEnumeration_NamedRangesEnumeration
-o sc.ScIndexEnumeration_ScenariosEnumeration
-o sc.ScIndexEnumeration_SheetCellRangesEnumeration
-o sc.ScIndexEnumeration_SheetLinksEnumeration
-o sc.ScIndexEnumeration_SpreadsheetViewPanesEnumeration
-o sc.ScIndexEnumeration_SpreadsheetsEnumeration
-o sc.ScIndexEnumeration_SubTotalFieldsEnumeration
-o sc.ScIndexEnumeration_TableAutoFormatEnumeration
-o sc.ScIndexEnumeration_TableChartsEnumeration
-o sc.ScIndexEnumeration_TableColumnsEnumeration
-o sc.ScIndexEnumeration_TableConditionalEntryEnumeration
# fdo#45337 -o sc.ScIndexEnumeration_TableRowsEnumeration
-o sc.ScIndexEnumeration_TextFieldEnumeration
-o sc.ScLabelRangeObj
-o sc.ScLabelRangesObj
-o sc.ScModelObj
-o sc.ScNamedRangeObj
-o sc.ScNamedRangesObj
-o sc.ScRecentFunctionsObj
# -o sc.ScScenariosObj
# -o sc.ScShapeObj
# -o sc.ScSheetLinkObj
-o sc.ScSheetLinksObj
-o sc.ScSpreadsheetSettings
-o sc.ScSpreadsheetSettingsObj
-o sc.ScStyleFamiliesObj
-o sc.ScStyleFamilyObj
# -o sc.ScStyleObj
-o sc.ScSubTotalDescriptorBase
-o sc.ScSubTotalFieldObj
# # i84656 -o sc.ScTabViewObj
# -o sc.ScTableColumnObj
-o sc.ScTableColumnsObj
-o sc.ScTableConditionalEntry
-o sc.ScTableConditionalFormat
# -o sc.ScTableRowObj
-o sc.ScTableRowsObj
# -o sc.ScTableSheetObj
-o sc.ScUniqueCellFormatsEnumeration
-o sc.ScUniqueCellFormatsObj
# -o sc.ScTableSheetsObj
-o sc.ScTableValidationObj
#-o sc.ScViewPaneObj
# #i89411 -o sc.XMLContentExporter
# #i89411 -o sc.XMLContentImporter
# #i89411 -o sc.XMLExporter
# #i89411 -o sc.XMLImporter
# #i89411 -o sc.XMLMetaExporter
# #i89411 -o sc.XMLMetaImporter
-o sc.XMLSettingsExporter
-o sc.XMLSettingsImporter
-o sc.XMLStylesExporter
-o sc.XMLStylesImporter
-o sc.XMLExporter

# i84653 -o sc.ScPageObj
# i84554 -o sc.AccessibleEditableTextPara_PreviewNote
# i88241 -o sc.AccessibleEditableTextPara_HeaderFooter
-o sc.AccessibleEditableTextPara_PreviewCell
-o sc.ScAccessibleCell
# i91044 -o sc.ScAccessibleCsvCell
# i91044 -o sc.ScAccessibleCsvGrid
# i84641 -o sc.ScAccessibleCsvRuler
# i88330 -o sc.ScAccessibleDocument
# i91045 -o sc.ScAccessibleDocumentPagePreview
-o sc.ScAccessiblePageHeader
-o sc.ScAccessiblePageHeaderArea
-o sc.ScAccessiblePreviewCell
-o sc.ScAccessiblePreviewHeaderCell
-o sc.ScAccessiblePreviewTable
-o sc.ScAccessibleSpreadsheet
-o sc.ScAnnotationObj
-o sc.ScAnnotationShapeObj
-o sc.ScAnnotationsObj
-o sc.ScAreaLinkObj
-o sc.ScAreaLinksObj
-o sc.ScAutoFormatFieldObj
-o sc.ScAutoFormatObj
-o sc.ScAutoFormatsObj
-o sc.ScCellCursorObj
-o sc.ScCellFieldObj
-o sc.ScCellFieldsObj
-o sc.ScCellFormatsEnumeration
-o sc.ScCellFormatsObj
-o sc.ScCellObj
-o sc.ScCellRangeObj
-o sc.ScCellRangesObj
-o sc.ScCellSearchObj
-o sc.ScCellTextCursor
-o sc.ScCellsEnumeration
-o sc.ScCellsObj
-o sc.ScChartObj
-o sc.ScChartsObj
-o sc.ScConsolidationDescriptor
-o sc.ScDDELinkObj
-o sc.ScDDELinksObj
-o sc.ScDataPilotFieldGroupItemObj
-o sc.ScDataPilotFieldGroupObj
-o sc.ScDataPilotFieldGroupsObj
-o sc.ScDataPilotFieldObj
-o sc.ScDataPilotFieldsObj
-o sc.ScDataPilotItemObj
-o sc.ScDataPilotItemsObj
-o sc.ScDataPilotTableObj
-o sc.ScDataPilotTablesObj
-o sc.ScDatabaseRangeObj
# -o sc.ScDatabaseRangesObj
-o sc.ScDocumentConfiguration
-o sc.ScDrawPageObj
-o sc.ScDrawPagesObj
-o sc.ScFilterDescriptorBase
-o sc.ScFunctionListObj
-o sc.ScHeaderFieldObj
-o sc.ScHeaderFieldsObj
-o sc.ScHeaderFooterContentObj
-o sc.ScHeaderFooterTextCursor
-o sc.ScHeaderFooterTextObj
-o sc.ScIndexEnumeration_CellAnnotationsEnumeration
-o sc.ScIndexEnumeration_CellAreaLinksEnumeration
-o sc.ScIndexEnumeration_DDELinksEnumeration
-o sc.ScIndexEnumeration_DataPilotFieldsEnumeration
-o sc.ScIndexEnumeration_DataPilotItemsEnumeration
-o sc.ScIndexEnumeration_DataPilotTablesEnumeration
-o sc.ScIndexEnumeration_DatabaseRangesEnumeration
-o sc.ScIndexEnumeration_FunctionDescriptionEnumeration
-o sc.ScIndexEnumeration_LabelRangesEnumeration
-o sc.ScIndexEnumeration_NamedRangesEnumeration
-o sc.ScIndexEnumeration_ScenariosEnumeration
-o sc.ScIndexEnumeration_SheetCellRangesEnumeration
-o sc.ScIndexEnumeration_SheetLinksEnumeration
-o sc.ScIndexEnumeration_SpreadsheetViewPanesEnumeration
-o sc.ScIndexEnumeration_SpreadsheetsEnumeration
-o sc.ScIndexEnumeration_SubTotalFieldsEnumeration
-o sc.ScIndexEnumeration_TableAutoFormatEnumeration
-o sc.ScIndexEnumeration_TableChartsEnumeration
-o sc.ScIndexEnumeration_TableColumnsEnumeration
-o sc.ScIndexEnumeration_TableConditionalEntryEnumeration
-o sc.ScIndexEnumeration_TableRowsEnumeration
-o sc.ScIndexEnumeration_TextFieldEnumeration
-o sc.ScLabelRangeObj
-o sc.ScLabelRangesObj
-o sc.ScModelObj
-o sc.ScNamedRangeObj
-o sc.ScNamedRangesObj
-o sc.ScRecentFunctionsObj
# -o sc.ScScenariosObj
# -o sc.ScShapeObj
# -o sc.ScSheetLinkObj
-o sc.ScSheetLinksObj
-o sc.ScSpreadsheetSettings
-o sc.ScSpreadsheetSettingsObj
-o sc.ScStyleFamiliesObj
-o sc.ScStyleFamilyObj
# -o sc.ScStyleObj
-o sc.ScSubTotalDescriptorBase
-o sc.ScSubTotalFieldObj
# # i84656 -o sc.ScTabViewObj
# -o sc.ScTableColumnObj
-o sc.ScTableColumnsObj
-o sc.ScTableConditionalEntry
-o sc.ScTableConditionalFormat
# -o sc.ScTableRowObj
-o sc.ScTableRowsObj
# -o sc.ScTableSheetObj
-o sc.ScUniqueCellFormatsEnumeration
-o sc.ScUniqueCellFormatsObj
# -o sc.ScTableSheetsObj
-o sc.ScTableValidationObj
#-o sc.ScViewPaneObj
# #i89411 -o sc.XMLContentExporter
# #i89411 -o sc.XMLContentImporter
# #i89411 -o sc.XMLExporter
# #i89411 -o sc.XMLImporter
# #i89411 -o sc.XMLMetaExporter
# #i89411 -o sc.XMLMetaImporter
-o sc.XMLSettingsExporter
-o sc.XMLSettingsImporter
-o sc.XMLStylesExporter
-o sc.XMLStylesImporter
-o sc.XMLExporter


MEM Read - load init data from file

MEM Read - load init data from file

function block=mdaq_mem_read_sim(block,flag)
    global %microdaq;
    if %microdaq.dsp_loaded == %F then
        select flag
        case 4 // Initialization
            disp("WARNING: mdaq_mem_read block isn''t supported in host simulation mode!")
        end
    else
        // if DSP loaded we can init memory with data file if provided
        select flag
        case 4 // Initialization
            if block.ipar(3) == 3 then
                if block.label <> "" then
                    if strindex(block.label,'file=') == 1 then
                        filename = msscanf(block.label, "file=%s");
                        try
                            data = csvRead(filename);
                        catch
                            warning("Unable load local file " + filename + " to MicroDAQ memory");
                            return;
                        end
                        if size(data, "*") <>  block.ipar(4) then
                            warning("File data do not match MEM Read block data size");
                            return;
                        end
                        mprintf(" ### Loading %s at %d memory index\n", filename, block.ipar(1) + 1);
                        mdaqClose();
                        mdaqDSPWrite(block.rpar(1) + 1, data);

                        return;
                    end
                    warning("Unable to load file data");
                    return;
                end
            end
        end
    end
endfunction

function block=mdaq_mem_read_sim(block,flag)
    global %microdaq;
    if %microdaq.dsp_loaded == %F then
        select flag
        case 4 // Initialization
            disp("WARNING: mdaq_mem_read block isn''t supported in host simulation mode!")
        end
    end
endfunction


Change calibration values and dependencies

//********************************************
//              DATA-IMPORT
//********************************************

// Öffnendialog starten

function [toes, ankle, knee, hip, shoulder, elbow, hand, neck] = readFromMDF(path)

// Einlesen der Daten
delimiter = " ";                                // Ist klar
regex_ignore = '/(Track).*$/';                  // Löschen aller mit "Track" beginnenden Zeilen
header = 5;                                     // Anzahl an Zeilen im Kopf
data = csvRead(data_path, delimiter, [], [], [], regex_ignore, [], header);

// Meta-Daten der Bilder
numberOfTracks = size(data,1) / max(data(:, 2))           // Number of Tracks
numberOfImages = max(data(:, 2))                          // Number of Images per Track
DELTA_T = 0.02;                                 // 50 FPS
CALIBRATION = 227; // 300;                              // Pix per m is correct, get the cal ratio from user via dialog box
Y_RESOLUTION = 479; //576 / 300;                             // Höhe in Pixeln  576!!! 479 bei FElix

// Kalibrieren
data = data / CALIBRATION;
Y_OFFSET = Y_RESOLUTION / CALIBRATION

// Eingelesenen Datensatz gemäß der Logik beim Tracken in 8 Datensätze unterteilen
// Jeder Datensatz wird logisch in x und y Werte unterteilt
// Gelenk.x und Gelenk.y enthalten jeweils eine 1 spaltige Matrix mit Koordinatenwerten
// Multiplikation mit -1 der y-Werte um "natürliches Koordinatensystem" zu erhalten
for i = 1 : numberOfTracks
    if i == 1 then
        toes.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        toes.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_OFFSET;
    elseif i == 2 then
        ankle.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        ankle.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_OFFSET;
    elseif i == 3 then
        knee.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        knee.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_OFFSET;
    elseif i == 4 then
        hip.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        hip.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_OFFSET;
    elseif i == 5 then
        shoulder.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        shoulder.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_OFFSET;
    elseif i == 6 then
        elbow.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        elbow.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_OFFSET;
    elseif i == 7 then
        hand.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        hand.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_OFFSET;
    elseif i == 8 then
        neck.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        neck.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_OFFSET;
    end
end

endfunction

//********************************************
//              DATA-IMPORT
//********************************************

// Öffnendialog starten

function [toes, ankle, knee, hip, shoulder, elbow, hand, neck] = readFromMDF(path)

// Einlesen der Daten
delimiter = " ";                                // Ist klar
regex_ignore = '/(Track).*$/';                  // Löschen aller mit "Track" beginnenden Zeilen
header = 5;                                     // Anzahl an Zeilen im Kopf
data = csvRead(data_path, delimiter, [], [], [], regex_ignore, [], header);

// Meta-Daten der Bilder
numberOfTracks = size(data,1) / max(data(:, 2))           // Number of Tracks
numberOfImages = max(data(:, 2))                          // Number of Images per Track
DELTA_T = 0.02;                                 // 50 FPS
CALIBRATION = 300;                              // Pix per m is correct, get the cal ratio from user via dialog box
Y_RESOLUTION = 576 / 300;                             // Höhe in Pixeln

// Kalibrieren
data = data / CALIBRATION;

// Eingelesenen Datensatz gemäß der Logik beim Tracken in 8 Datensätze unterteilen
// Jeder Datensatz wird logisch in x und y Werte unterteilt
// Gelenk.x und Gelenk.y enthalten jeweils eine 1 spaltige Matrix mit Koordinatenwerten
// Multiplikation mit -1 der y-Werte um "natürliches Koordinatensystem" zu erhalten
for i = 1 : numberOfTracks
    if i == 1 then
        toes.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        toes.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 2 then
        ankle.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        ankle.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 3 then
        knee.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        knee.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 4 then
        hip.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        hip.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 5 then
        shoulder.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        shoulder.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 6 then
        elbow.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        elbow.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 7 then
        hand.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        hand.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    elseif i == 8 then
        neck.x = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 3);
        neck.y = data(numberOfImages*(i - 1) + 1:i*numberOfImages , 4) * (-1) + Y_RESOLUTION;
    end
end

endfunction


INTEGRATION: CWS unoapi1 (1.4.280); FILE MERGED 2007/10/02 09:20:00 cn 1.4.280.1: #i79479# update lists

# -o forms.OButtonControl
# -o forms.OButtonModel
#- o forms.OCheckBoxControl
# -o forms.OCheckBoxModel
# -o forms.OComboBoxControl
# -o forms.OComboBoxModel
# -o forms.OCurrencyControl
# -o forms.OCurrencyModel
# -o forms.ODatabaseForm
# -o forms.ODateControl
# -o forms.ODateModel
# -o forms.OEditControl
# -o forms.OEditModel
# -o forms.OFileControlModel
# -o forms.OFixedTextModel
# -o forms.OFormattedControl
# -o forms.OFormattedFieldWrapper
# -o forms.OFormsCollection
# -o forms.OGridControlModel
# -o forms.OGroupBoxControl
# -o forms.OGroupBoxModel
# -o forms.OHiddenModel
# -o forms.OImageButtonControl
# -o forms.OImageButtonModel
# -o forms.OImageControlControl
# -o forms.OImageControlModel
# -o forms.OListBoxControl
# -o forms.OListBoxModel
# -o forms.ONavigationBarControl
# -o forms.ONavigationBarModel
# -o forms.ONumericControl
# -o forms.ONumericModel
# -o forms.OPatternControl
# -o forms.OPatternModel
# -o forms.ORadioButtonControl
# -o forms.ORadioButtonModel
# -o forms.OScrollBarModel
# -o forms.OSpinButtonModel
# -o forms.OTimeControl
# -o forms.OTimeModel

-o forms.OGridControlModel
-o forms.OImageButtonModel
-o forms.OGroupBoxModel
-o forms.OFormattedFieldWrapper
-o forms.OImageControlModel
-o forms.OEditControl
-o forms.OTimeControl
-o forms.OButtonControl
-o forms.OButtonModel
-o forms.OCheckBoxControl
-o forms.OCheckBoxModel
-o forms.OComboBoxControl
-o forms.OComboBoxModel
-o forms.OCurrencyControl
-o forms.OCurrencyModel
### i30258 ###-o forms.ODatabaseForm
-o forms.ODateControl
-o forms.ODateModel
-o forms.OFileControlModel
-o forms.OFixedTextModel
-o forms.OFormattedControl
-o forms.OFormsCollection
-o forms.OGroupBoxControl
-o forms.OHiddenModel
-o forms.OImageButtonControl
-o forms.OImageControlControl
-o forms.OListBoxControl
-o forms.OListBoxModel
-o forms.ONumericControl
-o forms.ONumericModel
-o forms.OPatternControl
-o forms.OPatternModel
-o forms.ORadioButtonControl
-o forms.ORadioButtonModel
-o forms.OTimeModel
-o forms.OSpinButtonModel
-o forms.OScrollBarModel
-o forms.ONavigationBarControl
-o forms.ONavigationBarModel
-o forms.OEditModel


axis -> mtlb_axis

axis -> mtlb_axis

// IMMUNOGENEIC_TUMOR_GROWTH model for tumor immune interaction
//
//   REFERENCE: Kuznetsov et al. (1994) Bull Math Biol 56, 295-321
//
//   University Lyon 1 - 2014-2015

function dXdt = oderhs(t,X)
    // F rhs of the ODE system dX/dt = f(X)
    //
    //   X = (x,y)
    //
    //   dx/dt = sigma + rho*x*y/(eta + y) - mu*x*y - delta*x
    //   dy/dt = alpha*y*(1-beta*y) - x*y

    // Non-dimensional model
    // System parameters
    sigma = 0.1181;
    rho = 1.131;
    eta = 20.19;
    mu = 0.00311;
    delta = 0.3743;
    alpha = 1.636;
    beta_par = 1e-2;

    x = X(1);
    y = X(2);

    dXdt = [sigma + rho*x.*y./(eta + y) - mu*x.*y - delta*x;
            alpha*y.*(1-beta_par*y) - x.*y];

endfunction

function x = nullx(y)
    // NULLX nullcline for x (dxdt = 0 when x = nullx(y))

    // Non-dimensional model
    // System parameters
    sigma = 0.1181;
    rho = 1.131;
    eta = 20.19;
    mu = 0.00311;
    delta = 0.3743;
    alpha = 1.636;
    beta_par = 1e-2;

    x = sigma./(delta+mu*y-rho*y./(eta+y));

endfunction

function x = nully(y)
    // NULLX nullcline for y (dydt = 0 when x = nully(y))

    // Non-dimensional model
    // System parameters
    sigma = 0.1181;
    rho = 1.131;
    eta = 20.19;
    mu = 0.00311;
    delta = 0.3743;
    alpha = 1.636;
    beta_par = 1e-2;

    x = alpha*(1-beta_par*y);

endfunction

// Simulations
// Compute a single trajectory with defined initial condition in interval [0,tfinal]
ic = [0.7616; 268.7980];
t0 = 0;
tspan = 0:100;
X = ode(ic,t0,t,oderhs);

//// Plot the trajectory in the phase space
figure(1); clf;
plot(X(1,:),X(2,:))
// plot the positive x-nullcline
yy = logspace(-1,3,300);
yyp = yy(nullx(yy)>0)
plot(nullx(yyp),yyp,'k')
// plot the y-nullcline
plot(nully(yy),yy,'r')
mtlb_axis([1e-1 5 1e-1 1e3])
xlabel('x')
ylabel('y')

// IMMUNOGENEIC_TUMOR_GROWTH model for tumor immune interaction
//
//   REFERENCE: Kuznetsov et al. (1994) Bull Math Biol 56, 295-321
//
//   University Lyon 1 - 2014-2015

function dXdt = oderhs(t,X)
    // F rhs of the ODE system dX/dt = f(X)
    //
    //   X = (x,y)
    //
    //   dx/dt = sigma + rho*x*y/(eta + y) - mu*x*y - delta*x
    //   dy/dt = alpha*y*(1-beta*y) - x*y

    // Non-dimensional model
    // System parameters
    sigma = 0.1181;
    rho = 1.131;
    eta = 20.19;
    mu = 0.00311;
    delta = 0.3743;
    alpha = 1.636;
    beta_par = 1e-2;

    x = X(1);
    y = X(2);

    dXdt = [sigma + rho*x.*y./(eta + y) - mu*x.*y - delta*x;
            alpha*y.*(1-beta_par*y) - x.*y];

endfunction

function x = nullx(y)
    // NULLX nullcline for x (dxdt = 0 when x = nullx(y))

    // Non-dimensional model
    // System parameters
    sigma = 0.1181;
    rho = 1.131;
    eta = 20.19;
    mu = 0.00311;
    delta = 0.3743;
    alpha = 1.636;
    beta_par = 1e-2;

    x = sigma./(delta+mu*y-rho*y./(eta+y));

endfunction

function x = nully(y)
    // NULLX nullcline for y (dydt = 0 when x = nully(y))

    // Non-dimensional model
    // System parameters
    sigma = 0.1181;
    rho = 1.131;
    eta = 20.19;
    mu = 0.00311;
    delta = 0.3743;
    alpha = 1.636;
    beta_par = 1e-2;

    x = alpha*(1-beta_par*y);

endfunction

// Simulations
// Compute a single trajectory with defined initial condition in interval [0,tfinal]
ic = [0.7616; 268.7980];
t0 = 0;
tspan = 0:100;
X = ode(ic,t0,t,oderhs);

//// Plot the trajectory in the phase space
figure(1); clf;
plot(X(1,:),X(2,:))
// plot the positive x-nullcline
yy = logspace(-1,3,300);
yyp = yy(nullx(yy)>0)
plot(nullx(yyp),yyp,'k')
// plot the y-nullcline
plot(nully(yy),yy,'r')
axis([1e-1 5 1e-1 1e3])
xlabel('x')
ylabel('y')


sb120: #i111042# disabled failing tests for now

-o sd.AccessibleDrawDocumentView
-o sd.AccessibleOutlineView
#i35935# -o sd.AccessibleSlideView
#i111042# -o sd.DrawController_DrawView
#i111042# -o sd.DrawController_HandoutView
#i111042# -o sd.DrawController_NotesView
-o sd.DrawController_OutlineView
#i111042# -o sd.DrawController_PresentationView
-o sd.SdDocLinkTargets
-o sd.SdDrawPage
-o sd.SdDrawPagesAccess
-o sd.SdGenericDrawPage
-o sd.SdLayer
-o sd.SdLayerManager
-o sd.SdMasterPage
-o sd.SdMasterPagesAccess
-o sd.SdPageLinkTargets
-o sd.SdXCustomPresentation
-o sd.SdXCustomPresentationAccess
#i84994# -o sd.SdXImpressDocument
-o sd.SdXPresentation
#i87746 -o sd.SdXShape

-o sd.AccessibleDrawDocumentView
-o sd.AccessibleOutlineView
#i35935# -o sd.AccessibleSlideView
-o sd.DrawController_DrawView
-o sd.DrawController_HandoutView
-o sd.DrawController_NotesView
-o sd.DrawController_OutlineView
-o sd.DrawController_PresentationView
-o sd.SdDocLinkTargets
-o sd.SdDrawPage
-o sd.SdDrawPagesAccess
-o sd.SdGenericDrawPage
-o sd.SdLayer
-o sd.SdLayerManager
-o sd.SdMasterPage
-o sd.SdMasterPagesAccess
-o sd.SdPageLinkTargets
-o sd.SdXCustomPresentation
-o sd.SdXCustomPresentationAccess
#i84994# -o sd.SdXImpressDocument
-o sd.SdXPresentation
#i87746 -o sd.SdXShape


Fix for silab 6.0.0

Fix for silab 6.0.0

function  mdaq_ai_scan_init(arg1, arg2, arg3, arg4, arg5, arg6)
    link_id = -1;

    if argn(2) == 5 then
        channels = arg1;
        ai_range = arg2;
        differential = arg3;
        scan_freq = arg4;
        scan_time = arg5;
    end

    if argn(2) == 6 then
        link_id = arg1;
        channels = arg2;
        ai_range = arg3;
        differential = arg4;
        scan_freq = arg5;
        scan_time = arg6;

        if link_id < 0 then
            disp("ERROR: Invalid link ID!")
            return;
        end
    end

    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        adc_info = get_adc_info(%microdaq.private.mdaq_hwid);
        if argn(2) > 6 | argn(2) < 5 then
            mprintf("Description:\n");
            mprintf("\tInit AI scan\n");
            mprintf("Usage:\n");
            mprintf("\tmdaq_ai_scan_init(link_id, channels, range, differential, frequency, time);\n");               mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
            mprintf("\tchannels - analog input channels to read\n");
            mprintf("\trange - analog input range:\n");
            for i = 1:size(adc_info.c_params.c_range_desc, "r")
                mprintf("\t    %s\n", string(i) + ": " + adc_info.c_params.c_range_desc(i));
            end

            if adc_info.c_params.c_diff(1) == 1 then
                mprintf("\tdifferential - measurement type (%%T - differential, %%F - single-ended)\n");
            else
                mprintf("\tdifferential - set %%F (differential mode not supported by AI converter)\n");
            end

            mprintf("\tfrequency - scan frequency\n");
            mprintf("\tduration - scan duration in seconds\n");
            return;
        end
    else
        error('Unable to detect MicroDAQ confituration - run mdaq_hwinfo and try again!');
        return;
    end

    if scan_time < 0 then
        scan_time = -1;
    end

    adc_ch_count = strtod(adc_info.channel);
    if differential then
        adc_ch_count = adc_ch_count / 2;
    end

    ch_count = max(size(channels));
    if ch_count < 1 | ch_count > adc_ch_count then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    if max(channels) > adc_ch_count | min(channels) < 1 then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    try
        bipolar = adc_info.c_params.c_bipolar(ai_range);
        ai_range_desc = adc_info.c_params.c_range_desc(ai_range);
        ai_range = adc_info.c_params.c_range(ai_range);
    catch
        error("Error: wrong AI range selected!");
    end

    if differential == %F | differential == 0 then
        differential = 28;
    else
        differential = 29;
    end

    if argn(2) == 5 then
        link_id = mdaq_open();
        if link_id < 0 then
            disp("ERROR: Unable to connect to MicroDAQ device!");
            return;
        end
    end

    result = [];
    result = call("sci_mlink_ai_scan_init",..
            link_id, 1, "i",..
            channels, 2, "i",..
            ch_count, 3, "i",..
            ai_range, 4, "i",..
            bipolar, 5, "i",..
            differential, 6, "i",..
            scan_freq, 7, "d",..
            scan_time, 8, "d",..
        "out",..
            [1, 1], 9, "i");

    disp("result: ");
    disp(result);
    if result < 0 & result <> -88 then
            error(mdaq_error(result), 10000 + abs(result))
    else
        if result == -88 then
            disp("Warninng: AI scanning interrupted!")
            mdaq_ai_scan_stop()

            // time to terminate TCP connection
            sleep(200);

            result = call("sci_mlink_ai_scan_init",..
                    link_id, 1, "i",..
                    channels, 2, "i",..
                    ch_count, 3, "i",..
                    ai_range, 4, "i",..
                    bipolar, 5, "i",..
                    differential, 6, "i",..
                    scan_freq, 7, "d",..
                    scan_time, 8, "d",..
                "out",..
                    [1, 1], 9, "i");
        end

        mprintf("Data acquisition session settings:\n");

        str = "";
        s = size(channels);
        for j=1:s(2)
            if j > 1
              str = str + ", ";
            end
            str = str + string(channels(1,j));
        end
        mprintf("\tChannles:\t%s\n", str);

        mprintf("\tInput Type:\t");
        if differential == 29 then
            mprintf("Differential\n");
        else
            mprintf("Single Ended\n");
        end

        mprintf("\tRange:\t\t");
        mprintf("%s\n", ai_range_desc);

        if scan_freq >= 1000
            mprintf("\tFrequency:\t%.3fkHz\n", scan_freq/1000);
        else
            mprintf("\tFrequency:\t%dHz\n", scan_freq);
        end

        if scan_time < 0
            mprintf("\tDuration:\tInf\n");
            mprintf("\tScan count:\tInf");
        else
            mprintf("\tDuration:\t%.2fsec\n", scan_time);
            mprintf("\tScan count:\t%d\n", scan_time * scan_freq);
        end
    end

    if argn(2) == 5 then
        mdaq_close(link_id);
    end

endfunction

function  mdaq_ai_scan_init(arg1, arg2, arg3, arg4, arg5, arg6)
    link_id = -1;

    if argn(2) == 5 then
        channels = arg1;
        ai_range = arg2;
        differential = arg3;
        scan_freq = arg4;
        scan_time = arg5;
    end

    if argn(2) == 6 then
        link_id = arg1;
        channels = arg2;
        ai_range = arg3;
        differential = arg4;
        scan_freq = arg5;
        scan_time = arg6;

        if link_id < 0 then
            disp("ERROR: Invalid link ID!")
            return;
        end
    end

    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        adc_info = get_adc_info(%microdaq.private.mdaq_hwid);
        if argn(2) > 6 | argn(2) < 5 then
            mprintf("Description:\n");
            mprintf("\tInit AI scan\n");
            mprintf("Usage:\n");
            mprintf("\tmdaq_ai_scan_init(link_id, channels, range, differential, frequency, time);\n");               mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
            mprintf("\tchannels - analog input channels to read\n");
            mprintf("\trange - analog input range:\n");
            for i = 1:size(adc_info.c_params.c_range_desc, "r")
                mprintf("\t    %s\n", string(i) + ": " + adc_info.c_params.c_range_desc(i));
            end

            if adc_info.c_params.c_diff(1) == 1 then
                mprintf("\tdifferential - measurement type (%%T - differential, %%F - single-ended)\n");
            else
                mprintf("\tdifferential - set %%F (differential mode not supported by AI converter)\n");
            end

            mprintf("\tfrequency - scan frequency\n");
            mprintf("\tduration - scan duration in seconds\n");
            return;
        end
    else
        error('Unable to detect MicroDAQ confituration - run mdaq_hwinfo and try again!');
        return;
    end

    if scan_time < 0 then
        scan_time = -1;
    end

    adc_ch_count = strtod(adc_info.channel);
    if differential then
        adc_ch_count = adc_ch_count / 2;
    end

    ch_count = max(size(channels));
    if ch_count < 1 | ch_count > adc_ch_count then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    if max(channels) > adc_ch_count | min(channels) < 1 then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    try
        bipolar = adc_info.c_params.c_bipolar(ai_range);
        ai_range_desc = adc_info.c_params.c_range_desc(ai_range);
        ai_range = adc_info.c_params.c_range(ai_range);
    catch
        error("Error: wrong AI range selected!");
    end

    if differential == %F | differential == 0 then
        differential = 28;
    else
        differential = 29;
    end

    if argn(2) == 5 then
        link_id = mdaq_open();
        if link_id < 0 then
            disp("ERROR: Unable to connect to MicroDAQ device!");
            return;
        end
    end

    result = [];
    result = call("sci_mlink_ai_scan_init",..
            link_id, 1, "i",..
            channels, 2, "i",..
            ch_count, 3, "i",..
            ai_range, 4, "i",..
            bipolar, 5, "i",..
            differential, 6, "i",..
            scan_freq, 7, "d",..
            scan_time, 8, "d",..
        "out",..
            [1, 1], 9, "i");

    disp("result: ");
    disp(result);
    if result < 0 & result <> -88 then
            error(mdaq_error(result), 10000 + abs(result))
    else
        if result == -88 then
            disp("Warninng: AI scanning interrupted!")
            mdaq_ai_scan_stop()

            // time to terminate TCP connection
            sleep(200);

            result = call("sci_mlink_ai_scan_init",..
                    link_id, 1, "i",..
                    channels, 2, "i",..
                    ch_count, 3, "i",..
                    ai_range, 4, "i",..
                    bipolar, 5, "i",..
                    differential, 6, "i",..
                    scan_freq, 7, "d",..
                    scan_time, 8, "d",..
                "out",..
                    [1, 1], 9, "i");
        end

        mprintf("Data acquisition session settings:\n");

        str = [];
        s = size(channels);
        for j=1:s(2)
            if j > 1
              str = str + ", ";
            end
            str = str + string(channels(1,j));
        end
        mprintf("\tChannles:\t%s\n", str);

        mprintf("\tInput Type:\t");
        if differential == 29 then
            mprintf("Differential\n");
        else
            mprintf("Single Ended\n");
        end

        mprintf("\tRange:\t\t");
        mprintf("%s\n", ai_range_desc);

        if scan_freq >= 1000
            mprintf("\tFrequency:\t%.3fkHz\n", scan_freq/1000);
        else
            mprintf("\tFrequency:\t%dHz\n", scan_freq);
        end

        if scan_time < 0
            mprintf("\tDuration:\tInf\n");
            mprintf("\tScan count:\tInf");
        else
            mprintf("\tDuration:\t%.2fsec\n", scan_time);
            mprintf("\tScan count:\t%d\n", scan_time * scan_freq);
        end
    end

    if argn(2) == 5 then
        mdaq_close(link_id);
    end

endfunction


fix for SCHEDULING-1393

fix for SCHEDULING-1393

git-svn-id: 27916816d6cfa57849e9a885196bf7392b80e1ac@20855 28e8926c-6b08-0410-baaa-805c5e19b8d6

function [] = PAinit()

    global ('PA_initialized', 'PA_scheduler_dir')

    jautoUnwrap(%t);

    version = ver();
    if strtod(part(version(1,2),1)) < 5
        error('This toolkit cannot be run on a version of Scilab anterior to version 5');
    end
    if ~exists('PA_scheduler_dir')
        error('The environment variable SCHEDULER_HOME must be defined, use setenv to define it in Scilab');
    end
    // disp(PA_scheduler_dir)
    if ~isdir(PA_scheduler_dir)
        error(strcat(['The path "',schedulerdir,'" doesn''t exist or is not a directory']));
    end
    plugins_dir = fullfile(PA_scheduler_dir,'plugins');
    if isdir(plugins_dir) then
        release_dir = listfiles(fullfile(PA_scheduler_dir,'plugins','org.ow2.proactive.scheduler.lib_*'));
        dist_lib_dir = fullfile(release_dir,'lib')
    else
        dist_lib_dir = fullfile(PA_scheduler_dir,'dist','lib');
    end
    schedjar=fullfile(dist_lib_dir,'ProActive.jar');
    if length(fileinfo(schedjar)) == 0
        error(strcat(['Can''t locate the scheduler jar at ""';schedjar;'"" , please make sure that SCHEDULER_HOME refers to the correct directory.']));
    end
    opt=PAoptions();

    jimport java.io.File;

    // Log4J file
    log4jFile = File.new(strcat([PA_scheduler_dir, filesep(), 'config', filesep(), 'log4j', filesep(), 'log4j-client']));
    log4jFileUri = jinvoke(log4jFile,'toURI');
    urlLog4jFile = jinvoke(log4jFileUri,'toURL');
    finalstring = jinvoke(urlLog4jFile,'toExternalForm');
    system_setproperty('log4j.configuration',finalstring);
    system_setproperty('proactive.configuration', opt.ProActiveConfiguration);

    // Policy
    system_setproperty('java.security.policy',strcat([PA_scheduler_dir, filesep(), 'config', filesep(), 'security.java.policy-client']));
    jremove(log4jFile);

    sep=pathsep();

    // Add ProActive Scheduler to the scilab classpath
    initcp = javaclasspath();
    if strcmp(getos(),'Windows') == 0
        for i=1:size(initcp,1)
            initcp(i)=getlongpathname(strsubst(initcp(1),'%20',' '))
        end
    end

    listjars = opt.ProActiveJars;

    cp = initcp;

    for i=1:size(listjars,1)
        cp = [cp; fullfile(dist_lib_dir,listjars(i).entries)];
    end

    javaclasspath(cp);

    // Call the native JNI connection to the Scheduler classes
    //initEmbedded();

    PA_initialized = 1;

endfunction

function [] = PAinit()

    global ('PA_initialized', 'PA_scheduler_dir')

    jautoUnwrap(%t);

    version = ver();
    if strtod(part(version(1,2),1)) < 5
        error('This toolkit cannot be run on a version of Scilab anterior to version 5');
    end
    if ~exists('PA_scheduler_dir')
        error('The environment variable SCHEDULER_HOME must be defined, use setenv to define it in Scilab');
    end
    // disp(PA_scheduler_dir)
    if ~isdir(PA_scheduler_dir)
        error(strcat(['The path "',schedulerdir,'" doesn''t exist or is not a directory']));
    end
    plugins_dir = fullfile(PA_scheduler_dir,'plugins');
    if isdir(plugins_dir) then
        release_dir = listfiles(fullfile(PA_scheduler_dir,'plugins','org.ow2.proactive.scheduler.lib_*'));
        dist_lib_dir = fullfile(release_dir,'lib')
    else
        dist_lib_dir = fullfile(PA_scheduler_dir,'dist','lib');
    end
    schedjar=fullfile(dist_lib_dir,'ProActive.jar');
    if length(fileinfo(schedjar)) == 0
        error(strcat(['Can''t locate the scheduler jar at ""';schedjar;'"" , please make sure that SCHEDULER_HOME refers to the correct directory.']));
    end
    opt=PAoptions();

    jimport java.io.File;

    // Log4J file
    log4jFile = File.new(strcat([PA_scheduler_dir, filesep(), 'config', filesep(), 'log4j', filesep(), 'log4j-client']));
    log4jFileUri = jinvoke(log4jFile,'toURI');
    urlLog4jFile = jinvoke(log4jFileUri,'toURL');
    finalstring = jinvoke(urlLog4jFile,'toExternalForm');
    system_setproperty('log4j.configuration',finalstring);
    system_setproperty('proactive.configuration', opt.ProActiveConfiguration);

    // Policy
    system_setproperty('java.security.policy',strcat([PA_scheduler_dir, filesep(), 'config', filesep(), 'security.java.policy-client']));
    jremove(log4jFile);

    sep=pathsep();

    // Add ProActive Scheduler to the scilab classpath
    initcp = javaclasspath();
    if strcmp(getos(),'Windows') == 0
        for i=1:size(initcp,1)
            initcp(i)=getlongpathname(strsubst(initcp(1),'%20',' '))
        end
    end

    listjars = opt.ProActiveJars;

    cp = initcp;

    for i=1:size(listjars,1)
        cp = [cp; fullfile(dist_lib_dir,listjars(i).entries)];
    end

    javaclasspath(cp);

    // Call the native JNI connection to the Scheduler classes
    //initEmbedded();

    PA_initialized = 1;
    predef(1);

endfunction


Change task object member order

Change task object member order

function %dsptlist_p(obj)
    mprintf("DSP application object\n")
    mprintf("  .init() - initializes DSP application\n")
    mprintf("  .start() - starts application\n")
    mprintf("  .write() - writes data\n")
    mprintf("  .read() - reads DSP data\n")
    mprintf("  .stop() - stops applications\n")
    mprintf("  .isDone() - checks if application is complited\n")
    mprintf("  .waitUntilDone() - waits until application is complited\n")
endfunction

function %dsptlist_p(obj)
    mprintf("DSP task object\n")
    mprintf("   .start() - starts task\n")
    mprintf("   .init() - initializes DSP task\n")
    mprintf("   .write() - writes DSP data\n")
    mprintf("   .read() - reads DSP data\n")
    mprintf("   .stop() - stops task\n")
    mprintf("   .isDone() - checks if task is done\n")
    mprintf("   .waitUntilDone() - blocks until task is done\n")
endfunction


Print error desc when mdaq_error calles

Print error desc when mdaq_error calles

function error_desc = mdaq_error(error_id)
    result = 0;
    [error_desc, result] = call("sci_mlink_error",..
            error_id, 1, 'i',..
        "out",..
            [1, 64], 2, 'c',..
            [1,1], 3, 'i');
     disp(error_desc);
endfunction

function error_desc = mdaq_error(error_id)
    result = 0;
    [error_desc, result] = call("sci_mlink_error",..
            error_id, 1, 'i',..
        "out",..
            [1, 64], 2, 'c',..
            [1,1], 3, 'i');
endfunction


Fix wrong macro name

Fix wrong macro name

function result = mlink_set_obj(connection_id, obj_name, obj_value)
    result = call("sci_mlink_set_obj",..
                        connection_id, 1, "i",..
                        obj_name, 2, "c",..
                        obj_value, 3, "r",..
                        1, 4, "i",..
                    "out",..
                        [1,1], 5, "i");
endfunction

function result = mdaq_set_obj(connection_id, obj_name, obj_value)
    result = call("sci_mlink_set_obj",..
                        connection_id, 1, "i",..
                        obj_name, 2, "c",..
                        obj_value, 3, "r",..
                        1, 4, "i",..
                    "out",..
                        [1,1], 5, "i");
    if result < 0 then
        disp(mdaq_error(result));
    end
endfunction


Fix wrong if statement

Fix wrong if statement

function mdaq_ao_data_queue(arg1, arg2, arg3)
    global %microdaq;
    link_id = -1;

    if argn(2) == 2 then
        data = arg1;
        blocking = arg2;
    end

    if argn(2) == 3 then
        link_id = arg1;
        data = arg2;
        blocking = arg3;

        if link_id < 0 then
            error("ERROR: Invalid link ID!")
            return;
        end
    end

    if argn(2) > 3 | argn(2) < 2 then
        mprintf("Description:\n");
        mprintf("\tQueues AO channel data in scanning continuous mode.\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_ao_data_queue(link_id, data, blocking);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tdata - AO scan data\n");
        mprintf("\tblocking - blocking mode (1-enable, 0-disable)\n");
        return;
    end

    if argn(2) == 2 then
        link_id = mdaq_open();
        if link_id < 0 then
            error("ERROR: Unable to connect to MicroDAQ device!");
            return;
        end
    end

//    if size(data, "c") > 1 & size(data, "r") > 1 then
//        error("ERROR: Wrong AO scan data size");
//        return
//    end
    data_size = size(data, "*");
    if %microdaq.private.ao_scan_ch_count <> size(data, "c") &..
       %microdaq.private.ao_scan_ch_count <> -1 then

        if link_id > -1 then
            mdaq_close(link_id);
        end
        error("ERROR: Wrong AO scan data size");
        return
    end

//MDAQ_API void sci_mlink_ao_data_queue(
//		IO		int 		*link_fd,
//		IN		double      *data,
//		IN		int			*data_size,
//		IN		int			*blocking,
//		OUT		int			*result)
//    mprintf("link_fd: %d\n", link_id)
//    disp(data);

    result = [];
    result = call("sci_mlink_ao_data_queue",..
                link_id, 1, "i",..
                data, 2, "d",..
                data_size, 3, "i",..
                blocking, 4, "i",..
                "out",..
                [1, 1], 5, "i");

    if result < 0  then
        mdaq_error(result)
    end

    if argn(2) == 2 then
        mdaq_close(link_id);
    end
endfunction

function mdaq_ao_data_queue(arg1, arg2, arg3)
    global %microdaq;
    link_id = -1;

    if argn(2) == 2 then
        data = arg1;
        blocking = arg2;
    end

    if argn(2) == 3 then
        link_id = arg1;
        data = arg2;
        blocking = arg3;

        if link_id < 0 then
            error("ERROR: Invalid link ID!")
            return;
        end
    end

    if argn(2) > 3 | argn(2) < 2 then
        mprintf("Description:\n");
        mprintf("\tQueues AO channel data in scanning continuous mode.\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_ao_data_queue(link_id, data, blocking);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tdata - AO scan data\n");
        mprintf("\tblocking - blocking mode (1-enable, 0-disable)\n");
        return;
    end

    if argn(2) == 2 then
        link_id = mdaq_open();
        if link_id < 0 then
            error("ERROR: Unable to connect to MicroDAQ device!");
            return;
        end
    end

//    if size(data, "c") > 1 & size(data, "r") > 1 then
//        error("ERROR: Wrong AO scan data size");
//        return
//    end
    data_size = size(data, "*");
    if %microdaq.private.ao_scan_ch_count <> size(data, "c")..
        and %microdaq.private.ao_scan_ch_count <> -1 then

        if link_id > -1 then
            mdaq_close(link_id);
        end
        error("ERROR: Wrong AO scan data size");
        return
    end

//MDAQ_API void sci_mlink_ao_data_queue(
//		IO		int 		*link_fd,
//		IN		double      *data,
//		IN		int			*data_size,
//		IN		int			*blocking,
//		OUT		int			*result)
//    mprintf("link_fd: %d\n", link_id)
//    disp(data);

    result = [];
    result = call("sci_mlink_ao_data_queue",..
                link_id, 1, "i",..
                data, 2, "d",..
                data_size, 3, "i",..
                blocking, 4, "i",..
                "out",..
                [1, 1], 5, "i");

    if result < 0  then
        mdaq_error(result)
    end

    if argn(2) == 2 then
        mdaq_close(link_id);
    end
endfunction