2015-10-13 14:12:34 +02:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
2015-10-22 14:17:39 -04:00
|
|
|
freq575GreenZones: [{from: 49.5, to: 50.5}],
|
2015-10-22 15:44:25 -04:00
|
|
|
freq575YellowZones: [{from: 49, to: 49.5}, {from: 50.5, to: 51}],
|
2015-10-22 16:18:42 -04:00
|
|
|
freq575AlarmZones: [{from: 49, to: 49.5}, {from: 50.5, to: 51}],
|
2015-10-22 07:28:31 -04:00
|
|
|
|
2015-10-23 07:20:10 -04:00
|
|
|
freq575Value: 0,
|
|
|
|
|
2015-10-23 08:52:29 -04:00
|
|
|
_waitForStateUpdate: false,
|
|
|
|
|
2015-10-21 00:22:54 +02:00
|
|
|
init: function() {
|
2015-10-22 15:44:25 -04:00
|
|
|
this.set('state', 1);
|
2015-10-22 14:17:39 -04:00
|
|
|
|
2015-10-22 15:44:25 -04:00
|
|
|
Ember.run.later(this, this._updateState, 100);
|
2015-10-21 00:22:54 +02:00
|
|
|
},
|
|
|
|
|
2015-10-13 14:12:34 +02:00
|
|
|
S1Entity: function() {
|
2015-10-15 17:09:02 +02:00
|
|
|
return this.model.findBy('id', 'S1_ElectricalGrid');
|
2015-10-13 14:12:34 +02:00
|
|
|
}.property('model.[]'),
|
|
|
|
|
2015-10-22 15:44:25 -04:00
|
|
|
Voltage203937: function() {
|
|
|
|
var entity = this.model.findBy('id', 'S1_ElectricalGrid');
|
2015-10-23 07:20:10 -04:00
|
|
|
|
2015-10-22 15:44:25 -04:00
|
|
|
if (entity) {
|
|
|
|
return [
|
|
|
|
{
|
2015-10-23 07:20:10 -04:00
|
|
|
label: 'RMS voltage [pu]',
|
2015-10-22 15:44:25 -04:00
|
|
|
data: entity.get('properties').findBy('name', 'Voltage203937').get('values'),
|
|
|
|
color: "rgb(51, 153, 255)"
|
|
|
|
}
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}.property('model.[]'),
|
2015-10-21 00:22:54 +02:00
|
|
|
|
2015-10-23 07:20:10 -04:00
|
|
|
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'));
|
|
|
|
}
|
2015-10-22 11:00:09 -04:00
|
|
|
}
|
2015-10-23 07:20:10 -04:00
|
|
|
}.on('init'),
|
2015-10-21 00:22:54 +02:00
|
|
|
|
2015-10-22 15:44:25 -04:00
|
|
|
LoadGenProfiles: function() {
|
|
|
|
var entity = this.model.findBy('id', 'S1_ElectricalGrid');
|
|
|
|
if (entity) {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: 'Total consumption [MW]',
|
|
|
|
data: entity.get('properties').findBy('name', 'LoadProfile').get('values'),
|
|
|
|
color: "rgb(51, 153, 255)"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Total PV generation [MW]',
|
|
|
|
data: entity.get('properties').findBy('name', 'GenProfile').get('values'),
|
|
|
|
color: "rgb(255, 91, 51)"
|
|
|
|
}
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}.property('model.[]'),
|
|
|
|
|
2015-10-22 07:28:31 -04:00
|
|
|
initState: function() {
|
|
|
|
return this.get('state') === 1;
|
|
|
|
}.property('state'),
|
|
|
|
|
|
|
|
eventState: function() {
|
|
|
|
return this.get('state') === 2;
|
|
|
|
}.property('state'),
|
|
|
|
|
2015-10-22 15:44:25 -04:00
|
|
|
_updateState: function() {
|
2015-10-22 14:17:39 -04:00
|
|
|
var control = this.store.peekRecord('data-file-control', 'DataFileControl');
|
|
|
|
var updated = false;
|
|
|
|
|
2015-10-22 15:44:25 -04:00
|
|
|
if (control.get('Filename') === '/share/data/m1_S1_ElectricalGrid_data.txt') {
|
2015-10-22 14:17:39 -04:00
|
|
|
if (this.get('state') !== 1) {
|
2015-10-22 15:44:25 -04:00
|
|
|
this.set('state', 1);
|
2015-10-22 14:17:39 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (this.get('state') !== 2) {
|
2015-10-22 15:44:25 -04:00
|
|
|
this.set('state', 2);
|
2015-10-22 14:17:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (control.get('Status') === 'EOF') {
|
|
|
|
if (this.get('state') === 1) {
|
|
|
|
control.set('ForceReload', true);
|
|
|
|
} else {
|
2015-10-22 15:44:25 -04:00
|
|
|
control.set('Filename', '/share/data/m1_S1_ElectricalGrid_data.txt');
|
2015-10-22 14:17:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (updated) {
|
2015-10-22 15:44:25 -04:00
|
|
|
control.save();
|
2015-10-22 14:17:39 -04:00
|
|
|
}
|
2015-10-22 15:44:25 -04:00
|
|
|
|
|
|
|
Ember.run.later(this, this._updateState, 100);
|
2015-10-22 14:17:39 -04:00
|
|
|
},
|
|
|
|
|
2015-10-22 15:44:25 -04:00
|
|
|
_updateDataFileControl: function(state) {
|
2015-10-22 14:17:39 -04:00
|
|
|
var control = this.store.peekRecord('data-file-control', 'DataFileControl');
|
|
|
|
|
2015-10-22 15:44:25 -04:00
|
|
|
if (state === 1) {
|
|
|
|
control.set('Filename', '/share/data/m1_S1_ElectricalGrid_data.txt');
|
2015-10-22 14:17:39 -04:00
|
|
|
} else {
|
2015-10-22 15:44:25 -04:00
|
|
|
control.set('Filename', '/share/data/m2_S1_ElectricalGrid_data.txt');
|
2015-10-22 14:17:39 -04:00
|
|
|
}
|
|
|
|
|
2015-10-22 15:44:25 -04:00
|
|
|
console.log("changed data control");
|
2015-10-22 14:17:39 -04:00
|
|
|
control.set('ForceReload', true);
|
|
|
|
control.save();
|
2015-10-22 15:44:25 -04:00
|
|
|
},
|
2015-10-22 14:17:39 -04:00
|
|
|
|
2015-10-21 00:22:54 +02:00
|
|
|
actions: {
|
|
|
|
resetData: function() {
|
2015-10-22 15:44:25 -04:00
|
|
|
this._updateDataFileControl(1);
|
2015-10-21 00:22:54 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
eventData: function() {
|
2015-10-22 15:44:25 -04:00
|
|
|
this._updateDataFileControl(2);
|
2015-10-21 00:22:54 +02:00
|
|
|
}
|
|
|
|
}
|
2015-10-13 14:12:34 +02:00
|
|
|
});
|