sb123: #i114637# disabled sw.SwAccessibleFootnoteView for now

-o sw.CharacterStyle
-o sw.ConditionalParagraphStyle
-o sw.PageStyle
-o sw.ParagraphStyle
#i111197 -o sw.SwAccessibleDocumentPageView
#i86751 -o sw.SwAccessibleDocumentView
-o sw.SwAccessibleEndnoteView
#i113142 -o sw.SwAccessibleFooterView
#i114637 -o sw.SwAccessibleFootnoteView
#i113142 -o sw.SwAccessibleHeaderView
#i89022 -o sw.SwAccessiblePageView
-o sw.SwAccessibleParagraphView
-o sw.SwAccessibleTableCellView
#i85634 -o sw.SwAccessibleTableView
#i111178 -o sw.SwAccessibleTextEmbeddedObject
#i111178 -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
#i85640 -o sw.SwXMailMerge
-o sw.SwXModule
-o sw.SwXNumberingRules
#i103696 -o sw.SwXParagraph
-o sw.SwXParagraphEnumeration
-o sw.SwXPrintSettings
-o sw.SwXPropertySet
-o sw.SwXPropertySetInfo
-o sw.SwXReferenceMark
-o sw.SwXReferenceMarks
#i111190 -o sw.SwXShape
-o sw.SwXStyleFamilies
-o sw.SwXStyleFamily
-o sw.SwXTableCellText
-o sw.SwXTableColumns
-o sw.SwXTableRows
-o sw.SwXTextColumns
-o sw.SwXTextCursor
#i89021 -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
#i103696 -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
#i85580 -o sw.SwXTextView
-o sw.SwXTextViewCursor
-o sw.SwXViewSettings
-o sw.XMLContentExporter
#i23394 -o sw.XMLContentImporter
#i111194-o sw.XMLExporter
-o sw.XMLImporter
#i23394 -o sw.XMLMetaExporter
-o sw.XMLMetaImporter
-o sw.XMLSettingsExporter
-o sw.XMLSettingsImporter
-o sw.XMLStylesExporter
#i23394 -o sw.XMLStylesImporter
-o sw.DocumentSettings

-o sw.CharacterStyle
-o sw.ConditionalParagraphStyle
-o sw.PageStyle
-o sw.ParagraphStyle
#i111197 -o sw.SwAccessibleDocumentPageView
#i86751 -o sw.SwAccessibleDocumentView
-o sw.SwAccessibleEndnoteView
#i113142 -o sw.SwAccessibleFooterView
-o sw.SwAccessibleFootnoteView
#i113142 -o sw.SwAccessibleHeaderView
#i89022 -o sw.SwAccessiblePageView
-o sw.SwAccessibleParagraphView
-o sw.SwAccessibleTableCellView
#i85634 -o sw.SwAccessibleTableView
#i111178 -o sw.SwAccessibleTextEmbeddedObject
#i111178 -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
#i85640 -o sw.SwXMailMerge
-o sw.SwXModule
-o sw.SwXNumberingRules
#i103696 -o sw.SwXParagraph
-o sw.SwXParagraphEnumeration
-o sw.SwXPrintSettings
-o sw.SwXPropertySet
-o sw.SwXPropertySetInfo
-o sw.SwXReferenceMark
-o sw.SwXReferenceMarks
#i111190 -o sw.SwXShape
-o sw.SwXStyleFamilies
-o sw.SwXStyleFamily
-o sw.SwXTableCellText
-o sw.SwXTableColumns
-o sw.SwXTableRows
-o sw.SwXTextColumns
-o sw.SwXTextCursor
#i89021 -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
#i103696 -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
#i85580 -o sw.SwXTextView
-o sw.SwXTextViewCursor
-o sw.SwXViewSettings
-o sw.XMLContentExporter
#i23394 -o sw.XMLContentImporter
#i111194-o sw.XMLExporter
-o sw.XMLImporter
#i23394 -o sw.XMLMetaExporter
-o sw.XMLMetaImporter
-o sw.XMLSettingsExporter
-o sw.XMLSettingsImporter
-o sw.XMLStylesExporter
#i23394 -o sw.XMLStylesImporter
-o sw.DocumentSettings


AO scan init: detect AO avaliable output ranges

