function pla_chip_gen03_ver06


   %basic declarations and definitions
   %-%read screen resolution
   screensize = get(0,'ScreenSize');
   %-%create plain window, center it on screen using screensize
   main_window = figure('menubar','none', 'name','PLA chip, generation 03', 'toolbar','none', 'position', [0.01*screensize(3),0.08*screensize(4),0.80*screensize(3),0.82*screensize(4)], 'closerequestfcn', @main_window_closerequestfcn);
   %main_window = figure('menubar','none', 'name','PLA chip, generation 03', 'toolbar','none', 'position', [0.01*screensize(3),0.08*screensize(4),0.80*screensize(3),0.82*screensize(4)]);
   %-%create horizontal slider bar in order to slide between screens
			%-%this is a workaround, needs two panels
			%-%slider interval from 0 to 1 defines the horizontal position of
			%-%inner panel in outer panel
			%-%all gui elements must be defined as children of inner_panel
			%-%define maximum horizontal coordinate, which is equivalent to slider
			%-%position right (value 1.0)
			horizontal_maximum = 4.0;
   outer_panel = uipanel('Parent', main_window, 'Position', [0.00 0.02 1.00 0.98], 'bordertype', 'none', 'clipping', 'off');
   inner_panel = uipanel('Parent', outer_panel, 'Position', [0.00 0.00 1.00 1.00], 'bordertype', 'none', 'clipping', 'off');
   slider      = uicontrol('Style','Slider','Parent', main_window, 'Units', 'normalized', 'Position', [0.00 0.00 1.00 0.02], 'Value', 0.00, 'callback', @slider_callback);

	  function slider_callback(hObject, eventdata)
      slider_position = get(slider,'Value');
      %set(inner_panel,'Position',[-slider_position*horizontal_maximum 0 horizontal_maximum 1])
      set(inner_panel,'Position',[-slider_position*horizontal_maximum  0 1 1])
			end
		
		 function main_window_closerequestfcn(src,evnt)
						%close box communication
						if (rack_boxes_comstatus==0)
 						disp('main_window_closerequestfcn: closing box communication');
						 rack_boxeshardware = vc_close(rack_boxeshardware, 1);
						end
						%stop all timers, in case assay is running
						dummyt=timer;
					 stop(timerfind);
						delete(timerfind);
						%close main_window
						delete(main_window);
   end
		
		
   %-%global variables
			valvebits={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
			%valvebits={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
					
			%valvebits panel (horizontal 0.0 - 1.0, vertical 0.8-1.0)
			%-%geometry settings
			valvebits_xmin = 0.01;
			valvebits_xmax = 0.99;
			valvebits_ymin = 1.91;
			valvebits_ymax = 1.98;
			%color settings
 		rack_valvebits_bgcolor_off = [0.3, 0.3, 0.3];
	 	rack_valvebits_bgcolor_on  = [0.7, 0.3, 0.3];
			%-%geometry calculations
			valvebits_position = [valvebits_xmin, valvebits_ymin, (valvebits_xmax-valvebits_xmin), (valvebits_ymax-valvebits_ymin)];
			
			%-%declaration
			valvebits_panel = uipanel('Parent', inner_panel, 'title', 'Valvebits', 'Position', valvebits_position);
   %buttons
			%-%geometry settings
			valvebits_buttons_horizontal_margin   = 0.001;
   valvebits_buttons_vertical_margin     = 0.100;
			valvebits_buttons_horizontal_distance = 0.001;
   %-%geometry calculations
   valvebits_buttons_width  = (1.0-2*valvebits_buttons_horizontal_margin-47*valvebits_buttons_horizontal_distance)/48.0;
			valvebits_buttons_height = 1.0-2*valvebits_buttons_vertical_margin;
			%-%declarations
            
            
   valvebits_pushbuttons(01) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_01', 'string', '<html><font size=3>01</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+00*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(02) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_02', 'string', '<html><font size=3>02</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+01*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(03) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_03', 'string', '<html><font size=3>03</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+02*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(04) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_04', 'string', '<html><font size=3>04</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+03*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(05) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_05', 'string', '<html><font size=3>05</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+04*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(06) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_06', 'string', '<html><font size=3>06</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+05*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(07) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_07', 'string', '<html><font size=3>07</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+06*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(08) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_08', 'string', '<html><font size=3>08</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+07*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(09) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_09', 'string', '<html><font size=3>09</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+08*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(10) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_10', 'string', '<html><font size=3>10</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+09*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(11) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_11', 'string', '<html><font size=3>11</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+10*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(12) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_12', 'string', '<html><font size=3>12</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+11*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(13) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_13', 'string', '<html><font size=3>13</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+12*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(14) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_14', 'string', '<html><font size=3>14</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+13*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(15) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_15', 'string', '<html><font size=3>15</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+14*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(16) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_16', 'string', '<html><font size=3>16</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+15*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(17) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_17', 'string', '<html><font size=3>17</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+16*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(18) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_18', 'string', '<html><font size=3>18</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+17*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(19) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_19', 'string', '<html><font size=3>19</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+18*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(20) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_20', 'string', '<html><font size=3>20</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+19*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(21) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_21', 'string', '<html><font size=3>21</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+20*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(22) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_22', 'string', '<html><font size=3>22</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+21*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(23) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_23', 'string', '<html><font size=3>23</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+22*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(24) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_24', 'string', '<html><font size=3>24</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+23*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(25) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_25', 'string', '<html><font size=3>25</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+24*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(26) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_26', 'string', '<html><font size=3>26</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+25*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(27) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_27', 'string', '<html><font size=3>27</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+26*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(28) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_28', 'string', '<html><font size=3>28</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+27*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(29) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_29', 'string', '<html><font size=3>29</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+28*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(30) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_30', 'string', '<html><font size=3>30</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+29*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(31) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_31', 'string', '<html><font size=3>31</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+30*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(32) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_32', 'string', '<html><font size=3>32</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+31*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(33) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_33', 'string', '<html><font size=3>33</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+32*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(34) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_34', 'string', '<html><font size=3>34</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+33*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(35) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_35', 'string', '<html><font size=3>35</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+34*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(36) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_36', 'string', '<html><font size=3>36</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+35*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(37) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_37', 'string', '<html><font size=3>37</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+36*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(38) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_38', 'string', '<html><font size=3>38</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+37*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(39) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_39', 'string', '<html><font size=3>39</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+38*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(40) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_40', 'string', '<html><font size=3>40</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+39*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(41) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_41', 'string', '<html><font size=3>41</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+40*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(42) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_42', 'string', '<html><font size=3>42</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+41*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(43) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_43', 'string', '<html><font size=3>43</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+42*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(44) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_44', 'string', '<html><font size=3>44</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+43*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(45) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_45', 'string', '<html><font size=3>45</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+44*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(46) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_46', 'string', '<html><font size=3>46</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+45*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(47) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_47', 'string', '<html><font size=3>47</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+46*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
   valvebits_pushbuttons(48) = uicontrol('Parent', valvebits_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'valvebits_pushbutton_48', 'string', '<html><font size=3>48</font></html>', 'callback', @callback_function, 'Position', [valvebits_buttons_horizontal_margin+47*(valvebits_buttons_width+valvebits_buttons_horizontal_distance), valvebits_buttons_vertical_margin, valvebits_buttons_width, valvebits_buttons_height]);
			
			

   
   
			
			
			
			%rack panel (horizontal from 0.0 - 1.0, vertical 0.0-0.8)
			%-%geometry settings
			rack_xmin = 0.01;
			rack_xmax = 0.49;
			rack_ymin = 0.51;
			rack_ymax = 0.98;
			%-%geometry calculations
			rack_position = [rack_xmin, rack_ymin, (rack_xmax-rack_xmin), (rack_ymax-rack_ymin)];
			%-%declaration
			rack_panel = uipanel('Parent', inner_panel, 'title', '', 'Position', rack_position);
			%left and right panel for boxes
			%-%geometry settings
			rack_boxes_horizontal_margin = 0.01;
			rack_boxes_ymin              = 1.81;
			rack_boxes_ymax              = 1.99;
			%-%declarations
			rack_boxes_panel  = uipanel('Parent', rack_panel, 'title', 'Control boxes',  'Position', [0.0+rack_boxes_horizontal_margin, rack_boxes_ymin, 1.0-2*rack_boxes_horizontal_margin, rack_boxes_ymax-rack_boxes_ymin]);
   %elements inside box panels
			%-%variable declarations
			rack_boxes_comstatus = 1; %default offline (0=online, 1=offline);
			rack_leftbox_id  = 'ELSC6CVR';
   rack_rightbox_id = 'ELCAEPFH';
   rack_boxeshardware.num = 2;
   rack_boxeshardware.info(1).sn       = rack_leftbox_id;
   rack_boxeshardware.info(1).handle   = 0;
   rack_boxeshardware.info(1).status   = 0;
   rack_boxeshardware.info(1).polarity = logical([ones(1, 24)]);
   rack_boxeshardware.info(2).sn       = rack_rightbox_id;
   rack_boxeshardware.info(2).handle   = 0;
   rack_boxeshardware.info(2).status   = 0;
   rack_boxeshardware.info(2).polarity = logical([ones(1, 24)]);
						
			%-%geometry settings
		 rack_leftbox_id_textfield_position      = [0.02, 0.25, 0.23, 0.50];
		 rack_rightbox_id_textfield_position     = [0.75, 0.25, 0.23, 0.50];
			rack_boxes_comstatus_textfield_position = [0.40, 0.25, 0.20, 0.50];
			
			%-%color settings
			rack_box_hardware_ok_color         = [0.0, 0.5, 0.0];
			rack_box_hardware_notok_color      = [0.5, 0.0, 0.0];
			rack_boxes_comstatus_online_color  = [0.0, 0.5, 0.0];
			rack_boxes_comstatus_offline_color = [0.5, 0.0, 0.0];
			
			%-%declarations
			rack_leftbox_id_textfield      = uicontrol('parent', rack_boxes_panel, 'style', 'text',       'string', rack_leftbox_id,     'units', 'normalized', 'fontunits', 'normalized', 'fontsize', 0.8, 'position', rack_leftbox_id_textfield_position);
			rack_rightbox_id_textfield     = uicontrol('parent', rack_boxes_panel, 'style', 'text',       'string', rack_rightbox_id,    'units', 'normalized', 'fontunits', 'normalized', 'fontsize', 0.8, 'position', rack_rightbox_id_textfield_position);
			rack_boxes_comstatus_textfield = uicontrol('parent', rack_boxes_panel, 'style', 'text',       'string', 'Hardware: offline', 'units', 'normalized', 'fontunits', 'normalized', 'fontsize', 0.8, 'position', rack_boxes_comstatus_textfield_position);
			
			%left and right panel for manifolds
			%-%geometry settings
			rack_leftright_horizontal_margin = 0.01;
			rack_leftright_ymin              = 0.01;
			rack_leftright_ymax              = 0.99;
			%-%declarations
		 rack_left_panel  = uipanel('Parent', rack_panel, 'title', 'control layer',  'Position', [0.0+rack_leftright_horizontal_margin, rack_leftright_ymin, 0.5-2*rack_leftright_horizontal_margin, rack_leftright_ymax-rack_leftright_ymin]);
		 rack_right_panel = uipanel('Parent', rack_panel, 'title', 'flow layer',    'Position', [0.5+rack_leftright_horizontal_margin, rack_leftright_ymin, 0.5-2*rack_leftright_horizontal_margin, rack_leftright_ymax-rack_leftright_ymin]);
   %6 panels for manifolds (t=top, m=middle, b=bottom, l=left, r=right)
			%-%geometry settings
			rack_manifold_horizontal_margin = 0.05;
			rack_manifold_vertical_margin   = 0.05;
			rack_manifold_vertical_distance = 0.02;
			%-%geometry calculations
			rack_manifold_height = (1.0-2*rack_manifold_vertical_margin-2*rack_manifold_vertical_distance)/3.0;
			rack_manifold_width  = 1.0-2*rack_manifold_horizontal_margin;
			%-%declarations
			rack_manifold_tl_panel = uipanel('Parent', rack_left_panel,  'title', '01 - 08', 'Position', [rack_manifold_horizontal_margin, rack_manifold_vertical_margin+2*rack_manifold_height+2*rack_manifold_vertical_distance, rack_manifold_width, rack_manifold_height]);
			rack_manifold_ml_panel = uipanel('Parent', rack_left_panel,  'title', '09 - 16', 'Position', [rack_manifold_horizontal_margin, rack_manifold_vertical_margin+1*rack_manifold_height+1*rack_manifold_vertical_distance, rack_manifold_width, rack_manifold_height]);
			rack_manifold_bl_panel = uipanel('Parent', rack_left_panel,  'title', '17 - 24', 'Position', [rack_manifold_horizontal_margin, rack_manifold_vertical_margin+0*rack_manifold_height+0*rack_manifold_vertical_distance, rack_manifold_width, rack_manifold_height]);
			rack_manifold_tr_panel = uipanel('Parent', rack_right_panel, 'title', '25 - 32', 'Position', [rack_manifold_horizontal_margin, rack_manifold_vertical_margin+2*rack_manifold_height+2*rack_manifold_vertical_distance, rack_manifold_width, rack_manifold_height]);
			rack_manifold_mr_panel = uipanel('Parent', rack_right_panel, 'title', '33 - 40', 'Position', [rack_manifold_horizontal_margin, rack_manifold_vertical_margin+1*rack_manifold_height+1*rack_manifold_vertical_distance, rack_manifold_width, rack_manifold_height]);
			rack_manifold_br_panel = uipanel('Parent', rack_right_panel, 'title', '41 - 48', 'Position', [rack_manifold_horizontal_margin, rack_manifold_vertical_margin+0*rack_manifold_height+0*rack_manifold_vertical_distance, rack_manifold_width, rack_manifold_height]);
			%8 valves per manifold
			%-%geometry settings
			rack_valve_horizontal_margin   = 0.10;
			rack_valve_vertical_margin     = 0.10;
			rack_valve_horizontal_distance = 0.01;
			%-%geometry calculations
			rack_valve_height = 1.0-2*rack_valve_vertical_margin;
			rack_valve_width  = (1.0-2*rack_valve_horizontal_margin-7*rack_valve_horizontal_distance)/8.0;
            button_bgcolor_control = [1, 0.5, 0.5];
            button_bgcolor_flow = [0.5, 0.5, 1];
            %set(valvebits_pushbuttons(c1), 'backgroundcolor', button_bgcolor_control);

			%-%declarations
			rack_pushbuttons(01) = uicontrol('Parent', rack_manifold_tl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_01', 'string', '<html><font size=6>01</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+0*rack_valve_width+0*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(02) = uicontrol('Parent', rack_manifold_tl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_02', 'string', '<html><font size=6>02</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+1*rack_valve_width+1*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(03) = uicontrol('Parent', rack_manifold_tl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_03', 'string', '<html><font size=6>03</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+2*rack_valve_width+2*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(04) = uicontrol('Parent', rack_manifold_tl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_04', 'string', '<html><font size=6>04</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+3*rack_valve_width+3*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(05) = uicontrol('Parent', rack_manifold_tl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_05', 'string', '<html><font size=6>05</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+4*rack_valve_width+4*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(06) = uicontrol('Parent', rack_manifold_tl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_06', 'string', '<html><font size=6>06</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+5*rack_valve_width+5*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(07) = uicontrol('Parent', rack_manifold_tl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_07', 'string', '<html><font size=6>07</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+6*rack_valve_width+6*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(08) = uicontrol('Parent', rack_manifold_tl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_08', 'string', '<html><font size=6>08</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+7*rack_valve_width+7*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(09) = uicontrol('Parent', rack_manifold_ml_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_09', 'string', '<html><font size=6>09</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+0*rack_valve_width+0*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(10) = uicontrol('Parent', rack_manifold_ml_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_10', 'string', '<html><font size=6>10</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+1*rack_valve_width+1*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(11) = uicontrol('Parent', rack_manifold_ml_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_11', 'string', '<html><font size=6>11</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+2*rack_valve_width+2*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(12) = uicontrol('Parent', rack_manifold_ml_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_12', 'string', '<html><font size=6>12</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+3*rack_valve_width+3*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(13) = uicontrol('Parent', rack_manifold_ml_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_13', 'string', '<html><font size=6>13</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+4*rack_valve_width+4*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(14) = uicontrol('Parent', rack_manifold_ml_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_14', 'string', '<html><font size=6>14</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+5*rack_valve_width+5*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(15) = uicontrol('Parent', rack_manifold_ml_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_15', 'string', '<html><font size=6>15</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+6*rack_valve_width+6*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(16) = uicontrol('Parent', rack_manifold_ml_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_16', 'string', '<html><font size=6>16</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+7*rack_valve_width+7*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(17) = uicontrol('Parent', rack_manifold_bl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_17', 'string', '<html><font size=6>17</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+0*rack_valve_width+0*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(18) = uicontrol('Parent', rack_manifold_bl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_18', 'string', '<html><font size=6>18</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+1*rack_valve_width+1*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(19) = uicontrol('Parent', rack_manifold_bl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_19', 'string', '<html><font size=6>19</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+2*rack_valve_width+2*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(20) = uicontrol('Parent', rack_manifold_bl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_20', 'string', '<html><font size=6>20</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+3*rack_valve_width+3*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(21) = uicontrol('Parent', rack_manifold_bl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_21', 'string', '<html><font size=6>21</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+4*rack_valve_width+4*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(22) = uicontrol('Parent', rack_manifold_bl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_22', 'string', '<html><font size=6>22</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+5*rack_valve_width+5*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(23) = uicontrol('Parent', rack_manifold_bl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_23', 'string', '<html><font size=6>23</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+6*rack_valve_width+6*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(24) = uicontrol('Parent', rack_manifold_bl_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_24', 'string', '<html><font size=6>24</font></html>', 'backgroundcolor', button_bgcolor_control, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+7*rack_valve_width+7*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(25) = uicontrol('Parent', rack_manifold_tr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_25', 'string', '<html><font size=6>25</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+0*rack_valve_width+0*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(26) = uicontrol('Parent', rack_manifold_tr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_26', 'string', '<html><font size=6>26</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+1*rack_valve_width+1*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(27) = uicontrol('Parent', rack_manifold_tr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_27', 'string', '<html><font size=6>27</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+2*rack_valve_width+2*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(28) = uicontrol('Parent', rack_manifold_tr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_28', 'string', '<html><font size=6>28</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+3*rack_valve_width+3*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(29) = uicontrol('Parent', rack_manifold_tr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_29', 'string', '<html><font size=6>29</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+4*rack_valve_width+4*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(30) = uicontrol('Parent', rack_manifold_tr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_30', 'string', '<html><font size=6>30</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+5*rack_valve_width+5*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(31) = uicontrol('Parent', rack_manifold_tr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_31', 'string', '<html><font size=6>31</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+6*rack_valve_width+6*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(32) = uicontrol('Parent', rack_manifold_tr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_32', 'string', '<html><font size=6>32</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+7*rack_valve_width+7*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(33) = uicontrol('Parent', rack_manifold_mr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_33', 'string', '<html><font size=6>33</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+0*rack_valve_width+0*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(34) = uicontrol('Parent', rack_manifold_mr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_34', 'string', '<html><font size=6>34</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+1*rack_valve_width+1*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(35) = uicontrol('Parent', rack_manifold_mr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_35', 'string', '<html><font size=6>35</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+2*rack_valve_width+2*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(36) = uicontrol('Parent', rack_manifold_mr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_36', 'string', '<html><font size=6>36</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+3*rack_valve_width+3*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(37) = uicontrol('Parent', rack_manifold_mr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_37', 'string', '<html><font size=6>37</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+4*rack_valve_width+4*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(38) = uicontrol('Parent', rack_manifold_mr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_38', 'string', '<html><font size=6>38</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+5*rack_valve_width+5*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(39) = uicontrol('Parent', rack_manifold_mr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_39', 'string', '<html><font size=6>39</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+6*rack_valve_width+6*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(40) = uicontrol('Parent', rack_manifold_mr_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_40', 'string', '<html><font size=6>40</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+7*rack_valve_width+7*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(41) = uicontrol('Parent', rack_manifold_br_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_41', 'string', '<html><font size=6>41</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+0*rack_valve_width+0*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(42) = uicontrol('Parent', rack_manifold_br_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_42', 'string', '<html><font size=6>42</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+1*rack_valve_width+1*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(43) = uicontrol('Parent', rack_manifold_br_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_43', 'string', '<html><font size=6>43</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+2*rack_valve_width+2*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(44) = uicontrol('Parent', rack_manifold_br_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_44', 'string', '<html><font size=6>44</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+3*rack_valve_width+3*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(45) = uicontrol('Parent', rack_manifold_br_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_45', 'string', '<html><font size=6>45</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+4*rack_valve_width+4*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(46) = uicontrol('Parent', rack_manifold_br_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_46', 'string', '<html><font size=6>46</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+5*rack_valve_width+5*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(47) = uicontrol('Parent', rack_manifold_br_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_47', 'string', '<html><font size=6>47</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+6*rack_valve_width+6*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);
			rack_pushbuttons(48) = uicontrol('Parent', rack_manifold_br_panel, 'units', 'normalized', 'tag', 'rack_pushbutton_48', 'string', '<html><font size=6>48</font></html>', 'backgroundcolor', button_bgcolor_flow, 'callback', @callback_function, 'Position', [rack_valve_horizontal_margin+7*rack_valve_width+7*rack_valve_horizontal_distance, rack_valve_vertical_margin, rack_valve_width, rack_valve_height]);

			
			%chip panel (horizontal from 2.0 - 3.0)
   %-%geometry settings
   chip_xmin = 0.51;
   chip_xmax = 0.99;
	  chip_ymin = 0.51;
  	chip_ymax = 0.98;
  	%-%declaration
  	chip_panel = uipanel('Parent', inner_panel, 'visible', 'on', 'title', 'Chip', 'Position', [chip_xmin, chip_ymin, chip_xmax-chip_xmin, chip_ymax-chip_ymin]);
			%inlet multiplexor (im) panel
			%-%geometry definitions
			chip_im_xmin = 0.01;
			chip_im_xmax = 0.06;
			chip_im_ymin = 0.01;
			chip_im_ymax = 0.99;
			%-%geometry calculations
			chip_im_position = [chip_im_xmin, chip_im_ymin, (chip_im_xmax-chip_im_xmin), (chip_im_ymax-chip_im_ymin)];
   %declaration
			chip_im_panel = uipanel('Parent', chip_panel, 'title', '', 'Position', chip_im_position);
   %16 buttons
			%-%geometry definitions
			chip_im_buttons_horizontal_margin = 0.010;
			chip_im_buttons_vertical_margin   = 0.03;
			chip_im_buttons_vertical_distance = 0.005;
			%-%geometry_calculations
			chip_im_buttons_width  =  1.0-2*chip_im_buttons_horizontal_margin;
			chip_im_buttons_height = (1.0-2*chip_im_buttons_vertical_margin-15*chip_im_buttons_vertical_distance)/16.0;
			%-%declarations
   chip_im_pushbuttons(01) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_01', 'string', '<html><font size=5>A1</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+15*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(02) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_02', 'string', '<html><font size=5>A2</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+14*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(03) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_03', 'string', '<html><font size=5>A3</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+13*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(04) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_04', 'string', '<html><font size=5>A4</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+12*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(05) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_05', 'string', '<html><font size=5>A5</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+11*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(06) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_06', 'string', '<html><font size=5>A6</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+10*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(07) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_07', 'string', '<html><font size=5>A7</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+09*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(08) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_08', 'string', '<html><font size=5>A8</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+08*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(09) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_09', 'string', '<html><font size=5>B1</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+07*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(10) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_10', 'string', '<html><font size=5>B2</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+06*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(11) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_11', 'string', '<html><font size=5>B3</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+05*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(12) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_12', 'string', '<html><font size=5>B4</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+04*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(13) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_13', 'string', '<html><font size=5>B5</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+03*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(14) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_14', 'string', '<html><font size=5>B6</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+02*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(15) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_15', 'string', '<html><font size=5>B7</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+01*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);
   chip_im_pushbuttons(16) = uicontrol('Parent', chip_im_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_im_pushbutton_16', 'string', '<html><font size=5>B8</font></html>', 'callback', @callback_function, 'Position', [chip_im_buttons_horizontal_margin, chip_im_buttons_vertical_margin+00*(chip_im_buttons_height+chip_im_buttons_vertical_distance), chip_im_buttons_width, chip_im_buttons_height]);

			
			
			
			
			%matrix vertical multiplexor (vm) panel
			%-%geometry definitions
			chip_vm_xmin = 0.20;
			chip_vm_xmax = 0.99;
			chip_vm_ymin = 0.01;
			chip_vm_ymax = 0.19;
			%-%geometry calculations
			chip_vm_position = [chip_vm_xmin, chip_vm_ymin, (chip_vm_xmax-chip_vm_xmin), (chip_vm_ymax-chip_vm_ymin)];
   %declaration
			chip_vm_panel = uipanel('Parent', chip_panel, 'title', '', 'Position', chip_vm_position);
   %16 buttons
			%-%geometry definitions
			chip_vm_buttons_horizontal_margin   = 0.010;
			chip_vm_buttons_horizontal_distance = 0.005;
			chip_vm_buttons_vertical_margin   = 0.03;
			%-%geometry_calculations
			chip_vm_buttons_width  = (1.0-2*chip_vm_buttons_horizontal_margin-17*chip_vm_buttons_horizontal_distance)/18.0;
			chip_vm_buttons_height = 1.0-2*chip_vm_buttons_vertical_margin;
			%-%declarations
   chip_vm_pushbuttons(01) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_01', 'string', '<html><font size=6>01</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+00*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(02) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_02', 'string', '<html><font size=6>02</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+01*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(03) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_03', 'string', '<html><font size=6>03</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+02*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(04) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_04', 'string', '<html><font size=6>04</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+03*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(05) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_05', 'string', '<html><font size=6>05</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+04*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(06) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_06', 'string', '<html><font size=6>06</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+05*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(07) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_07', 'string', '<html><font size=6>07</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+06*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(08) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_08', 'string', '<html><font size=6>08</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+07*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(09) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_09', 'string', '<html><font size=6>09</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+08*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(10) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_10', 'string', '<html><font size=6>10</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+09*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(11) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_11', 'string', '<html><font size=6>11</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+10*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(12) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_12', 'string', '<html><font size=6>12</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+11*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(13) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_13', 'string', '<html><font size=6>13</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+12*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(14) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_14', 'string', '<html><font size=6>14</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+13*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(15) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_15', 'string', '<html><font size=6>15</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+14*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(16) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_16', 'string', '<html><font size=6>16</font></html>',        'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+15*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(17) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_17', 'string', '<html><font size=6>cl.</font></html>', 'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+16*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
   chip_vm_pushbuttons(18) = uicontrol('Parent', chip_vm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_vm_pushbutton_18', 'string', '<html><font size=6>op.</font></html>',  'callback', @callback_function, 'Position', [chip_vm_buttons_horizontal_margin+17*(chip_vm_buttons_width+chip_vm_buttons_horizontal_distance), chip_vm_buttons_vertical_margin, chip_vm_buttons_width, chip_vm_buttons_height]);
			%matrix horizontal multiplexor (hm) panel
			%-%geometry definitions
			chip_hm_xmin = 0.15;
			chip_hm_xmax = 0.20;
			chip_hm_ymin = 0.21;
			chip_hm_ymax = 0.99;
			%-%geometry calculations
			chip_hm_position = [chip_hm_xmin, chip_hm_ymin, (chip_hm_xmax-chip_hm_xmin), (chip_hm_ymax-chip_hm_ymin)];
   %declaration
			chip_hm_panel = uipanel('Parent', chip_panel, 'title', '', 'Position', chip_hm_position);
   %8 buttons
			%-%geometry definitions
			chip_hm_buttons_horizontal_margin = 0.010;
			chip_hm_buttons_vertical_margin   = 0.03;
			chip_hm_buttons_vertical_distance = 0.005;
			%-%geometry_calculations
			chip_hm_buttons_width  = 1.0-2*chip_hm_buttons_horizontal_margin;
			chip_hm_buttons_height = (1.0-2*chip_hm_buttons_vertical_margin-7*chip_hm_buttons_vertical_distance)/8.0;
			%-%declarations
   chip_hm_pushbuttons(01) = uicontrol('Parent', chip_hm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_hm_pushbutton_01', 'string', '<html><font size=6>01</font></html>', 'callback', @callback_function, 'Position', [chip_hm_buttons_horizontal_margin, chip_hm_buttons_vertical_margin+07*(chip_hm_buttons_height+chip_hm_buttons_vertical_distance), chip_hm_buttons_width, chip_hm_buttons_height]);
   chip_hm_pushbuttons(02) = uicontrol('Parent', chip_hm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_hm_pushbutton_02', 'string', '<html><font size=6>02</font></html>', 'callback', @callback_function, 'Position', [chip_hm_buttons_horizontal_margin, chip_hm_buttons_vertical_margin+06*(chip_hm_buttons_height+chip_hm_buttons_vertical_distance), chip_hm_buttons_width, chip_hm_buttons_height]);
   chip_hm_pushbuttons(03) = uicontrol('Parent', chip_hm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_hm_pushbutton_03', 'string', '<html><font size=6>03</font></html>', 'callback', @callback_function, 'Position', [chip_hm_buttons_horizontal_margin, chip_hm_buttons_vertical_margin+05*(chip_hm_buttons_height+chip_hm_buttons_vertical_distance), chip_hm_buttons_width, chip_hm_buttons_height]);
   chip_hm_pushbuttons(04) = uicontrol('Parent', chip_hm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_hm_pushbutton_04', 'string', '<html><font size=6>04</font></html>', 'callback', @callback_function, 'Position', [chip_hm_buttons_horizontal_margin, chip_hm_buttons_vertical_margin+04*(chip_hm_buttons_height+chip_hm_buttons_vertical_distance), chip_hm_buttons_width, chip_hm_buttons_height]);
   chip_hm_pushbuttons(05) = uicontrol('Parent', chip_hm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_hm_pushbutton_05', 'string', '<html><font size=6>05</font></html>', 'callback', @callback_function, 'Position', [chip_hm_buttons_horizontal_margin, chip_hm_buttons_vertical_margin+03*(chip_hm_buttons_height+chip_hm_buttons_vertical_distance), chip_hm_buttons_width, chip_hm_buttons_height]);
   chip_hm_pushbuttons(06) = uicontrol('Parent', chip_hm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_hm_pushbutton_06', 'string', '<html><font size=6>06</font></html>', 'callback', @callback_function, 'Position', [chip_hm_buttons_horizontal_margin, chip_hm_buttons_vertical_margin+02*(chip_hm_buttons_height+chip_hm_buttons_vertical_distance), chip_hm_buttons_width, chip_hm_buttons_height]);
   chip_hm_pushbuttons(07) = uicontrol('Parent', chip_hm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_hm_pushbutton_07', 'string', '<html><font size=6>07</font></html>', 'callback', @callback_function, 'Position', [chip_hm_buttons_horizontal_margin, chip_hm_buttons_vertical_margin+01*(chip_hm_buttons_height+chip_hm_buttons_vertical_distance), chip_hm_buttons_width, chip_hm_buttons_height]);
   chip_hm_pushbuttons(08) = uicontrol('Parent', chip_hm_panel, 'style', 'pushbutton', 'units', 'normalized', 'tag', 'chip_hm_pushbutton_08', 'string', '<html><font size=6>08</font></html>', 'callback', @callback_function, 'Position', [chip_hm_buttons_horizontal_margin, chip_hm_buttons_vertical_margin+00*(chip_hm_buttons_height+chip_hm_buttons_vertical_distance), chip_hm_buttons_width, chip_hm_buttons_height]);

			
			
			
			
			
			
			
			%assay panel (horizontal from 1.0 - 2.0)
			%-%geometry settings
			assay_xmin = 0.01;
   assay_xmax = 0.99;
			assay_ymin = 0.01;
			assay_ymax = 0.49;
			%-%declaration
			assay_panel = uipanel('Parent', inner_panel, 'title', 'Assay automation', 'Position', [assay_xmin, assay_ymin, assay_xmax-assay_xmin, assay_ymax-assay_ymin]);
   %pushbuttons panel
			%-%geometry settings
			assay_pushbuttons_panel_xmin = 0.01;
			assay_pushbuttons_panel_xmax = 0.09;
			assay_pushbuttons_panel_ymin = 0.04;
			assay_pushbuttons_panel_ymax = 0.96;
			assay_pushbuttons_panel = uipanel('Parent', assay_panel, 'title', '', 'Position', [assay_pushbuttons_panel_xmin, assay_pushbuttons_panel_ymin, assay_pushbuttons_panel_xmax-assay_pushbuttons_panel_xmin, assay_pushbuttons_panel_ymax-assay_pushbuttons_panel_ymin]);
			%pushbuttons
			%-%geometry settings
			assay_pushbuttons_horizontal_margin = 0.1;
			assay_pushbuttons_vertical_margin   = 0.1;
			assay_pushbuttons_vertical_distance = 0.1;
   %-%geometry calculations
			assay_pushbutton_width  = 1.0-2*assay_pushbuttons_horizontal_margin;
			assay_pushbutton_height = (1.0-2*assay_pushbuttons_vertical_margin-2*assay_pushbuttons_vertical_distance)/3.0;
			%-%declarations
			assay_pushbuttons(01) = uicontrol('Parent', assay_pushbuttons_panel, 'units', 'normalized', 'tag', 'assay_pushbutton_load', 'string', '<html><font size=5>Load Assay</font></html>', 'callback', @callback_function, 'Position', [assay_pushbuttons_horizontal_margin, assay_pushbuttons_vertical_margin+2*assay_pushbutton_height+2*assay_pushbuttons_vertical_distance, assay_pushbutton_width, assay_pushbutton_height]);
			assay_pushbuttons(02) = uicontrol('Parent', assay_pushbuttons_panel, 'units', 'normalized', 'tag', 'assay_pushbutton_run',  'string', '<html><font size=5>Run Assay</font></html>',  'callback', @callback_function, 'Position', [assay_pushbuttons_horizontal_margin, assay_pushbuttons_vertical_margin+1*assay_pushbutton_height+1*assay_pushbuttons_vertical_distance, assay_pushbutton_width, assay_pushbutton_height]);
			assay_pushbuttons(03) = uicontrol('Parent', assay_pushbuttons_panel, 'units', 'normalized', 'tag', 'assay_pushbutton_stop', 'string', '<html><font size=5>Stop Assay</font></html>', 'callback', @callback_function, 'Position', [assay_pushbuttons_horizontal_margin, assay_pushbuttons_vertical_margin+0*assay_pushbutton_height+0*assay_pushbuttons_vertical_distance, assay_pushbutton_width, assay_pushbutton_height]);
   %assay table
			%-%geometry settings
			assay_table_xmin = 0.10;
			assay_table_xmax = 0.96;
			assay_table_ymin = 0.06;
			assay_table_ymax = 0.94;
			%-%declaration
   assay_table = uitable('Parent', assay_panel, 'units', 'normalized', 'position', [assay_table_xmin, assay_table_ymin, assay_table_xmax-assay_table_xmin, assay_table_ymax-assay_table_ymin]);
   set(assay_table, 'columnname', {'Step', 'Start', 'End', 'Duration /s', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48'});
   set(assay_table, 'columnformat',{'char', 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char' 'char'});
   set(assay_table, 'columnwidth', {400 160 160 120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20});
			
			%nchip panel (horizontal from 0.0 - 1.0)
   %-%geometry settings
   nchip_xmin = 1.20;
   nchip_xmax = 1.80;
	  nchip_ymin = 0.01;
  	nchip_ymax = 0.99;
			%-%geometry calculations
			nchip_position = [nchip_xmin, nchip_ymin, nchip_xmax-nchip_xmin, nchip_ymax-nchip_ymin];
  	%-%declaration
  	%nchip_panel = uipanel('Parent', inner_panel, 'visible', 'on', 'title', 'nchip', 'Position', nchip_position);
  	nchip_panel = uipanel('Parent', inner_panel, 'visible', 'off', 'title', 'nchip', 'Position', nchip_position);
   %nchip image
			%-%geometry definitions
			nchip_image_width  = 1200;
			nchip_image_height = 900;
			%declaration, initialization with default matlab bgcolor [212,208,200]
			nchip_matrix = ones(nchip_image_height, nchip_image_width,3);
			%nchip_matrix(:,:,1) = 212/255;
			%nchip_matrix(:,:,2) = 208/255;
			%nchip_matrix(:,:,3) = 200/255;
			nchip_matrix(:,:,1) = 192/255;
			nchip_matrix(:,:,2) = 188/255;
			nchip_matrix(:,:,3) = 180/255;
			nchip_axes = axes('parent', nchip_panel, 'position', [0.0, 0.0, 1.0, 1.0]);
 		nchip_imageimage = imshow(nchip_matrix, 'parent', nchip_axes);
			%declaration of elements
			%-%flowchannels
			nchip_flowchannels = zeros(1,4); %in order to avoid empty errors
			nchip_flowchannels = [nchip_flowchannels; 100,300,200,220];
			
			%test channels
			for c1=1:10
			   nchip_flowchannels = [nchip_flowchannels; 100, 300, 200, 220];
			end
			
			
			%rule for overlapping
			%!( P2.y < P3.y || P1.y > P4.y || P2.x < P3.x || P1.x > P4.x )"
			
			
			
			
	%startup procedures
	%-%rack
	%-%-%boxes
	%-%search for usb connected box hardware
	rack_leftbox_hardware_status  = get_boxhardware_status(rack_leftbox_id);
	rack_rightbox_hardware_status = get_boxhardware_status(rack_rightbox_id);
 %-%-%set boxstatus depending on found boxes
	if (rack_leftbox_hardware_status==0 && rack_rightbox_hardware_status==0)
		rack_boxes_comstatus=0;
		disp('startup procedures: opening box communication');
	 rack_boxeshardware = vc_open_setup(rack_boxeshardware);
	else
		rack_boxes_comstatus=1;
	end
	update_all
			
			
			
	function resize_chip_sketch_panel(hObject, eventdata)
		%disp information
		%disp('resizing chip_panel');
        %get normalized position of chip panel in outer panel
		chip_panel_position_normalized = get(chip_panel, 'position');
		%disp information
		%disp(['chip panel width/height normalized: ', num2str(chip_panel_position_normalized(3)), ' / ', num2str(chip_panel_position_normalized(4))]); 
		%get normalized position of outer panel in main_window
		outer_panel_position_normalized = get(outer_panel, 'position');
		%disp information
		%disp(['outer panel width/height normalized: ', num2str(outer_panel_position_normalized(3)), ' / ', num2str(outer_panel_position_normalized(4))]); 
		%get pixel position of main_window
		main_window_pixel_position = get(main_window, 'position');
		%disp information
		%disp(['main window width/height (pixel): ', num2str(main_window_pixel_position(3)), ' / ', num2str(main_window_pixel_position(4))]); 
		%calculate chip panel in pixel
		chip_panel_width_pixel  = main_window_pixel_position(3)*outer_panel_position_normalized(3)*chip_panel_position_normalized(3);
		chip_panel_height_pixel = main_window_pixel_position(4)*outer_panel_position_normalized(4)*chip_panel_position_normalized(4);
		%disp information
		%disp(['chip panel width/height (pixel): ', num2str(chip_panel_width_pixel), ' / ', num2str(chip_panel_height_pixel)]); 
		%calculate position of chip_sketch_panel
		%-%case1, chip_panel width>height
		if (chip_panel_width_pixel/chip_panel_height_pixel>chip_sketch_coordinates_deltax/chip_sketch_coordinates_deltay)
			chip_sketch_panel_xmin   = (1.0-chip_sketch_coordinates_deltax/chip_sketch_coordinates_deltay*chip_panel_height_pixel/chip_panel_width_pixel)/2.0;
			chip_sketch_panel_ymin   = 0.0;
			chip_sketch_panel_width  = chip_sketch_coordinates_deltax/chip_sketch_coordinates_deltay*chip_panel_height_pixel/chip_panel_width_pixel;
			chip_sketch_panel_height = 1.0;
		end
		%-%case2, chip_panel width<=height
		if (chip_panel_width_pixel/chip_panel_height_pixel<=chip_sketch_coordinates_deltax/chip_sketch_coordinates_deltay)
			chip_sketch_panel_xmin   = 0.0;
			chip_sketch_panel_ymin   = (1.0-chip_sketch_coordinates_deltay/chip_sketch_coordinates_deltax*chip_panel_width_pixel/chip_panel_height_pixel)/2.0;
			chip_sketch_panel_width  = 1.0;
			chip_sketch_panel_height = chip_sketch_coordinates_deltay/chip_sketch_coordinates_deltax*chip_panel_width_pixel/chip_panel_height_pixel;
		end
		%set the new size
		set(chip_sketch_panel, 'position', [chip_sketch_panel_xmin, chip_sketch_panel_ymin, chip_sketch_panel_width, chip_sketch_panel_height]);
	end
			
			
	function callback_function(hObject, eventdata)
	   %cout information
				%disp('This is callback function.');
				%get tag
				tag=get(hObject, 'tag');
				%cout information
				%disp(['tag: ', tag]);
				%split tag
				tag_parts = regexp(tag, '_', 'split');
    %cout information
				%disp(['tag_parts: ', tag_parts]);
				
				%execute code depending on tag

				%-%valvebits
				if (strcmp(tag_parts(1), 'valvebits')==1)
					%pushbuttons
				  if (strcmp(tag_parts(2), 'pushbutton')==1)
							%get id as number
							id = str2num(tag_parts{3});
							%switch the valvebit corresponding id (-1 means switch)
							set_valvebit(id, -1);
						end
				end
				
				%-%rack
				if (strcmp(tag_parts(1), 'rack')==1)
					%boxes
			  if (strcmp(tag_parts(2), 'boxes')==1)
					 %startcombutton
					end
				%pushbuttons
				  if (strcmp(tag_parts(2), 'pushbutton')==1)
							%get id as number
							id = str2num(tag_parts{3});
							%switch the valvebit corresponding id (-1 means switch)
							set_valvebit(id, -1);
						end
				end
	
				
				%-%chip
				if (strcmp(tag_parts(1), 'chip')==1)
						%inlet multiplexor
				  if (strcmp(tag_parts(2), 'im') && strcmp(tag_parts(3), 'pushbutton')==1)
							%switch the valvebits according to multiplexor logic
							if (strcmp(tag_parts(4), '01')) set_valvebit(1,0); set_valvebit(2,1); set_valvebit(3,0); set_valvebit(4,1); set_valvebit(5,0); set_valvebit(6,1); end
							if (strcmp(tag_parts(4), '02')) set_valvebit(1,1); set_valvebit(2,0); set_valvebit(3,0); set_valvebit(4,1); set_valvebit(5,0); set_valvebit(6,1); end
							if (strcmp(tag_parts(4), '03')) set_valvebit(1,0); set_valvebit(2,1); set_valvebit(3,1); set_valvebit(4,0); set_valvebit(5,0); set_valvebit(6,1); end
							if (strcmp(tag_parts(4), '04')) set_valvebit(1,1); set_valvebit(2,0); set_valvebit(3,1); set_valvebit(4,0); set_valvebit(5,0); set_valvebit(6,1); end
							if (strcmp(tag_parts(4), '05')) set_valvebit(1,0); set_valvebit(2,1); set_valvebit(3,0); set_valvebit(4,1); set_valvebit(5,1); set_valvebit(6,0); end
							if (strcmp(tag_parts(4), '06')) set_valvebit(1,1); set_valvebit(2,0); set_valvebit(3,0); set_valvebit(4,1); set_valvebit(5,1); set_valvebit(6,0); end
							if (strcmp(tag_parts(4), '07')) set_valvebit(1,0); set_valvebit(2,1); set_valvebit(3,1); set_valvebit(4,0); set_valvebit(5,1); set_valvebit(6,0); end
							if (strcmp(tag_parts(4), '08')) set_valvebit(1,1); set_valvebit(2,0); set_valvebit(3,1); set_valvebit(4,0); set_valvebit(5,1); set_valvebit(6,0); end
							if (strcmp(tag_parts(4), '09')) set_valvebit(1,0); set_valvebit(2,1); set_valvebit(3,0); set_valvebit(4,1); set_valvebit(5,0); set_valvebit(6,1); end
							if (strcmp(tag_parts(4), '10')) set_valvebit(1,1); set_valvebit(2,0); set_valvebit(3,0); set_valvebit(4,1); set_valvebit(5,0); set_valvebit(6,1); end
							if (strcmp(tag_parts(4), '11')) set_valvebit(1,0); set_valvebit(2,1); set_valvebit(3,1); set_valvebit(4,0); set_valvebit(5,0); set_valvebit(6,1); end
							if (strcmp(tag_parts(4), '12')) set_valvebit(1,1); set_valvebit(2,0); set_valvebit(3,1); set_valvebit(4,0); set_valvebit(5,0); set_valvebit(6,1); end
							if (strcmp(tag_parts(4), '13')) set_valvebit(1,0); set_valvebit(2,1); set_valvebit(3,0); set_valvebit(4,1); set_valvebit(5,1); set_valvebit(6,0); end
							if (strcmp(tag_parts(4), '14')) set_valvebit(1,1); set_valvebit(2,0); set_valvebit(3,0); set_valvebit(4,1); set_valvebit(5,1); set_valvebit(6,0); end
							if (strcmp(tag_parts(4), '15')) set_valvebit(1,0); set_valvebit(2,1); set_valvebit(3,1); set_valvebit(4,0); set_valvebit(5,1); set_valvebit(6,0); end
							if (strcmp(tag_parts(4), '16')) set_valvebit(1,1); set_valvebit(2,0); set_valvebit(3,1); set_valvebit(4,0); set_valvebit(5,1); set_valvebit(6,0); end
						end

					%vertical multiplexor
				  if (strcmp(tag_parts(2), 'vm') && strcmp(tag_parts(3), 'pushbutton')==1)
							%switch the valvebits according to multiplexor logic
							if (strcmp(tag_parts(4), '01')) set_valvebit(14,1); set_valvebit(15,0); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '02')) set_valvebit(14,1); set_valvebit(15,0); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '03')) set_valvebit(14,1); set_valvebit(15,0); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '04')) set_valvebit(14,1); set_valvebit(15,0); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '05')) set_valvebit(14,1); set_valvebit(15,0); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '06')) set_valvebit(14,1); set_valvebit(15,0); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '07')) set_valvebit(14,1); set_valvebit(15,0); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '08')) set_valvebit(14,1); set_valvebit(15,0); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '09')) set_valvebit(14,0); set_valvebit(15,1); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '10')) set_valvebit(14,0); set_valvebit(15,1); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '11')) set_valvebit(14,0); set_valvebit(15,1); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '12')) set_valvebit(14,0); set_valvebit(15,1); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '13')) set_valvebit(14,0); set_valvebit(15,1); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '14')) set_valvebit(14,0); set_valvebit(15,1); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '15')) set_valvebit(14,0); set_valvebit(15,1); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '16')) set_valvebit(14,0); set_valvebit(15,1); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '17')) set_valvebit(14,1); set_valvebit(15,1); set_valvebit(16,1); set_valvebit(17,1); set_valvebit(18,1); set_valvebit(19,1); set_valvebit(20,1); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '18')) set_valvebit(14,0); set_valvebit(15,0); set_valvebit(16,0); set_valvebit(17,0); set_valvebit(18,0); set_valvebit(19,0); set_valvebit(20,0); set_valvebit(21,0); end
						end
					%horizontal multiplexor
				  if (strcmp(tag_parts(2), 'hm') && strcmp(tag_parts(3), 'pushbutton')==1)
							%switch the valvebits according to multiplexor logic
							if (strcmp(tag_parts(4), '01')) set_valvebit(14,1); set_valvebit(15,1); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '02')) set_valvebit(14,1); set_valvebit(15,1); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '03')) set_valvebit(14,1); set_valvebit(15,1); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '04')) set_valvebit(14,1); set_valvebit(15,1); set_valvebit(16,0); set_valvebit(17,1); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '05')) set_valvebit(14,1); set_valvebit(15,1); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '06')) set_valvebit(14,1); set_valvebit(15,1); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,0); set_valvebit(19,1); set_valvebit(20,1); set_valvebit(21,0); end
							if (strcmp(tag_parts(4), '07')) set_valvebit(14,1); set_valvebit(15,1); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,0); set_valvebit(21,1); end
							if (strcmp(tag_parts(4), '08')) set_valvebit(14,1); set_valvebit(15,1); set_valvebit(16,1); set_valvebit(17,0); set_valvebit(18,1); set_valvebit(19,0); set_valvebit(20,1); set_valvebit(21,0); end
						end
                end
                
                
                
                
                
                
                
                
