Changeset 18713 for trunk/FACT++
- Timestamp:
- 01/06/17 11:56:10 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/getSchedule.js
r18173 r18713 3 3 function getSchedule() 4 4 { 5 // List of all available measurement types (see also Observation_class.js)6 var measurementType = [ "STARTUP", "IDLE", "DRSCALIB", "SINGLEPE", "DATA", "RATESCAN", "SHUTDOWN", "OVTEST", "RATESCAN2", "SLEEP", "CUSTOM" ];7 8 5 // Get current time 9 6 var start = new Date();//new Date("2013-04-07 19:00:00 UTC"); … … 19 16 var db = new Database($['schedule-database']); 20 17 21 // get all sources from database22 var sources = db.query("SELECT * from Source");23 24 18 // Get the current schedule 25 var rows = db.query("SELECT * FROM Schedule WHERE fStart>'"+start.toISOString()+"' ORDER BY fStart, fMeasurementID"); 19 var rows = db.query("SELECT * FROM Schedule "+ 20 "LEFT JOIN MeasurementType USING (fMeasurementTypeKey) "+ 21 "LEFT JOIN Source USING (fSourceKey) "+ 22 "WHERE fStart>'"+start.toISOString()+"' "+ 23 "ORDER BY fStart, fMeasurementID"); 26 24 27 25 // Close db connection … … 36 34 for (var i=0; i<rows.length; i++) 37 35 { 36 var id = rows[i]['fScheduleID']; 38 37 var sub = rows[i]['fMeasurementID']; 39 38 if (sub==0) … … 42 41 var m = { } 43 42 44 var task = rows[i]['fMeasurementTypeKey']; 45 m.task = measurementType[task]; 43 m.task = rows[i]['fMeasurementTypeName']; 44 if (!m.task) 45 throw new Error("No valid measurement type for id=("+id+":"+sub+")"); 46 46 47 var src = rows[i]['fSourceKey']; 48 if (src) 49 { 50 // Convert SourceKey to SourceName 51 var arr = sources.filter(function(e) { return e['fSourceKEY']==src; }); 52 if (arr.length==0) 53 throw new Error("SourceKey "+src+" unknown."); 47 // For simplicity, measurements suspend and resume must be unique in an observation 48 if ((m.task=="suspend" || m.task=="resume") && sub>0) 49 throw new Error("Measurement "+m.task+" not the only one in the observation (id="+id+")"); 54 50 55 m.source = arr[0]['fSourceName']; 56 } 51 m.source = rows[i]['fSourceName']; 57 52 58 53 var data = rows[i]['fData']; … … 67 62 schedule[entry] = { }; 68 63 69 schedule[entry].id = rows[i]['fScheduleID'];64 schedule[entry].id = id; 70 65 schedule[entry].date = new Date(rows[i]['fStart']+" UTC"); 71 66
Note:
See TracChangeset
for help on using the changeset viewer.