diff --git a/app/adapters/application.js b/app/adapters/application.js index 815c08e..e13d4e5 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -56,7 +56,6 @@ export default DS.RESTAdapter.extend({ var serializer = store.serializerFor(type.modelName); serializer.serializeIntoHash(requestBody, type, snapshot); - console.log(requestBody); var url = this.host + '/' + this.namespace + '/updateContext'; return this.ajax(url, 'POST', { data: requestBody }); diff --git a/app/components/d3-alarm.js b/app/components/d3-alarm.js index 13f9560..93ce18b 100644 --- a/app/components/d3-alarm.js +++ b/app/components/d3-alarm.js @@ -30,16 +30,19 @@ export default Ember.Component.extend({ .style("stroke", "#000") .style("stroke-width", "0.5px"); - this._redraw(this.value); + this._redraw(); }, - _redraw: function(value) { + _redraw: function() { var litAlarm = false; var cx = this.size / 2; var radius = this.size / 2 * 0.97; for (var zone in this.alarmZones) { - if (this.alarmZones[zone].from >= value && this.alarmZones[zone].to <= value) { + var from = this.alarmZones[zone].from; + var to = this.alarmZones[zone].to; + + if (this.value >= from && this.value <= to) { litAlarm = true; } } @@ -49,7 +52,7 @@ export default Ember.Component.extend({ .attr("cx", cx) .attr("cy", cx) .attr("r", radius * 0.8) - .style("fill", "#C33") + .style("fill", "#F00") .style("stroke", "#000") .style("stroke-width", "0.5px"); } else { @@ -61,5 +64,7 @@ export default Ember.Component.extend({ .style("stroke", "#000") .style("stroke-width", "0.5px"); } + + // reschedule }.observes('value') }); diff --git a/app/components/d3-gauge.js b/app/components/d3-gauge.js index c28190b..541454f 100644 --- a/app/components/d3-gauge.js +++ b/app/components/d3-gauge.js @@ -168,18 +168,20 @@ export default Ember.Component.extend({ _redraw: function(value, transitionDuration) { var pointerContainer = this.svgBody.select(".pointerContainer"); - pointerContainer.selectAll("text").text(Math.floor(value * 100) / 100); + pointerContainer.selectAll("text").text(Math.floor(this.value * 100) / 100); var pointer = pointerContainer.selectAll("path"); var _this = this; + transitionDuration = 0; pointer.transition() .duration(transitionDuration) .attrTween("transform", function() { - var pointerValue = value; - if (value > _this.maxValue) { + var pointerValue = _this.value; + + if (pointerValue > _this.maxValue) { pointerValue = _this.maxValue + 0.02 * (_this.maxValue - _this.minValue); - } else if (value < _this.minValue) { + } else if (pointerValue < _this.minValue) { pointerValue = _this.minValue - 0.02 * (_this.maxValue - _this.minValue); } diff --git a/app/controllers/lab-mashup.js b/app/controllers/lab-mashup.js index 6a92a5c..7125d7f 100644 --- a/app/controllers/lab-mashup.js +++ b/app/controllers/lab-mashup.js @@ -5,6 +5,8 @@ export default Ember.Controller.extend({ freq575YellowZones: [{from: 49, to: 49.5}, {from: 50.5, to: 51}], freq575AlarmZones: [{from: 49, to: 49.5}, {from: 50.5, to: 51}], + freq575Value: 0, + init: function() { this.set('state', 1); @@ -17,10 +19,11 @@ export default Ember.Controller.extend({ Voltage203937: function() { var entity = this.model.findBy('id', 'S1_ElectricalGrid'); + if (entity) { return [ { - label: 'Voltage203937', + label: 'RMS voltage [pu]', data: entity.get('properties').findBy('name', 'Voltage203937').get('values'), color: "rgb(51, 153, 255)" } @@ -30,17 +33,18 @@ export default Ember.Controller.extend({ } }.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 {}; + Freq575Observer: function() { + Ember.run.later(this, this.Freq575Observer, 100); + + if (this.model) { + var entity = this.model.findBy('id', 'S1_ElectricalGrid'); + + if (entity) { + var attribute = entity.get('properties').findBy('name', 'Freq_575'); + this.set('freq575Value', attribute.get('currentValue')); + } } - }.property('model.[]'), + }.on('init'), LoadGenProfiles: function() { var entity = this.model.findBy('id', 'S1_ElectricalGrid'); @@ -95,7 +99,6 @@ export default Ember.Controller.extend({ } if (updated) { - console.log("Update data control"); control.save(); } diff --git a/app/models/property.js b/app/models/property.js index e2a0222..03dbd1a 100644 --- a/app/models/property.js +++ b/app/models/property.js @@ -9,6 +9,7 @@ export default DS.Model.extend({ source: DS.attr('string'), minValue: DS.attr('number'), maxValue: DS.attr('number'), + currentValue: DS.attr('number'), entity: DS.belongsTo('entity'), category: DS.belongsTo('category') }); diff --git a/app/serializers/application.js b/app/serializers/application.js index 5137095..a9f3851 100644 --- a/app/serializers/application.js +++ b/app/serializers/application.js @@ -80,11 +80,6 @@ export default DS.RESTSerializer.extend({ } }, - modelNameFromPayloadKey: function(payloadKey) { - console.log(payloadKey); - return this._super(payloadKey); - }, - _normalizePayload: function(payload, handleItem) { var propertyIndex = 0; @@ -188,9 +183,11 @@ export default DS.RESTSerializer.extend({ value[0] = +value[0] * 1000; property.attributes.values.push(value); + property.attributes.currentValue = value[1]; }); } else { property.attributes.values.push([(new Date()).getTime(), attribute.value]); + property.attributes.currentValue = attribute.value; } } @@ -237,6 +234,7 @@ export default DS.RESTSerializer.extend({ }); record.set('timestamp', item.attributes.timestamp); + record.set('currentValue', item.attributes.currentValue); } } else { // add new item diff --git a/app/templates/lab-mashup.hbs b/app/templates/lab-mashup.hbs index 87af0c8..62b520b 100644 --- a/app/templates/lab-mashup.hbs +++ b/app/templates/lab-mashup.hbs @@ -48,8 +48,8 @@ Frequency measuerement
at STURA substation - {{d3-alarm value=Freq575Value alarmZones=freq575AlarmZones}} - {{d3-gauge label="Freq" value=Freq575Value minValue=49 maxValue=51 minorTicks=4 size=180 greenZones=freq575GreenZones yellowZones=freq575YellowZones}} + {{d3-alarm value=freq575Value alarmZones=freq575AlarmZones}} + {{d3-gauge label="Freq" value=freq575Value minValue=49 maxValue=51 minorTicks=4 size=180 greenZones=freq575GreenZones yellowZones=freq575YellowZones}}