/* keep a cache of loaded CSV files */
CSV_Cache = new Array();
+
/*
- load a CSV file, returing column names and data
+ load a CSV file, returing column names and data via a callback
*/
function load_CSV(d, filename, callback) {
/* maybe its in the global cache? */
if (CSV_Cache[filename] !== undefined) {
+ if (CSV_Cache[filename].pending) {
+ /* it might be pending */
+ var q = CSV_Cache[filename].queue.length;
+ CSV_Cache[filename].queue[q] = {filename:filename, d:d, callback:callback};
+ return;
+ }
d.filename = CSV_Cache[filename].filename;
d.labels = CSV_Cache[filename].labels;
d.data = CSV_Cache[filename].data;
+ writeDebug("cache hit: " + filename);
callback(d);
return;
}
+ CSV_Cache[filename] = { pending: true, queue: new Array()};
+
/*
async callback when the CSV is loaded
*/
}
/* save into the global cache */
- CSV_Cache[caller.filename] = { filename: caller.filename, labels:labels, data:data };
+ CSV_Cache[caller.filename].filename = filename;
+ CSV_Cache[caller.filename].labels = labels;
+ CSV_Cache[caller.filename].data = data;
+ for (var q=0; q<CSV_Cache[caller.filename].queue.length; q++) {
+ CSV_Cache[caller.filename].queue[q].d.data = data;
+ CSV_Cache[caller.filename].queue[q].d.labels = labels;
+ CSV_Cache[caller.filename].queue[q].callback(CSV_Cache[caller.filename].queue[q].d);
+ }
+ CSV_Cache[caller.filename].pending = false;
+ CSV_Cache[caller.filename].queue = null;
+
caller.ret.filename = caller.filename;
caller.ret.labels = labels;
caller.ret.data = data;
"E-Total",
{ includeZero: false });
+ heading(3, "Fan voltage for each inverter (V)");
+
+ graph_csv_files("Fan Voltage",
+ todays_csv_files(),
+ "U-Fan",
+ { includeZero: true,
+ avoidMinZero: true,
+ valueRange: [0, 12] });
+
}
function set_date() {