function  mdaq_ao_scan_init(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
    global %microdaq;

    link_id = -1;
    if argn(2) == 6 then
        channels = arg1;
        ao_range = arg2;
        continuous = arg3;
        ao_trigger = arg4;
        scan_freq = arg5;
        scan_time = arg6;
    end

    if argn(2) == 7 then
        link_id = arg1;
        channels = arg2;
        ao_range = arg3;
        continuous = arg4;
        ao_trigger = arg5;
        scan_freq = arg6;
        scan_time = arg7;

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

    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        dac_info = get_dac_info(%microdaq.private.mdaq_hwid);
        if argn(2) > 6 | argn(2) < 5 then
        mprintf("Description:\n");
        mprintf("\Initiates AO scan\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_ao_scan_init(link_id, channels, range, continuous, trigger, frequency, duration);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tchannels - analog output channels to write\n");
        mprintf("\trange - analog output range\n");
            for i = 1:size(dac_info.c_params.c_range_desc, "r")
                mprintf("\t    %s\n", string(i) + ": " + dac_info.c_params.c_range_desc(i));
            end

        mprintf("\tcontinuous - scanning mode (%%T/%%F)\n");
        mprintf("\ttrigger - DIO number (DIO1-8), high state triggers scanning\n");
        mprintf("\tfrequency - analog output scan frequency\n");
        mprintf("\tduration - analog output scan duration in seconds\n");
            return;
        end
    else
        error('Unable to detect MicroDAQ confituration - run mdaq_hwinfo and try again!');
        return;
    end

    if scan_time < 0 then
        scan_time = -1;
    end

    dac_ch_count = strtod(dac_info.channel);

    ch_count = max(size(channels));
    if ch_count < 1 | ch_count > dac_ch_count then
        disp("Error: Wrong AO channel selected!")
        return;
    end

    if max(channels) > dac_ch_count | min(channels) < 1 then
        disp("Error: Wrong AO channel selected!")
        return;
    end

    ao_range_desc_index = ao_range;
    try
        ao_range = dac_info.c_params.c_range(ao_range);
    catch
        error("Error: wrong AO range selected!");
    end

    if size(ao_range, "*") == 1 then
        tmp = ones(1, ch_count);
        ao_range = tmp * ao_range;
    else
        //if size(ao_range, "*") <> ch_count then
            disp("ERROR: Wrong AO range selected!");
            return;
       // end
    end

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

    if ao_range > 4 | ao_range < 0 then
        disp("ERROR: Wrong AO output range!")
        return;
    end
    if ao_trigger == [] | ao_trigger > 8 then
        ao_trigger = 0;
    end

    if continuous == %T | continuous == 1 then
        continuous = 1;
    else
        continuous = 0;
    end

    %microdaq.private.ao_scan_ch_count = ch_count;

    result = [];

    result = call("sci_mlink_ao_scan_init",..
            link_id, 1, "i",..
            channels, 2, "i",..
            ch_count, 3, "i",..
            ao_range, 4, "i",..
            continuous, 5, "i", ..
            ao_trigger,6, "i",..
            scan_freq, 7, "d",..
            scan_time, 8, "d",..
        "out",..
            [1, 1], 9, "i");

    mprintf("result: %d\n", result);

    if result < 0 then
        mdaq_error(result);
    else
        mprintf("Data acquisition session settings:\n");

        range_table = [ "0-5V" "0-10V" "±5V" "±10V" "±2.5V" ];
        str = "";
        s = size(channels);
        for j=1:s(2)
            if j > 1
              str = str + ", ";
            end
            str = str + string(channels(1,j)) + "(" + dac_info.c_params.c_range_desc(ao_range_desc_index) +")";
        end
        mprintf("\tChannles:\t%s\n", str);

        if ao_trigger == 0 then
            mprintf("\tTrigger:\tNONE\n");
        else
            mprintf("\tTrigger:\tDIO%d\n", ao_trigger);
        end

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

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

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

function  mdaq_ao_scan_init(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
    global %microdaq;

    link_id = -1;
    if argn(2) == 6 then
        channels = arg1;
        ao_range = arg2;
        continuous = arg3;
        ao_trigger = arg4;
        scan_freq = arg5;
        scan_time = arg6;
    end

    if argn(2) == 7 then
        link_id = arg1;
        channels = arg2;
        ao_range = arg3;
        continuous = arg4;
        ao_trigger = arg5;
        scan_freq = arg6;
        scan_time = arg7;

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

    if argn(2) > 6 | argn(2) < 5 then
        mprintf("Description:\n");
        mprintf("\Initiates AO scan\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_ao_scan_init(link_id, channels, range, continuous, trigger, frequency, duration);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tchannels - analog output channels to write\n");
        mprintf("\trange - analog output range\n");
        mprintf("\tcontinuous - scanning mode (0-single, 1-continuous)\n");
        mprintf("\t\tAvaliable output ranges: \n");
        mprintf("\t\t  0: 0-5V\n");
        mprintf("\t\t  1: 0-10V\n");
        mprintf("\t\t  2: ±5V\n");
        mprintf("\t\t  3: ±10V\n");
        mprintf("\t\t  4: ±2.5V\n");
        mprintf("\ttrigger - DIO number (DIO1-8), high state triggers scanning\n");
        mprintf("\tfrequency - analog output scan frequency\n");
        mprintf("\tduration - analog output scan duration in seconds\n");
        return;
    end

    if scan_time < 0 then
        scan_time = -1;
    end

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

    if size(ao_range, "*") == 1 then
        tmp = ones(1, ch_count);
        ao_range = tmp * ao_range;
    else
        if size(ao_range, "*") <> ch_count then
            disp("ERROR: Wrong AO range selected!");
            return;
        end
    end

    if max(channels) > 16 then
        disp("ERROR: Wrong AO channel selected!")
        return;
    end

    s = size(channels);
    if s(1) > 1 then
        disp("ERROR: Wrong AO channel input parameter!")
        return
    end

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

    if ao_range > 4 | ao_range < 0 then
        disp("ERROR: Wrong AO output range!")
        return;
    end
    if ao_trigger == [] | ao_trigger > 8 then
        ao_trigger = 0;
    end

    %microdaq.private.ao_scan_ch_count = ch_count;

    result = [];

//MDAQ_API void  sci_mlink_ao_scan_init(
//		IO		int 		*link_fd,
//		IN		int		 	*ch,
//		IN		int 		*ch_count,
//		IN		int		 	*range,
//		IN		int		    *continuous,
//		IN		int			*trigger,
//		IN		double 		*freq,
//		IN		double 		*scan_time,
//		OUT		int			*result)

    result = call("sci_mlink_ao_scan_init",..
            link_id, 1, "i",..
            channels, 2, "i",..
            ch_count, 3, "i",..
            ao_range, 4, "i",..
            continuous, 5, "i", ..
            ao_trigger,6, "i",..
            scan_freq, 7, "d",..
            scan_time, 8, "d",..
        "out",..
            [1, 1], 9, "i");

    mprintf("result: %d\n", result);

    if result < 0 then
        mdaq_error(result);
    else
        mprintf("Data acquisition session settings:\n");

        range_table = [ "0-5V" "0-10V" "±5V" "±10V" "±2.5V" ];
        str = "";
        s = size(channels);
        for j=1:s(2)
            if j > 1
              str = str + ", ";
            end
            str = str + string(channels(1,j)) + "(" +range_table(ao_range(j)+1) +")";
        end
        mprintf("\tChannles:\t%s\n", str);

        if ao_trigger == 0 then
            mprintf("\tTrigger:\tNONE\n");
        else
            mprintf("\tTrigger:\tDIO%d\n", ao_trigger);
        end

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

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

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


Delete Gustatory_Synesthesia_Localizer_MRI.sce

########################################################
# Sounds -> Synesthesia - blocked fMRI				   #
# O. Colizoli, 2012									   #
# Universiteit van Amsterdam (Dept. Psych.)			   #
# 													   #
# Presentation SCE file 		                       #
# blocked fMRI - ABCDABCD			                   #
# 16 seconds active, 16 sec baseline (fixation cross)  #
# 4 conditions:                                        #
# Dutch words spoken                                   #
# Foreign words spoken                                 #
# Musical instruments                                  #
# Daily environmental sounds                           #
# Instructions - passive viewing, maintain fixation    #
# 4 conditions x 5 blocks = 20 blocks total            #
# 16 images per block x 5 blocks per condition         #
########################################################

scenario = "Gustatory_Synesthesia_Localizer_MRI";

default_background_color = 0, 0, 0;
default_font = "courier new";
default_font_size = 60;
default_text_color = 255,255,255;
response_matching = simple_matching;
response_logging = log_all;
active_buttons = 8;
button_codes = 1,2,3,4,5,6,7,8;

scenario_type = fMRI_emulation;
scan_period = 2000;   # (ms) only here to make emulation possible if desired
#scenario_type = fMRI;
pulses_per_scan = 1;
pulse_code = 255;

begin;

################ STIMULUS DEFINITIONS ################

array{ #spoken words dutch
sound { wavefile { filename = "Dutch_news1.wav";};  description = "DutchNews1"; } dutch_spoken1; #1
sound { wavefile { filename = "Dutch_news2.wav";};  description = "DutchNews2"; } dutch_spoken2; #2
sound { wavefile { filename = "Dutch_news3.wav";};  description = "DutchNews3"; } dutch_spoken3; #3
sound { wavefile { filename = "Dutch_news4.wav";};  description = "DutchNews4"; } dutch_spoken4; #4
sound { wavefile { filename = "Dutch_news5.wav";};  description = "DutchNews5"; } dutch_spoken5; #5
} spoken_dutch;

array{ #spoken words dutch
sound { wavefile { filename = "Turkish_news1.wav";};  description = "TurkishNews1"; } foreign_spoken1; #1
sound { wavefile { filename = "Turkish_news2.wav";};  description = "TurkishNews2"; } foreign_spoken2; #2
sound { wavefile { filename = "Turkish_news3.wav";};  description = "TurkishNews3"; } foreign_spoken3; #3
sound { wavefile { filename = "Russian_news1.wav";};  description = "RussianNews1"; } foreign_spoken4; #4
sound { wavefile { filename = "Russian_news2.wav";};  description = "RussianNews2"; } foreign_spoken5; #5
} spoken_foreign;

array{ # 10 musical instruments
sound { wavefile { filename = "Doedelzak fragment.wav";};  description = "bagpipe"; } music1; #1
sound { wavefile { filename = "Drums fragment.wav";};  description = "drums"; } music2; #2
sound { wavefile { filename = "Gitaar fragment.wav";}; description = "guitar"; } music3; #3
sound { wavefile { filename = "Hobo fragment.wav";}; description = "oboe"; } music4; #4
sound { wavefile { filename = "Trompet fragment.wav";}; description = "trumpet"; } music5; #5
sound { wavefile { filename = "triangel.wav";}; description = "triangle"; } music6; #6
sound { wavefile { filename = "accordeon.wav";}; description = "accordian"; } music7; #7
sound { wavefile { filename = "trommels.wav";}; description = "drumline"; } music8; #8
sound { wavefile { filename = "mondharmonica.wav";}; description = "harmonica"; } music9; #9
sound { wavefile { filename = "xylofoon.wav";}; description = "xylophone"; } music10; #10
} music;

array{ # 80 words
sound { wavefile { filename = "Applause.wav";};  description = "applause"; } noise1; #1
sound { wavefile { filename = "Rain.wav";};  description = "rain"; } noise2; #2
sound { wavefile { filename = "Siren.wav";}; description = "siren"; } noise3; #3
sound { wavefile { filename = "wind.wav";}; description = "wind"; } noise4; #4
sound { wavefile { filename = "electric_fan.wav";}; description = "electric_fan"; } noise5; #5
sound { wavefile { filename = "pckeyboard.wav";}; description = "keyboard"; } noise6; #6
sound { wavefile { filename = "typewriter.wav";}; description = "typewriter"; } noise7; #7
sound { wavefile { filename = "race_car.wav";}; description = "race_car"; } noise8; #8
} noise;

picture { description = "rest"; text {caption = "+"; font_size = 30; font = "Times New Roman";}; x = 0; y = 0; } rest;

#Instructions for participants
picture { text {caption = "You will hear a series of words and sounds.

Please keep your eyes closed during this entire scan.

The experiment will start at any moment.
Make sure that you stay still and close your eyes! ";
font_size = 24; font = "Times New Roman";
}; x = 0; y = 0; } startTrialPicture;

# Blank and fixation screens
picture {background_color = 0,0,0;} white_screen;
picture {text {caption = "+";  font_size=30; font = "Times New Roman";} fix_text; x = 0; y = 0; }  pic_fix;

############ Start fMRI Trial ####################
trial {
   picture startTrialPicture;
   time = 0;
   duration = next_picture;
   picture startTrialPicture;
   mri_pulse = 1;
   duration = 1000;
} startTrial;

################# Spoken language Trial ################################
trial {
		all_responses = false;	           # Does not log all responses, only those during active events #
		trial_duration = 15995;
		trial_type = fixed;

	stimulus_event {
					sound music1;
					time = 0;
					duration = 15995; # 16 seconds
					response_active = true;
					}spoken_event;

} spoken_trial;

################# Music Trial ################################
trial {
		all_responses = false;
		trial_duration = 7995; # Does not log all responses, only those during active events #
		trial_type = fixed;

	stimulus_event {
					sound music1;
					time = 0;
					duration = 7995; # 8 seconds
					response_active = true;
					}music_event;

} music_trial;

################# Noise Trial ################################
trial {
		all_responses = false;	           # Does not log all responses, only those during active events #
		trial_duration = 1995;
		trial_type = fixed;

	stimulus_event {
					sound music1;
					time = 0;
					duration = 1995; # 2 seconds
					response_active = true;
					}noise_event;

} noise_trial;

################# Baseline ################################
trial {
		all_responses = false;	           # Does not log all responses, only those during active events #
		trial_type = fixed;

	stimulus_event {
					picture white_screen;
					time = 0;
					duration = 15995;
					code = "rest";
					response_active = false;
					}rest_event;

} rest_trial;

################################## START PCL ####################################

begin_pcl;

############# DECLARATIONS ##############
preset int run = 1;

int start_time = clock.time();

string subnr = logfile.subject();
logfile.set_filename(subnr + "_run" + string(run) + "_Sound_Color_Syn_Localizer_MRI.log");
output_file output = new output_file;
output.open( subnr + "_run" + string(run) + "_Sound_Color_Syn_Localizer_MRI_output.txt" );
output.print(start_time);output.print("\n");
output.print( "block\ttrialnr\tpic_trial\tsound\tresponse_button\tRT\n" );

string sound_is = "";
int isi = 0;
int j = 1;
int k1 = 1;
int k2 = 1;
int m = 1;
int c1 = 1;
int c2 = 1;
int z = 1;

string dspoken = "1";
string fspoken = "2";
string minstr = "3";
string environ = "4";
string baseline = "5";

int lastResponse = 0;
double lastRT = 0.0;

int trial_number = 1;

###############################################################################

### START OF THE TRIALS LOOPS ###

###################
sub condition1 begin # dutch_spoken

		spoken_event.set_stimulus( spoken_dutch[k1] );
		sound_is = spoken_dutch[k1].description();
		spoken_event.set_event_code(dspoken);

		spoken_trial.present();

		if response_manager.response_count() > 0
			then
				stimulus_data last = stimulus_manager.last_stimulus_data();
				lastRT = last.reaction_time_double();
				lastResponse = response_manager.last_response();
			else
				lastRT = 0.0;
				lastResponse = 0;
		end;

		output.print("dutch_spoken");output.print("\t");
		output.print(trial_number);output.print("\t");
		output.print(k1);output.print("\t");
		output.print(sound_is);output.print("\t");
		output.print(lastResponse);output.print("\t");
		output.print(lastRT);output.print("\n");

		trial_number = trial_number + 1;

		k1 = k1 + 1;
end;

###################
sub condition2 begin # dutch_foreign

		spoken_event.set_stimulus( spoken_foreign[k2] );
		sound_is = spoken_foreign[k2].description();
		spoken_event.set_event_code(fspoken);

		spoken_trial.present();

		if response_manager.response_count() > 0
			then
				stimulus_data last = stimulus_manager.last_stimulus_data();
				lastRT = last.reaction_time_double();
				lastResponse = response_manager.last_response();
			else
				lastRT = 0.0;
				lastResponse = 0;
		end;

		output.print("foreign_spoken");output.print("\t");
		output.print(trial_number);output.print("\t");
		output.print(k2);output.print("\t");
		output.print(sound_is);output.print("\t");
		output.print(lastResponse);output.print("\t");
		output.print(lastRT);output.print("\n");

		trial_number = trial_number + 1;

		k2 = k2 + 1;
end;

###################
sub condition3 begin # music

loop j = 1 until j > 2  begin;

		music_event.set_stimulus( music[c1] );
		sound_is = music[c1].description();
		music_event.set_event_code(minstr);

		music_trial.present();

		if response_manager.response_count() > 0
			then
				stimulus_data last = stimulus_manager.last_stimulus_data();
				lastRT = last.reaction_time_double();
				lastResponse = response_manager.last_response();
			else
				lastRT = 0.0;
				lastResponse = 0;
		end;

		output.print("music");output.print("\t");
		output.print(trial_number);output.print("\t");
		output.print(c1);output.print("\t");
		output.print(sound_is);output.print("\t");
		output.print(lastResponse);output.print("\t");
		output.print(lastRT);output.print("\n");

		trial_number = trial_number + 1;

		c1 = c1 + 1;
		j = j + 1;
	end;
end;

###################
sub condition4 begin # noise

noise.shuffle();

loop j = 1 until j > 8  begin;

		noise_event.set_stimulus( noise[j] );
		sound_is = noise[j].description();
		noise_event.set_event_code(environ);

		noise_trial.present();

		if response_manager.response_count() > 0
			then
				stimulus_data last = stimulus_manager.last_stimulus_data();
				lastRT = last.reaction_time_double();
				lastResponse = response_manager.last_response();
			else
				lastRT = 0.0;
				lastResponse = 0;
		end;

		output.print("noise");output.print("\t");
		output.print(trial_number);output.print("\t");
		output.print(j);output.print("\t");
		output.print(sound_is);output.print("\t");
		output.print(lastResponse);output.print("\t");
		output.print(lastRT);output.print("\n");

		trial_number = trial_number + 1;

		j = j + 1;
	end;
end;

######### Define subject conditions, counterbalancing

array <int> randomize_conditions [4][20] =
{
	{4,2,3,1,2,1,3,4,1,2,3,4,2,1,3,4,1,2,4,3},
	{1,2,4,3,2,1,3,4,1,2,4,3,1,2,3,4,3,4,2,1},
	{2,4,1,3,1,2,4,3,1,4,3,2,3,4,1,2,4,3,2,1},
	{3,2,4,1,3,1,2,4,3,2,4,1,4,1,2,3,1,2,4,3}
};

		spoken_dutch.shuffle();
		spoken_foreign.shuffle();
		music.shuffle();

		startTrial.present();

		# Begin with rest - Baseline block

		rest_event.set_event_code(baseline);
		rest_event.set_duration(17995);

		rest_event.set_stimulus( rest );
		rest_trial.present();

	loop k1 = 1 until k1 > spoken_dutch.count() begin;
	loop k2 = 1 until k2 > spoken_foreign.count() begin;
	loop c1 = 1 until c1 > 5 begin;
	# loop c2 = 1 until c2 > noise.count() begin;

		#the run number picks which of the 4 pseudo randomized condition orders
	loop z = 1 until z > 20 begin;

			if randomize_conditions[run][z] == 1
					then condition1();
					# Baseline block
					rest_event.set_event_code(baseline);
					rest_event.set_duration(15995);
					rest_event.set_stimulus( rest );
					rest_trial.present();
					z = z + 1;
			elseif randomize_conditions[run][z] == 2
					then condition2();
					# Baseline block
					rest_event.set_event_code(baseline);
					rest_event.set_stimulus( rest );
					rest_event.set_duration(15995);
					rest_trial.present();
					z = z + 1;
			elseif randomize_conditions[run][z] == 3
					then condition3();
					# Baseline block
					rest_event.set_event_code(baseline);
					rest_event.set_stimulus( rest );
					rest_event.set_duration(15995);
					rest_trial.present();
					z = z + 1;
			elseif randomize_conditions[run][z] == 4
					then condition4();
					# Baseline block
					rest_event.set_event_code(baseline);
					rest_event.set_stimulus( rest );
					rest_event.set_duration(15995);
					rest_trial.present();
					z = z + 1;
			end;

		end;
	end;
	end;
end;

int end_time = clock.time();
output.print(end_time);output.print("\n");


sb120: #i111216# disabled failing tests for now

#i98339 -o svx.AccessibleControlShape
-o svx.AccessibleEditableTextPara
-o svx.AccessibleGraphicShape
#i46736 -o svx.AccessibleImageBullet
-o svx.AccessibleOLEShape
-o svx.AccessiblePageShape
#i111216 -o svx.AccessiblePresentationGraphicShape
#i111216 -o svx.AccessiblePresentationOLEShape
#i85539 -o svx.AccessiblePresentationShape
-o svx.AccessibleShape
#i90294 -o svx.GraphicExporter
-o svx.SvxDrawPage
#i85501 -o svx.SvxGraphCtrlAccessibleContext
#i87746 -o svx.SvxGraphicObject
#i85263 -o svx.SvxShape
#i87746 -o svx.SvxShapeCircle
-o svx.SvxShapeCollection
#i85263 -o svx.SvxShapeConnector
#i87746 -o svx.SvxShapeControl
#i87746 -o svx.SvxShapeDimensioning
#i87746 -o svx.SvxShapeGroup
#i87746 -o svx.SvxShapePolyPolygon
#i87746 -o svx.SvxShapePolyPolygonBezier
-o svx.SvxUnoNumberingRules
-o svx.SvxUnoText
-o svx.SvxUnoTextContent
-o svx.SvxUnoTextContentEnum
-o svx.SvxUnoTextCursor
-o svx.SvxUnoTextField
-o svx.SvxUnoTextRange
-o svx.SvxUnoTextRangeEnumeration

#i98339 -o svx.AccessibleControlShape
-o svx.AccessibleEditableTextPara
-o svx.AccessibleGraphicShape
#i46736 -o svx.AccessibleImageBullet
-o svx.AccessibleOLEShape
-o svx.AccessiblePageShape
-o svx.AccessiblePresentationGraphicShape
-o svx.AccessiblePresentationOLEShape
#i85539 -o svx.AccessiblePresentationShape
-o svx.AccessibleShape
#i90294 -o svx.GraphicExporter
-o svx.SvxDrawPage
#i85501 -o svx.SvxGraphCtrlAccessibleContext
#i87746 -o svx.SvxGraphicObject
#i85263 -o svx.SvxShape
#i87746 -o svx.SvxShapeCircle
-o svx.SvxShapeCollection
#i85263 -o svx.SvxShapeConnector
#i87746 -o svx.SvxShapeControl
#i87746 -o svx.SvxShapeDimensioning
#i87746 -o svx.SvxShapeGroup
#i87746 -o svx.SvxShapePolyPolygon
#i87746 -o svx.SvxShapePolyPolygonBezier
-o svx.SvxUnoNumberingRules
-o svx.SvxUnoText
-o svx.SvxUnoTextContent
-o svx.SvxUnoTextContentEnum
-o svx.SvxUnoTextCursor
-o svx.SvxUnoTextField
-o svx.SvxUnoTextRange
-o svx.SvxUnoTextRangeEnumeration


INTEGRATION: CWS qadev32 (1.4.6); FILE MERGED 2008/05/05 10:51:57 cn 1.4.6.2: #i87216# update lists 2008/04/16 18:03:19 cn 1.4.6.1: #i87216# update lists

#i86007 -o toolkit.AccessibleButton
#i88332 -o toolkit.AccessibleCheckBox
#i86008 -o toolkit.AccessibleComboBox
-o toolkit.AccessibleDropDownComboBox
-o toolkit.AccessibleDropDownListBox
#i86110 -o toolkit.AccessibleEdit
-o toolkit.AccessibleFixedText
#i86110 -o toolkit.AccessibleList
#i86110 -o toolkit.AccessibleListBox
#i86110 -o toolkit.AccessibleListItem
-o toolkit.AccessibleMenu
-o toolkit.AccessibleMenuBar
#i86009 -o toolkit.AccessibleMenuItem
-o toolkit.AccessibleMenuSeparator
#i52607 -o toolkit.AccessiblePopupMenu
#i86107,i86110 -o toolkit.AccessibleRadioButton
-o toolkit.AccessibleScrollBar
-o toolkit.AccessibleStatusBar
-o toolkit.AccessibleStatusBarItem
-o toolkit.AccessibleTabControl
-o toolkit.AccessibleTabPage
#i86287 -o toolkit.AccessibleToolBox
#i88605 -o toolkit.AccessibleToolBoxItem
-o toolkit.AccessibleWindow
-o toolkit.MutableTreeDataModel
-o toolkit.MutableTreeNode
-o toolkit.TabController
-o toolkit.TabControllerModel
#i80788 -o toolkit.Toolkit
-o toolkit.UnoControlButton
-o toolkit.UnoControlButtonModel
-o toolkit.UnoControlCheckBox
-o toolkit.UnoControlCheckBoxModel
-o toolkit.UnoControlComboBox
-o toolkit.UnoControlComboBoxModel
-o toolkit.UnoControlContainer
-o toolkit.UnoControlContainerModel
-o toolkit.UnoControlCurrencyField
-o toolkit.UnoControlCurrencyFieldModel
-o toolkit.UnoControlDateField
-o toolkit.UnoControlDateFieldModel
#i80788 -o toolkit.UnoControlDialog
-o toolkit.UnoControlDialogModel
-o toolkit.UnoControlEdit
-o toolkit.UnoControlEditModel
#i86011 -o toolkit.UnoControlFileControl
-o toolkit.UnoControlFileControlModel
-o toolkit.UnoControlFixedLineModel
-o toolkit.UnoControlFixedText
-o toolkit.UnoControlFixedTextModel
#i86013 -o toolkit.UnoControlFormattedField
-o toolkit.UnoControlFormattedFieldModel
-o toolkit.UnoControlGroupBox
-o toolkit.UnoControlGroupBoxModel
-o toolkit.UnoControlImageControl
-o toolkit.UnoControlImageControlModel
#i86019 -o toolkit.UnoControlListBox
-o toolkit.UnoControlListBoxModel
-o toolkit.UnoControlNumericField
-o toolkit.UnoControlNumericFieldModel
-o toolkit.UnoControlPatternField
-o toolkit.UnoControlPatternFieldModel
-o toolkit.UnoControlProgressBarModel
-o toolkit.UnoControlRadioButton
-o toolkit.UnoControlRadioButtonModel
-o toolkit.UnoControlScrollBarModel
-o toolkit.UnoControlTimeField
-o toolkit.UnoControlTimeFieldModel
-o toolkit.UnoScrollBarControl
#i86020 -o toolkit.UnoSimpleAnimationControl
#i86021 -o toolkit.UnoSimpleAnimationControlModel
-o toolkit.UnoSpinButtonControl
-o toolkit.UnoSpinButtonControlModel
#i86022 -o toolkit.UnoThrobberControl
#i86023 -o toolkit.UnoThrobberControlModel
#i86298 -o toolkit.UnoTreeControl
-o toolkit.UnoTreeModel

#i86007 -o toolkit.AccessibleButton
-o toolkit.AccessibleCheckBox
#i86008 -o toolkit.AccessibleComboBox
-o toolkit.AccessibleDropDownComboBox
-o toolkit.AccessibleDropDownListBox
#i86110 -o toolkit.AccessibleEdit
-o toolkit.AccessibleFixedText
#i86110 -o toolkit.AccessibleList
#i86110 -o toolkit.AccessibleListBox
#i86110 -o toolkit.AccessibleListItem
-o toolkit.AccessibleMenu
-o toolkit.AccessibleMenuBar
#i86009 -o toolkit.AccessibleMenuItem
-o toolkit.AccessibleMenuSeparator
#i52607 -o toolkit.AccessiblePopupMenu
#i86107,i86110 -o toolkit.AccessibleRadioButton
-o toolkit.AccessibleScrollBar
-o toolkit.AccessibleStatusBar
-o toolkit.AccessibleStatusBarItem
-o toolkit.AccessibleTabControl
-o toolkit.AccessibleTabPage
#i86287 -o toolkit.AccessibleToolBox
-o toolkit.AccessibleToolBoxItem
-o toolkit.AccessibleWindow
-o toolkit.MutableTreeDataModel
-o toolkit.MutableTreeNode
-o toolkit.TabController
-o toolkit.TabControllerModel
#i80788 -o toolkit.Toolkit
-o toolkit.UnoControlButton
-o toolkit.UnoControlButtonModel
-o toolkit.UnoControlCheckBox
-o toolkit.UnoControlCheckBoxModel
-o toolkit.UnoControlComboBox
-o toolkit.UnoControlComboBoxModel
-o toolkit.UnoControlContainer
-o toolkit.UnoControlContainerModel
-o toolkit.UnoControlCurrencyField
-o toolkit.UnoControlCurrencyFieldModel
-o toolkit.UnoControlDateField
-o toolkit.UnoControlDateFieldModel
#i80788 -o toolkit.UnoControlDialog
-o toolkit.UnoControlDialogModel
-o toolkit.UnoControlEdit
-o toolkit.UnoControlEditModel
#i86011 -o toolkit.UnoControlFileControl
-o toolkit.UnoControlFileControlModel
-o toolkit.UnoControlFixedLineModel
-o toolkit.UnoControlFixedText
-o toolkit.UnoControlFixedTextModel
#i86013 -o toolkit.UnoControlFormattedField
-o toolkit.UnoControlFormattedFieldModel
-o toolkit.UnoControlGroupBox
-o toolkit.UnoControlGroupBoxModel
-o toolkit.UnoControlImageControl
-o toolkit.UnoControlImageControlModel
#i86019 -o toolkit.UnoControlListBox
-o toolkit.UnoControlListBoxModel
-o toolkit.UnoControlNumericField
-o toolkit.UnoControlNumericFieldModel
-o toolkit.UnoControlPatternField
-o toolkit.UnoControlPatternFieldModel
-o toolkit.UnoControlProgressBarModel
-o toolkit.UnoControlRadioButton
-o toolkit.UnoControlRadioButtonModel
-o toolkit.UnoControlScrollBarModel
-o toolkit.UnoControlTimeField
-o toolkit.UnoControlTimeFieldModel
-o toolkit.UnoScrollBarControl
#i86020 -o toolkit.UnoSimpleAnimationControl
#i86021 -o toolkit.UnoSimpleAnimationControlModel
-o toolkit.UnoSpinButtonControl
-o toolkit.UnoSpinButtonControlModel
#i86022 -o toolkit.UnoThrobberControl
#i86023 -o toolkit.UnoThrobberControlModel
#i86298 -o toolkit.UnoTreeControl
-o toolkit.UnoTreeModel


fix v0.4

fix v0.4

- Fixed the filepath issue

//Scilab code generated by Scilab GUI Designer
//Do not modify this file
//Undertake any modifications in the corresponding .sgd file via the Designer

//mode(0);
//lines(0);
pathname = get_absolute_file_path('ControlPanel.sce');
chdir(pathname);
exec ("commands.sce", -1);

function form = new_form()
	form = figure( "visible", "off", "menubar_visible", "off", "toolbar_visible", "off", "infobar_visible", "off");
	form.figure_position = [ 805 , 222];
	form.axes_size = [ 684 , 438];
	form.figure_name = "MDX-15/20 Control Panel - Craftweeks";
	form.tag = "form";
	form.background = color(240 , 240 , 240);
//	form.event_handler = "form_callback";
	//form.event_handler_enable = "on";
	form.resize = "off";
endfunction

handles.dummy = 0;
handles.form = new_form();

function textfieldobj = new_textfield_X()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "320|160|20|22";
	textfieldobj.Tag = "textfieldX";
	textfieldobj.String = "X";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	textfieldobj.Callback = "textfield1_Form_callback";
endfunction

handles.textfield_X = new_textfield_X()

function editfieldobj = new_editboxX()
	editfieldobj = uicontrol(findobj("tag" , "form"),"Style","edit");
	editfieldobj.Position = "340|160|81|22";
	editfieldobj.Tag = "XPosition";
	editfieldobj.String = "NaN";
	editfieldobj.BackgroundColor = "-1|-1|-1";
	editfieldobj.Callback = "editboxX_callback";
endfunction

handles.editboxX = new_editboxX();

function textfieldobj = new_textfield_Y()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "320|135|20|22";
	textfieldobj.Tag = "textfieldY";
	textfieldobj.String = "Y";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	textfieldobj.Callback = "textfield1_Form_callback";
endfunction

handles.textfield_Y = new_textfield_Y()

function editfieldobj = new_editboxY()
	editfieldobj = uicontrol(findobj("tag" , "form"),"Style","edit");
	editfieldobj.Position = "340|135|81|22";
	editfieldobj.Tag = "YPosition";
	editfieldobj.String = "NaN";
	editfieldobj.BackgroundColor = "-1|-1|-1";
	editfieldobj.Callback = "editboxY_callback";
endfunction

handles.editboxY = new_editboxY();

function textfieldobj = new_textfield_Z()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "320|110|20|22";
	textfieldobj.Tag = "textfieldZ";
	textfieldobj.String = "Z";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	textfieldobj.Callback = "textfield1_Form_callback";
endfunction

handles.textfield_Z = new_textfield_Z()

function editfieldobj = new_editboxZ()
	editfieldobj = uicontrol(findobj("tag" , "form"),"Style","edit");
	editfieldobj.Position = "340|110|81|22";
	editfieldobj.Tag = "ZPosition";
	editfieldobj.String = "NaN";
	editfieldobj.BackgroundColor = "-1|-1|-1";
	editfieldobj.Callback = "editboxZ_callback";
endfunction

handles.editboxZ = new_editboxZ();

function textfieldobj = new_TextZO()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "452|110|81|22";
	textfieldobj.Tag = "textfield1_RolandMODELAMDX20ControlPanel";
	textfieldobj.String = "";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	//textfieldobj.Callback = "textfield1_RolandMODELAMDX20ControlPanel_callback";
endfunction

handles.TextZO = new_TextZO();

function pushbuttonobj = new_pushbutton1()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "540|110|91|25";
	pushbuttonobj.Tag = "pushbutton1";
	pushbuttonobj.String = "Printer";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "printer_callback";
endfunction

handles.pushbutton1 = new_pushbutton1();

function pushbuttonobj = new_pushbuttonSpooler()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "540|85|91|25";
	pushbuttonobj.Tag = "pushbuttonSpooler";
	pushbuttonobj.String = "Stop Spool";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "spooler_callback";
endfunction

handles.pushbuttonSpooler = new_pushbuttonSpooler();

function pushbuttonobj = new_pushbuttonGO()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "340|35|81|25";
	pushbuttonobj.Tag = "pushbuttonGO";
	pushbuttonobj.String = "Go";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "go_callback";
	pushbuttonobj.Enable = "off";
endfunction

handles.pushbuttonGO = new_pushbuttonGO();

function pushbuttonobj = new_pushbutton4()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "117|397|81|25";
	pushbuttonobj.Tag = "pushbutton4";
	pushbuttonobj.String = "Reset";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "reset_callback";
endfunction

handles.pushbutton4 = new_pushbutton4();

function pushbuttonobj = new_pushbutton5()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|325|55|25";
	pushbuttonobj.Tag = "pushbuttonY_10";
	pushbuttonobj.String = "-10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "in10mm_callback";
endfunction

handles.pushbutton5 = new_pushbutton5();

function pushbuttonobj = new_pushbutton6()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|300|55|25";
	pushbuttonobj.Tag = "pushbuttonY_1";
	pushbuttonobj.String = "-1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "in1mm_callback";
endfunction

handles.pushbutton6 = new_pushbutton6();

function pushbuttonobj = new_pushbutton7()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|275|55|25";
	pushbuttonobj.Tag = "pushbuttonY_01";
	pushbuttonobj.String = "-0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "in01mm_callback";
endfunction

handles.pushbutton7 = new_pushbutton7();

function pushbuttonobj = new_pushbutton8()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|175|55|25";
	pushbuttonobj.Tag = "pushbuttonY01";
	pushbuttonobj.String = "+0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "out01mm_callback";
endfunction

handles.pushbutton8 = new_pushbutton8();

function pushbuttonobj = new_pushbutton9()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|150|55|25";
	pushbuttonobj.Tag = "pushbuttonY1";
	pushbuttonobj.String = "+1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "out1mm_callback";
endfunction

handles.pushbutton9 = new_pushbutton9();

function pushbuttonobj = new_pushbutton10()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|125|55|25";
	pushbuttonobj.Tag = "pushbuttonY10";
	pushbuttonobj.String = "+10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "out10mm_callback";
endfunction

handles.pushbutton10 = new_pushbutton10();

function pushbuttonobj = new_pushbutton11()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "25|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX_10";
	pushbuttonobj.String = "-10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "left10mm_callback";
endfunction

handles.pushbutton11 = new_pushbutton11();

function pushbuttonobj = new_pushbutton12()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "80|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX_1";
	pushbuttonobj.String = "-1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "left1mm_callback";
endfunction

handles.pushbutton12 = new_pushbutton12();

function pushbuttonobj = new_pushbutton13()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "135|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX_01";
	pushbuttonobj.String = "-0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "left01mm_callback";
endfunction

handles.pushbutton13 = new_pushbutton13();

function pushbuttonobj = new_pushbutton14()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "265|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX01";
	pushbuttonobj.String = "+0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "right01mm_callback";
endfunction

handles.pushbutton14 = new_pushbutton14();

function pushbuttonobj = new_pushbutton15()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "320|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX1";
	pushbuttonobj.String = "+1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "right1mm_callback";
endfunction

handles.pushbutton15 = new_pushbutton15();

function pushbuttonobj = new_pushbutton16()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "375|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX10";
	pushbuttonobj.String = "+10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "right10mm_callback";
endfunction

handles.pushbutton16 = new_pushbutton16();

function pushbuttonobj = new_pushbutton17()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "322|335|60|25";
	pushbuttonobj.Tag = "pushbutton17";
	pushbuttonobj.String = "Y0";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "yminhome_callback";
endfunction

handles.pushbutton17 = new_pushbutton17();

function pushbuttonobj = new_pushbutton18()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "290|310|60|25";
	pushbuttonobj.Tag = "pushbutton18";
	pushbuttonobj.String = "X0";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "xminhome_callback";
endfunction

handles.pushbutton18 = new_pushbutton18();

function pushbuttonobj = new_pushbutton19()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "350|310|60|25";
	pushbuttonobj.Tag = "pushbutton19";
	pushbuttonobj.String = "Xmax";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "xmaxhome_callback";
endfunction

handles.pushbutton19 = new_pushbutton19();

function pushbuttonobj = new_pushbutton20()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "322|285|60|25";
	pushbuttonobj.Tag = "pushbutton20";
	pushbuttonobj.String = "Ymax";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "ymaxhome_callback";
endfunction

handles.pushbutton20 = new_pushbutton20();

function pushbuttonobj = new_pushbutton21()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|310|55|25";
	pushbuttonobj.Tag = "pushbuttonZ10";
	pushbuttonobj.String = "+10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "up10mm_callback";
endfunction

handles.pushbutton21 = new_pushbutton21();

function pushbuttonobj = new_pushbutton22()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|285|55|25";
	pushbuttonobj.Tag = "pushbuttonZ1";
	pushbuttonobj.String = "+1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "up1mm_callback";
endfunction

handles.pushbutton22 = new_pushbutton22();

function pushbuttonobj = new_pushbutton23()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|260|55|25";
	pushbuttonobj.Tag = "pushbuttonZ01";
	pushbuttonobj.String = "+0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "up01mm_callback";
endfunction

handles.pushbutton23 = new_pushbutton23();

function pushbuttonobj = new_pushbutton24()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "470|235|40|25";
	pushbuttonobj.Tag = "pushbutton24";
	pushbuttonobj.String = "+";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "up1step_callback";
endfunction

handles.pushbutton24 = new_pushbutton24();

function pushbuttonobj = new_pushbutton25()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "470|210|40|25";
	pushbuttonobj.Tag = "pushbutton25";
	pushbuttonobj.String = "-";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "down1step_callback";
endfunction

handles.pushbutton25 = new_pushbutton25();

function pushbuttonobj = new_pushbutton26()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|185|55|25";
	pushbuttonobj.Tag = "pushbuttonZ01";
	pushbuttonobj.String = "-0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "down01mm_callback";
endfunction

handles.pushbutton26 = new_pushbutton26();

function pushbuttonobj = new_pushbutton27()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|160|55|25";
	pushbuttonobj.Tag = "pushbuttonZ_1";
	pushbuttonobj.String = "-1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "down1mm_callback";
endfunction

handles.pushbutton27 = new_pushbutton27();

function pushbuttonobj = new_pushbutton28()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|135|55|25";
	pushbuttonobj.Tag = "pushbuttonZ_10";
	pushbuttonobj.String = "-10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "down10mm_callback";
endfunction

handles.pushbutton28 = new_pushbutton28();

function pushbuttonobj = new_pushbutton29()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "450|85|81|25";
	pushbuttonobj.Tag = "pushbutton29";
	pushbuttonobj.String = "Set ZO";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "setZO_callback";
endfunction

handles.pushbutton29 = new_pushbutton29();

function pushbuttonobj = new_pushbutton30()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "208|250|40|25";
	pushbuttonobj.Tag = "pushbutton30";
	pushbuttonobj.String = "^";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "in1step_callback";
endfunction

handles.pushbutton30 = new_pushbutton30();

function pushbuttonobj = new_pushbutton31()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "208|200|40|25";
	pushbuttonobj.Tag = "pushbutton31";
	pushbuttonobj.String = "v";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "out1step_callback";
endfunction

handles.pushbutton31 = new_pushbutton31();

function pushbuttonobj = new_pushbutton32()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "190|225|38|25";
	pushbuttonobj.Tag = "pushbutton32";
	pushbuttonobj.String = "<";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "left1step_callback";
endfunction

handles.pushbutton32 = new_pushbutton32();

function pushbuttonobj = new_pushbutton33()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "228|225|38|25";
	pushbuttonobj.Tag = "pushbutton33";
	pushbuttonobj.String = ">";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "right1step_callback";
endfunction

handles.pushbutton33 = new_pushbutton33();

function pushbuttonobj = new_pushbutton34()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "75|335|81|25";
	pushbuttonobj.Tag = "pushbutton34";
	pushbuttonobj.String = "Home";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "home_callback";
endfunction

handles.pushbutton34 = new_pushbutton34();

function pushbuttonobj = new_pushbutton35()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "540|35|91|25";
	pushbuttonobj.Tag = "pushbutton35";
	pushbuttonobj.String = "Help";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "help_callback";
endfunction

handles.pushbutton35 = new_pushbutton35();

function popupmenuobj = new_popupmenu1()
	popupmenuobj = uicontrol(findobj("tag" , "form"),"Style","popupmenu");
	popupmenuobj.Position = "28|400|81|20";
	popupmenuobj.Tag = "popupmenu1";
	popupmenuobj.String = "COM 1|COM 2|COM 3";
	popupmenuobj.BackgroundColor = "1|1|1";
	popupmenuobj.Value = 1;
	popupmenuobj.Callback = "changeport_callback";
endfunction

handles.popupmenu1 = new_popupmenu1();

function checkboxobj = new_checkbox1()
	checkboxobj = uicontrol(findobj("tag" , "form"),"Style","checkbox");
	checkboxobj.Position = "280|65|55|22";
	checkboxobj.Tag = "checkbox1";
	checkboxobj.String = "Direct";
	checkboxobj.BackgroundColor = "-1|-1|-1";
	checkboxobj.Value = checkboxobj.Max;
	checkboxobj.Callback = "directgo_callback";
endfunction

handles.checkbox1 = new_checkbox1();

function radiobuttonobj = new_radiobuttonMDX15()
	radiobuttonobj = uicontrol(findobj("tag" , "form"),"Style","radiobutton");
	radiobuttonobj.Position = "200|397|70|25";
	radiobuttonobj.Tag = "radiobuttonMDX15";
	radiobuttonobj.String = "MDX-15";
	radiobuttonobj.Groupname = "machine_model";
	radiobuttonobj.BackgroundColor = "-1|-1|-1";
	radiobuttonobj.Value = radiobuttonobj.Min;
	radiobuttonobj.Callback = "setAsMDX15_callback";
endfunction

handles.radiobuttonMDX15 = new_radiobuttonMDX15();

function radiobuttonobj = new_radiobuttonMDX20()
	radiobuttonobj = uicontrol(findobj("tag" , "form"),"Style","radiobutton");
	radiobuttonobj.Position = "270|397|81|25";
	radiobuttonobj.Tag = "radiobuttonMDX20";
	radiobuttonobj.String = "MDX-20";
	radiobuttonobj.Groupname = "machine_model";
	radiobuttonobj.BackgroundColor = "-1|-1|-1";
	radiobuttonobj.Value = radiobuttonobj.Max;
	radiobuttonobj.Callback = "setAsMDX20_callback";

endfunction

handles.radiobuttonMDX20 = new_radiobuttonMDX20();

function textfieldobj = new_textfield_V()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "300|85|40|22";
	textfieldobj.Tag = "textfieldV_Form";
	textfieldobj.String = "Velocity";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	textfieldobj.Callback = "textfieldV_Form_callback";
endfunction

handles.textfield_V = new_textfield_V()

function sliderobj = new_hsliderV()
	sliderobj = uicontrol(findobj("tag" , "form"),"Style","slider");
	sliderobj.Position = "340|85|81|22";
	sliderobj.Tag = "hsliderV_Form";
	sliderobj.String = "Velocity";
	sliderobj.BackgroundColor = "-1|-1|-1";
	sliderobj.Max = 15;
	sliderobj.Min = 0;
	sliderobj.SliderStep = [1,10];
	sliderobj.Value = 15;
	sliderobj.Callback = "velocity_callback";
endfunction

handles.hsliderV = new_hsliderV();

function checkboxobj = new_checkboxSON()
	checkboxobj = uicontrol(findobj("tag" , "form"),"Style","checkbox");
	checkboxobj.Position = "340|65|81|22";
	checkboxobj.Tag = "checkboxSON";
	checkboxobj.String = "Spindle On";
	checkboxobj.BackgroundColor = "-1|-1|-1";
	checkboxobj.Value = checkboxobj.Max;
	checkboxobj.Callback = "checkboxSON_callback";
endfunction

handles.checkboxSON = new_checkboxSON();

function imageobj = new_imageLogo()
	imageobj =  uicontrol(findobj("tag" , "form"),"Style","image");
	imageobj.Position = "540|328|100|100";
	imageobj.Tag = "imageLogo";
	imageobj.String = "craftweeks_logo.png"
	imageobj.BackgroundColor = "-1|-1|-1";
	imageobj.Value = [1 1 0 0 0];
endfunction

function frameobj = new_frameXY()
	frameobj =  uicontrol(findobj("tag" , "form"),"Style","frame");
	frameobj.Position = "0|80|198|132";
	frameobj.Tag = "frameXY";
	frameobj.String = "frameXY"
	frameobj.BackgroundColor = "1|1|1";
endfunction

handles.frameXY = new_frameXY()
handles.axisXY = newaxes(handles.frameXY)
handles.axisXY.auto_clear = 'on';
plot(handles.axisXY, 0,0);
isoview(0,XMAX, 0, YMAX);

handles.imageLogo = new_imageLogo();

set(handles.form, "visible", "on");

//Scilab code generated by Scilab GUI Designer
//Do not modify this file
//Undertake any modifications in the corresponding .sgd file via the Designer

//mode(0);
//lines(0);

exec ("commands.sce", -1);

function form = new_form()
	form = figure( "visible", "off", "menubar_visible", "off", "toolbar_visible", "off", "infobar_visible", "off");
	form.figure_position = [ 805 , 222];
	form.axes_size = [ 684 , 438];
	form.figure_name = "MDX-15/20 Control Panel - Craftweeks";
	form.tag = "form";
	form.background = color(240 , 240 , 240);
//	form.event_handler = "form_callback";
	//form.event_handler_enable = "on";
	form.resize = "off";
endfunction

handles.dummy = 0;
handles.form = new_form();

function textfieldobj = new_textfield_X()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "320|160|20|22";
	textfieldobj.Tag = "textfieldX";
	textfieldobj.String = "X";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	textfieldobj.Callback = "textfield1_Form_callback";
endfunction

handles.textfield_X = new_textfield_X()

function editfieldobj = new_editboxX()
	editfieldobj = uicontrol(findobj("tag" , "form"),"Style","edit");
	editfieldobj.Position = "340|160|81|22";
	editfieldobj.Tag = "XPosition";
	editfieldobj.String = "NaN";
	editfieldobj.BackgroundColor = "-1|-1|-1";
	editfieldobj.Callback = "editboxX_callback";
endfunction

handles.editboxX = new_editboxX();

function textfieldobj = new_textfield_Y()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "320|135|20|22";
	textfieldobj.Tag = "textfieldY";
	textfieldobj.String = "Y";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	textfieldobj.Callback = "textfield1_Form_callback";
endfunction

handles.textfield_Y = new_textfield_Y()

function editfieldobj = new_editboxY()
	editfieldobj = uicontrol(findobj("tag" , "form"),"Style","edit");
	editfieldobj.Position = "340|135|81|22";
	editfieldobj.Tag = "YPosition";
	editfieldobj.String = "NaN";
	editfieldobj.BackgroundColor = "-1|-1|-1";
	editfieldobj.Callback = "editboxY_callback";
endfunction

handles.editboxY = new_editboxY();

function textfieldobj = new_textfield_Z()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "320|110|20|22";
	textfieldobj.Tag = "textfieldZ";
	textfieldobj.String = "Z";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	textfieldobj.Callback = "textfield1_Form_callback";
endfunction

handles.textfield_Z = new_textfield_Z()

function editfieldobj = new_editboxZ()
	editfieldobj = uicontrol(findobj("tag" , "form"),"Style","edit");
	editfieldobj.Position = "340|110|81|22";
	editfieldobj.Tag = "ZPosition";
	editfieldobj.String = "NaN";
	editfieldobj.BackgroundColor = "-1|-1|-1";
	editfieldobj.Callback = "editboxZ_callback";
endfunction

handles.editboxZ = new_editboxZ();

function textfieldobj = new_TextZO()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "452|110|81|22";
	textfieldobj.Tag = "textfield1_RolandMODELAMDX20ControlPanel";
	textfieldobj.String = "";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	//textfieldobj.Callback = "textfield1_RolandMODELAMDX20ControlPanel_callback";
endfunction

handles.TextZO = new_TextZO();

function pushbuttonobj = new_pushbutton1()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "540|110|91|25";
	pushbuttonobj.Tag = "pushbutton1";
	pushbuttonobj.String = "Printer";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "printer_callback";
endfunction

handles.pushbutton1 = new_pushbutton1();

function pushbuttonobj = new_pushbuttonSpooler()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "540|85|91|25";
	pushbuttonobj.Tag = "pushbuttonSpooler";
	pushbuttonobj.String = "Stop Spool";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "spooler_callback";
endfunction

handles.pushbuttonSpooler = new_pushbuttonSpooler();

function pushbuttonobj = new_pushbuttonGO()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "340|35|81|25";
	pushbuttonobj.Tag = "pushbuttonGO";
	pushbuttonobj.String = "Go";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "go_callback";
	pushbuttonobj.Enable = "off";
endfunction

handles.pushbuttonGO = new_pushbuttonGO();

function pushbuttonobj = new_pushbutton4()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "117|397|81|25";
	pushbuttonobj.Tag = "pushbutton4";
	pushbuttonobj.String = "Reset";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "reset_callback";
endfunction

handles.pushbutton4 = new_pushbutton4();

function pushbuttonobj = new_pushbutton5()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|325|55|25";
	pushbuttonobj.Tag = "pushbuttonY_10";
	pushbuttonobj.String = "-10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "in10mm_callback";
endfunction

handles.pushbutton5 = new_pushbutton5();

function pushbuttonobj = new_pushbutton6()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|300|55|25";
	pushbuttonobj.Tag = "pushbuttonY_1";
	pushbuttonobj.String = "-1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "in1mm_callback";
endfunction

handles.pushbutton6 = new_pushbutton6();

function pushbuttonobj = new_pushbutton7()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|275|55|25";
	pushbuttonobj.Tag = "pushbuttonY_01";
	pushbuttonobj.String = "-0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "in01mm_callback";
endfunction

handles.pushbutton7 = new_pushbutton7();

function pushbuttonobj = new_pushbutton8()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|175|55|25";
	pushbuttonobj.Tag = "pushbuttonY01";
	pushbuttonobj.String = "+0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "out01mm_callback";
endfunction

handles.pushbutton8 = new_pushbutton8();

function pushbuttonobj = new_pushbutton9()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|150|55|25";
	pushbuttonobj.Tag = "pushbuttonY1";
	pushbuttonobj.String = "+1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "out1mm_callback";
endfunction

handles.pushbutton9 = new_pushbutton9();

function pushbuttonobj = new_pushbutton10()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "200|125|55|25";
	pushbuttonobj.Tag = "pushbuttonY10";
	pushbuttonobj.String = "+10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "out10mm_callback";
endfunction

handles.pushbutton10 = new_pushbutton10();

function pushbuttonobj = new_pushbutton11()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "25|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX_10";
	pushbuttonobj.String = "-10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "left10mm_callback";
endfunction

handles.pushbutton11 = new_pushbutton11();

function pushbuttonobj = new_pushbutton12()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "80|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX_1";
	pushbuttonobj.String = "-1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "left1mm_callback";
endfunction

handles.pushbutton12 = new_pushbutton12();

function pushbuttonobj = new_pushbutton13()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "135|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX_01";
	pushbuttonobj.String = "-0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "left01mm_callback";
endfunction

handles.pushbutton13 = new_pushbutton13();

function pushbuttonobj = new_pushbutton14()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "265|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX01";
	pushbuttonobj.String = "+0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "right01mm_callback";
endfunction

handles.pushbutton14 = new_pushbutton14();

function pushbuttonobj = new_pushbutton15()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "320|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX1";
	pushbuttonobj.String = "+1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "right1mm_callback";
endfunction

handles.pushbutton15 = new_pushbutton15();

function pushbuttonobj = new_pushbutton16()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "375|225|55|25";
	pushbuttonobj.Tag = "pushbuttonX10";
	pushbuttonobj.String = "+10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "right10mm_callback";
endfunction

handles.pushbutton16 = new_pushbutton16();

function pushbuttonobj = new_pushbutton17()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "322|335|60|25";
	pushbuttonobj.Tag = "pushbutton17";
	pushbuttonobj.String = "Y0";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "yminhome_callback";
endfunction

handles.pushbutton17 = new_pushbutton17();

function pushbuttonobj = new_pushbutton18()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "290|310|60|25";
	pushbuttonobj.Tag = "pushbutton18";
	pushbuttonobj.String = "X0";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "xminhome_callback";
endfunction

handles.pushbutton18 = new_pushbutton18();

function pushbuttonobj = new_pushbutton19()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "350|310|60|25";
	pushbuttonobj.Tag = "pushbutton19";
	pushbuttonobj.String = "Xmax";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "xmaxhome_callback";
endfunction

handles.pushbutton19 = new_pushbutton19();

function pushbuttonobj = new_pushbutton20()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "322|285|60|25";
	pushbuttonobj.Tag = "pushbutton20";
	pushbuttonobj.String = "Ymax";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "ymaxhome_callback";
endfunction

handles.pushbutton20 = new_pushbutton20();

function pushbuttonobj = new_pushbutton21()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|310|55|25";
	pushbuttonobj.Tag = "pushbuttonZ10";
	pushbuttonobj.String = "+10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "up10mm_callback";
endfunction

handles.pushbutton21 = new_pushbutton21();

function pushbuttonobj = new_pushbutton22()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|285|55|25";
	pushbuttonobj.Tag = "pushbuttonZ1";
	pushbuttonobj.String = "+1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "up1mm_callback";
endfunction

handles.pushbutton22 = new_pushbutton22();

function pushbuttonobj = new_pushbutton23()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|260|55|25";
	pushbuttonobj.Tag = "pushbuttonZ01";
	pushbuttonobj.String = "+0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "up01mm_callback";
endfunction

handles.pushbutton23 = new_pushbutton23();

function pushbuttonobj = new_pushbutton24()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "470|235|40|25";
	pushbuttonobj.Tag = "pushbutton24";
	pushbuttonobj.String = "+";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "up1step_callback";
endfunction

handles.pushbutton24 = new_pushbutton24();

function pushbuttonobj = new_pushbutton25()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "470|210|40|25";
	pushbuttonobj.Tag = "pushbutton25";
	pushbuttonobj.String = "-";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "down1step_callback";
endfunction

handles.pushbutton25 = new_pushbutton25();

function pushbuttonobj = new_pushbutton26()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|185|55|25";
	pushbuttonobj.Tag = "pushbuttonZ01";
	pushbuttonobj.String = "-0.1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "down01mm_callback";
endfunction

handles.pushbutton26 = new_pushbutton26();

function pushbuttonobj = new_pushbutton27()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|160|55|25";
	pushbuttonobj.Tag = "pushbuttonZ_1";
	pushbuttonobj.String = "-1";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "down1mm_callback";
endfunction

handles.pushbutton27 = new_pushbutton27();

function pushbuttonobj = new_pushbutton28()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "462|135|55|25";
	pushbuttonobj.Tag = "pushbuttonZ_10";
	pushbuttonobj.String = "-10";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "down10mm_callback";
endfunction

handles.pushbutton28 = new_pushbutton28();

function pushbuttonobj = new_pushbutton29()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "450|85|81|25";
	pushbuttonobj.Tag = "pushbutton29";
	pushbuttonobj.String = "Set ZO";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "setZO_callback";
endfunction

handles.pushbutton29 = new_pushbutton29();

function pushbuttonobj = new_pushbutton30()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "208|250|40|25";
	pushbuttonobj.Tag = "pushbutton30";
	pushbuttonobj.String = "^";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "in1step_callback";
endfunction

handles.pushbutton30 = new_pushbutton30();

function pushbuttonobj = new_pushbutton31()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "208|200|40|25";
	pushbuttonobj.Tag = "pushbutton31";
	pushbuttonobj.String = "v";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "out1step_callback";
endfunction

handles.pushbutton31 = new_pushbutton31();

function pushbuttonobj = new_pushbutton32()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "190|225|38|25";
	pushbuttonobj.Tag = "pushbutton32";
	pushbuttonobj.String = "<";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "left1step_callback";
endfunction

handles.pushbutton32 = new_pushbutton32();

function pushbuttonobj = new_pushbutton33()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "228|225|38|25";
	pushbuttonobj.Tag = "pushbutton33";
	pushbuttonobj.String = ">";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "right1step_callback";
endfunction

handles.pushbutton33 = new_pushbutton33();

function pushbuttonobj = new_pushbutton34()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "75|335|81|25";
	pushbuttonobj.Tag = "pushbutton34";
	pushbuttonobj.String = "Home";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "home_callback";
endfunction

handles.pushbutton34 = new_pushbutton34();

function pushbuttonobj = new_pushbutton35()
	pushbuttonobj = uicontrol(findobj("tag" , "form"),"Style","pushbutton");
	pushbuttonobj.Position = "540|35|91|25";
	pushbuttonobj.Tag = "pushbutton35";
	pushbuttonobj.String = "Help";
	pushbuttonobj.BackgroundColor = "-1|-1|-1";
	pushbuttonobj.Callback = "help_callback";
endfunction

handles.pushbutton35 = new_pushbutton35();

function popupmenuobj = new_popupmenu1()
	popupmenuobj = uicontrol(findobj("tag" , "form"),"Style","popupmenu");
	popupmenuobj.Position = "28|400|81|20";
	popupmenuobj.Tag = "popupmenu1";
	popupmenuobj.String = "COM 1|COM 2|COM 3";
	popupmenuobj.BackgroundColor = "1|1|1";
	popupmenuobj.Value = 1;
	popupmenuobj.Callback = "changeport_callback";
endfunction

handles.popupmenu1 = new_popupmenu1();

function checkboxobj = new_checkbox1()
	checkboxobj = uicontrol(findobj("tag" , "form"),"Style","checkbox");
	checkboxobj.Position = "280|65|55|22";
	checkboxobj.Tag = "checkbox1";
	checkboxobj.String = "Direct";
	checkboxobj.BackgroundColor = "-1|-1|-1";
	checkboxobj.Value = checkboxobj.Max;
	checkboxobj.Callback = "directgo_callback";
endfunction

handles.checkbox1 = new_checkbox1();

function radiobuttonobj = new_radiobuttonMDX15()
	radiobuttonobj = uicontrol(findobj("tag" , "form"),"Style","radiobutton");
	radiobuttonobj.Position = "200|397|70|25";
	radiobuttonobj.Tag = "radiobuttonMDX15";
	radiobuttonobj.String = "MDX-15";
	radiobuttonobj.Groupname = "machine_model";
	radiobuttonobj.BackgroundColor = "-1|-1|-1";
	radiobuttonobj.Value = radiobuttonobj.Min;
	radiobuttonobj.Callback = "setAsMDX15_callback";
endfunction

handles.radiobuttonMDX15 = new_radiobuttonMDX15();

function radiobuttonobj = new_radiobuttonMDX20()
	radiobuttonobj = uicontrol(findobj("tag" , "form"),"Style","radiobutton");
	radiobuttonobj.Position = "270|397|81|25";
	radiobuttonobj.Tag = "radiobuttonMDX20";
	radiobuttonobj.String = "MDX-20";
	radiobuttonobj.Groupname = "machine_model";
	radiobuttonobj.BackgroundColor = "-1|-1|-1";
	radiobuttonobj.Value = radiobuttonobj.Max;
	radiobuttonobj.Callback = "setAsMDX20_callback";

endfunction

handles.radiobuttonMDX20 = new_radiobuttonMDX20();

function textfieldobj = new_textfield_V()
	textfieldobj = uicontrol(findobj("tag" , "form"),"Style","text");
	textfieldobj.Position = "300|85|40|22";
	textfieldobj.Tag = "textfieldV_Form";
	textfieldobj.String = "Velocity";
	textfieldobj.BackgroundColor = "-1|-1|-1";
	textfieldobj.Callback = "textfieldV_Form_callback";
endfunction

handles.textfield_V = new_textfield_V()

function sliderobj = new_hsliderV()
	sliderobj = uicontrol(findobj("tag" , "form"),"Style","slider");
	sliderobj.Position = "340|85|81|22";
	sliderobj.Tag = "hsliderV_Form";
	sliderobj.String = "Velocity";
	sliderobj.BackgroundColor = "-1|-1|-1";
	sliderobj.Max = 15;
	sliderobj.Min = 0;
	sliderobj.SliderStep = [1,10];
	sliderobj.Value = 15;
	sliderobj.Callback = "velocity_callback";
endfunction

handles.hsliderV = new_hsliderV();

function checkboxobj = new_checkboxSON()
	checkboxobj = uicontrol(findobj("tag" , "form"),"Style","checkbox");
	checkboxobj.Position = "340|65|81|22";
	checkboxobj.Tag = "checkboxSON";
	checkboxobj.String = "Spindle On";
	checkboxobj.BackgroundColor = "-1|-1|-1";
	checkboxobj.Value = checkboxobj.Max;
	checkboxobj.Callback = "checkboxSON_callback";
endfunction

handles.checkboxSON = new_checkboxSON();

function imageobj = new_imageLogo()
	imageobj =  uicontrol(findobj("tag" , "form"),"Style","image");
	imageobj.Position = "540|328|100|100";
	imageobj.Tag = "imageLogo";
	imageobj.String = "craftweeks_logo.png"
	imageobj.BackgroundColor = "-1|-1|-1";
	imageobj.Value = [1 1 0 0 0];
endfunction

function frameobj = new_frameXY()
	frameobj =  uicontrol(findobj("tag" , "form"),"Style","frame");
	frameobj.Position = "0|80|198|132";
	frameobj.Tag = "frameXY";
	frameobj.String = "frameXY"
	frameobj.BackgroundColor = "1|1|1";
endfunction

handles.frameXY = new_frameXY()
handles.axisXY = newaxes(handles.frameXY)
handles.axisXY.auto_clear = 'on';
plot(handles.axisXY, 0,0);
isoview(0,XMAX, 0, YMAX);

handles.imageLogo = new_imageLogo();

set(handles.form, "visible", "on");


Deleted: pru_reg/set, webscope blocks from pallet

function [res] = build_mdaq_palette(palette_path)
    toolbox_dir = mdaq_toolbox_path();
    xpal = list();

    //Create complete mdaq palette
    if isdef("gen_palette") == %T then
        //load xcos library
        if isdef("c_pass1") == %F then
            loadXcosLibs();
        end
    end

    //Temporary (load & use them somewhere else)
    blocks = [
    "mdaq_sinus"
    "mdaq_square"
    "mdaq_step"
    ];
    xpal_temp = tbx_build_pal(toolbox_dir, "temp_blocks", blocks);
    xcosPalAdd( xpal_temp, ['temp']);

    // MicroDAQ
    blocks = ["mdaq_adc"
    "mdaq_dac"
    "mdaq_dio_config"
    "mdaq_dio_get"
    "mdaq_dio_set"
    "mdaq_encoder"
    "mdaq_func_key"
    "mdaq_led"
    "mdaq_mem_read"
    "mdaq_mem_write"
    "mdaq_pwm"
    "mdaq_signal"
    "mdaq_param"
    "mdaq_tcp_recv"
    "mdaq_tcp_send"
    "mdaq_udp_recv"
    "mdaq_udp_send"
    "mdaq_to_file"
    "mdaq_uart_config"
    "mdaq_uart_read"
    "mdaq_uart_write"
    "mdaq_time"
    "mdaq_stop"
    "mdaq_setup"
    ];
    xpal($+1) = tbx_build_pal(toolbox_dir, "MicroDAQ", blocks);

    // Commonly Used Blocks
    blocks = ["mdaq_setup"
    "mdaq_signal"
    "CONST_m"
    "MUX"
    "DEMUX"
    "GAINBLK"
    "PROD_f"
    "SUMMATION"
    "mdaq_step"
    "mdaq_sinus"
    "DOLLAR"
    "CLOCK_c"
    "IFTHEL_f"
    "CLKFROM"
    "CLKGOTO"
    "CSCOPE"
    "TOWS_c"
    ];
    xpal($+1) = tbx_compose_pal('Commonly Used Blocks', blocks);

    //Continuous time systems
    blocks = ["CLSS"
    "DERIV"
    "INTEGRAL_m"
    "TCLSS"
    "VARIABLE_DELAY"
    ];
    xpal($+1) = tbx_compose_pal('Continuous time systems', blocks);

    //Discontinuities
    blocks = ["SATURATION"
    "BACKLASH"
    "DEADBAND"
    "HYSTHERESIS"
    "RATELIMITER"
    ];
    xpal($+1) = tbx_compose_pal('Discontinuities', blocks);

    //Discrete time systems
    blocks = ["mdaq_pid_z"
    "DLR"
    "DLSS"
    "DOLLAR"
    "DOLLAR_m"
    "REGISTER"
    "SAMPHOLD_m"
    "TCLSS"
    ];
    xpal($+1) = tbx_compose_pal('Discrete time systems', blocks);

    //Lookup Tables
    //    blocks = [];
    //    xpal($+1) = tbx_compose_pal('Lookup Tables', blocks);
    //

    //Event handling
    blocks = ["CLOCK_c"
    "SampleCLK"
    "CLKFROM"
    "CLKGOTO"
    "CLKOUTV_f"
    "CLKSOMV_f"
    "EDGE_TRIGGER"
    "ESELECT_f"
    "EVTGEN_f"
    "Extract_Activation"
    "M_freq"
    "MCLOCK_f"
    "MFCLCK_f"
    "freq_div"
    "IFTHEL_f"
    ];
    xpal($+1) = tbx_compose_pal('Event handling', blocks);

    //Mathematical Operations
    blocks = ["ABS_VALUE"
    "BIGSOM_f"
    "EXPBLK_m"
    "GAINBLK"
    "MAXMIN"
    "PROD_f"
    "PRODUCT"
    "SIGNUM"
    "SQRT"
    "SUM_f"
    "SUMMATION"
    "TrigFun"
    ];
    xpal($+1) = tbx_compose_pal('Mathematical Operations', blocks);

    //Matrix
    blocks = ["CUMSUM"
    "EXTRACT"
    "MATCATV"
    "MATMAGPHI"
    "MATMUL"
    "MATRESH"
    "MATSUM"
    "SQRT"
    "SUBMAT"
    ];
    xpal($+1) = tbx_compose_pal('Matrix', blocks);

    //Integer
    blocks = ["BITCLEAR"
    "BITSET"
    "DLATCH"
    "EXTRACTBITS"
    "INTMUL"
    "JKFLIPFLOP"
    ];
    xpal($+1) = tbx_compose_pal('Integer', blocks);

    //Port & Subsystem
    blocks = ["CLKINV_f"
    "CLKOUTV_f"
    "SUPER_f"
    ];
    xpal($+1) = tbx_compose_pal('Port & Subsystem', blocks);

    //    //Zero crossing detection
    //    blocks = [];
    //    xpal($+1) = tbx_compose_pal('Zero crossing detection', blocks);

    //Signal Routing
    blocks = ["DEMUX"
    "MUX"
    "FROM"
    "GOTO"
    "CLKFROM"
    "CLKGOTO"
    "ISELECT_m"
    "M_SWITCH"
    "SELECT_m"
    "SWITCH2_m"
    ];
    xpal($+1) = tbx_compose_pal('Signal Routing', blocks);

    //Signal Processing
    blocks = ["SAMPHOLD_m"];
    xpal($+1) = tbx_compose_pal('Signal Processing', blocks);

    //    //Implicit
    //    blocks = [];
    //    xpal($+1) = tbx_compose_pal('Implicit', blocks);

    //    //Annotations
    //    blocks = [];
    //    xpal($+1) = tbx_compose_pal('Annotations', blocks);

    //Sinks
    blocks = ["AFFICH_m"
    "CLKOUTV_f"
    "CSCOPE"
    "CMSCOPE"
    "OUT_f"
    "TOWS_c"
    ];
    xpal($+1) = tbx_compose_pal('Sinks', blocks);

    //Sources
    blocks = ["CLKINV_f"
    "CLOCK_c"
    "CONST_m"
    "CONST"
    "mdaq_sinus"
    "mdaq_square"
    "mdaq_step"];
    xpal($+1) = tbx_compose_pal('Sources', blocks);

    //User-Defined Functions
    blocks = ["SUPER_f"];
    xpal($+1) = tbx_compose_pal('User-Defined Functions', blocks);

    for i=1:size(xpal)
        xcosPalAdd(xpal(i), ['MicroDAQ']);
        if i < 10 then
            idx = "0"+string(i);
        else
            idx = string(i);
        end
        xcosPalExport(xpal(i), palette_path+filesep()+idx+".sod");
    end

    xcosPalDelete("temp");
    res = 0;
endfunction

function [res] = build_mdaq_palette(palette_path)
    toolbox_dir = mdaq_toolbox_path();
    xpal = list();

    //Create complete mdaq palette
    if isdef("gen_palette") == %T then
        //load xcos library
        if isdef("c_pass1") == %F then
            loadXcosLibs();
        end
    end

    //Temporary (load & use them somewhere else)
    blocks = [
    "mdaq_sinus"
    "mdaq_square"
    "mdaq_step"
    ];
    xpal_temp = tbx_build_pal(toolbox_dir, "temp_blocks", blocks);
    xcosPalAdd( xpal_temp, ['temp']);

    // MicroDAQ
    blocks = ["mdaq_adc"
    "mdaq_dac"
    "mdaq_dio_config"
    "mdaq_dio_get"
    "mdaq_dio_set"
    "mdaq_encoder"
    "mdaq_func_key"
    "mdaq_led"
    "mdaq_mem_read"
    "mdaq_mem_write"
    "mdaq_pru_reg_get"
    "mdaq_pru_reg_set"
    "mdaq_pwm"
    "mdaq_signal"
    "mdaq_param"
    "mdaq_tcp_recv"
    "mdaq_tcp_send"
    "mdaq_udp_recv"
    "mdaq_udp_send"
    "mdaq_to_file"
    "mdaq_uart_config"
    "mdaq_uart_read"
    "mdaq_uart_write"
    "mdaq_webscope"
    "mdaq_time"
    "mdaq_stop"
    "mdaq_setup"
    ];
    xpal($+1) = tbx_build_pal(toolbox_dir, "MicroDAQ", blocks);

    // Commonly Used Blocks
    blocks = ["mdaq_setup"
    "mdaq_signal"
    "CONST_m"
    "MUX"
    "DEMUX"
    "GAINBLK"
    "PROD_f"
    "SUMMATION"
    "mdaq_step"
    "mdaq_sinus"
    "DOLLAR"
    "CLOCK_c"
    "IFTHEL_f"
    "CLKFROM"
    "CLKGOTO"
    "CSCOPE"
    "TOWS_c"
    ];
    xpal($+1) = tbx_compose_pal('Commonly Used Blocks', blocks);

    //Continuous time systems
    blocks = ["CLSS"
    "DERIV"
    "INTEGRAL_m"
    "TCLSS"
    "VARIABLE_DELAY"
    ];
    xpal($+1) = tbx_compose_pal('Continuous time systems', blocks);

    //Discontinuities
    blocks = ["SATURATION"
    "BACKLASH"
    "DEADBAND"
    "HYSTHERESIS"
    "RATELIMITER"
    ];
    xpal($+1) = tbx_compose_pal('Discontinuities', blocks);

    //Discrete time systems
    blocks = ["mdaq_pid_z"
    "DLR"
    "DLSS"
    "DOLLAR"
    "DOLLAR_m"
    "REGISTER"
    "SAMPHOLD_m"
    "TCLSS"
    ];
    xpal($+1) = tbx_compose_pal('Discrete time systems', blocks);

    //Lookup Tables
    //    blocks = [];
    //    xpal($+1) = tbx_compose_pal('Lookup Tables', blocks);
    //

    //Event handling
    blocks = ["CLOCK_c"
    "SampleCLK"
    "CLKFROM"
    "CLKGOTO"
    "CLKOUTV_f"
    "CLKSOMV_f"
    "EDGE_TRIGGER"
    "ESELECT_f"
    "EVTGEN_f"
    "Extract_Activation"
    "M_freq"
    "MCLOCK_f"
    "MFCLCK_f"
    "freq_div"
    "IFTHEL_f"
    ];
    xpal($+1) = tbx_compose_pal('Event handling', blocks);

    //Mathematical Operations
    blocks = ["ABS_VALUE"
    "BIGSOM_f"
    "EXPBLK_m"
    "GAINBLK"
    "MAXMIN"
    "PROD_f"
    "PRODUCT"
    "SIGNUM"
    "SQRT"
    "SUM_f"
    "SUMMATION"
    "TrigFun"
    ];
    xpal($+1) = tbx_compose_pal('Mathematical Operations', blocks);

    //Matrix
    blocks = ["CUMSUM"
    "EXTRACT"
    "MATCATV"
    "MATMAGPHI"
    "MATMUL"
    "MATRESH"
    "MATSUM"
    "SQRT"
    "SUBMAT"
    ];
    xpal($+1) = tbx_compose_pal('Matrix', blocks);

    //Integer
    blocks = ["BITCLEAR"
    "BITSET"
    "DLATCH"
    "EXTRACTBITS"
    "INTMUL"
    "JKFLIPFLOP"
    ];
    xpal($+1) = tbx_compose_pal('Integer', blocks);

    //Port & Subsystem
    blocks = ["CLKINV_f"
    "CLKOUTV_f"
    "SUPER_f"
    ];
    xpal($+1) = tbx_compose_pal('Port & Subsystem', blocks);

    //    //Zero crossing detection
    //    blocks = [];
    //    xpal($+1) = tbx_compose_pal('Zero crossing detection', blocks);

    //Signal Routing
    blocks = ["DEMUX"
    "MUX"
    "FROM"
    "GOTO"
    "CLKFROM"
    "CLKGOTO"
    "ISELECT_m"
    "M_SWITCH"
    "SELECT_m"
    "SWITCH2_m"
    ];
    xpal($+1) = tbx_compose_pal('Signal Routing', blocks);

    //Signal Processing
    blocks = ["SAMPHOLD_m"];
    xpal($+1) = tbx_compose_pal('Signal Processing', blocks);

    //    //Implicit
    //    blocks = [];
    //    xpal($+1) = tbx_compose_pal('Implicit', blocks);

    //    //Annotations
    //    blocks = [];
    //    xpal($+1) = tbx_compose_pal('Annotations', blocks);

    //Sinks
    blocks = ["AFFICH_m"
    "CLKOUTV_f"
    "CSCOPE"
    "CMSCOPE"
    "OUT_f"
    "TOWS_c"
    ];
    xpal($+1) = tbx_compose_pal('Sinks', blocks);

    //Sources
    blocks = ["CLKINV_f"
    "CLOCK_c"
    "CONST_m"
    "CONST"
    "mdaq_sinus"
    "mdaq_square"
    "mdaq_step"];
    xpal($+1) = tbx_compose_pal('Sources', blocks);

    //User-Defined Functions
    blocks = ["SUPER_f"];
    xpal($+1) = tbx_compose_pal('User-Defined Functions', blocks);

    for i=1:size(xpal)
        xcosPalAdd(xpal(i), ['MicroDAQ']);
        if i < 10 then
            idx = "0"+string(i);
        else
            idx = string(i);
        end
        xcosPalExport(xpal(i), palette_path+filesep()+idx+".sod");
    end

    xcosPalDelete("temp");
    res = 0;
endfunction