Victor_testing


test if settings and calibrations are same for old device
/**
 * Macro for data evaluation on PhotosynQ.org
 * by: David M. Kramer
 * created: December 24, 2018 6:50 PM
 */
 
 // Define the output object here
var output = {};

var warnings =0;
var errors =0; 

// Check if the key time exists in json
if (json.time !== undefined){
    // Add key time and value to output
    output.time = json.time;
}
s=json.recall.settings;
output.settings=JSON.stringify(s);

output.par_method=s.par_method;

if ((s.par_method == 1) || (s.par_method == 0)) {
} else {
  errors += 1;
  danger("par_method setting should be 1 or 0. Enter par_method+0+ if using old method or par_method+1+ if using CaliQ or rapid settings",output);
}
 
output.usb_on=s.usb_on;
if ((s.usb_on == 1) || (s.usb_on == 0)) {
} else {
    errors += 1;
  danger("usb_on setting should be 1 or 0. \n Try setting usb_on",output);
}

output.mag_orientation=s.mag_orientation;
if ((s.mag_orientation == 1) || (s.mag_orientation == 0) || (s.mag_orientation == 255)) {
  output.mag_orient="ok";
} else {
    errors += 1;

  danger("mag_orientation setting should be 1 or 0. \n Try setting open_closed_positions", output);
}

output.blink_mode=s.blink_mode;
if ((s.blink_mode > 7) || (s.blink_mode <0)) {
  warnings+=1;
  warning("blink_mode settings incorrect. try set_blink_mode", output);
}
// output.mag_x_offset=s.mag_x_offset;
// if (s.mag_x_offset<9000) {
//  warning("mag_x_offset has not been set. Try running compass calibration", output); 
// }

if (s.thickness_a.isnan) {
 danger("thickness not calibrated", output); 
  errors += 1;
}

if ((s.detector_offsets[0].isnan) || (s.detector_offsets[1].isnan)) {
    danger("detector offset values not set", output);
  errors += 1;
    }

if ((s.detector_offsets[0]<-100) || (s.detector_offsets[0]>1000)) {
    danger("detector 1 (main) offset values out of range", output);
  errors += 1;
    }

if ((s.detector_offsets[1]<-100) || (s.detector_offsets[1]>1000)) {
    danger("detector 3 (clamp) offset values out of range", output);
  errors += 1;
    }

if (((s.thickness_min<0) || (s.thickness_min.isnan)) || ((s.thickness_max.isnan) || (s.thickness_max> 65535)))  {
   danger("thickness max/min values out of range. recalibrate thickness", output); 
}

if ( ((s.closed_position.isnan) || (s.open_position.isnan)) || 
    	((s.closed_position<0) || (s.open_position<0)) || 
    	((s.closed_position>65535) || (s.open_position>65535)) ) {
  danger("open/closed positions out of range", output); 
}

var open_closed_positions_ok = 0;

if (s.open_position - s.closed_position > 0) { 
  if (s.mag_orientation != 1) { 
    open_closed_positions_ok=0;
  } else 
  {open_closed_positions_ok = 1;}
  }
  else {

    if (s.mag_orientation == 1) { 
	  open_closed_positions_ok=0;
  }else 
  {open_closed_positions_ok = 1;}
 }

if (open_closed_positions_ok==0) {	
    danger("open/closed positions out of range. \n Reset with set_op & set_cp, or set_open_closed_positions", output); 
	 errors += 1;
 
}

if (s.device_version == "2" ) {
  if (s.pix_pin == 14) {
  } else  { 
    danger("pix_pin setting wrong! Make sure correct formware is uploaded", output);
	 errors += 1;
  }
}

if (s.device_version == "1" ) {
  if (s.pix_pin == 7) {
  } else    
    danger("pix_pin setting wrong! Make sure correct formware is uploaded", output);
  errors += 1;

}


if ( ((s.mag_x_scale <-3000) || (s.mag_x_scale > 3000)) || ((s.mag_y_scale <-3000) || (s.mag_y_scale > 3000))) {
  warning("compass x scale not set. Try running calibrate_compass", output);
  warnings+=1;
}


if (errors>0) {
 danger("WARNING: " + errors + " error(s) found. Check calibrations and settings!", output); 
}

if (warnings>0) {
 warning("Alert: " + warnings + " warning(s) found. Check calibrations and settings!", output); 
}
output.toDevice="";