%-%assay
%-%-%load button
if (strcmp(tag, 'assay_pushbutton_load')==1)
 %run file select dialog
 [filename, pathname] = uigetfile('*.txt', 'Pick an Assay file');
 if isequal(filename,0) | isequal(pathname,0)
 user pressed cancel, do nothing
 else
 filename = fullfile(pathname, filename);
 %load assay data
 fileid = fopen(filename);
 importdata = textscan(fileid, '%s %f %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d');
 fclose(fileid);
 numberofsteps = size(importdata{1},1);
 tabledata = cell(numberofsteps, 52);
 for c1=1:numberofsteps;
  tabledata{c1,1} = importdata{1}{c1};
  for c2=2:50;
   tabledata{c1,c2+2} = importdata{c2}(c1);
  end
 end
 %set data to table
 set(assay_table, 'data', tabledata);
 end
end



				%-%run button
				if (strcmp(tag, 'assay_pushbutton_run')==1)
							%stop all old timers
							%-%dummy for case no timer exists, to avoid errors
							dummyt=timer;
							%-%stop command
  					stop(timerfind);
							delete(timerfind);
       %get data from assay table and information about it
							tabledata = get(assay_table, 'data');
							totalnumberofsteps = size(tabledata,1);
							%dialogbox for start and stop numbers
							%-%define dialog box contents
       prompt = {'From step:','To step:'};
       title = 'Run assay';
       num_lines = 1;
       def = {'1',num2str(totalnumberofsteps)};
       answer = inputdlg(prompt,title,num_lines,def);
							%-%process answer
							sizeofanswer = size(answer);
	      %-%handle case cancel button was pressed
	      if (sizeofanswer(1)==0)
								%do nothing
							else
								%todo errorhandling of user input
								%get start and stopstep
								startstep = str2num(answer{1,1});
								disp(['startstep: ', num2str(startstep)]);
								stopstep  = str2num(answer{2,1});
								disp(['stopstep: ', num2str(stopstep)]);
 							numberofsteps = stopstep-startstep+1;
								disp(['numberofsteps: ', num2str(numberofsteps)]);
								%define a start delay time. This is for stability of the first
								%timer, in order to avoid, that the first timers startat is in the
								%past. A few seconds are sufficient.
								timerstartdelay = 120;
								disp(['timerstartdelay: ', num2str(timerstartdelay), ' sec']);
 					  %get system time now
 							timenow = now;
 							timenow_string = datestr(timenow, 'dd.mm.yyyy - HH:MM:SS');
								disp(['timenow_string:         ', timenow_string]);
