diff --git a/app/components/d3-gauge.js b/app/components/d3-gauge.js index 28fb1f7..64a217f 100644 --- a/app/components/d3-gauge.js +++ b/app/components/d3-gauge.js @@ -66,7 +66,6 @@ export default Ember.Component.extend({ for (var index in this.redZones) { var zone = this.redZones[index]; - console.log(zone); this.drawBand(this.redZones[index].from, this.redZones[index].to, this.redColor); } diff --git a/app/controllers/lab-mashup.js b/app/controllers/lab-mashup.js index 2c7233a..fad2de5 100644 --- a/app/controllers/lab-mashup.js +++ b/app/controllers/lab-mashup.js @@ -5,38 +5,6 @@ export default Ember.Controller.extend({ redZone: [{from: 50, to: 60}], yellowZone: [{from: 40, to: 50}], - dataSetOne: [ - { - label: 'Total consumption [MW]', - data: [[900000.0, 4.61], [1800000.0, 4.49], [2700000.0, 4.51], [3600000.0, 4.45], [4500000.0, 4.90], [5400000.0, 4.76], [6300000.0, 4.77], [7200000.0, 4.70], [8100000.0, 4.73], [9000000.0, 4.80], [9900000.0, 4.89], [10800000.0, 4.81], [11700000.0, 4.65], [12600000.0, 4.59], [13500000.0, 4.65], [14400000.0, 4.82], [15300000.0, 4.62], [16200000.0, 4.73], [17100000.0, 4.62], [18000000.0, 4.65], [18900000.0, 4.77], [19800000.0, 4.79], [20700000.0, 5.57], [21600000.0, 6.14], [22500000.0, 8.33], [23400000.0, 9.56], [24300000.0, 10.94], [25200000.0, 11.03], [26100000.0, 12.34], [27000000.0, 13.36], [27900000.0, 14.13], [28800000.0, 15.00], [29700000.0, 15.61], [30600000.0, 16.70], [31500000.0, 17.21], [32400000.0, 18.31], [33300000.0, 17.85], [34200000.0, 18.04], [35100000.0, 17.72], [36000000.0, 18.02], [36900000.0, 17.64], [37800000.0, 18.26], [38700000.0, 18.30], [39600000.0, 18.72], [40500000.0, 18.60], [41400000.0, 18.54], [42300000.0, 18.31], [43200000.0, 16.91], [44100000.0, 13.61], [45000000.0, 12.47], [45900000.0, 15.83], [46800000.0, 15.73], [47700000.0, 16.38], [48600000.0, 16.19], [49500000.0, 17.06], [50400000.0, 16.71], [51300000.0, 15.89], [52200000.0, 15.99], [53100000.0, 15.50], [54000000.0, 15.58], [54900000.0, 15.66], [55800000.0, 15.50], [56700000.0, 15.63], [57600000.0, 15.67], [58500000.0, 15.79], [59400000.0, 15.39], [60300000.0, 14.85], [61200000.0, 13.97], [62100000.0, 13.31], [63000000.0, 12.83], [63900000.0, 12.53], [64800000.0, 11.78], [65700000.0, 11.56], [66600000.0, 11.67], [67500000.0, 10.97], [68400000.0, 10.20], [69300000.0, 9.59], [70200000.0, 8.94], [71100000.0, 8.97], [72000000.0, 9.86], [72900000.0, 10.25], [73800000.0, 9.54], [74700000.0, 10.04], [75600000.0, 9.98], [76500000.0, 9.44], [77400000.0, 8.91], [78300000.0, 8.39], [79200000.0, 7.00], [80100000.0, 5.07], [81000000.0, 4.80], [81900000.0, 4.67], [82800000.0, 4.19], [83700000.0, 4.16], [84600000.0, 4.25], [85500000.0, 4.40], [86400000.0, 4.38]], - color: "rgb(51, 153, 255)" - } - ], - dataSetTwo: [ - { - label: 'Total PV generation [MW]', - data: [[900000.0, 0.00], [1800000.0, 0.00], [2700000.0, 0.00], [3600000.0, 0.00], [4500000.0, 0.00], [5400000.0, 0.00], [6300000.0, 0.00], [7200000.0, 0.00], [8100000.0, 0.00], [9000000.0, 0.00], [9900000.0, 0.00], [10800000.0, 0.00], [11700000.0, 0.00], [12600000.0, 0.00], [13500000.0, 0.00], [14400000.0, 0.00], [15300000.0, 0.00], [16200000.0, 0.00], [17100000.0, 0.00], [18000000.0, 0.00], [18900000.0, 0.00], [19800000.0, 0.00], [20700000.0, 0.00], [21600000.0, 0.00], [22500000.0, 0.00], [23400000.0, 0.00], [24300000.0, 0.00], [25200000.0, 0.15], [26100000.0, 0.63], [27000000.0, 0.63], [27900000.0, 0.54], [28800000.0, 0.27], [29700000.0, 0.43], [30600000.0, 0.46], [31500000.0, 0.19], [32400000.0, 0.35], [33300000.0, 0.47], [34200000.0, 0.44], [35100000.0, 0.62], [36000000.0, 0.61], [36900000.0, 0.85], [37800000.0, 1.48], [38700000.0, 2.35], [39600000.0, 1.08], [40500000.0, 1.20], [41400000.0, 2.71], [42300000.0, 1.84], [43200000.0, 1.83], [44100000.0, 1.48], [45000000.0, 4.24], [45900000.0, 0.43], [46800000.0, 0.43], [47700000.0, 0.23], [48600000.0, 0.19], [49500000.0, 0.09], [50400000.0, 0.02], [51300000.0, 0.73], [52200000.0, 0.86], [53100000.0, 0.85], [54000000.0, 0.85], [54900000.0, 1.76], [55800000.0, 2.37], [56700000.0, 2.37], [57600000.0, 2.13], [58500000.0, 1.76], [59400000.0, 1.68], [60300000.0, 2.57], [61200000.0, 2.37], [62100000.0, 1.59], [63000000.0, 2.52], [63900000.0, 1.58], [64800000.0, 1.06], [65700000.0, 0.89], [66600000.0, 0.73], [67500000.0, 0.86], [68400000.0, 1.54], [69300000.0, 0.85], [70200000.0, 0.65], [71100000.0, 0.43], [72000000.0, 0.23], [72900000.0, 0.19], [73800000.0, 0.09], [74700000.0, 0.02], [75600000.0, 0.01], [76500000.0, 0.00], [77400000.0, 0.00], [78300000.0, 0.00], [79200000.0, 0.00], [80100000.0, 0.00], [81000000.0, 0.00], [81900000.0, 0.00], [82800000.0, 0.00], [83700000.0, 0.00], [84600000.0, 0.00], [85500000.0, 0.00], [86400000.0, 0.00]], - color: "rgb(255, 91, 51)" - } - ], - dataSet: [], - dataOptions: { - series: { - lines: { - show: true, - lineWidth: 2 - }, - shadowSize: 0 - }, - xaxis: { - mode: 'time', - timeformat: '%H:%M' - }, - yaxis: { - tickDecimals: 3 - } - }, - init: function() { this.set('dataSet', this.get('dataSetOne')); }, @@ -45,17 +13,6 @@ export default Ember.Controller.extend({ return this.model.findBy('id', 'S1_ElectricalGrid'); }.property('model.[]'), - S2Entity: function() { - return this.model.findBy('id', 'S2_ElectricalGrid'); - }.property('model.[]'), - - S1Freq575: function() { - var entity = this.model.findBy('id', 'S1_ElectricalGrid'); - if (entity) { - return entity.get('properties').findBy('name', 'Freq_575'); - } - }.property('model.[]'), - Voltage203937: function() { var entity = this.model.findBy('id', 'S1_ElectricalGrid'); if (entity) { @@ -65,12 +22,17 @@ export default Ember.Controller.extend({ } }.property('model.[]'), - S2Flow1551412_204871: function() { - var entity = this.model.findBy('id', 'S2_ElectricalGrid'); - if (entity) { - return entity.get('properties').findBy('name', 'Flow1551412_204871'); - } - }.property('model.[]'), + Freq575Value: function() { + var entity = this.model.findBy('id', 'S1_ElectricalGrid'); + if (entity) { + var attribute = entity.get('properties').findBy('name', 'Freq_575'); + var valuesLength = attribute.get('values').length; + var tuple = attribute.get('values')[valuesLength - 1]; + return tuple[1]; + } else { + return {}; + } + }.property('model.[]'), initState: function() { return this.get('state') === 1; diff --git a/app/routes/lab-mashup.js b/app/routes/lab-mashup.js index 13de805..8845ccb 100644 --- a/app/routes/lab-mashup.js +++ b/app/routes/lab-mashup.js @@ -6,12 +6,7 @@ export default Ember.Route.extend({ { id: 'S1_ElectricalGrid', isPattern: false, - type: 'ElectricalGridMonitoring' - }, - { - id: 'S2_ElectricalGrid', - isPattern: false, - type: 'ElectricalGridMonitoring' + type: '' } ]}); //return this.store.findAll('entity'); @@ -30,12 +25,7 @@ export default Ember.Route.extend({ { id: 'S1_ElectricalGrid', isPattern: false, - type: 'ElectricalGridMonitoring' - }, - { - id: 'S2_ElectricalGrid', - isPattern: false, - type: 'ElectricalGridMonitoring' + type: '' } ]}); //this.store.findAll('entity'); diff --git a/app/serializers/application.js b/app/serializers/application.js index b142874..7e18fae 100644 --- a/app/serializers/application.js +++ b/app/serializers/application.js @@ -78,30 +78,38 @@ export default DS.RESTSerializer.extend({ } if (item.contextElement.attributes) { - item.contextElement.attributes.forEach(function(attribute) { - if (attribute.type !== 'category') { - // find metadata - var timestamp = 0; - var source = ""; - var minValue; - var maxValue; + var timestamp = 0; - attribute.metadatas.forEach(function(metadata) { - if (metadata.name === 'timestamp') { - timestamp = Date.parse(metadata.value); - } else if (metadata.name === 'source') { - source = metadata.value; - } else if (metadata.name === 'min') { - minValue = metadata.value; - } else if (metadata.name === 'max') { - maxValue = metadata.value; - } - }); + item.contextElement.attributes.forEach(function(attribute) { + if (attribute.name === 'timestamp') { + timestamp = attribute.value; + } + }); + + item.contextElement.attributes.forEach(function(attribute) { + if (attribute.id !== 'timestamp') { + // find metadata + var source = ""; + var minValue; + var maxValue; + + if (attribute.metadatas) { + attribute.metadatas.forEach(function(metadata) { + if (metadata.name === 'timestamp') { + timestamp = Date.parse(metadata.value); + } else if (metadata.name === 'source') { + source = metadata.value; + } else if (metadata.name === 'min') { + minValue = metadata.value; + } else if (metadata.name === 'max') { + maxValue = metadata.value; + } + }); + } if (timestamp === 0) { timestamp = (new Date()).getTime(); } - // create property var property = { @@ -112,9 +120,9 @@ export default DS.RESTSerializer.extend({ type: attribute.type, timestamp: timestamp, visible: false, - source: source, - minValue: minValue, - maxValue: maxValue, + source: source, + minValue: minValue, + maxValue: maxValue, values: [] }, relationships: { diff --git a/app/templates/lab-mashup.hbs b/app/templates/lab-mashup.hbs index 26cb868..cfa6b08 100644 --- a/app/templates/lab-mashup.hbs +++ b/app/templates/lab-mashup.hbs @@ -33,7 +33,7 @@
- {{d3-gauge label="Frequency" value=23 maxValue=60 minorTicks=4 redZones=redZone yellowZones=yellowZone}} + {{d3-gauge label="Frequency" value=Freq575Value maxValue=60 minorTicks=4 redZones=redZone yellowZones=yellowZone}}