output.toDevice += "set_thickness+";
output.toDevice +=(s.thickness_a + "+");
output.toDevice +=(s.thickness_b + "+");
output.toDevice +=(s.thickness_c + "+");
output.toDevice +=(s.thickness_min + "+");
output.toDevice +=(s.thickness_max + "+");

output.toDevice += "mag_scale+";
output.toDevice +=(s.mag_x_scale + "+");
output.toDevice +=(s.mag_y_scale + "+");

output.toDevice += "set_spad_scale+";
output.toDevice +=(s.spad_scale + "+");

output.toDevice += "set_detector_offset+";
for (var detector_number=0; detector_number<4; detector_number++){
	output.toDevice +=(detector_number + "+");
	output.toDevice +=(s.detector_offsets[detector_number] + "+");
  
}

output.toDevice += "set_par_to_dac_calibration+";
	//par_to_dac_slope1[led-1]

output.toDevice += "TEST+junk+";
/*

else if (led > 0 || led < NUM_LEDS + 1) {
            store(par_to_dac_slope1[led-1], Serial_Input_Double("+", 0));  // sat 
            store(par_to_dac_slope2[led-1], Serial_Input_Double("+", 0));  // tau
            store(par_to_dac_slope3[led-1], Serial_Input_Double("+", 0));  // offset
          
*/

//set_led_par

/*
    case hash("set_spad_scale"):{
      store(spad_scale, Serial_Input_Double("+", 0));

=
case hash("mag_scale"): //analogRead(BAT_TEST);     
      {

        store(mag_x_scale,Serial_Input_Double("+", 0));  // the offsets can be stored in the mag3110 chip. However, the scales cannot (why not???)
        store(mag_y_scale,Serial_Input_Double("+", 0));
      }
      break;
*/

/*
case hash("set_thickness"):{

      store(thickness_a, Serial_Input_Double("+", 0));
      store(thickness_b, Serial_Input_Double("+", 0));
      store(thickness_c, Serial_Input_Double("+", 0));
      store(thickness_min, Serial_Input_Double("+", 0));
      store(thickness_max, Serial_Input_Double("+", 0));

*/

  // Return data
return output;
{
  "time": 1545792855098,
  "device_name": "MultispeQ",
  "device_version": "2",
  "device_id": "32:21:3c:e9",
  "device_battery": 106,
  "device_firmware": 2.0056,
  "sample": [
    [
      {
        "time": 1545792855116,
        "protocol_id": 1,
        "recall": {
          "time": 1545792855116,
          "settings": {
            "time": 1545792855116,
            "device_id": "32:21:3c:e9",
            "device_version": 2,
            "compiled": [
              "Dec 26 2018",
              "11:43:27"
            ],
            "device_mod": 4294967295,
            "mag_x_scale": -9999,
            "mag_y_scale": -9999,
            "mag_z_scale": -9999,
            "light_slope_all": [
              0.499
            ],
            "light_slope_r": [
              -0.453
            ],
            "light_slope_g": [
              -0.566
            ],
            "light_slope_b": [
              0.365
            ],
            "light_yint": [
              1.635
            ],
            "thickness_a": 13924.67,
            "thickness_b": -1.516,
            "thickness_c": 41221.461,
            "mag_orientation": 255,
            "open_position": 39879,
            "closed_position": 41820,
            "spad_scale": 1,
            "blink_mode": 7,
            "thickness_min": 52102.199,
            "thickness_max": 36746.199,
            "shutdown_time (s)": 600,
            "usb_on": 0,
            "pix_pin": 14,
            "par_to_dac_slope1": [
              8834.318,
              203029.953,
              2504.805,
              16723.625,
              10000,
              10000,
              561875.125,
              10000,
              10000,
              10000
            ],
            "par_to_dac_slope2": [
              3848.96,
              61157.99,
              2616.52,
              7247.14,
              2000,
              2000,
              337086.56,
              2000,
              2000,
              2000
            ],
            "par_to_dac_slope3": [
              -139.2,
              -226.44,
              -59.06,
              -253.58,
              -200,
              -200,
              -136.84,
              -200,
              -200,
              -500
            ],
            "par_method": 1,
            "detector_offsets": [
              71,
              0,
              9,
              0
            ],
            "par_tweek": 1
          }
        },
        "data_raw": [

        ]
      }
    ]
  ],
  "app_os": "macOS 17.7.0",
  "app_name": "PhotosynQ",
  "app_version": "1.0.2",
  "app_device": "x64",
  "location": false,
  "time_offset": "Australia/Darwin"
}
Default avatar
Created by

Victor


Protocol connections:
0
Latest Update:
Jan 2019