Subversion Repositories f9daq

Rev

Rev 267 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 267 Rev 319
Line -... Line 1...
-
 
1
 
1
Blockly.JavaScript['particle_combiner'] = function(block) {
2
Blockly.JavaScript['particle_combiner'] = function(block) {
2
  var value_list1 = Blockly.JavaScript.valueToCode(block, 'list1', Blockly.JavaScript.ORDER_ATOMIC);
3
  var value_list1 = Blockly.JavaScript.valueToCode(block, 'list1', Blockly.JavaScript.ORDER_ATOMIC);
3
  if (value_list1.length==0) value_list1='""';
4
  if (value_list1.length==0) value_list1='""';
4
  var value_list2 = Blockly.JavaScript.valueToCode(block, 'list2', Blockly.JavaScript.ORDER_ATOMIC);
5
  var value_list2 = Blockly.JavaScript.valueToCode(block, 'list2', Blockly.JavaScript.ORDER_ATOMIC);
5
  if (value_list2.length==0) value_list2='""';
6
  if (value_list2.length==0) value_list2='""';
6
  var dropdown_simplepid = block.getFieldValue('simplepid');
7
  var dropdown_simplepid = block.getFieldValue('simplepid');
7
  var dropdown_sameparticles = block.getFieldValue('sameparticles');
8
  var dropdown_sameparticles = block.getFieldValue('sameparticles');
8
  var number_mass0 = block.getFieldValue('mass0');
9
  var number_mass0 = block.getFieldValue('mass0');
9
  var number_mass1 = block.getFieldValue('mass1');
10
  var number_mass1 = block.getFieldValue('mass1');
10
  var value_histogram = Blockly.JavaScript.valueToCode(block, 'histogram', Blockly.JavaScript.ORDER_ATOMIC);
11
  var histograms = Blockly.JavaScript.statementToCode(block, 'histogram');
11
  if (value_histogram.length==0) value_histogram='""';
12
  var code = '{"combiner":{"list1":' + value_list1 + ',"list2":' +  value_list2 ;
12
  // TODO: Assemble JavaScript into code variable.
13
      code += ',"sameparticles":"'+ dropdown_sameparticles +'","pid":"' + dropdown_simplepid ;
13
  var code = '{"combiner":{"list1":' + value_list1 + ',"list2":' +  value_list2 + ',"sameparticles":"'+ dropdown_sameparticles +'","pid":"' + dropdown_simplepid +  '","m0":"' + number_mass0 +  '","m1":"' + number_mass1 + '","histogram":' + value_histogram + '}}\n';
14
      code +=  '","m0":"' + number_mass0 +  '","m1":"' + number_mass1 + '","histogram":[' + histograms + ']}}\n';
14
  // TODO: Change ORDER_NONE to the correct strength.
-
 
15
  return [code, Blockly.JavaScript.ORDER_NONE];
15
  return [code, Blockly.JavaScript.ORDER_NONE];
16
};
16
};
17
 
17
 
18
Blockly.JavaScript['particle_selector'] = function(block) {
18
Blockly.JavaScript['particle_selector'] = function(block) {
19
  var value_list1 = Blockly.JavaScript.valueToCode(block, 'list1', Blockly.JavaScript.ORDER_ATOMIC);
19
  var value_list1 = Blockly.JavaScript.valueToCode(block, 'list1', Blockly.JavaScript.ORDER_ATOMIC);
20
  if (value_list1.length==0) value_list1='""';
20
  if (value_list1.length==0) value_list1='""';
21
  var dropdown_chargelist = block.getFieldValue('chargelist');
21
  var dropdown_chargelist = block.getFieldValue('chargelist');
22
  var dropdown_simplepid = block.getFieldValue('simplepid');
22
  var dropdown_simplepid = block.getFieldValue('simplepid');
23
  var value_histogram = Blockly.JavaScript.valueToCode(block, 'histogram', Blockly.JavaScript.ORDER_ATOMIC);
23
  var histograms = Blockly.JavaScript.statementToCode(block, 'histogram');
24
  if (value_histogram.length==0) value_histogram='""';
24
  var code = '{"selector":{"list1":' + value_list1 ;
25
  // TODO: Assemble JavaScript into code variable.
25
      code  += ',"charge":"' +  dropdown_chargelist ;
26
  var code = '{"selector":{"list1":' + value_list1 + ',"charge":"' +  dropdown_chargelist + '","pid":"' + dropdown_simplepid +  '","histogram":' + value_histogram + '}}\n';
26
      code  += '","pid":"' + dropdown_simplepid +  '","histogram":[' + histograms + ']}}\n';
27
  // TODO: Change ORDER_NONE to the correct strength.
-
 
28
  return [code, Blockly.JavaScript.ORDER_NONE];
27
  return [code, Blockly.JavaScript.ORDER_NONE];
29
};
28
};
30
 
29
 
