Ignore:
Timestamp:
01/06/17 11:58:00 (8 years ago)
Author:
tbretz
Message:
Improved the partially wrong error messages, made them more consistent, added SUSPEND/RESUME
File:
1 edited

Legend:

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

    r18430 r18714  
    2020    if (isNaN(utc.valueOf()))
    2121        throw new Error('"'+obj.date+'" not a valid Date... try something like "2013-01-08 23:05 UTC".');
     22
    2223    ret.start = utc;
    2324    ret.id    = obj.id;
     
    6869        case 'DATA':
    6970            if (i!=obj.measurements.length-1)
    70                 throw new Error("DATA [n="+i+", "+utc.toUTCString()+"] must be the last in the list of measurements [cnt="+obj.measurements.length+"]");
     71                throw new Error("Measurement DATA [n="+i+", "+utc.toUTCString()+"] must be the last in the list of measurements [cnt="+obj.measurements.length+"]");
    7172            if (ret[i].source == undefined)
    72                 throw new Error("Observation must have either 'source' or 'task' " +
    73                                 "if 'task' == 'data' it must have also have 'source' ");
    74             if (ret[i].lidclosed == true)
    75                 throw new Error("Observation must not have 'lidclosed'== true " +
    76                                 "if 'task' == 'data' ");
     73                throw new Error("Measurement DATA must have a source defined");
     74            // This is obsolete. We cannot check everything which is not evaluated anyways
     75            //if (ret[i].lidclosed == true)
     76            //    throw new Error("Observation must not have 'lidclosed'==true " +
     77            //                    "if 'task'=='data'");
     78            break;
     79
     80        case 'SUSPEND':
     81        case 'RESUME':
     82            if (obj.measurements.length!=1)
     83                throw new Error("Measurement "+ret[i].task+" [n="+i+", "+utc.toUTCString()+"] must be the only measurements [cnt="+obj.measurements.length+"] in an observation");
    7784            break;
    7885
    7986        case 'STARTUP':
    80             if (ret[i].source != undefined)
    81                 console.out("warning. Observation with task='startup' also has source defined");
    82             break;
    83 
    8487        case 'SHUTDOWN':
    8588            if (ret[i].source != undefined)
    86                 console.out("warning. Observation with task='shutdown' also has source defined");
     89                console.out("WARNING - Measurement "+ret[i].task+" has a source defined");
    8790            break;
    8891
    8992        case 'RATESCAN':
    9093            if (ret[i].source == undefined && (isNaN(ret[i].ra) || isNaN(ret[i].dec)))
    91                 throw new Error("Observation must have either 'source' or 'ra' & 'dec' " +
    92                                 "if 'task' == 'ratescan'");
    93             if (ret[i].lidclosed == true)
    94                 throw new Error("Observation must not have 'lidclosed'== true " +
    95                                 "if 'task' == 'ratescan' ");
     94                throw new Error("Measurement RATESCAN must have either a source or 'ra' & 'dec' defined");
     95            // This is obsolete. We cannot check everything which is not evaluated anyways
     96            //if (ret[i].lidclosed == true)
     97            //    throw new Error("Observation RATESCAN must not have 'lidclosed'==true");
    9698            break;
    9799
    98100        case 'RATESCAN2':
    99101            if ((ret[i].lidclosed != true) && ret[i].source == undefined && (isNaN(ret[i].ra) || isNaN(ret[i].dec)))
    100                 throw new Error("Observation must have either 'source' or 'ra' & 'dec' " +
    101                                 "if 'task' == 'ratescan2' and lidclosed==false or not given");
     102                throw new Error("Measurement RATESCAN2 ('lidclosed'==false or undefined) must have either a source or 'ra' & 'dec' defined");
    102103            if (ret[i].lidclosed == true && (isNaN(ret[i].az) || isNaN(ret[i].az)))
    103                 throw new Error("Observation must have 'zd' & 'az' " +
    104                                 "if 'task' == 'ratescan2' and option 'lidclosed'=='true'");
     104                throw new Error("Measurement RATESCAN2 ('lidclosed'==true) must have 'zd' & 'az' defined");
    105105            break;
    106106
    107107        case 'CUSTOM':
    108 
    109108            if (isNaN(ret[i].az) || isNaN(ret[i].az) || isNaN(ret[i].time) || isNaN(ret[i].threshold))
    110                 throw new Error("Observation must have 'zd' & 'az', 'time' and 'threshold' " +
    111                                 "if 'task' == 'custom' ");
     109                throw new Error("Measurement CUSTOM must have 'zd' & 'az', 'time' and 'threshold' defined.");
    112110            break;
    113111
     
    120118
    121119        default:
    122             throw new Error("The observation type "+ret[i].task+" is unknown.");
     120            throw new Error("The measurement type "+ret[i].task+" is unknown.");
    123121        }
    124122    }
Note: See TracChangeset for help on using the changeset viewer.