fix for SCHEDULING-1380

fix for SCHEDULING-1380

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

function outputs = PAsolve(varargin)
    global ('PA_connected','DataRegistry', 'DataRegistryInit', 'SOLVEid')

    if ~exists('PA_connected') | PA_connected ~= 1
        error('A connection to the ProActive scheduler must be established in order to use PAsolve, see PAconnect');
    end

    if exists('SOLVEid') & type(SOLVEid) == 8
        SOLVEid = SOLVEid + 1;
    else
        SOLVEid = int32(0);
    end

    opt=PAoptions();

    deff ("y=ischar(x)","y=type(x)==10","n");
    if ischar(varargin(1)) then
        Func = varargin(1);
        NN=length(varargin)-1;
        Tasks = PATask(1,NN);
        Tasks(1,1:NN).Func = Func;
        for i=1:NN
            if typeof(varargin(i+1)) == 'list'
                Tasks(1,i).Params =varargin(i+1);
            else
                Tasks(1,i).Params =list(varargin(i+1));
            end
        end
        MM = 1;
    elseif typeof(varargin(1)) == 'PATask'
        if length(varargin) == 1
            Tasks = varargin(1);
            NN = size(Tasks,2);
            MM = size(Tasks,1);
        else
            NN=argn(2);
            MM = -1;
            for i=1:NN
                if typeof(varargin(i)) == 'PATask'
                    if (size(varargin(i),2) ~= 1)
                        error(strcat(['parameter ', string(i), ' should be a column vector.']));
                    end
                    sz = size(varargin(i),1);
                    if MM == -1
                        MM = sz;
                        Tasks=PATask(MM,NN);
                    elseif MM ~= sz
                        error(strcat(['parameter ', string(i), ' should be a column vector of the same length than other parameters.']));
                    end
                    Tasks(1:sz,i) = varargin(i);
                else
                    error(strcat(['parameter ', num2str(i), ' is a ', typeof(varargin(i)), ', expected PATask instead.']));
                end
            end

        end
    end

    jimport org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabGlobalConfig;
    jimport org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabTaskConfig;
    jimport org.ow2.proactive.scheduler.ext.common.util.FileUtils;
    jimport org.ow2.proactive.scheduler.ext.matsci.client.AODataspaceRegistry;
    jimport java.lang.String;
    jimport java.net.URL;
    jimport java.io.File;

    solve_config = jnewInstance(PASolveScilabGlobalConfig);

    solve_config.setDebug(opt.Debug);
    solve_config.setTimeStamp(opt.TimeStamp);
    solve_config.setFork(opt.Fork);
    solve_config.setRunAsMe(opt.RunAsMe);
    solve_config.setPriority(opt.Priority);
    solve_config.setTransferSource(opt.TransferSource);
    //solve_config.setTransferEnv(opt.TransferEnv);
    solve_config.setTransferVariables(opt.TransferVariables);
    solve_config.setKeepEngine(opt.KeepEngine);
    jinvoke(solve_config,'setWindowsStartupOptionsAsString',opt.WindowsStartupOptions);
    jinvoke(solve_config,'setLinuxStartupOptionsAsString',opt.LinuxStartupOptions);

    solve_config.setInputSpaceName('ScilabInputSpace');
    solve_config.setOutputSpaceName('ScilabOutputSpace');

    solve_config.setVersionPref(opt.VersionPref);
    solve_config.setVersionRejAsString(opt.VersionRej);
    solve_config.setVersionMin(opt.VersionMin);
    solve_config.setVersionMax(opt.VersionMax);
    solve_config.setCheckMatSciUrl(opt.FindScilabScript);
    if ischar(opt.CustomScript)
        selects = opt.CustomScript
        try
            url=URL.new(selects);
            ok = true;
        catch
            ok = false;
        end
        jremove(url);

        if ~ok
            solve_config.setCustomScriptUrl(strcat(['file:', selects]));
        else
            solve_config.setCustomScriptUrl(selects);
        end
    end

    solve_config.setZipSourceFiles(%f);

    curr_dir = pwd();
    fs=filesep();
    curr_dir_java = File.new(curr_dir);
    if ~jinvoke(curr_dir_java,'canWrite')
        jremove(curr_dir_java);
        error('Current Directory should have write access rights');
    end
    jremove(curr_dir_java);

    // PAScheduler sub directory init

    subdir = '.PAScheduler';
    solve_config.setTempSubDirName(subdir);

    if isempty(opt.CustomDataspaceURL)
        if ~isdir(strcat([curr_dir, fs, subdir]))
            mkdir(curr_dir,subdir);
        end
        pa_dir = strcat([curr_dir, fs, subdir]);
    else
        if isempty(opt.CustomDataspacePath)
            error('if CustomDataspaceURL is specified, CustomDataspacePath must be specified also');
        end
        if ~isdir(strcat([opt.CustomDataspacePath, fs, subdir]))
            mkdir(opt.CustomDataspacePath,subdir);
        end
        pa_dir = strcat([opt.CustomDataspacePath, fs, subdir]);
    end

    if isempty(opt.CustomDataspaceURL)
        if ~exists('DataRegistryInit') | DataRegistryInit ~= 1
            DataRegistry = AODataspaceRegistry.new('ScilabInputSpace','ScilabOutputSpace','ScilabSession',opt.Debug);
            DataRegistryInit = 1;
        end
        pair = DataRegistry.createDataSpace(curr_dir);
        px=jinvoke(pair,'getX');
        py=jinvoke(pair,'getY');
        pxs = jcast(px,'java.lang.String');
        pys = jcast(py,'java.lang.String');
        solve_config.setInputSpaceURL(pxs);
        solve_config.setOutputSpaceURL(pys);
        if opt.Debug then
            disp('using Dataspace:')
            disp(pxs)
        end

    else
        solve_config.setOutputSpaceURL(opt.CustomDataspaceURL);
        solve_config.setInputSpaceURL(opt.CustomDataspaceURL);
    end

    variableInFileBaseName = ['ScilabPAsolveVarIn_' string(SOLVEid)];
    variableOutFileBaseName = ['ScilabPAsolveVarOut_' string(SOLVEid)];
    outVarFiles = list(NN);
    //tmpFiles = list();
    taskFilesToClean = list();

    task_configs = jarray('org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabTaskConfig', NN,MM);
    for i=1:NN
        taskFilesToClean($+1)=list();
        for j=1:MM
            t_conf = jnewInstance(PASolveScilabTaskConfig);
            task_configs(i-1,j-1) = t_conf;
            if ~isempty(Tasks(j,i).Description) then
                t_conf.setDescription(Tasks(j,i).Description);
            end

            // Input Files
            if ~isempty(Tasks(j,i).InputFiles) then
                ilen = length(Tasks(j,i).InputFiles);
                if ilen > 0 then
                    inputFiles = jarray('java.lang.String', ilen);
                    filelist = Tasks(j,i).InputFiles;
                    for k=1:ilen
                        filename = filelist(k);
                        inputFiles(k-1)=String.new(strsubst(filename,'\','/'));
                    end

                    t_conf.setInputFiles(inputFiles);
                    t_conf.setInputFilesThere(%t);
                end
            end

            // Output Files
            if ~isempty(Tasks(j,i).OutputFiles) then
                filelist = Tasks(j,i).OutputFiles;
                ilen = length(filelist);
                if ilen > 0 then
                    outputFiles = jarray('java.lang.String', ilen);
                    for k=1:ilen
                        filename = filelist(k);
                        outputFiles(k-1)=String.new(strsubst(filename,'\','/'));
                    end

                    t_conf.setOutputFiles(outputFiles);
                    t_conf.setOutputFilesThere(%t);
                end
            end

            // Custom Script
            if ~isempty(Tasks(j,i).SelectionScript) then
                selects = Tasks(j,i).SelectionScript;
                try
                    url = URL.new(selects);
                    ok = true;
                catch
                    ok = false;
                end
                jremove(url);

                if ~ok
                    t_conf.setCustomScriptUrl(strcat(['file:', selects ]));
                else
                    t_conf.setCustomScriptUrl(selects);
                end
            end

            // Function
            Func = Tasks(j,i).Func;
            execstr(strcat(['functype = type(';Func;');']));
            if (functype <> 13) & (functype <> 11)  then
                error('invalid function type for function ""' + Func + '"". Consider calling this function with a macro instead.');
            end

            // Source Files

            if ~isempty(Tasks(j,i).Sources) then
                srcs = Tasks(j,i).Sources;
                for k=1:length(srcs)
                    srcPath = srcs(k);
                    if isfile(srcPath) then
                        [ppath,fname,extension]=fileparts(srcPath);
                        srcName = strcat(strcat([fname,extension]));
                        if ~isfile(strcat([pa_dir,fs,fname,extension])) then
                            if opt.Debug then
                                disp(strcat(['Copying file ', srcPath, ' to ',pa_dir]));
                            end
                            copyfile(srcPath,pa_dir);
                            // TODO find a cleaning mechanisme
                            //taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(pa_dir+fs+fname+extension));
                            //tmpFiles($+1)=strcat([pa_dir,fs,fname,extension]);
                        end
                        strName = String.new(srcName);
                        t_conf.addSourceFile(strName);
                    else
                        error(strcat(['Source file ', srcPath, ' cannot be found']));
                    end

                end

            end

            // Saving main function name (with or without Sources attribute)
            sourceNames = jarray('java.lang.String', 1);
            sFN = 'ScilabPAsolve_src'+string(SOLVEid)+indToFile([i j])+'.bin';
            execstr('save(pa_dir+fs+sFN,'+Func+');');
            strName = String.new(sFN);
            sourceNames(0) = strName;
            t_conf.setFunctionVarFiles(sourceNames);
            code=[];
            taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(pa_dir+fs+sFN));

            t_conf.setFunctionName(Func);
            t_conf.addSourceFile(sFN);

            // Params
            argi = Tasks(j,i).Params;
            if opt.TransferVariables
                inVarFN = strcat([variableInFileBaseName, indToFile([i j]), '.dat']);
                outVarFN = strcat([variableOutFileBaseName, indToFile([i j]), '.dat']);
                inVarFP = strcat([pa_dir, fs, inVarFN]);
                outVarFP = strcat([pa_dir, fs, outVarFN]);
                // Creating input parameters mat files
                fd=mopen(inVarFP,'wb');
                inl = argi;
                if length(inl) == 0
                    inl=list(%t);
                end
                for k=1:length(inl)
                    execstr('in'+string(k)+'=inl(k);');
                    execstr('save(fd,in'+string(k)+')');
                end
                mclose(fd);

                jinvoke(t_conf,'setInputVariablesFileName',inVarFN);
                jinvoke(t_conf,'setOutputVariablesFileName',outVarFN);
                if j > 1 & Tasks(j,i).Compose
                    cinVarFN = strcat([variableOutFileBaseName,indToFile([i j-1]),'.dat']);
                    cinVarFP = pa_dir+fs+cinVarFN;
                    jinvoke(t_conf,'setComposedInputVariablesFileName',cinVarFN);
                end
                outVarFiles(i) = outVarFP;
                taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(inVarFP));
                //if j < MM
                // because of disconnected mode, the final out is handled
                //differently
                taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(outVarFP));
                //end

                inputscript = 'i=0';
            else
                inputscript = createInputScript(argi);
            end

            t_conf.setInputScript(inputscript);

            //mainScript = createMainScript(Func, opt);
            mainScript = 'out = '+Tasks(j,i).Func+'(';
            if j > 1 & Tasks(j,i).Compose
                mainScript = mainScript + 'in';
                if length(argi) > 0 then
                    mainScript = mainScript + ',';
                end
            end
            if length(argi) > 0
                for k=1:length(argi)-1
                    mainScript = mainScript + 'in'+string(k)+',';
                end
                mainScript = mainScript + ('in'+string(length(argi)));
            end
            mainScript = mainScript + ');';
            t_conf.setMainScript(mainScript);

            t_conf.setOutputs('out');

        end
    end
    jimport org.ow2.proactive.scheduler.ext.scilab.client.ScilabSolver;
    jimport org.objectweb.proactive.api.PAFuture;
    solver = jnewInstance(ScilabSolver);

    pairinfolist = solver.solve(solve_config, task_configs);

    jobinfo = jinvoke(pairinfolist,'getX');
    resfutureList =  jinvoke(pairinfolist,'getY');
    jid = string(jinvoke(jobinfo,'getJobId'));
    disp('Job submitted : '+ jid);

    ftn = jinvoke(jobinfo,'getFinalTasksNamesAsList');

    taskinfo = struct('cleanFileSet',[],'cleanDirSet',[], 'outFile',[], 'jobid',[], 'taskid',[] );
    results=list(NN);
    for i=1:NN
        taskinfo.cleanFileSet = taskFilesToClean(i);
        taskinfo.cleanDirSet = list(pa_dir);
        taskinfo.outFile = outVarFiles(i);
        taskinfo.jobid = jid;
        taskinfo.taskid = jinvoke(ftn,'get',i-1);

        results(i)=PAResult(jinvoke(resfutureList,'get',i-1), taskinfo);

    end
    outputs = PAResL(results);
    jremove(solver, solve_config, task_configs);

endfunction

function nm=indToFile(ind)
    nm='';
    if ind==-1
        return;
    end
    for JJ=ind
        nm=strcat([nm, '_', string(JJ)]);
    end
endfunction

function inputScript = createInputScript(arg)
    // We transform the argument to executable scilab code
    argcode = sci2exp(arg,'in');
    // The inputscript will contain the argument and the code of the functions
    inputscript_array=[argcode];
    // The code defining the function is made of many lines, we pack it by using ASCII 31 delimiters
    s=size(inputscript_array);
    inputscript_str='';
    for j=1:(s(1)-1)
        inputscript_str=inputscript_str+inputscript_array(j)+ascii(31);
    end
    inputscript_str=inputscript_str+inputscript_array(s(1));
    // We tranform the final packed command as an assigment to evaluate
    inputscript_assignment = sci2exp(inputscript_str, 'inputscript');
    // We add the code used to decode the packed instructions
    inputscript_decode = 'TOKENS = tokens(inputscript,ascii(31)); execstr(TOKENS,''errcatch'',''m'');';
    inputScript = strcat([inputscript_assignment;';';inputscript_decode]);
endfunction

function mainScript = createMainScript(funcName, opt)
    debugv = opt.Debug;
    if debugv == 1
        //mainScript = strcat(['mode(3)';ascii(31);'out=';funcName;'(in)';ascii(31);ascii(30);'output = sci2exp(output,''''output'''',0)';ascii(31);'disp(out)']);
        mainScript = strcat(['mode(3)';ascii(31);'out=';funcName;'(in)';ascii(31);'disp(out)']);
    else
        //mainScript = strcat(['out=';funcName;'(in);';ascii(31);ascii(30);'output = sci2exp(output,''''output'''',0);']);
        mainScript = strcat(['out=';funcName;'(in);']);
    end
endfunction

function outputs = PAsolve(varargin)
    global ('PA_connected','DataRegistry', 'DataRegistryInit', 'SOLVEid')

    if ~exists('PA_connected') | PA_connected ~= 1
        error('A connection to the ProActive scheduler must be established in order to use PAsolve, see PAconnect');
    end

    if exists('SOLVEid') & type(SOLVEid) == 8
        SOLVEid = SOLVEid + 1;
    else
        SOLVEid = int32(0);
    end

    opt=PAoptions();

    deff ("y=ischar(x)","y=type(x)==10","n");
    if ischar(varargin(1)) then
        Func = varargin(1);
        NN=length(varargin)-1;
        Tasks = PATask(1,NN);
        Tasks(1,1:NN).Func = Func;
        for i=1:NN
            if typeof(varargin(i+1)) == 'list'
                Tasks(1,i).Params =varargin(i+1);
            else
                Tasks(1,i).Params =list(varargin(i+1));
            end
        end
        MM = 1;
    elseif typeof(varargin(1)) == 'PATask'
        if length(varargin) == 1
            Tasks = varargin(1);
            NN = size(Tasks,2);
            MM = size(Tasks,1);
        else
            NN=nargin;
            MM = -1;
            for i=1:NN
                if typeof(varargin(i)) == 'PATask'
                    if (size(varargin(i),2) ~= 1)
                        error(strcat(['parameter ', string(i), ' should be a column vector.']));
                    end
                    sz = size(varargin(i),1);
                    if MM == -1
                        MM = sz;
                        Tasks=PATask(MM,NN);
                    elseif MM ~= sz
                        error(strcat(['parameter ', string(i), ' should be a column vector of the same length than other parameters.']));
                    end
                    Tasks(1:sz,i) = varargin(i);
                else
                    error(strcat(['parameter ', num2str(i), ' is a ', typeof(varargin(i)), ', expected PATask instead.']));
                end
            end

        end
    end

    jimport org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabGlobalConfig;
    jimport org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabTaskConfig;
    jimport org.ow2.proactive.scheduler.ext.common.util.FileUtils;
    jimport org.ow2.proactive.scheduler.ext.matsci.client.AODataspaceRegistry;
    jimport java.lang.String;
    jimport java.net.URL;
    jimport java.io.File;

    solve_config = jnewInstance(PASolveScilabGlobalConfig);

    solve_config.setDebug(opt.Debug);
    solve_config.setTimeStamp(opt.TimeStamp);
    solve_config.setFork(opt.Fork);
    solve_config.setRunAsMe(opt.RunAsMe);
    solve_config.setPriority(opt.Priority);
    solve_config.setTransferSource(opt.TransferSource);
    //solve_config.setTransferEnv(opt.TransferEnv);
    solve_config.setTransferVariables(opt.TransferVariables);
    solve_config.setKeepEngine(opt.KeepEngine);
    jinvoke(solve_config,'setWindowsStartupOptionsAsString',opt.WindowsStartupOptions);
    jinvoke(solve_config,'setLinuxStartupOptionsAsString',opt.LinuxStartupOptions);

    solve_config.setInputSpaceName('ScilabInputSpace');
    solve_config.setOutputSpaceName('ScilabOutputSpace');

    solve_config.setVersionPref(opt.VersionPref);
    solve_config.setVersionRejAsString(opt.VersionRej);
    solve_config.setVersionMin(opt.VersionMin);
    solve_config.setVersionMax(opt.VersionMax);
    solve_config.setCheckMatSciUrl(opt.FindScilabScript);
    if ischar(opt.CustomScript)
        selects = opt.CustomScript
        try
            url=URL.new(selects);
            ok = true;
        catch
            ok = false;
        end
        jremove(url);

        if ~ok
            solve_config.setCustomScriptUrl(strcat(['file:', selects]));
        else
            solve_config.setCustomScriptUrl(selects);
        end
    end

    solve_config.setZipSourceFiles(%f);

    curr_dir = pwd();
    fs=filesep();
    curr_dir_java = File.new(curr_dir);
    if ~jinvoke(curr_dir_java,'canWrite')
        jremove(curr_dir_java);
        error('Current Directory should have write access rights');
    end
    jremove(curr_dir_java);

    // PAScheduler sub directory init

    subdir = '.PAScheduler';
    solve_config.setTempSubDirName(subdir);

    if isempty(opt.CustomDataspaceURL)
        if ~isdir(strcat([curr_dir, fs, subdir]))
            mkdir(curr_dir,subdir);
        end
        pa_dir = strcat([curr_dir, fs, subdir]);
    else
        if isempty(opt.CustomDataspacePath)
            error('if CustomDataspaceURL is specified, CustomDataspacePath must be specified also');
        end
        if ~isdir(strcat([opt.CustomDataspacePath, fs, subdir]))
            mkdir(opt.CustomDataspacePath,subdir);
        end
        pa_dir = strcat([opt.CustomDataspacePath, fs, subdir]);
    end

    if isempty(opt.CustomDataspaceURL)
        if ~exists('DataRegistryInit') | DataRegistryInit ~= 1
            DataRegistry = AODataspaceRegistry.new('ScilabInputSpace','ScilabOutputSpace','ScilabSession',opt.Debug);
            DataRegistryInit = 1;
        end
        pair = DataRegistry.createDataSpace(curr_dir);
        px=jinvoke(pair,'getX');
        py=jinvoke(pair,'getY');
        pxs = jcast(px,'java.lang.String');
        pys = jcast(py,'java.lang.String');
        solve_config.setInputSpaceURL(pxs);
        solve_config.setOutputSpaceURL(pys);
        if opt.Debug then
            disp('using Dataspace:')
            disp(pxs)
        end

    else
        solve_config.setOutputSpaceURL(opt.CustomDataspaceURL);
        solve_config.setInputSpaceURL(opt.CustomDataspaceURL);
    end

    variableInFileBaseName = ['ScilabPAsolveVarIn_' string(SOLVEid)];
    variableOutFileBaseName = ['ScilabPAsolveVarOut_' string(SOLVEid)];
    outVarFiles = list(NN);
    //tmpFiles = list();
    taskFilesToClean = list();

    task_configs = jarray('org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabTaskConfig', NN,MM);
    for i=1:NN
        taskFilesToClean($+1)=list();
        for j=1:MM
            t_conf = jnewInstance(PASolveScilabTaskConfig);
            task_configs(i-1,j-1) = t_conf;
            if ~isempty(Tasks(j,i).Description) then
                t_conf.setDescription(Tasks(j,i).Description);
            end

            // Input Files
            if ~isempty(Tasks(j,i).InputFiles) then
                ilen = length(Tasks(j,i).InputFiles);
                if ilen > 0 then
                    inputFiles = jarray('java.lang.String', ilen);
                    filelist = Tasks(j,i).InputFiles;
                    for k=1:ilen
                        filename = filelist(k);
                        inputFiles(k-1)=String.new(strsubst(filename,'\','/'));
                    end

                    t_conf.setInputFiles(inputFiles);
                    t_conf.setInputFilesThere(%t);
                end
            end

            // Output Files
            if ~isempty(Tasks(j,i).OutputFiles) then
                filelist = Tasks(j,i).OutputFiles;
                ilen = length(filelist);
                if ilen > 0 then
                    outputFiles = jarray('java.lang.String', ilen);
                    for k=1:ilen
                        filename = filelist(k);
                        outputFiles(k-1)=String.new(strsubst(filename,'\','/'));
                    end

                    t_conf.setOutputFiles(outputFiles);
                    t_conf.setOutputFilesThere(%t);
                end
            end

            // Custom Script
            if ~isempty(Tasks(j,i).SelectionScript) then
                selects = Tasks(j,i).SelectionScript;
                try
                    url = URL.new(selects);
                    ok = true;
                catch
                    ok = false;
                end
                jremove(url);

                if ~ok
                    t_conf.setCustomScriptUrl(strcat(['file:', selects ]));
                else
                    t_conf.setCustomScriptUrl(selects);
                end
            end

            // Function
            Func = Tasks(j,i).Func;
            execstr(strcat(['functype = type(';Func;');']));
            if (functype <> 13) & (functype <> 11)  then
                error('invalid function type for function ""' + Func + '"". Consider calling this function with a macro instead.');
            end

            // Source Files

            if ~isempty(Tasks(j,i).Sources) then
                srcs = Tasks(j,i).Sources;
                for k=1:length(srcs)
                    srcPath = srcs(k);
                    if isfile(srcPath) then
                        [ppath,fname,extension]=fileparts(srcPath);
                        srcName = strcat(strcat([fname,extension]));
                        if ~isfile(strcat([pa_dir,fs,fname,extension])) then
                            if opt.Debug then
                                disp(strcat(['Copying file ', srcPath, ' to ',pa_dir]));
                            end
                            copyfile(srcPath,pa_dir);
                            // TODO find a cleaning mechanisme
                            //taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(pa_dir+fs+fname+extension));
                            //tmpFiles($+1)=strcat([pa_dir,fs,fname,extension]);
                        end
                        strName = String.new(srcName);
                        t_conf.addSourceFile(strName);
                    else
                        error(strcat(['Source file ', srcPath, ' cannot be found']));
                    end

                end

            end

            // Saving main function name (with or without Sources attribute)
            sourceNames = jarray('java.lang.String', 1);
            sFN = 'ScilabPAsolve_src'+string(SOLVEid)+indToFile([i j])+'.bin';
            execstr('save(pa_dir+fs+sFN,'+Func+');');
            strName = String.new(sFN);
            sourceNames(0) = strName;
            t_conf.setFunctionVarFiles(sourceNames);
            code=[];
            taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(pa_dir+fs+sFN));

            t_conf.setFunctionName(Func);
            t_conf.addSourceFile(sFN);

            // Params
            argi = Tasks(j,i).Params;
            if opt.TransferVariables
                inVarFN = strcat([variableInFileBaseName, indToFile([i j]), '.dat']);
                outVarFN = strcat([variableOutFileBaseName, indToFile([i j]), '.dat']);
                inVarFP = strcat([pa_dir, fs, inVarFN]);
                outVarFP = strcat([pa_dir, fs, outVarFN]);
                // Creating input parameters mat files
                fd=mopen(inVarFP,'wb');
                inl = argi;
                if length(inl) == 0
                    inl=list(%t);
                end
                for k=1:length(inl)
                    execstr('in'+string(k)+'=inl(k);');
                    execstr('save(fd,in'+string(k)+')');
                end
                mclose(fd);

                jinvoke(t_conf,'setInputVariablesFileName',inVarFN);
                jinvoke(t_conf,'setOutputVariablesFileName',outVarFN);
                if j > 1 & Tasks(j,i).Compose
                    cinVarFN = strcat([variableOutFileBaseName,indToFile([i j-1]),'.dat']);
                    cinVarFP = pa_dir+fs+cinVarFN;
                    jinvoke(t_conf,'setComposedInputVariablesFileName',cinVarFN);
                end
                outVarFiles(i) = outVarFP;
                taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(inVarFP));
                //if j < MM
                // because of disconnected mode, the final out is handled
                //differently
                taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(outVarFP));
                //end

                inputscript = 'i=0';
            else
                inputscript = createInputScript(argi);
            end

            t_conf.setInputScript(inputscript);

            //mainScript = createMainScript(Func, opt);
            mainScript = 'out = '+Tasks(j,i).Func+'(';
            if j > 1 & Tasks(j,i).Compose
                mainScript = mainScript + 'in';
                if length(argi) > 0 then
                    mainScript = mainScript + ',';
                end
            end
            if length(argi) > 0
                for k=1:length(argi)-1
                    mainScript = mainScript + 'in'+string(k)+',';
                end
                mainScript = mainScript + ('in'+string(length(argi)));
            end
            mainScript = mainScript + ');';
            t_conf.setMainScript(mainScript);

            t_conf.setOutputs('out');

        end
    end
    jimport org.ow2.proactive.scheduler.ext.scilab.client.ScilabSolver;
    jimport org.objectweb.proactive.api.PAFuture;
    solver = jnewInstance(ScilabSolver);

    pairinfolist = solver.solve(solve_config, task_configs);

    jobinfo = jinvoke(pairinfolist,'getX');
    resfutureList =  jinvoke(pairinfolist,'getY');
    jid = string(jinvoke(jobinfo,'getJobId'));
    disp('Job submitted : '+ jid);

    ftn = jinvoke(jobinfo,'getFinalTasksNamesAsList');

    taskinfo = struct('cleanFileSet',[],'cleanDirSet',[], 'outFile',[], 'jobid',[], 'taskid',[] );
    results=list(NN);
    for i=1:NN
        taskinfo.cleanFileSet = taskFilesToClean(i);
        taskinfo.cleanDirSet = list(pa_dir);
        taskinfo.outFile = outVarFiles(i);
        taskinfo.jobid = jid;
        taskinfo.taskid = jinvoke(ftn,'get',i-1);

        results(i)=PAResult(jinvoke(resfutureList,'get',i-1), taskinfo);

    end
    outputs = PAResL(results);

endfunction

function nm=indToFile(ind)
    nm='';
    if ind==-1
        return;
    end
    for JJ=ind
        nm=strcat([nm, '_', string(JJ)]);
    end
endfunction

function inputScript = createInputScript(arg)
    // We transform the argument to executable scilab code
    argcode = sci2exp(arg,'in');
    // The inputscript will contain the argument and the code of the functions
    inputscript_array=[argcode];
    // The code defining the function is made of many lines, we pack it by using ASCII 31 delimiters
    s=size(inputscript_array);
    inputscript_str='';
    for j=1:(s(1)-1)
        inputscript_str=inputscript_str+inputscript_array(j)+ascii(31);
    end
    inputscript_str=inputscript_str+inputscript_array(s(1));
    // We tranform the final packed command as an assigment to evaluate
    inputscript_assignment = sci2exp(inputscript_str, 'inputscript');
    // We add the code used to decode the packed instructions
    inputscript_decode = 'TOKENS = tokens(inputscript,ascii(31)); execstr(TOKENS,''errcatch'',''m'');';
    inputScript = strcat([inputscript_assignment;';';inputscript_decode]);
endfunction

function mainScript = createMainScript(funcName, opt)
    debugv = opt.Debug;
    if debugv == 1
        //mainScript = strcat(['mode(3)';ascii(31);'out=';funcName;'(in)';ascii(31);ascii(30);'output = sci2exp(output,''''output'''',0)';ascii(31);'disp(out)']);
        mainScript = strcat(['mode(3)';ascii(31);'out=';funcName;'(in)';ascii(31);'disp(out)']);
    else
        //mainScript = strcat(['out=';funcName;'(in);';ascii(31);ascii(30);'output = sci2exp(output,''''output'''',0);']);
        mainScript = strcat(['out=';funcName;'(in);']);
    end
endfunction


sort in ascending order

sort in ascending order

location = 'C:\cygwin\home\Zhan\repository\graph-classifier\dataset\'
cdf1_file = 'inDegC.rmat-12-8.txt.tab'
cdf2_file = 'inDegC.rmat-8-8.txt.tab'

mode(-1)

cdf_raw = fscanfMat(location + cdf1_file)
l = size(cdf_raw, 1), i_last = 1
for r = 1:l
  i = cdf_raw(r, 1), v = cdf_raw(r, 2)
  for j = i_last:i, cdf1(j) = v, end
  i_last = i
end

clear cdf_raw

cdf_raw = fscanfMat(location + cdf2_file)
l = size(cdf_raw, 1), i_last = 1
for r = 1:l
  i = cdf_raw(r, 1), v = cdf_raw(r, 2)
  for j = i_last:i, cdf2(j) = v, end
  i_last = i
end

clear cdf1_file cdf2_file cdf_raw l r i i_last j v

cdf1=gsort(cdf1, 'g', 'i')
cdf2=gsort(cdf2, 'g', 'i')

i1 = 1, fn1 = 0, l1 = size(cdf1, 1)
i2 = 1, fn2 = 0, l2 = size(cdf2, 1)
d = 0
while (i1 <= l1) & (i2 <= l2)
  d1 = cdf1(i1)
  d2 = cdf2(i2)
  if d1 <= d2 then i1 = i1 + 1, fn1 = i1 / l1; end
  if d2 <= d1 then i2 = i2 + 1, fn2 = i2 / l2; end
  d0 = abs(fn2 - fn1)
  if d0 > d then d = d0; end
end

clear i1 i2 fn1 fn2 d0 d1 d2

en = sqrt(l1 * l2/(l1 + l2))

alam = (en + 0.12 + 0.11 / en) * d
eps1 = 0.001, eps2 = 1.0e-8, fac = 2, s = 0, term_bf = 0, ks_significance = 1
a2 = -2.0 * alam * alam
for i = 1:100
  term = fac * exp(a2 * i * i)
  s = s + term
  if (abs(term) <= eps1 * term_bf) | (abs(term) <= eps2 * s) then
    ks_significance = s
    break
  end
  fac = -fac
  term_bf = abs(term)
end

clear en l1 l2 alam eps1 eps2 fac s term_bf a2 i term

mode(0)

location = 'C:\cygwin\home\Zhan\repository\graph-classifier\dataset\'
cdf1_file = 'inDegC.rmat-12-8.txt.tab'
cdf2_file = 'inDegC.rmat-11-8.txt.tab'

mode(-1)

cdf_raw = fscanfMat(location + cdf1_file)
l = size(cdf_raw, 1), i_last = 1
for r = 1:l
  i = cdf_raw(r, 1), v = cdf_raw(r, 2)
  for j = i_last:i, cdf1(j) = v, end
  i_last = i
end

clear cdf_raw

cdf_raw = fscanfMat(location + cdf2_file)
l = size(cdf_raw, 1), i_last = 1
for r = 1:l
  i = cdf_raw(r, 1), v = cdf_raw(r, 2)
  for j = i_last:i, cdf2(j) = v, end
  i_last = i
end

clear cdf1_file cdf2_file cdf_raw l r i i_last j v

i1 = 1, fn1 = 0, l1 = size(cdf1, 1)
i2 = 1, fn2 = 0, l2 = size(cdf2, 1)
d = 0
while (i1 <= l1) & (i2 <= l2)
  d1 = cdf1(i1)
  d2 = cdf2(i2)
  if d1 <= d2 then i1 = i1 + 1, fn1 = i1 / l1; end
  if d2 <= d1 then i2 = i2 + 1, fn2 = i2 / l2; end
  d0 = abs(fn2 - fn1)
  if d0 > d then d = d0; end
end

clear i1 i2 fn1 fn2 d0 d1 d2

en = sqrt(l1 * l2/(l1 + l2))

alam = (en + 0.12 + 0.11 / en) * d
eps1 = 0.001, eps2 = 1.0e-8, fac = 2, s = 0, term_bf = 0, ks_significance = 1
a2 = -2.0 * alam * alam
for i = 1:100
  term = fac * exp(a2 * i * i)
  s = s + term
  if (abs(term) <= eps1 * term_bf) | (abs(term) <= eps2 * s) then
    ks_significance = s
    break
  end
  fac = -fac
  term_bf = abs(term)
end

clear en l1 l2 alam eps1 eps2 fac s term_bf a2 i term

mode(0)


fix for SCHEDULING-1399

fix for SCHEDULING-1399

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

function outputs = PAsolve(varargin)
    global ('PA_connected','DataRegistry', 'DataRegistryInit', 'SOLVEid')

    if ~exists('PA_connected') | PA_connected ~= 1
        error('A connection to the ProActive scheduler must be established in order to use PAsolve, see PAconnect');
    end

    if exists('SOLVEid') & type(SOLVEid) == 8
        SOLVEid = SOLVEid + 1;
    else
        SOLVEid = int32(0);
    end

    opt=PAoptions();

    deff ("y=ischar(x)","y=type(x)==10","n");
    if ischar(varargin(1)) then
        Func = varargin(1);
        NN=length(varargin)-1;
        Tasks = PATask(1,NN);
        Tasks(1,1:NN).Func = Func;
        for i=1:NN
            if typeof(varargin(i+1)) == 'list'
                Tasks(1,i).Params =varargin(i+1);
            else
                Tasks(1,i).Params =list(varargin(i+1));
            end
        end
        MM = 1;
    elseif typeof(varargin(1)) == 'PATask'
        if length(varargin) == 1
            Tasks = varargin(1);
            NN = size(Tasks,2);
            MM = size(Tasks,1);
        else
            NN=argn(2);
            MM = -1;
            for i=1:NN
                if typeof(varargin(i)) == 'PATask'
                    if (size(varargin(i),2) ~= 1)
                        error(strcat(['parameter ', string(i), ' should be a column vector.']));
                    end
                    sz = size(varargin(i),1);
                    if MM == -1
                        MM = sz;
                        Tasks=PATask(MM,NN);
                    elseif MM ~= sz
                        error(strcat(['parameter ', string(i), ' should be a column vector of the same length than other parameters.']));
                    end
                    Tasks(1:sz,i) = varargin(i);
                else
                    error(strcat(['parameter ', num2str(i), ' is a ', typeof(varargin(i)), ', expected PATask instead.']));
                end
            end

        end
    end

    jimport org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabGlobalConfig;
    jimport org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabTaskConfig;
    jimport org.ow2.proactive.scheduler.ext.common.util.FileUtils;
    jimport org.ow2.proactive.scheduler.ext.matsci.client.AODataspaceRegistry;
    jimport java.lang.String;
    jimport java.net.URL;
    jimport java.io.File;

    solve_config = jnewInstance(PASolveScilabGlobalConfig);

    solve_config.setDebug(opt.Debug);
    solve_config.setTimeStamp(opt.TimeStamp);
    solve_config.setFork(opt.Fork);
    solve_config.setRunAsMe(opt.RunAsMe);
    solve_config.setPriority(opt.Priority);
    solve_config.setTransferSource(opt.TransferSource);
    //solve_config.setTransferEnv(opt.TransferEnv);
    solve_config.setTransferVariables(opt.TransferVariables);
    solve_config.setKeepEngine(opt.KeepEngine);
    jinvoke(solve_config,'setWindowsStartupOptionsAsString',opt.WindowsStartupOptions);
    jinvoke(solve_config,'setLinuxStartupOptionsAsString',opt.LinuxStartupOptions);

    solve_config.setInputSpaceName('ScilabInputSpace');
    solve_config.setOutputSpaceName('ScilabOutputSpace');

    solve_config.setVersionPref(opt.VersionPref);
    solve_config.setVersionRejAsString(opt.VersionRej);
    solve_config.setVersionMin(opt.VersionMin);
    solve_config.setVersionMax(opt.VersionMax);
    solve_config.setCheckMatSciUrl(opt.FindScilabScript);
    if ischar(opt.CustomScript)
        selects = opt.CustomScript
        try
            url=URL.new(selects);
            ok = true;
        catch
            ok = false;
        end
        jremove(url);

        if ~ok
            solve_config.setCustomScriptUrl(strcat(['file:', selects]));
        else
            solve_config.setCustomScriptUrl(selects);
        end
    end

    solve_config.setZipSourceFiles(%f);

    curr_dir = pwd();
    fs=filesep();
    curr_dir_java = File.new(curr_dir);
    if ~jinvoke(curr_dir_java,'canWrite')
        jremove(curr_dir_java);
        error('Current Directory should have write access rights');
    end
    jremove(curr_dir_java);

    // PAScheduler sub directory init

    subdir = '.PAScheduler';
    solve_config.setTempSubDirName(subdir);

    if isempty(opt.CustomDataspaceURL)
        if ~isdir(strcat([curr_dir, fs, subdir]))
            mkdir(curr_dir,subdir);
        end
        pa_dir = strcat([curr_dir, fs, subdir]);
    else
        if isempty(opt.CustomDataspacePath)
            error('if CustomDataspaceURL is specified, CustomDataspacePath must be specified also');
        end
        if ~isdir(strcat([opt.CustomDataspacePath, fs, subdir]))
            mkdir(opt.CustomDataspacePath,subdir);
        end
        pa_dir = strcat([opt.CustomDataspacePath, fs, subdir]);
    end

    if isempty(opt.CustomDataspaceURL)
        if ~exists('DataRegistryInit') | DataRegistryInit ~= 1
            DataRegistry = AODataspaceRegistry.new('ScilabInputSpace','ScilabOutputSpace','ScilabSession',opt.Debug);
            DataRegistryInit = 1;
        end
        pair = DataRegistry.createDataSpace(curr_dir);
        px=jinvoke(pair,'getX');
        py=jinvoke(pair,'getY');
        pxs = jcast(px,'java.lang.String');
        pys = jcast(py,'java.lang.String');
        solve_config.setInputSpaceURL(pxs);
        solve_config.setOutputSpaceURL(pys);
        if opt.Debug then
            disp('using Dataspace:')
            disp(pxs)
        end

    else
        solve_config.setOutputSpaceURL(opt.CustomDataspaceURL);
        solve_config.setInputSpaceURL(opt.CustomDataspaceURL);
    end

    variableInFileBaseName = ['ScilabPAsolveVarIn_' string(SOLVEid)];
    variableOutFileBaseName = ['ScilabPAsolveVarOut_' string(SOLVEid)];
    outVarFiles = list(NN);
    //tmpFiles = list();
    taskFilesToClean = list();

    task_configs = jarray('org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabTaskConfig', NN,MM);
    for i=1:NN
        taskFilesToClean($+1)=list();
        for j=1:MM
            t_conf = jnewInstance(PASolveScilabTaskConfig);
            task_configs(i-1,j-1) = t_conf;
            if ~isempty(Tasks(j,i).Description) then
                t_conf.setDescription(Tasks(j,i).Description);
            end

            // Input Files
            if ~isempty(Tasks(j,i).InputFiles) then
                ilen = length(Tasks(j,i).InputFiles);
                if ilen > 0 then
                    inputFiles = jarray('java.lang.String', ilen);
                    filelist = Tasks(j,i).InputFiles;
                    for k=1:ilen
                        filename = filelist(k);
                        inputFiles(k-1)=String.new(strsubst(filename,'\','/'));
                    end

                    t_conf.setInputFiles(inputFiles);
                    t_conf.setInputFilesThere(%t);
                end
            end

            // Output Files
            if ~isempty(Tasks(j,i).OutputFiles) then
                filelist = Tasks(j,i).OutputFiles;
                ilen = length(filelist);
                if ilen > 0 then
                    outputFiles = jarray('java.lang.String', ilen);
                    for k=1:ilen
                        filename = filelist(k);
                        outputFiles(k-1)=String.new(strsubst(filename,'\','/'));
                    end

                    t_conf.setOutputFiles(outputFiles);
                    t_conf.setOutputFilesThere(%t);
                end
            end

            // Custom Script
            if ~isempty(Tasks(j,i).SelectionScript) then
                selects = Tasks(j,i).SelectionScript;
                try
                    url = URL.new(selects);
                    ok = %t;
                catch
                    ok = %f;
                end
                jremove(url);

                if ~ok
                    t_conf.setCustomScriptUrl(strcat(['file:', selects ]));
                else
                    t_conf.setCustomScriptUrl(selects);
                end
            end

            // Function
            Func = Tasks(j,i).Func;
            execstr(strcat(['functype = type(';Func;');']));
            if (functype <> 13) & (functype <> 11)  then
                error('invalid function type for function ""' + Func + '"". Consider calling this function with a macro instead.');
            end

            // Source Files

            if ~isempty(Tasks(j,i).Sources) then
                srcs = Tasks(j,i).Sources;
                for k=1:length(srcs)
                    srcPath = srcs(k);
                    if isfile(srcPath) then
                        [ppath,fname,extension]=fileparts(srcPath);
                        srcName = strcat(strcat([fname,extension]));

                        if opt.Debug then
                            disp(strcat(['Copying file ', srcPath, ' to ',pa_dir]));
                        end
                        copyfile(srcPath,pa_dir);
                        // TODO find a cleaning mechanisme
                        //taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(pa_dir+fs+fname+extension));
                        //tmpFiles($+1)=strcat([pa_dir,fs,fname,extension]);

                        strName = String.new(srcName);
                        t_conf.addSourceFile(strName);
                    else
                        error(strcat(['Source file ', srcPath, ' cannot be found']));
                    end

                end

            end

            // Saving main function name (with or without Sources attribute)
            sourceNames = jarray('java.lang.String', 1);
            sFN = 'ScilabPAsolve_src'+string(SOLVEid)+indToFile([i j])+'.bin';
            execstr('save(pa_dir+fs+sFN,'+Func+');');
            strName = String.new(sFN);
            sourceNames(0) = strName;
            t_conf.setFunctionVarFiles(sourceNames);
            code=[];
            taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(pa_dir+fs+sFN));

            t_conf.setFunctionName(Func);
            t_conf.addSourceFile(sFN);

            // Params
            argi = Tasks(j,i).Params;
            if opt.TransferVariables
                inVarFN = strcat([variableInFileBaseName, indToFile([i j]), '.dat']);
                outVarFN = strcat([variableOutFileBaseName, indToFile([i j]), '.dat']);
                inVarFP = strcat([pa_dir, fs, inVarFN]);
                outVarFP = strcat([pa_dir, fs, outVarFN]);
                // Creating input parameters mat files
                fd=mopen(inVarFP,'wb');
                inl = argi;
                if length(inl) == 0
                    inl=list(%t);
                end
                for k=1:length(inl)
                    execstr('in'+string(k)+'=inl(k);');
                    execstr('save(fd,in'+string(k)+')');
                end
                mclose(fd);

                jinvoke(t_conf,'setInputVariablesFileName',inVarFN);
                jinvoke(t_conf,'setOutputVariablesFileName',outVarFN);
                if j > 1 & Tasks(j,i).Compose
                    cinVarFN = strcat([variableOutFileBaseName,indToFile([i j-1]),'.dat']);
                    cinVarFP = pa_dir+fs+cinVarFN;
                    jinvoke(t_conf,'setComposedInputVariablesFileName',cinVarFN);
                end
                outVarFiles(i) = outVarFP;
                taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(inVarFP));
                //if j < MM
                // because of disconnected mode, the final out is handled
                //differently
                taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(outVarFP));
                //end

                inputscript = 'i=0';
            else
                inputscript = createInputScript(argi);
            end

            t_conf.setInputScript(inputscript);

            //mainScript = createMainScript(Func, opt);
            mainScript = 'out = '+Tasks(j,i).Func+'(';
            if j > 1 & Tasks(j,i).Compose
                mainScript = mainScript + 'in';
                if length(argi) > 0 then
                    mainScript = mainScript + ',';
                end
            end
            if length(argi) > 0
                for k=1:length(argi)-1
                    mainScript = mainScript + 'in'+string(k)+',';
                end
                mainScript = mainScript + ('in'+string(length(argi)));
            end
            mainScript = mainScript + ');';
            t_conf.setMainScript(mainScript);

            t_conf.setOutputs('out');

        end
    end
    jimport org.ow2.proactive.scheduler.ext.scilab.client.ScilabSolver;
    jimport org.objectweb.proactive.api.PAFuture;
    solver = jnewInstance(ScilabSolver);

    pairinfolist = solver.solve(solve_config, task_configs);

    jobinfo = jinvoke(pairinfolist,'getX');
    resfutureList =  jinvoke(pairinfolist,'getY');
    jid = string(jinvoke(jobinfo,'getJobId'));
    disp('Job submitted : '+ jid);

    ftn = jinvoke(jobinfo,'getFinalTasksNamesAsList');

    taskinfo = struct('cleanFileSet',[],'cleanDirSet',[], 'outFile',[], 'jobid',[], 'taskid',[] );
    results=list(NN);
    for i=1:NN
        taskinfo.cleanFileSet = taskFilesToClean(i);
        taskinfo.cleanDirSet = list(pa_dir);
        taskinfo.outFile = outVarFiles(i);
        taskinfo.jobid = jid;
        taskinfo.taskid = jinvoke(ftn,'get',i-1);

        results(i)=PAResult(jinvoke(resfutureList,'get',i-1), taskinfo);

    end
    outputs = PAResL(results);
    jremove(solver, solve_config, task_configs);

endfunction

function nm=indToFile(ind)
    nm='';
    if ind==-1
        return;
    end
    for JJ=ind
        nm=strcat([nm, '_', string(JJ)]);
    end
endfunction

function inputScript = createInputScript(arg)
    // We transform the argument to executable scilab code
    argcode = sci2exp(arg,'in');
    // The inputscript will contain the argument and the code of the functions
    inputscript_array=[argcode];
    // The code defining the function is made of many lines, we pack it by using ASCII 31 delimiters
    s=size(inputscript_array);
    inputscript_str='';
    for j=1:(s(1)-1)
        inputscript_str=inputscript_str+inputscript_array(j)+ascii(31);
    end
    inputscript_str=inputscript_str+inputscript_array(s(1));
    // We tranform the final packed command as an assigment to evaluate
    inputscript_assignment = sci2exp(inputscript_str, 'inputscript');
    // We add the code used to decode the packed instructions
    inputscript_decode = 'TOKENS = tokens(inputscript,ascii(31)); execstr(TOKENS,''errcatch'',''m'');';
    inputScript = strcat([inputscript_assignment;';';inputscript_decode]);
endfunction

function mainScript = createMainScript(funcName, opt)
    debugv = opt.Debug;
    if debugv == 1
        //mainScript = strcat(['mode(3)';ascii(31);'out=';funcName;'(in)';ascii(31);ascii(30);'output = sci2exp(output,''''output'''',0)';ascii(31);'disp(out)']);
        mainScript = strcat(['mode(3)';ascii(31);'out=';funcName;'(in)';ascii(31);'disp(out)']);
    else
        //mainScript = strcat(['out=';funcName;'(in);';ascii(31);ascii(30);'output = sci2exp(output,''''output'''',0);']);
        mainScript = strcat(['out=';funcName;'(in);']);
    end
endfunction

function outputs = PAsolve(varargin)
    global ('PA_connected','DataRegistry', 'DataRegistryInit', 'SOLVEid')

    if ~exists('PA_connected') | PA_connected ~= 1
        error('A connection to the ProActive scheduler must be established in order to use PAsolve, see PAconnect');
    end

    if exists('SOLVEid') & type(SOLVEid) == 8
        SOLVEid = SOLVEid + 1;
    else
        SOLVEid = int32(0);
    end

    opt=PAoptions();

    deff ("y=ischar(x)","y=type(x)==10","n");
    if ischar(varargin(1)) then
        Func = varargin(1);
        NN=length(varargin)-1;
        Tasks = PATask(1,NN);
        Tasks(1,1:NN).Func = Func;
        for i=1:NN
            if typeof(varargin(i+1)) == 'list'
                Tasks(1,i).Params =varargin(i+1);
            else
                Tasks(1,i).Params =list(varargin(i+1));
            end
        end
        MM = 1;
    elseif typeof(varargin(1)) == 'PATask'
        if length(varargin) == 1
            Tasks = varargin(1);
            NN = size(Tasks,2);
            MM = size(Tasks,1);
        else
            NN=argn(2);
            MM = -1;
            for i=1:NN
                if typeof(varargin(i)) == 'PATask'
                    if (size(varargin(i),2) ~= 1)
                        error(strcat(['parameter ', string(i), ' should be a column vector.']));
                    end
                    sz = size(varargin(i),1);
                    if MM == -1
                        MM = sz;
                        Tasks=PATask(MM,NN);
                    elseif MM ~= sz
                        error(strcat(['parameter ', string(i), ' should be a column vector of the same length than other parameters.']));
                    end
                    Tasks(1:sz,i) = varargin(i);
                else
                    error(strcat(['parameter ', num2str(i), ' is a ', typeof(varargin(i)), ', expected PATask instead.']));
                end
            end

        end
    end

    jimport org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabGlobalConfig;
    jimport org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabTaskConfig;
    jimport org.ow2.proactive.scheduler.ext.common.util.FileUtils;
    jimport org.ow2.proactive.scheduler.ext.matsci.client.AODataspaceRegistry;
    jimport java.lang.String;
    jimport java.net.URL;
    jimport java.io.File;

    solve_config = jnewInstance(PASolveScilabGlobalConfig);

    solve_config.setDebug(opt.Debug);
    solve_config.setTimeStamp(opt.TimeStamp);
    solve_config.setFork(opt.Fork);
    solve_config.setRunAsMe(opt.RunAsMe);
    solve_config.setPriority(opt.Priority);
    solve_config.setTransferSource(opt.TransferSource);
    //solve_config.setTransferEnv(opt.TransferEnv);
    solve_config.setTransferVariables(opt.TransferVariables);
    solve_config.setKeepEngine(opt.KeepEngine);
    jinvoke(solve_config,'setWindowsStartupOptionsAsString',opt.WindowsStartupOptions);
    jinvoke(solve_config,'setLinuxStartupOptionsAsString',opt.LinuxStartupOptions);

    solve_config.setInputSpaceName('ScilabInputSpace');
    solve_config.setOutputSpaceName('ScilabOutputSpace');

    solve_config.setVersionPref(opt.VersionPref);
    solve_config.setVersionRejAsString(opt.VersionRej);
    solve_config.setVersionMin(opt.VersionMin);
    solve_config.setVersionMax(opt.VersionMax);
    solve_config.setCheckMatSciUrl(opt.FindScilabScript);
    if ischar(opt.CustomScript)
        selects = opt.CustomScript
        try
            url=URL.new(selects);
            ok = true;
        catch
            ok = false;
        end
        jremove(url);

        if ~ok
            solve_config.setCustomScriptUrl(strcat(['file:', selects]));
        else
            solve_config.setCustomScriptUrl(selects);
        end
    end

    solve_config.setZipSourceFiles(%f);

    curr_dir = pwd();
    fs=filesep();
    curr_dir_java = File.new(curr_dir);
    if ~jinvoke(curr_dir_java,'canWrite')
        jremove(curr_dir_java);
        error('Current Directory should have write access rights');
    end
    jremove(curr_dir_java);

    // PAScheduler sub directory init

    subdir = '.PAScheduler';
    solve_config.setTempSubDirName(subdir);

    if isempty(opt.CustomDataspaceURL)
        if ~isdir(strcat([curr_dir, fs, subdir]))
            mkdir(curr_dir,subdir);
        end
        pa_dir = strcat([curr_dir, fs, subdir]);
    else
        if isempty(opt.CustomDataspacePath)
            error('if CustomDataspaceURL is specified, CustomDataspacePath must be specified also');
        end
        if ~isdir(strcat([opt.CustomDataspacePath, fs, subdir]))
            mkdir(opt.CustomDataspacePath,subdir);
        end
        pa_dir = strcat([opt.CustomDataspacePath, fs, subdir]);
    end

    if isempty(opt.CustomDataspaceURL)
        if ~exists('DataRegistryInit') | DataRegistryInit ~= 1
            DataRegistry = AODataspaceRegistry.new('ScilabInputSpace','ScilabOutputSpace','ScilabSession',opt.Debug);
            DataRegistryInit = 1;
        end
        pair = DataRegistry.createDataSpace(curr_dir);
        px=jinvoke(pair,'getX');
        py=jinvoke(pair,'getY');
        pxs = jcast(px,'java.lang.String');
        pys = jcast(py,'java.lang.String');
        solve_config.setInputSpaceURL(pxs);
        solve_config.setOutputSpaceURL(pys);
        if opt.Debug then
            disp('using Dataspace:')
            disp(pxs)
        end

    else
        solve_config.setOutputSpaceURL(opt.CustomDataspaceURL);
        solve_config.setInputSpaceURL(opt.CustomDataspaceURL);
    end

    variableInFileBaseName = ['ScilabPAsolveVarIn_' string(SOLVEid)];
    variableOutFileBaseName = ['ScilabPAsolveVarOut_' string(SOLVEid)];
    outVarFiles = list(NN);
    //tmpFiles = list();
    taskFilesToClean = list();

    task_configs = jarray('org.ow2.proactive.scheduler.ext.scilab.common.PASolveScilabTaskConfig', NN,MM);
    for i=1:NN
        taskFilesToClean($+1)=list();
        for j=1:MM
            t_conf = jnewInstance(PASolveScilabTaskConfig);
            task_configs(i-1,j-1) = t_conf;
            if ~isempty(Tasks(j,i).Description) then
                t_conf.setDescription(Tasks(j,i).Description);
            end

            // Input Files
            if ~isempty(Tasks(j,i).InputFiles) then
                ilen = length(Tasks(j,i).InputFiles);
                if ilen > 0 then
                    inputFiles = jarray('java.lang.String', ilen);
                    filelist = Tasks(j,i).InputFiles;
                    for k=1:ilen
                        filename = filelist(k);
                        inputFiles(k-1)=String.new(strsubst(filename,'\','/'));
                    end

                    t_conf.setInputFiles(inputFiles);
                    t_conf.setInputFilesThere(%t);
                end
            end

            // Output Files
            if ~isempty(Tasks(j,i).OutputFiles) then
                filelist = Tasks(j,i).OutputFiles;
                ilen = length(filelist);
                if ilen > 0 then
                    outputFiles = jarray('java.lang.String', ilen);
                    for k=1:ilen
                        filename = filelist(k);
                        outputFiles(k-1)=String.new(strsubst(filename,'\','/'));
                    end

                    t_conf.setOutputFiles(outputFiles);
                    t_conf.setOutputFilesThere(%t);
                end
            end

            // Custom Script
            if ~isempty(Tasks(j,i).SelectionScript) then
                selects = Tasks(j,i).SelectionScript;
                try
                    url = URL.new(selects);
                    ok = true;
                catch
                    ok = false;
                end
                jremove(url);

                if ~ok
                    t_conf.setCustomScriptUrl(strcat(['file:', selects ]));
                else
                    t_conf.setCustomScriptUrl(selects);
                end
            end

            // Function
            Func = Tasks(j,i).Func;
            execstr(strcat(['functype = type(';Func;');']));
            if (functype <> 13) & (functype <> 11)  then
                error('invalid function type for function ""' + Func + '"". Consider calling this function with a macro instead.');
            end

            // Source Files

            if ~isempty(Tasks(j,i).Sources) then
                srcs = Tasks(j,i).Sources;
                for k=1:length(srcs)
                    srcPath = srcs(k);
                    if isfile(srcPath) then
                        [ppath,fname,extension]=fileparts(srcPath);
                        srcName = strcat(strcat([fname,extension]));

                        if opt.Debug then
                            disp(strcat(['Copying file ', srcPath, ' to ',pa_dir]));
                        end
                        copyfile(srcPath,pa_dir);
                        // TODO find a cleaning mechanisme
                        //taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(pa_dir+fs+fname+extension));
                        //tmpFiles($+1)=strcat([pa_dir,fs,fname,extension]);

                        strName = String.new(srcName);
                        t_conf.addSourceFile(strName);
                    else
                        error(strcat(['Source file ', srcPath, ' cannot be found']));
                    end

                end

            end

            // Saving main function name (with or without Sources attribute)
            sourceNames = jarray('java.lang.String', 1);
            sFN = 'ScilabPAsolve_src'+string(SOLVEid)+indToFile([i j])+'.bin';
            execstr('save(pa_dir+fs+sFN,'+Func+');');
            strName = String.new(sFN);
            sourceNames(0) = strName;
            t_conf.setFunctionVarFiles(sourceNames);
            code=[];
            taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(pa_dir+fs+sFN));

            t_conf.setFunctionName(Func);
            t_conf.addSourceFile(sFN);

            // Params
            argi = Tasks(j,i).Params;
            if opt.TransferVariables
                inVarFN = strcat([variableInFileBaseName, indToFile([i j]), '.dat']);
                outVarFN = strcat([variableOutFileBaseName, indToFile([i j]), '.dat']);
                inVarFP = strcat([pa_dir, fs, inVarFN]);
                outVarFP = strcat([pa_dir, fs, outVarFN]);
                // Creating input parameters mat files
                fd=mopen(inVarFP,'wb');
                inl = argi;
                if length(inl) == 0
                    inl=list(%t);
                end
                for k=1:length(inl)
                    execstr('in'+string(k)+'=inl(k);');
                    execstr('save(fd,in'+string(k)+')');
                end
                mclose(fd);

                jinvoke(t_conf,'setInputVariablesFileName',inVarFN);
                jinvoke(t_conf,'setOutputVariablesFileName',outVarFN);
                if j > 1 & Tasks(j,i).Compose
                    cinVarFN = strcat([variableOutFileBaseName,indToFile([i j-1]),'.dat']);
                    cinVarFP = pa_dir+fs+cinVarFN;
                    jinvoke(t_conf,'setComposedInputVariablesFileName',cinVarFN);
                end
                outVarFiles(i) = outVarFP;
                taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(inVarFP));
                //if j < MM
                // because of disconnected mode, the final out is handled
                //differently
                taskFilesToClean(i)=lstcat(taskFilesToClean(i), list(outVarFP));
                //end

                inputscript = 'i=0';
            else
                inputscript = createInputScript(argi);
            end

            t_conf.setInputScript(inputscript);

            //mainScript = createMainScript(Func, opt);
            mainScript = 'out = '+Tasks(j,i).Func+'(';
            if j > 1 & Tasks(j,i).Compose
                mainScript = mainScript + 'in';
                if length(argi) > 0 then
                    mainScript = mainScript + ',';
                end
            end
            if length(argi) > 0
                for k=1:length(argi)-1
                    mainScript = mainScript + 'in'+string(k)+',';
                end
                mainScript = mainScript + ('in'+string(length(argi)));
            end
            mainScript = mainScript + ');';
            t_conf.setMainScript(mainScript);

            t_conf.setOutputs('out');

        end
    end
    jimport org.ow2.proactive.scheduler.ext.scilab.client.ScilabSolver;
    jimport org.objectweb.proactive.api.PAFuture;
    solver = jnewInstance(ScilabSolver);

    pairinfolist = solver.solve(solve_config, task_configs);

    jobinfo = jinvoke(pairinfolist,'getX');
    resfutureList =  jinvoke(pairinfolist,'getY');
    jid = string(jinvoke(jobinfo,'getJobId'));
    disp('Job submitted : '+ jid);

    ftn = jinvoke(jobinfo,'getFinalTasksNamesAsList');

    taskinfo = struct('cleanFileSet',[],'cleanDirSet',[], 'outFile',[], 'jobid',[], 'taskid',[] );
    results=list(NN);
    for i=1:NN
        taskinfo.cleanFileSet = taskFilesToClean(i);
        taskinfo.cleanDirSet = list(pa_dir);
        taskinfo.outFile = outVarFiles(i);
        taskinfo.jobid = jid;
        taskinfo.taskid = jinvoke(ftn,'get',i-1);

        results(i)=PAResult(jinvoke(resfutureList,'get',i-1), taskinfo);

    end
    outputs = PAResL(results);
    jremove(solver, solve_config, task_configs);

endfunction

function nm=indToFile(ind)
    nm='';
    if ind==-1
        return;
    end
    for JJ=ind
        nm=strcat([nm, '_', string(JJ)]);
    end
endfunction

function inputScript = createInputScript(arg)
    // We transform the argument to executable scilab code
    argcode = sci2exp(arg,'in');
    // The inputscript will contain the argument and the code of the functions
    inputscript_array=[argcode];
    // The code defining the function is made of many lines, we pack it by using ASCII 31 delimiters
    s=size(inputscript_array);
    inputscript_str='';
    for j=1:(s(1)-1)
        inputscript_str=inputscript_str+inputscript_array(j)+ascii(31);
    end
    inputscript_str=inputscript_str+inputscript_array(s(1));
    // We tranform the final packed command as an assigment to evaluate
    inputscript_assignment = sci2exp(inputscript_str, 'inputscript');
    // We add the code used to decode the packed instructions
    inputscript_decode = 'TOKENS = tokens(inputscript,ascii(31)); execstr(TOKENS,''errcatch'',''m'');';
    inputScript = strcat([inputscript_assignment;';';inputscript_decode]);
endfunction

function mainScript = createMainScript(funcName, opt)
    debugv = opt.Debug;
    if debugv == 1
        //mainScript = strcat(['mode(3)';ascii(31);'out=';funcName;'(in)';ascii(31);ascii(30);'output = sci2exp(output,''''output'''',0)';ascii(31);'disp(out)']);
        mainScript = strcat(['mode(3)';ascii(31);'out=';funcName;'(in)';ascii(31);'disp(out)']);
    else
        //mainScript = strcat(['out=';funcName;'(in);';ascii(31);ascii(30);'output = sci2exp(output,''''output'''',0);']);
        mainScript = strcat(['out=';funcName;'(in);']);
    end
endfunction


testing with echo

testing with echo


Add stick plot animation

Add stick plot animation

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

scf(0);
plot(toes.x,toes.y);
toes.speed = CalcSpeed(toes)

toes.speed.x = MovingMean(toes.speed.x)
toes.speed.x = MovingMean(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, ?#
scf(1);clf();

data_tmp = [toes.x(1),toes.y(1);ankle.x(1),ankle.y(1);knee.x(1),knee.y(1);hip.x(1),hip.y(1);neck.x(1),neck.y(1);shoulder.x(1),shoulder.y(1);elbow.x(1),elbow.y(1);hand.x(1),hand.y(1)];
plot(data_tmp(:,1), data_tmp(:,2))
e = gce();
h_stick = e.children;

a = gca();
a.data_bounds=[0,0;2,2];

for i = 1 : size(toes.x,1)
    drawlater
    data_tmp = [toes.x(i),toes.y(i);ankle.x(i),ankle.y(i);knee.x(i),knee.y(i);hip.x(i),hip.y(i);neck.x(i),neck.y(i);shoulder.x(i),shoulder.y(i);elbow.x(i),elbow.y(i);hand.x(i),hand.y(i)];
    h_stick.data = data_tmp;
    sleep(100);
    drawnow
    disp(i)
end

//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);

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)


Warn code generation is not for superblock

function mdaq_code_gen(load_dsp_app)

    if  check_mdaq_compiler() == %F then
        messagebox("Can''t locate compiler for compiling generated code. To solve this problem run microdaq_setup() function", "Settings error", "error");
        return;
    end

    standalone = %f;
    debug_build = %t;
    profiling = %f;
    solver_type = 0;
    continue_code_gen = %f;

    scs_m;

    // TODO: make general solution for scilab 5/6
    try
        size(scs_m.objs)
    catch
        messagebox("Can''t generate code from inside of superblock.", "Code generation problem", "error")
        return
    end

    if argn(2)<2 then
        k=1;
        for i=1:(size(scs_m.objs)-1)
            // in case of superblock set k
            if scs_m.objs(i).model.sim(1)=="super" then
                k=i;
            end

            // in case of mdaq_setup get code gen parameters
            if scs_m.objs(i).model.sim(1)=="mdaq_setup" then

                // get build mode from model setup block
                if scs_m.objs(i).model.ipar(1) == 1 then
                    debug_build = %f;
                else
                    debug_build = %t;
                end

                // get build type from model setup block
                if scs_m.objs(i).model.ipar(2) == 1 then
                    standalone = %f;
                else
                    standalone = %t;
                end

                // check if profiling is enabled
                if scs_m.objs(i).model.ipar(3) == 1 then
                    profiling = %t;
                else
                    profiling = %f;
                end
                solver_type = scs_m.objs(i).model.ipar(4);

                // mdaq_setup block found so code gen can be executed
                continue_code_gen = %t;
            end;
        end
    end

    if continue_code_gen == %f then
        messagebox("Can''t determine model settings - use SETUP block from MicroDAQ palette.", "SETUP missing", "error");
        return;
    end

    if scs_m.objs(k).model.sim(1)=="super" then
        XX = scs_m.objs(k); //** isolate the super block to use

        // Save format
        oldFormat = format();
        format('v',10);

        [ok, XX, alreadyran, flgcdgen, szclkINTemp, freof] =  do_compile_superblock_rt(XX, scs_m, k, %f, standalone, debug_build, profiling, solver_type, load_dsp_app);

        // Restore format
        format(oldFormat(2), oldFormat(1));
        if ok == %f then
            messagebox("Can''t generate code from model. Check model for errors", "Model error", "error");
        end
    else
        messagebox("Can''t find superblock for code generation",  "Model structure problem", "error");
    end

endfunction

function mdaq_code_gen(load_dsp_app)

    if  check_mdaq_compiler() == %F then
        message("ERROR: Unable to find compiler - configure toolbox with microdaq_setup! ");
        return;
    end

    standalone = %f;
    debug_build = %t;
    profiling = %f;
    solver_type = 0;
    continue_code_gen = %f;

    scs_m;

    if argn(2)<2 then
        k=1;
        for i=1:(size(scs_m.objs)-1)

            // in case of superblock set k
            if scs_m.objs(i).model.sim(1)=="super" then
                k=i;
            end

            // in case of mdaq_setup get code gen parameters
            if scs_m.objs(i).model.sim(1)=="mdaq_setup" then

                // get build mode from model setup block
                if scs_m.objs(i).model.ipar(1) == 1 then
                    debug_build = %f;
                else
                    debug_build = %t;
                end

                // get build type from model setup block
                if scs_m.objs(i).model.ipar(2) == 1 then
                    standalone = %f;
                else
                    standalone = %t;
                end

                // check if profiling is enabled
                if scs_m.objs(i).model.ipar(3) == 1 then
                    profiling = %t;
                else
                    profiling = %f;
                end
                solver_type = scs_m.objs(i).model.ipar(4);

                // mdaq_setup block found so code gen can be executed
                continue_code_gen = %t;
            end;
        end
    end

    if continue_code_gen == %f then
        messagebox('Unable to generate code, place SETUP (''mdaq_setup'') block from MicroDAQ palette and try again',  "Simulation problem", "error");
        return;
    end

    if scs_m.objs(k).model.sim(1)=="super" then
        XX = scs_m.objs(k); //** isolate the super block to use

        // Save format
        oldFormat = format();
        format('v',10);

        [ok, XX, alreadyran, flgcdgen, szclkINTemp, freof] =  do_compile_superblock_rt(XX, scs_m, k, %f, standalone, debug_build, profiling, solver_type, load_dsp_app);

        // Restore format
        format(oldFormat(2), oldFormat(1));
        if ok == %f then

            disp("### ERROR: Unable to generate code from model");
        end
    else
        messagebox('MicroDAQ code generator requires superblock to generate code',  "Model structure problem", "error");
    end

endfunction


Add Scilab version control for 6.0

Add Scilab version control for 6.0

mode(-1);
lines(0);
global PA_matsci_dir

TOOLBOX_NAME = 'ProActiveConnector';
TOOLBOX_TITLE = 'ProActive Connector';

// Version Check
version = getversion('scilab');
if version(1) < 5 | (version(1) == 5 & version(2) < 5 | version(1) >= 6)
	error(gettext('Scilab version higher than 5.5.0 and lower than 6 is required.'));
end

disp('Build ProActive');

root_tlbx = get_absolute_file_path('builder.sce');
if ~exists('PA_matsci_dir') | PA_matsci_dir == []
    if part(root_tlbx, length(root_tlbx)) == '/' then
       PA_matsci_dir=part(root_tlbx, 1:length(root_tlbx)-1);
    else
        PA_matsci_dir=root_tlbx;
    end
end
// ====================================================================
//if ~with_module('development_tools') then
//    error(msprintf(gettext('%s module not installed."),'development_tools'));
//end
macros=root_tlbx+'macros';

//ilib_build('importjava',sci_gtw,[cpp c jni gateway],[],'','-ljvm',include);

tbx_builder_macros(root_tlbx);
tbx_builder_help(root_tlbx);
tbx_build_loader(TOOLBOX_NAME, root_tlbx);
tbx_build_cleaner(TOOLBOX_NAME, root_tlbx);

//genlib('toolbox_pascheduler',macros);

clear root_tlbx TOOLBOX_NAME TOOLBOX_TITLE;

mode(-1);
lines(0);
global PA_matsci_dir

TOOLBOX_NAME = 'ProActiveConnector';
TOOLBOX_TITLE = 'ProActive Connector';

// Version Check
version = getversion('scilab');
if version(1) < 5 | (version(1) = 5 & version(2) < 5)
	error(gettext('Scilab 5.5.0 or more is required.'));
end

disp('Build ProActive');

root_tlbx = get_absolute_file_path('builder.sce');
if ~exists('PA_matsci_dir') | PA_matsci_dir == []
    if part(root_tlbx, length(root_tlbx)) == '/' then
       PA_matsci_dir=part(root_tlbx, 1:length(root_tlbx)-1);
    else
        PA_matsci_dir=root_tlbx;
    end
end
// ====================================================================
//if ~with_module('development_tools') then
//    error(msprintf(gettext('%s module not installed."),'development_tools'));
//end
macros=root_tlbx+'macros';

//ilib_build('importjava',sci_gtw,[cpp c jni gateway],[],'','-ljvm',include);

tbx_builder_macros(root_tlbx);
tbx_builder_help(root_tlbx);
tbx_build_loader(TOOLBOX_NAME, root_tlbx);
tbx_build_cleaner(TOOLBOX_NAME, root_tlbx);

//genlib('toolbox_pascheduler',macros);

clear root_tlbx TOOLBOX_NAME TOOLBOX_TITLE;


INTEGRATION: CWS sab008 (1.2.22); FILE MERGED 2004/03/04 13:16:01 sw 1.2.22.2: #115035# 2004/02/19 12:15:03 sw 1.2.22.1: #111653#

### 114242 ### -o sc.ScPageObj
### 111147 ### -o sc.AccessibleEditableTextPara_PreviewNote
-o sc.ScSpreadsheetSettings
-o sc.ScTabViewObj
-o sc.ScAccessibleCell
-o sc.ScSpreadsheetSettingsObj
-o sc.ScShapeObj
-o sc.ScDocumentConfiguration
-o sc.ScCellCursorObj
-o sc.ScCellRangeObj
-o sc.ScCellRangesObj
-o sc.ScTableSheetObj
-o sc.AccessibleEditableTextPara_HeaderFooter
-o sc.AccessibleEditableTextPara_PreviewCell
-o sc.ScAccessibleDocumentPagePreview
-o sc.ScAccessiblePageHeader
-o sc.ScAccessiblePageHeaderArea
-o sc.ScAccessiblePreviewCell
-o sc.ScAccessiblePreviewHeaderCell
-o sc.ScAccessiblePreviewTable
-o sc.ScAnnotationObj
-o sc.ScAnnotationsObj
-o sc.ScAreaLinkObj
-o sc.ScAreaLinksObj
-o sc.ScAutoFormatFieldObj
-o sc.ScAutoFormatObj
-o sc.ScAutoFormatsObj
-o sc.ScCellFieldObj
-o sc.ScCellFieldsObj
-o sc.ScCellFormatsEnumeration
-o sc.ScCellFormatsObj
-o sc.ScCellObj
-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.ScDataPilotFieldObj
-o sc.ScDataPilotFieldsObj
-o sc.ScDataPilotTableObj
-o sc.ScDataPilotTablesObj
-o sc.ScDatabaseRangeObj
-o sc.ScDatabaseRangesObj
-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_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.ScSheetLinkObj
-o sc.ScSheetLinksObj
-o sc.ScStyleFamiliesObj
-o sc.ScStyleFamilyObj
-o sc.ScStyleObj
-o sc.ScSubTotalDescriptorBase
-o sc.ScSubTotalFieldObj
-o sc.ScTableColumnObj
-o sc.ScTableColumnsObj
-o sc.ScTableConditionalEntry
-o sc.ScTableConditionalFormat
-o sc.ScTableRowObj
-o sc.ScTableRowsObj
-o sc.ScTableSheetsObj
-o sc.ScTableValidationObj
-o sc.ScViewPaneObj
-o sc.XMLContentExporter
-o sc.XMLContentImporter
-o sc.XMLExporter
-o sc.XMLImporter
-o sc.XMLMetaExporter
-o sc.XMLMetaImporter
-o sc.XMLSettingsExporter
-o sc.XMLSettingsImporter
-o sc.XMLStylesExporter
-o sc.XMLStylesImporter
-o sc.ScAccessibleSpreadsheet
-o sc.ScAccessibleCsvGrid
-o sc.ScAccessibleCsvCell
-o sc.ScAccessibleCsvRuler
-o sc.ScAccessibleDocument

### 114242 ### -o sc.ScPageObj
### 111147 ### -o sc.AccessibleEditableTextPara_PreviewNote
-o sc.ScCellCursorObj
-o sc.ScCellRangeObj
-o sc.ScCellRangesObj
-o sc.ScTableSheetObj
-o sc.AccessibleEditableTextPara_HeaderFooter
-o sc.AccessibleEditableTextPara_PreviewCell
-o sc.ScAccessibleCell
-o sc.ScAccessibleDocumentPagePreview
-o sc.ScAccessiblePageHeader
-o sc.ScAccessiblePageHeaderArea
-o sc.ScAccessiblePreviewCell
-o sc.ScAccessiblePreviewHeaderCell
-o sc.ScAccessiblePreviewTable
-o sc.ScAnnotationObj
-o sc.ScAnnotationsObj
-o sc.ScAreaLinkObj
-o sc.ScAreaLinksObj
-o sc.ScAutoFormatFieldObj
-o sc.ScAutoFormatObj
-o sc.ScAutoFormatsObj
-o sc.ScCellFieldObj
-o sc.ScCellFieldsObj
-o sc.ScCellFormatsEnumeration
-o sc.ScCellFormatsObj
-o sc.ScCellObj
-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.ScDataPilotFieldObj
-o sc.ScDataPilotFieldsObj
-o sc.ScDataPilotTableObj
-o sc.ScDataPilotTablesObj
-o sc.ScDatabaseRangeObj
-o sc.ScDatabaseRangesObj
-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_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.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
-o sc.ScTabViewObj
-o sc.ScTableColumnObj
-o sc.ScTableColumnsObj
-o sc.ScTableConditionalEntry
-o sc.ScTableConditionalFormat
-o sc.ScTableRowObj
-o sc.ScTableRowsObj
-o sc.ScTableSheetsObj
-o sc.ScTableValidationObj
-o sc.ScViewPaneObj
-o sc.XMLContentExporter
-o sc.XMLContentImporter
-o sc.XMLExporter
-o sc.XMLImporter
-o sc.XMLMetaExporter
-o sc.XMLMetaImporter
-o sc.XMLSettingsExporter
-o sc.XMLSettingsImporter
-o sc.XMLStylesExporter
-o sc.XMLStylesImporter
-o sc.ScAccessibleSpreadsheet
-o sc.ScAccessibleCsvGrid
-o sc.ScAccessibleCsvCell
-o sc.ScAccessibleCsvRuler
-o sc.ScAccessibleDocument


Don't change directory after function complited

function mdaq_block_build(debug_build)
    if  check_mdaq_compiler() == %F then
        disp("ERROR: Compiler not found - run microdaq_setup! ");
        return;
    end

    mprintf(" ### Building user block macros...\n")
    macros_path = mdaq_toolbox_path() + "macros" + filesep() + "user_blocks" + filesep();
    tbx_build_macros("microdaq", macros_path);

    blocks = [];
    cd(macros_path);
    macros = ls("*_sim.sci")
    for i=1:size(macros,'*')
        blocks(i) = part(macros(i), 1:length(macros(i)) - 8);
    end

    p_dir = pwd();
    cd(mdaq_toolbox_path());
    tbx_build_blocks(mdaq_toolbox_path(), blocks, "macros" + filesep() + "user_blocks");

//    root_tlbx = mdaq_toolbox_path();
//    if isfile(root_tlbx + filesep() + "macros" + filesep() + "user_blocks" + filesep() + "names")  == %T then
//        errcatch(999,"continue");
//        xcosPalDelete("MicroDAQ User");
//        pal = xcosPal("MicroDAQ User");
//        microdaq_blocks = mgetl( root_tlbx + filesep() + "macros" + filesep() + "user_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
//
//        for i=1:size(blocks, "*")
//            h5  = ls(root_tlbx + "/images/h5/"  + blocks(i) + "." + ["sod" "h5"]);
//            gif = ls(root_tlbx + "/images/gif/" + blocks(i) + "." + ["png" "jpg" "gif"]);
//            svg = ls(root_tlbx + "/images/svg/" + blocks(i) + "." + ["png" "jpg" "gif" "svg"]);
//            pal = xcosPalAddBlock(pal, h5(1), gif(1), svg(1));
//        end
//
//        if ~xcosPalAdd(pal,"MicroDAQ User") then
//            error(msprintf(gettext("%s: Unable to export %s.\n"), "microdaq.start", "pal"));
//        end
//    end

    root_path = mdaq_toolbox_path();
    userlib_src_path = root_path + filesep() + "src" + filesep() + "c"+ filesep() + "userlib" + filesep();
    userlib_path = root_path + filesep() + "etc" + filesep() + "userlib" + filesep() + "lib" + filesep();

    wd = pwd();
    chdir(userlib_src_path);
    GMAKE = root_path + "\etc\bin\gmake.exe";
    mprintf(" ### Building userlib...\n")
    if getenv('WIN32','NO')=='OK' then
        if argn(2) > 0 & argn(2) < 2 then
            if debug_build then
                unix_w(GMAKE + ' -f Makefile' + ' OPT_FLAG=-g');
            else
                unix_w(GMAKE + ' -f Makefile' );
            end

        else
            unix_w(GMAKE + ' -f Makefile' );
        end

    else
        if argn(2) > 0 & argn(2) < 2 then
            if debug_build then
                unix_w('make' + ' OPT_FLAG=-g')
            else
                unix_w('make')
            end
        else
            unix_w('make')
        end

    end

    if isfile("userlib.lib") then
        copyfile("userlib.lib", userlib_path);
    end
    chdir(p_dir);
endfunction

function mdaq_block_build(debug_build)
    if  check_mdaq_compiler() == %F then
        disp("ERROR: Compiler not found - run microdaq_setup! ");
        return;
    end

    mprintf(" ### Building user block macros...\n")
    macros_path = mdaq_toolbox_path() + "macros" + filesep() + "user_blocks" + filesep();
    tbx_build_macros("microdaq", macros_path);

    blocks = [];
    cd(macros_path);
    macros = ls("*_sim.sci")
    for i=1:size(macros,'*')
        blocks(i) = part(macros(i), 1:length(macros(i)) - 8);
    end

    p_dir = pwd();
    cd(mdaq_toolbox_path());
    tbx_build_blocks(mdaq_toolbox_path(), blocks, "macros" + filesep() + "user_blocks");

    root_path = mdaq_toolbox_path();
    userlib_src_path = root_path + filesep() + "src" + filesep() + "c"+ filesep() + "userlib" + filesep();
    userlib_path = root_path + filesep() + "etc" + filesep() + "userlib" + filesep() + "lib" + filesep();

    wd = pwd();
    chdir(userlib_src_path);
    GMAKE = root_path + "\etc\bin\gmake.exe";
    mprintf(" ### Building userlib...\n")
    if getenv('WIN32','NO')=='OK' then
        if argn(2) > 0 & argn(2) < 2 then
            if debug_build then
                unix_w(GMAKE + ' -f Makefile' + ' OPT_FLAG=-g');
            else
                unix_w(GMAKE + ' -f Makefile' );
            end

        else
            unix_w(GMAKE + ' -f Makefile' );
        end

    else
        if argn(2) > 0 & argn(2) < 2 then
            if debug_build then
                unix_w('make' + ' OPT_FLAG=-g')
            else
                unix_w('make')
            end
        else
            unix_w('make')
        end

    end

    if isfile("userlib.lib") then
        copyfile("userlib.lib", userlib_path);
    end
    chdir(wd);
endfunction


INTEGRATION: CWS unoapi1 (1.6.854); FILE MERGED 2007/10/11 21:33:27 cn 1.6.854.2: #i79479# update lists 2007/07/12 19:25:43 cn 1.6.854.1: #i79479# update list

# -o sw.CharacterStyle
# -o sw.ConditionalParagraphStyle
# -o sw.PageStyle
# -o sw.ParagraphStyle
# -o sw.SwAccessibleDocumentPageView
# -o sw.SwAccessibleDocumentView
# -o sw.SwAccessibleEndnoteView
# -o sw.SwAccessibleFooterView
# -o sw.SwAccessibleFootnoteView
# -o sw.SwAccessibleHeaderView
# -o sw.SwAccessiblePageView
# -o sw.SwAccessibleParagraphView
# -o sw.SwAccessibleTableCellView
# -o sw.SwAccessibleTableView
# -o sw.SwAccessibleTextEmbeddedObject
# -o sw.SwAccessibleTextFrameView
# -o sw.SwAccessibleTextGraphicObject
-o sw.SwXAutoTextContainer
-o sw.SwXAutoTextEntry
-o sw.SwXAutoTextGroup
-o sw.SwXBodyText
-o sw.SwXBookmark
-o sw.SwXBookmarks
-o sw.SwXCell
-o sw.SwXCellRange
-o sw.SwXChapterNumbering
-o sw.SwXDocumentIndex
-o sw.SwXDocumentIndexMark
-o sw.SwXDocumentIndexes
-o sw.SwXDrawPage
-o sw.SwXEndnoteProperties
-o sw.SwXFieldEnumeration
-o sw.SwXFieldMaster
-o sw.SwXFootnote
-o sw.SwXFootnoteProperties
-o sw.SwXFootnoteText
-o sw.SwXFootnotes
-o sw.SwXFrames
-o sw.SwXHeadFootText
-o sw.SwXLineNumberingProperties
#-o sw.SwXMailMerge
-o sw.SwXModule
-o sw.SwXNumberingRules
-o sw.SwXParagraph
-o sw.SwXParagraphEnumeration
-o sw.SwXPrintSettings
-o sw.SwXPropertySet
-o sw.SwXPropertySetInfo
-o sw.SwXReferenceMark
-o sw.SwXReferenceMarks
-o sw.SwXShape
-o sw.SwXStyleFamilies
-o sw.SwXStyleFamily
-o sw.SwXTableCellText
-o sw.SwXTableColumns
-o sw.SwXTableRows
-o sw.SwXTextColumns
-o sw.SwXTextCursor
-o sw.SwXTextDefaults
-o sw.SwXTextDocument
-o sw.SwXTextEmbeddedObject
-o sw.SwXTextEmbeddedObjects
-o sw.SwXTextField
-o sw.SwXTextFieldMasters
-o sw.SwXTextFieldTypes
-o sw.SwXTextFrame
-o sw.SwXTextFrameText
-o sw.SwXTextGraphicObject
-o sw.SwXTextGraphicObjects
-o sw.SwXTextPortion
-o sw.SwXTextPortionEnumeration
-o sw.SwXTextRange
-o sw.SwXTextRanges
-o sw.SwXTextSearch
-o sw.SwXTextSection
-o sw.SwXTextSections
-o sw.SwXTextTable
-o sw.SwXTextTableCursor
-o sw.SwXTextTableRow
-o sw.SwXTextTables
-o sw.SwXTextView
-o sw.SwXTextViewCursor
-o sw.SwXViewSettings
-o sw.XMLContentExporter
-o sw.XMLContentImporter
-o sw.XMLExporter
-o sw.XMLImporter
-o sw.XMLMetaExporter
-o sw.XMLMetaImporter
-o sw.XMLSettingsExporter
-o sw.XMLSettingsImporter
-o sw.XMLStylesExporter
-o sw.XMLStylesImporter
-o sw.DocumentSettings

# test works on windows with cws tl12 except swXMailMerge and SwXMLImporter
# but this could be a problem of the NONPRO-Version

-o sw.CharacterStyle
-o sw.ConditionalParagraphStyle
-o sw.PageStyle
-o sw.ParagraphStyle
-o sw.SwAccessibleDocumentPageView
-o sw.SwAccessibleDocumentView
-o sw.SwAccessibleEndnoteView
-o sw.SwAccessibleFooterView
-o sw.SwAccessibleFootnoteView
-o sw.SwAccessibleHeaderView
-o sw.SwAccessiblePageView
-o sw.SwAccessibleParagraphView
-o sw.SwAccessibleTableCellView
-o sw.SwAccessibleTableView
-o sw.SwAccessibleTextEmbeddedObject
-o sw.SwAccessibleTextFrameView
-o sw.SwAccessibleTextGraphicObject
-o sw.SwXAutoTextContainer
# i41735#-o sw.SwXAutoTextEntry
-o sw.SwXAutoTextGroup
-o sw.SwXBodyText
-o sw.SwXBookmark
-o sw.SwXBookmarks
-o sw.SwXCell
-o sw.SwXCellRange
-o sw.SwXChapterNumbering
-o sw.SwXDocumentIndex
-o sw.SwXDocumentIndexMark
-o sw.SwXDocumentIndexes
-o sw.SwXDrawPage
-o sw.SwXEndnoteProperties
-o sw.SwXFieldEnumeration
-o sw.SwXFieldMaster
-o sw.SwXFootnote
-o sw.SwXFootnoteProperties
-o sw.SwXFootnoteText
-o sw.SwXFootnotes
-o sw.SwXFrames
-o sw.SwXHeadFootText
-o sw.SwXLineNumberingProperties
-o sw.SwXMailMerge
-o sw.SwXModule
-o sw.SwXNumberingRules
-o sw.SwXParagraph
-o sw.SwXParagraphEnumeration
-o sw.SwXPrintSettings
-o sw.SwXPropertySet
-o sw.SwXPropertySetInfo
-o sw.SwXReferenceMark
-o sw.SwXReferenceMarks
-o sw.SwXShape
-o sw.SwXStyleFamilies
-o sw.SwXStyleFamily
-o sw.SwXTableCellText
-o sw.SwXTableColumns
-o sw.SwXTableRows
-o sw.SwXTextColumns
-o sw.SwXTextCursor
-o sw.SwXTextDefaults
-o sw.SwXTextDocument
-o sw.SwXTextEmbeddedObject
-o sw.SwXTextEmbeddedObjects
-o sw.SwXTextField
-o sw.SwXTextFieldMasters
-o sw.SwXTextFieldTypes
-o sw.SwXTextFrame
-o sw.SwXTextFrameText
-o sw.SwXTextGraphicObject
-o sw.SwXTextGraphicObjects
-o sw.SwXTextPortion
-o sw.SwXTextPortionEnumeration
-o sw.SwXTextRange
-o sw.SwXTextRanges
-o sw.SwXTextSearch
-o sw.SwXTextSection
-o sw.SwXTextSections
-o sw.SwXTextTable
-o sw.SwXTextTableCursor
-o sw.SwXTextTableRow
-o sw.SwXTextTables
-o sw.SwXTextView
-o sw.SwXTextViewCursor
-o sw.SwXViewSettings
-o sw.XMLContentExporter
-o sw.XMLContentImporter
-o sw.XMLExporter
-o sw.XMLImporter
-o sw.XMLMetaExporter
-o sw.XMLMetaImporter
-o sw.XMLSettingsExporter
-o sw.XMLSettingsImporter
-o sw.XMLStylesExporter
-o sw.XMLStylesImporter
-o sw.DocumentSettings