31
Blockly.JavaScript['histogram_creator'] = function(block) {
30
Blockly.JavaScript['histogram_creator'] = function(block) {
32
  var text_name = block.getFieldValue('name');
31
  var text_name = block.getFieldValue('name');
33
  var number_nbins = block.getFieldValue('nbins');
32
  var number_nbins = block.getFieldValue('nbins');
34
  var number_min = block.getFieldValue('min');
33
  var number_min = block.getFieldValue('min');
35
  var number_max = block.getFieldValue('max');
34
  var number_max = block.getFieldValue('max');
36
  var dropdown_varname = block.getFieldValue('varname');
35
  var dropdown_varname = block.getFieldValue('varname');
37
  // TODO: Assemble JavaScript into code variable.
36
  var code = '{"h1d":{"varname":"'+ dropdown_varname + '",';
38
 
-
 
39
  var code = '{"h1d":{"varname":"'+ dropdown_varname + '","name":"' +  text_name + '","nbins":"' + number_nbins + '","min":"' + number_min +  '","max":"' + number_max + '"}}\n';
37
      code = code  + ' "name":"' +  text_name + '","nbins":"' + number_nbins + '",';
40
  // TODO: Change ORDER_NONE to the correct strength.
38
      code = code  + ' "min":"' + number_min +  '","max":"' + number_max + '"}}\n';
41
  return [code, Blockly.JavaScript.ORDER_NONE];
39
  return code;
42
};
40
};
43
 
41
 
44
Blockly.JavaScript['simple_analysis'] = function(block) {
42
Blockly.JavaScript['simple_analysis'] = function(block) {
45
  var number_neve = block.getFieldValue('neve');
43
  var number_neve = block.getFieldValue('neve');
46
  var number_first= block.getFieldValue('first');
44
  var number_first= block.getFieldValue('first');
47
  var number_print= block.getFieldValue('print');
45
  var number_print= block.getFieldValue('print');
48
  var dropdown_datasource = block.getFieldValue('datasource');
46
  var dropdown_datasource = block.getFieldValue('datasource');
49
  var value_list = Blockly.JavaScript.valueToCode(block, 'list', Blockly.JavaScript.ORDER_ATOMIC);
47
  var value_list = Blockly.JavaScript.valueToCode(block, 'list', Blockly.JavaScript.ORDER_ATOMIC);
50
  if (value_list.length==0) value_list='""';
48
  if (value_list.length==0) value_list='""';
51
  // TODO: Assemble JavaScript into code variable.
-
 
52
  var code = '{"analysis":{"neve":"' + number_neve + '","first":"' + number_first + '","print":"' + number_print +  '","datasource":"' + dropdown_datasource + '","list":' + value_list + '}}\n';
49
  var code = '{"analysis":{"neve":"' + number_neve + '","first":"' + number_first + '","print":"' + number_print +  '","datasource":"' + dropdown_datasource + '","list":' + value_list + '}}\n';
53
 
50
 
54
  return code;
51
  return code;
55
};
52
};
56
 
53
 
57
Blockly.JavaScript['particle_mass_fix'] = function(block) {
54
Blockly.JavaScript['particle_mass_fix'] = function(block) {
58
  var value_list = Blockly.JavaScript.valueToCode(block, 'list', Blockly.JavaScript.ORDER_ATOMIC);
55
  var value_list = Blockly.JavaScript.valueToCode(block, 'list', Blockly.JavaScript.ORDER_ATOMIC);
59
  if (value_list.length==0) value_list='""';
56
  if (value_list.length==0) value_list='""';
60
  // TODO: Assemble JavaScript into code variable.
-
 
61
  var code = '{"fix_mass":{"list":' + value_list + '}}\n';
57
  var code = '{"fix_mass":{"list":' + value_list + '}}\n';
62
  // TODO: Change ORDER_NONE to the correct strength.
-
 
63
  return [code, Blockly.JavaScript.ORDER_NONE];
58
  return [code, Blockly.JavaScript.ORDER_NONE];
64
};
59
};
65
 
60
 
66
Blockly.JavaScript['primary_list'] = function(block) {
61
Blockly.JavaScript['primary_list'] = function(block) {
67
  var value_histogram = Blockly.JavaScript.valueToCode(block, 'histogram', Blockly.JavaScript.ORDER_ATOMIC);
62
  var value_histogram = Blockly.JavaScript.valueToCode(block, 'histogram', Blockly.JavaScript.ORDER_ATOMIC);
68
   if (value_histogram.length==0) value_histogram='""';
63
   if (value_histogram.length==0) value_histogram='""';
69
  // TODO: Assemble JavaScript into code variable.
-
 
70
  var code = '{"primary":' +  '{"histogram":' + value_histogram + '}}\n';
64
  var code = '{"primary":' +  '{"histogram":' + value_histogram + '}}\n';
71
  // TODO: Change ORDER_NONE to the correct strength.
-
 
72
  return [code, Blockly.JavaScript.ORDER_NONE];
65
  return [code, Blockly.JavaScript.ORDER_NONE];
73
};
66
};