Changeset 15082 for trunk/FACT++/scripts


Ignore:
Timestamp:
03/15/13 13:46:40 (12 years ago)
Author:
tbretz
Message:
Some minor logic fixed around the bias crate calibration.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/scripts/Startup.js

    r14996 r15082  
    4444
    4545console.out("");
     46dim.alarm();
    4647
    4748var loop;
     
    175176    dim.send("PWR_CONTROL/TOGGLE_DRIVE");
    176177}
    177     include("scripts/handleDriveArmed.js");
    178 
    179     checkSend(["DRIVE_CONTROL"]);
    180 
    181     loop = new Handler("ArmDrive");
    182     loop.add(handleDriveArmed);
    183     loop.run();
     178
     179include("scripts/handleDriveArmed.js");
     180
     181checkSend(["DRIVE_CONTROL"]);
     182
     183loop = new Handler("ArmDrive");
     184loop.add(handleDriveArmed);
     185loop.run();
    184186
    185187
     
    195197//  2) The feedback is stopped
    196198//  3) The voltage is off
    197 
    198 // Check age of calibration
    199 var service_calibration = new Subscription("FEEDBACK/CALIBRATION");
    200 
    201 var data_calibration = service_calibration.get(-5000);
    202 //if (!data_calibration)
    203 //    throw new Error("Could not connect to FEEDBACK/CALIBRATION");
    204 
    205 function makeCurrentCalibration( reason_string  )
    206 {
    207      console.out( reason_string );
    208  
     199function makeCurrentCalibration()
     200{
    209201     dim.send("BIAS_CONTROL/SET_GLOBAL_DAC", 1);
    210202     dim.wait("BIAS_CONTROL", "VoltageOn", 3000);
    211  
     203
    212204     var now = new Date();
    213205     dim.send("FEEDBACK/CALIBRATE_CURRENTS");
     
    227219}
    228220
    229 if (!data_calibration)
    230 {
    231    // FEEDBACK might just be freshly started and
    232    // will not yet serve this service.
    233    var reason_msg = "No current calibration avaliable. New calibration needed.";
    234    makeCurrentCalibration( reason_msg );
    235 }
    236 else
    237 {
    238     var age = data_calibration.time;
    239     var now = new Date();
    240 
    241     //service_calibration.close();
    242 
    243     var diff = (now-age)/3600000;
    244 
    245     if ((diff>8 && now.getHours()>16)/* || empty*/)
    246     {
    247         var reason_msg = "Last BIAS crate calibration taken at "+age.toUTCString()+": New calibration needed.";
    248         makeCurrentCalibration( reason_msg );
    249     }
    250 }
    251 
    252 
    253 
     221// Check age of calibration
     222var service_calibration = new Subscription("FEEDBACK/CALIBRATION");
     223
     224var data_calibration = service_calibration.get(3000, false);
     225
     226var age = data_calibration.time;
     227var now = new Date();
     228
     229var diff = (now-age)/3600000;
     230
     231// !data_calibration.data: FEEDBACK might just be freshly
     232// started and will not yet serve this service.
     233if (data_calibration.data==null || (diff>8 && now.getHours()>16))
     234{
     235    if (data_calibration.data==null)
     236        console.out("No BIAS crate calibration avaliable: New calibration needed.");
     237    else
     238        console.out("Last BIAS crate calibration taken at "+age.toUTCString()+": New calibration needed.");
     239
     240    makeCurrentCalibration();
     241}
     242
     243service_calibration.close();
    254244
    255245// ================================================================
Note: See TracChangeset for help on using the changeset viewer.