var dataPnlBg = "rgba(30, 30, 30, 0.65)", dataPnlBgShadow = "rgba(10, 10, 10, 0.85)", dataPnlFg = "rgb(255, 255, 255)", util = new UtilClass, DataPanel = function () { }; DataPanel.prototype.Create = function (a, b) { this.canD = a, this.ctxD = b, this.flashX = 45, this.strikeRate = 0, this.closeRate = 0, this.closeAlarmState = 0, this.trend = 0, this.trendState = 0, this.cgX1 = 15, this.cgY1 = 126, this.cgX2 = this.canD.width - this.cgX1 - 10, this.cgY2 = this.cgY1 + 50, this.cgY3 = 70, this.cgY4 = this.cgY3 + 120 }, DataPanel.prototype.Init = function () { var a = this.canD.width, b = this.canD.height; this.ctxD.clearRect(0, 0, a, b), this.ctxD.fillStyle = pnlBg, this.ctxD.strokeStyle = pnlBg, this.ctxD.save(), util.roundRect(this.ctxD, 0, 0, this.canD.width, this.canD.height, 4, !0, !1), this.ctxD.restore(), this.renderPanel() }, DataPanel.prototype.SetFlash = function (a) { var b = this; null == a && (a = 0), this.ctxD.save(), this.ctxD.fillStyle = pnlBg, this.ctxD.clearRect(16, 9, 22, 27), this.ctxD.fillRect(16, 9, 22, 27), this.ctxD.shadowColor = "#000", this.ctxD.shadowBlur = 0, this.ctxD.shadowOffsetX = 1, this.ctxD.shadowOffsetY = 1, this.ctxD.drawImage(flashInd[a], 16, 9), this.ctxD.restore(), 1 == a && setTimeout(function () { b.SetFlash() }, 1e3) }, DataPanel.prototype.UpdateMainGraph = function (a) { null == a && (a = GraphTimeSpan.H1); var b = bufPointer - a; 0 > b && (b += 1440); for (var c = 0, d = 0; a >= d; d++) srBufTotal[b] > c && (c = srBufTotal[b]), b++ >= 1440 && (b = 0); c += 5, c = 10 * Math.ceil(c / 10), 20 > c && (c = 20); var e = c / 4, f = []; a == GraphTimeSpan.H0 ? f = new Array("0", " ", "15", " ", "30").reverse() : a == GraphTimeSpan.H1 ? f = new Array("0", "15", "30", "45", "60").reverse() : a == GraphTimeSpan.H2 ? f = new Array("0", "30", "60", "90", "120").reverse() : a == GraphTimeSpan.H4 ? f = new Array("0", "1", "2", "3", "4").reverse() : a == GraphTimeSpan.H8 ? f = new Array("0", "2", "4", "6", "8").reverse() : a == GraphTimeSpan.H12 && (f = new Array("0", "3", "6", "9", "12").reverse()); var g = a < GraphTimeSpan.H4 ? "min" : "hrs", h = this.cgX2 - this.cgX1, i = h / 4, k = this.cgY4 - this.cgY3, l = k / 4; this.ctxD.save(), this.ctxD.fillStyle = pnlBg, this.ctxD.clearRect(this.cgX1 - 12, this.cgY3 - 20, h + 35, k + (appSettings.ShowTypes ? 120 : 44)), this.ctxD.fillRect(this.cgX1 - 12, this.cgY3 - 20, h + 35, k + (appSettings.ShowTypes ? 120 : 44)), this.ctxD.setLineDash([1, 3]), this.ctxD.strokeStyle = "rgb(170, 170, 170)", this.ctxD.lineWidth = 1, this.ctxD.beginPath(), this.ctxD.translate(.5, .5); for (var d = 1; 5 > d; d++) this.ctxD.moveTo(this.cgX1, this.cgY4 - d * l), this.ctxD.lineTo(this.cgX2, this.cgY4 - d * l); for (var d = 0; 4 > d; d++) this.ctxD.moveTo(this.cgX1 + d * i, this.cgY4), this.ctxD.lineTo(this.cgX1 + d * i, this.cgY3); this.ctxD.stroke(), this.ctxD.restore(); var n = h / a, o = k / c; this.ctxD.save(), this.ctxD.fillStyle = 0, this.ctxD.lineWidth = 1, this.ctxD.beginPath(), this.ctxD.translate(.5, .5); var p, q, r = utl.timestampMin() - a; 0 > r && (r += 1440); var b = r; if (appSettings.ShowTypes) { this.ctxD.strokeStyle = StrikeCol.ICF; for (var d = 0; a >= d; d++) p = this.cgX1 + d * n, q = this.cgY4 - srBufICF[b] * o, 0 == d ? this.ctxD.moveTo(p, q) : this.ctxD.lineTo(p, q), b++ >= 1440 && (b = 0); this.ctxD.stroke(), this.ctxD.beginPath(), b = r, this.ctxD.strokeStyle = StrikeCol.CGP; for (var d = 0; a >= d; d++) p = this.cgX1 + d * n, q = this.cgY4 - srBufCGP[b] * o, 0 == d ? this.ctxD.moveTo(p, q) : this.ctxD.lineTo(p, q), b++ >= 1440 && (b = 0); this.ctxD.stroke(), this.ctxD.beginPath(), b = r, this.ctxD.strokeStyle = StrikeCol.CGN; for (var d = 0; a >= d; d++) p = this.cgX1 + d * n, q = this.cgY4 - srBufCGN[b] * o, 0 == d ? this.ctxD.moveTo(p, q) : this.ctxD.lineTo(p, q), b++ >= 1440 && (b = 0); this.ctxD.stroke() } this.ctxD.beginPath(), b = r; for (var d = 0; a >= d; d++) p = this.cgX1 + d * n, q = this.cgY4 - srBufTotal[b] * o, this.ctxD.strokeStyle = StrikeCol.SUM, 0 == d ? this.ctxD.moveTo(p, q) : this.ctxD.lineTo(p, q), b++ >= 1440 && (b = 0); this.ctxD.stroke(), this.ctxD.restore(), this.ctxD.save(), this.ctxD.fillStyle = 0, this.ctxD.strokeStyle = "rgb(170, 170, 170)", this.ctxD.lineWidth = 1, this.ctxD.beginPath(), this.ctxD.translate(.5, .5), this.ctxD.moveTo(this.cgX2, this.cgY3), this.ctxD.lineTo(this.cgX2, this.cgY4), this.ctxD.lineTo(this.cgX1, this.cgY4), this.ctxD.stroke(), this.ctxD.restore(), this.ctxD.save(), this.ctxD.strokeStyle = 0; var s = 0; appSettings.ShowTypes && (this.ctxD.fillStyle = StrikeCol.CGP, this.ctxD.fillRect(this.cgX1, this.cgY3 - 12, 5, 5), s += 34, this.ctxD.fillStyle = StrikeCol.CGN, this.ctxD.fillRect(this.cgX1 + s, this.cgY3 - 12, 5, 5), s += 34, this.ctxD.fillStyle = StrikeCol.ICF, this.ctxD.fillRect(this.cgX1 + s, this.cgY3 - 12, 5, 5), s += 34), this.ctxD.fillStyle = StrikeCol.SUM, this.ctxD.fillRect(this.cgX1 + s, this.cgY3 - 12, 5, 5), this.ctxD.restore(), this.ctxD.save(), this.ctxD.shadowColor = "#000", this.ctxD.shadowBlur = 0, this.ctxD.shadowOffsetX = 1, this.ctxD.shadowOffsetY = 1, this.ctxD.fillStyle = "White", this.ctxD.font = "bold 9px Segoe UI"; for (var d = 0; 5 > d; d++) this.ctxD.fillText(f[d], this.cgX1 + d * i - 3, this.cgY4 + 10); for (var d = 1; 5 > d; d++) this.ctxD.fillText(Math.round(e * d).toFixed(0).toString(), this.cgX2 + 5, this.cgY4 - d * l + 4); this.ctxD.fillStyle = "LightGray", this.ctxD.fillText("x-" + g + " y-rate", this.cgX2 - 60, this.cgY3 - 6), s = 8, appSettings.ShowTypes && (this.ctxD.fillText("+CG", this.cgX1 + s, this.cgY3 - 6), s += 34, this.ctxD.fillText("-CG", this.cgX1 + s, this.cgY3 - 6), s += 34, this.ctxD.fillText("CLD", this.cgX1 + s, this.cgY3 - 6), s += 34), this.ctxD.fillText(appSettings.ShowTypes ? "SUM" : "ALL STRIKES", this.cgX1 + s, this.cgY3 - 6); var t = this.cgY3 + k + 92; if (appSettings.ShowTypes) { this.ctxD.fillText("Type", this.cgX1, t - 48), this.ctxD.fillText("Distribution " + f[0] + " " + g, this.cgX1 + 35, t - 48), this.ctxD.fillText("Count", this.cgX1 + 165, t - 48), this.ctxD.fillStyle = "White", this.ctxD.fillText("CG(+)", this.cgX1, t - 32), this.ctxD.fillText("CG(-)", this.cgX1, t - 16), this.ctxD.fillText("CLD", this.cgX1, t), this.ctxD.fillText(pctCGP.toString() + "%", this.cgX1 + 120, t - 32), this.ctxD.fillText(pctCGN.toString() + "%", this.cgX1 + 120, t - 16), this.ctxD.fillText(pctICF.toString() + "%", this.cgX1 + 120, t), this.ctxD.fillText(totalCountCGP.toString(), this.cgX1 + 165, t - 32), this.ctxD.fillText(totalCountCGN.toString(), this.cgX1 + 165, t - 16), this.ctxD.fillText(totalCountICF.toString(), this.cgX1 + 165, t), this.ctxD.restore(), this.ctxD.save(); var u = this.cgX1 + 35, v = 76, w = 8, x = .01 * pctCGP * v; this.ctxD.translate(.5, .5), this.ctxD.fillStyle = StrikeCol.CGP, this.ctxD.fillRect(u, t - 39, x, w), x = .01 * pctCGN * v, this.ctxD.fillStyle = StrikeCol.CGN, this.ctxD.fillRect(u, t - 23, x, w), x = .01 * pctICF * v, this.ctxD.fillStyle = StrikeCol.ICF, this.ctxD.fillRect(u, t - 7, x, w), this.ctxD.restore(), this.ctxD.save(), this.ctxD.translate(.5, .5), this.ctxD.strokeStyle = "Gray", this.ctxD.strokeRect(u, t - 39, v, w), this.ctxD.strokeRect(u, t - 23, v, w), this.ctxD.strokeRect(u, t - 7, v, w) } this.ctxD.restore(), this.ctxD.save(), this.ctxD.shadowColor = "#000", this.ctxD.shadowBlur = 0, this.ctxD.shadowOffsetX = 1, this.ctxD.shadowOffsetY = 1, this.ctxD.strokeStyle = "DarkGray", this.ctxD.beginPath(), this.ctxD.translate(.5, .5), this.ctxD.moveTo(5, t - 70), this.ctxD.lineTo(this.canD.width - 5, t - 70), this.ctxD.stroke(), this.ctxD.restore(), this.UpdateStatusPanel() }, DataPanel.prototype.UpdateStatusPanel = function () { var a = this.cgX1 - 12, b = this.canD.height - 27, c = this.canD.width - 25, d = 25; this.ctxD.save(), this.ctxD.fillStyle = pnlBg, this.ctxD.clearRect(a + 20, b - 5, c, d + 5), this.ctxD.fillRect(a + 20, b - 5, c, d + 5), this.ctxD.shadowColor = "#000", this.ctxD.shadowBlur = 0, this.ctxD.shadowOffsetX = 1, this.ctxD.shadowOffsetY = 1, this.ctxD.fillStyle = "LightGray", this.ctxD.fillText("Lat", this.cgX1 + 40, b + 7), this.ctxD.fillText("Lon", this.cgX1 + 40, b + 21), this.ctxD.fillText("Detector", this.cgX1 + 108, b + 7), this.ctxD.fillText("NexStorm", this.cgX1 + 108, b + 21), this.ctxD.fillStyle = "White", this.ctxD.fillText("Data", this.cgX1 + 10, b + 7), this.ctxD.fillText("Error", this.cgX1 + 10, b + 21), this.ctxD.fillText(SensorData.Lat.toFixed(3) + "\xb0", this.cgX1 + 60, b + 7), this.ctxD.fillText(SensorData.Lon.toFixed(3) + "\xb0", this.cgX1 + 60, b + 21), this.ctxD.fillText(SensorData.DecType, this.cgX1 + 156, b + 7), this.ctxD.fillText(SensorData.NSVersion, this.cgX1 + 156, b + 21), this.ctxD.restore(), 0 == errorStatus && this.SetErrorStatus(errorStatus), 0 == networkStatus && this.SetNetworkStatus(networkStatus) }, DataPanel.prototype.SetNetworkStatus = function (a) { var b = this, c = this.canD.height - 27; null == a && (a = 0), this.ctxD.save(), this.ctxD.translate(.5, .5), this.ctxD.fillStyle = pnlBg, this.ctxD.clearRect(this.cgX1, c, 6, 6), this.ctxD.fillRect(this.cgX1, c, 6, 6), this.ctxD.shadowColor = "#000", this.ctxD.shadowBlur = 0, this.ctxD.shadowOffsetX = 1, this.ctxD.shadowOffsetY = 1, this.ctxD.strokeStyle = "gray", this.ctxD.strokeRect(this.cgX1, c, 6, 6), this.ctxD.restore(), this.ctxD.save(), this.ctxD.translate(.5, .5), 0 != a && (this.ctxD.fillStyle = StrikeCol.IND, this.ctxD.fillRect(this.cgX1 + 2, c + 2, 3, 3)), this.ctxD.restore(), a > 0 && setTimeout(function () { b.SetNetworkStatus(0) }, 1e3) }, DataPanel.prototype.SetErrorStatus = function (a) { var b = this, c = this.canD.height - 13; null == a && (a = 0), this.ctxD.save(), this.ctxD.translate(.5, .5), this.ctxD.fillStyle = pnlBg, this.ctxD.clearRect(this.cgX1, c, 6, 6), this.ctxD.fillRect(this.cgX1, c, 6, 6), this.ctxD.shadowColor = "#000", this.ctxD.shadowBlur = 0, this.ctxD.shadowOffsetX = 1, this.ctxD.shadowOffsetY = 1, this.ctxD.strokeStyle = "gray", this.ctxD.strokeRect(this.cgX1, c, 6, 6), this.ctxD.restore(), this.ctxD.save(), this.ctxD.translate(.5, .5), 0 != a && (this.ctxD.fillStyle = StrikeCol.IND_ERR, this.ctxD.fillRect(this.cgX1 + 2, c + 2, 3, 3)), this.ctxD.restore(), a > 0 && setTimeout(function () { b.SetErrorStatus(0) }, 2500) }, DataPanel.prototype.UpdateCounters = function () { this.strikeRate = strikeRateCnt.currentCount(); var a = strikeRateCnt.computeTrend2(); this.trend = a.slope, isNaN(this.trend) && (this.trend = 0), this.ctxD.save(), this.ctxD.fillStyle = pnlBg; var b = this.flashX + 61; this.ctxD.clearRect(b, 3, 60, 30), this.ctxD.fillRect(b, 3, 60, 30), this.ctxD.clearRect(this.flashX + 130, 3, 70, 30), this.ctxD.fillRect(this.flashX + 130, 3, 70, 30), this.ctxD.shadowColor = "#000", this.ctxD.shadowBlur = 0, this.ctxD.shadowOffsetX = 1, this.ctxD.shadowOffsetY = 1, this.ctxD.fillStyle = "White", this.ctxD.font = "bold 26px Segoe UI", this.ctxD.fillText(this.strikeRate.toString(), b, 30), this.ctxD.fillStyle = "LightGray", this.ctxD.font = "bold 9px Segoe UI", this.ctxD.fillText("TREND", this.flashX + 130, 19); var e = "\xb1"; this.trend > 0 ? e = "+" : this.trend < 0 && (e = ""), this.ctxD.fillText(e + parseFloat(this.trend).toFixed(2).toString(), this.flashX + 130, 30), this.trendState = 0, this.trend > .1 ? this.trendState = 1 : this.trend < -.1 && (this.trendState = 2), this.ctxD.drawImage(trendInd[this.trendState], this.flashX + 165, 9), this.ctxD.restore(), this.UpdateMainGraph(selectedTimeSpanMain) }, DataPanel.prototype.renderPanel = function () { this.ctxD.save(), this.ctxD.shadowColor = "#000", this.ctxD.shadowBlur = 0, this.ctxD.shadowOffsetX = 1, this.ctxD.shadowOffsetY = 1, this.ctxD.fillStyle = "White", this.ctxD.font = "bold 26px Segoe UI", this.ctxD.fillText(this.strikeRate.toString(), this.flashX + 61, 30), this.ctxD.fillStyle = "LightGray", this.ctxD.font = "bold 9px Segoe UI", this.ctxD.fillText("DISCHARGES", this.flashX, 19), this.ctxD.fillText("PER MINUTE", this.flashX, 30), this.ctxD.fillText("TREND", this.flashX + 130, 19), this.ctxD.fillStyle = "White"; var c = "\xb1"; this.trend > 0 ? c = "+" : this.trend < 0 && (c = ""), this.ctxD.fillText(c + parseFloat(this.trend).toFixed(2).toString(), this.flashX + 130, 30), this.ctxD.drawImage(flashInd[0], 16, 9), this.ctxD.drawImage(trendInd[this.trendState], this.flashX + 165, 9), this.ctxD.strokeStyle = "DarkGray", this.ctxD.beginPath(), this.ctxD.translate(.5, .5), this.ctxD.moveTo(5, 45), this.ctxD.lineTo(this.canD.width - 5, 45), this.ctxD.moveTo(5, this.canD.height - 34), this.ctxD.lineTo(this.canD.width - 5, this.canD.height - 34), this.ctxD.stroke(), this.ctxD.restore(), this.UpdateMainGraph(selectedTimeSpanMain) };