// // Copyright (C) 2007 - Cogent Real-Time Systems Inc. All rights reserved. // var DataHub_iframe; var DataHub_points = []; var DataHub_url; function DataHubStream (iframeid, sourceurl) { this.iframeid = iframeid; this.url = sourceurl; this.wasloaded = false; this.activity = false; this.request_children = false; this.parent_point = null; this.recursive = false; this.points = {}; this.qualities = []; this.qualities[0x00] = "Bad"; this.qualities[0x40] = "Uncertain"; this.qualities[0x04] = "Config error"; this.qualities[0x08] = "Not connected"; this.qualities[0x0c] = "Device failure"; this.qualities[0x10] = "Sensor failure"; this.qualities[0x14] = "Last known"; this.qualities[0x18] = "Comm failure"; this.qualities[0x1c] = "Out of service"; this.qualities[0x20] = "Waiting for data"; this.qualities[0x44] = "Last usable"; this.qualities[0x50] = "Sensor calibration"; this.qualities[0x54] = "EGU exceeded"; this.qualities[0x58] = "Sub normal"; this.qualities[0xc0] = "Good"; this.qualities[0xd8] = "Local override"; } DataHubStream.prototype.Attach = function () { this.iframe = document.getElementById(this.iframeid); } DataHubStream.prototype.GetUrl = function () { var str, i; if (this.parent_point) { str = this.url + "&name=" + this.parent_point + "&children=true"; if (this.recursive) str = str + "&recursive=true"; } else { str = this.url + "&name="; for (i in this.points) { str = str + this.points[i].name + "|"; } } return str; } DataHubStream.prototype.RegisterChildren = function (parentname, recursive) { this.parent_point = parentname; this.recursive = recursive; } DataHubStream.prototype.RegisterEvent = function (ptname, expression) { this.Register(ptname, expression); } DataHubStream.prototype.Register = function (ptname, expression) { var pt = this.points[ptname]; var idx, i; if (!pt) { pt = { name: ptname, quality: 0, timestamp: 0, previous: null, value: null, callbacks: [], ncallbacks: 0, maxcallbacks: 0 }; this.points[ptname] = pt; } if (pt.ncallbacks == pt.maxcallbacks) { idx = pt.maxcallbacks; pt.maxcallbacks++; } else { for (i=0; i= 10 || x < 0 ? "" : "0") + x; } // Prepend enough zeros to make a number 3 digits long function LZZ(x) { return x < 0 || x >= 100 ? "" + x : "0" + LZ(x); } Date.prototype.ISOlocaltimeStr = new Function(" /* Date.ISOlocaltimeStr hh:mm:ss */\n" + " with (this)\n return" + " LZ(getHours())+':'+LZ(getMinutes())+':'+LZ(getSeconds())") Date.prototype.ISOlocaldateStr = new Function(" /* Date.ISOlocaldateStr YYYY-MM-DD */\n" + " with (this)\n return " + "getFullYear()+'-'+LZ(getMonth()+1)+'-'+LZ(getDate())") Date.prototype.ISOlocalDTstr = new Function(" /* Date.ISOlocalDTstr YYYY-MM-DD hh:mm:ss */\n" + " with (this)\n return " + "ISOlocaldateStr()+' '+ISOlocaltimeStr()") // Override the default line plotter for Dojo graphs. We do not want // a little ball at the end of each line segment. if(typeof(dojo) != "undefined" && dojo.render.svg.capable){ dojo.require("dojo.svg"); // Mixin the SVG-specific plotter object. dojo.mixin(dojo.charting.Plotters, { Line: function( /* array */data, /* dojo.charting.PlotArea */plotarea, /* dojo.charting.Plot */plot, /* function? */applyTo ){ // summary // Plots the series as a line. // Bindings: x/y var area = plotarea.getArea(); var line = document.createElementNS(dojo.svg.xmlns.svg, "g"); if(data.length == 0){ return line; } var path = document.createElementNS(dojo.svg.xmlns.svg, "path"); line.appendChild(path); path.setAttribute("fill", "none"); path.setAttribute("stroke", data[0].series.color); path.setAttribute("stroke-width" , "2"); path.setAttribute("stroke-opacity", "0.85"); if(data[0].series.label != null){ path.setAttribute("title", data[0].series.label); } var cmd=[]; for(var i=0; i