%        %calculate assay start time from timenow and start delay
%								time_assaystart = timenow+timerstartdelay/(24*60*60);
% 							time_assaystart_string = datestr(time_assaystart, 'dd.mm.yyyy - HH:MM:SS');
%								disp(['time_assaystart_string: ', time_assaystart_string]);
								%declare the timers 
								%-%declare loop time variable, initialize as now + startdelay
								current_loop_time = timenow+timerstartdelay/(24*60*60);
 							current_loop_time_string = datestr(current_loop_time, 'dd.mm.yyyy - HH:MM:SS');
								disp(['current_loop_time_string:         ', current_loop_time_string]);
								%declare dummytimers, for timer arrays must not have any gaps
								for c1=1:startstep-1;
									timers(c1) = timer();
								end
								%loop the steps
								for c1=startstep:stopstep;
									%get start time and end time for current step
									this_start_time = current_loop_time;
         this_end_time   = this_start_time + tabledata{c1,4}/(24*60*60);
									%display information
									disp(['step: ', num2str(c1), ' --- current_loop_time: ', datestr(current_loop_time, 'dd.mm.yyyy - HH:MM:SS'), ' --- this_start_time: ', datestr(this_start_time, 'dd.mm.yyyy - HH:MM:SS'), ' --- this_end_time: ', datestr(this_end_time, 'dd.mm.yyyy - HH:MM:SS')]);
         %declare, initialize and start the timer
  							timers(c1) = timer('timerfcn', {@assay_timer_function, c1, tabledata});
         startat(timers(c1), this_start_time);
 							 %write the absolute time to table
  							tabledata{c1,2} = datestr(this_start_time, 'dd.mm.yyyy - HH:MM:SS');
  							tabledata{c1,3} = datestr(this_end_time,   'dd.mm.yyyy - HH:MM:SS');
									%update current_loop_time
									current_loop_time = this_end_time;
								end
 							%set data to table
 							set(assay_table, 'data', tabledata);
							end
						end
 				%-%stop button
 				if (strcmp(tag, 'assay_pushbutton_stop')==1)
					%stop all timers
					dummyt=timer;
					stop(timerfind);
					delete(timerfind);
				end
	update_all
	end


	function set_valvebit(id, value)
		%%%%%%%%%%%%%%%%%%
		%sets a value in valvebits to 0 or 1 or switches its state
		%%%%%%%%%%%%%%%%%%
		%id: valvebits index (1<=id<=48)
		%value:  0 sets to 0
		%        1 sets to 1
		%       -1 switches 0->1 or 1->0
		%%%%%%%%%%%%%%%%%%
		%check 1<=id<=48
		if (id>=1 && id<=48)
			if (value==0)
				valvebits{id}=0;
			end
			if (value==1)
				valvebits{id}=1;
			end
			if (value==-1)
				if (valvebits{id}==0)
					valvebits{id}=1;
				else
					valvebits{id}=0;
				end
			end
			%update all elements
			update_all;
		end
	end

	function assay_timer_function(obj, event, id, tabledata)
		%cout information
		disp(['timer step: ', num2str(id), '--- start: ', datestr(now, 'dd.mm.yyyy - HH:MM:SS')]);
		%set valvebits using current line in tabledata
		for c1=1:48;
			valvebits{c1}=tabledata{id, c1+4};
		end
  %set the color of the active step in table 		
		currenttabledata = get(assay_table, 'data');
  currenttabledata{id,1} = ['<html><font color="green">' num2str(currenttabledata{id,1}) '</font></html>'];
		set(assay_table, 'data', currenttabledata);
		update_all
	end


function boxhardware_status = get_boxhardware_status(serial_number)
   boxhardware_status=1; %default not ok
   %declare a test valve control environment with that box and ask its status
   testvc.num = 1;
			testvc.info(1).sn = serial_number;
			testvc.info(1).handle=0;
			testvc.info(1).status=0;
			testvc.info(1).polarity = logical([ones(1,24)]);
			testvc             = vc_open_setup(testvc);
			boxhardware_status = testvc.info(1).status;
			testvc             = vc_close(testvc, 1);
end


	function update_all()
		update_hardware
		update_screen
	end

	function update_hardware()
	   %%%%%%%%%%%%%%%%%%	
	   %communicates current valvebits vector to hardware
	   %%%%%%%%%%%%%%%%%%
				%test boxes comstatus
				if (rack_boxes_comstatus==0)
					%close control valves first
					for (c1=1:24);
						if (valvebits{c1}==1)
							rack_boxeshardware = vc_set_bits_ac(rack_boxeshardware, c1-1, valvebits{c1});
						end
					end
 				%open flow valves
					for (c1=25:48);
						if (valvebits{c1}==0)
							rack_boxeshardware = vc_set_bits_ac(rack_boxeshardware, c1-1, valvebits{c1});
						end
					end
					%close flow valves
					for (c1=25:48);
						if (valvebits{c1}==1)
							rack_boxeshardware = vc_set_bits_ac(rack_boxeshardware, c1-1, valvebits{c1});
						end
					end
 				%open control valves
					for (c1=1:24);
						if (valvebits{c1}==0)
							rack_boxeshardware = vc_set_bits_ac(rack_boxeshardware, c1-1, valvebits{c1});
						end
					end
     %alternative, do all in one step
     %for (c1=1:48);
					%	rack_boxeshardware = vc_set_bits_ac(rack_boxeshardware, c1-1, valvebits{c1});
					%end
				end
	end

	function update_screen()
		update_screen_valvebits
		update_screen_rack
		update_screen_assay
		%update_screen_nchip
	end

	function update_screen_valvebits()
		%define parameters
		%bgcolor_off = [0.3, 0.3, 0.3];
		%bgcolor_on  = [0.7, 0.3, 0.3];
		%update the pushbuttons
		for c1=1:48;
			if (valvebits{c1}==0)
			%	set(valvebits_pushbuttons(c1), 'backgroundcolor', rack_valvebits_bgcolor_off);
			end
			if (valvebits{c1}==1)
			%	set(valvebits_pushbuttons(c1), 'backgroundcolor', rack_valvebits_bgcolor_on);
			end
		end
 end

	function update_screen_rack()
		%boxes and comstatus
		%-%leftbox
		if (rack_leftbox_hardware_status==0)
			set(rack_leftbox_id_textfield, 'backgroundcolor', rack_box_hardware_ok_color);
		else
			set(rack_leftbox_id_textfield, 'backgroundcolor', rack_box_hardware_notok_color);
		end
		%-%rightbox
	 if (rack_rightbox_hardware_status==0)
		 set(rack_rightbox_id_textfield, 'backgroundcolor', rack_box_hardware_ok_color);
		else
		 set(rack_rightbox_id_textfield, 'backgroundcolor', rack_box_hardware_notok_color);
		end
		%comstatus
 	if (rack_boxes_comstatus==0)
 		set(rack_boxes_comstatus_textfield, 'string', 'Hardware: online');
 		set(rack_boxes_comstatus_textfield, 'backgroundcolor', rack_boxes_comstatus_online_color);
		else
 		set(rack_boxes_comstatus_textfield, 'string', 'Hardware: offline');
 		set(rack_boxes_comstatus_textfield, 'backgroundcolor', rack_boxes_comstatus_offline_color);
		end
		%update the pushbuttons
		for c1=1:48;
			if (valvebits{c1}==0)
			%	set(rack_pushbuttons(c1), 'backgroundcolor', rack_valvebits_bgcolor_off);
			end
			if (valvebits{c1}==1)
			%	set(rack_pushbuttons(c1), 'backgroundcolor', rack_valvebits_bgcolor_on);
			end
		end
 end
		
		
		

	function update_screen_assay()
	end

function update_screen_nchip()
	  size_of_nchip_flowchannels = size(nchip_flowchannels,1);
  	if (size_of_nchip_flowchannels>=2)
  	   for c1=2:size_of_nchip_flowchannels;
  							a = round(nchip_flowchannels(c1,1));
  							b = round(nchip_flowchannels(c1,2));
  							c = round(nchip_flowchannels(c1,3));
  							d = round(nchip_flowchannels(c1,4));
   						nchip_matrix(a:b,c:d,:) = 0.5;
						end
			end
			nchip_imageimage = imshow(nchip_matrix, 'parent', nchip_axes);
end

end





