2015-10-13 14:12:34 +02:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
2015-10-22 07:28:31 -04:00
|
|
|
state: 1,
|
2015-10-22 14:17:39 -04:00
|
|
|
freq575GreenZones: [{from: 49.5, to: 50.5}],
|
|
|
|
freq575YellowZones: [{from: 47.5, to: 49.5}, {from: 50.5, to: 52.5}],
|
|
|
|
freq575RedZones: [{from: 45.0, to: 47.5}, {from: 52.5, to: 55}],
|
2015-10-22 07:28:31 -04:00
|
|
|
|
2015-10-21 00:22:54 +02:00
|
|
|
init: function() {
|
|
|
|
this.set('dataSet', this.get('dataSetOne'));
|
2015-10-22 14:17:39 -04:00
|
|
|
|
|
|
|
this._updateButtons();
|
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 07:28:31 -04:00
|
|
|
Voltage203937: function() {
|
|
|
|
var entity = this.model.findBy('id', 'S1_ElectricalGrid');
|
2015-10-16 00:36:02 +02:00
|
|
|
if (entity) {
|
|
|
|
return entity.get('properties').findBy('name', 'Voltage203937');
|
2015-10-22 07:28:31 -04:00
|
|
|
} else {
|
|
|
|
return {};
|
2015-10-16 00:36:02 +02:00
|
|
|
}
|
|
|
|
}.property('model.[]'),
|
2015-10-21 00:22:54 +02:00
|
|
|
|
2015-10-22 11:00:09 -04:00
|
|
|
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.[]'),
|
2015-10-21 00:22:54 +02:00
|
|
|
|
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 14:17:39 -04:00
|
|
|
_updateButtons: function() {
|
|
|
|
var control = this.store.peekRecord('data-file-control', 'DataFileControl');
|
|
|
|
var updated = false;
|
|
|
|
|
|
|
|
if (control.get('Filename') === 'm1_S1_ElectricalGrid_data.txt') {
|
|
|
|
if (this.get('state') !== 1) {
|
|
|
|
his.set('state', 1);
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (this.get('state') !== 2) {
|
|
|
|
this.set('state', 2);
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (control.get('Status') === 'EOF') {
|
|
|
|
if (this.get('state') === 1) {
|
|
|
|
control.set('ForceReload', true);
|
|
|
|
} else {
|
|
|
|
control.set('Filename', 'm1_S1_ElectricalGrid_data.txt');
|
|
|
|
}
|
|
|
|
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (updated) {
|
|
|
|
control.save();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateDataFileControl: function() {
|
|
|
|
var control = this.store.peekRecord('data-file-control', 'DataFileControl');
|
|
|
|
|
|
|
|
if (this.get('state') === 1) {
|
|
|
|
control.set('Filename', 'm1_S1_ElectricalGrid_data.txt');
|
|
|
|
} else {
|
|
|
|
control.set('Filename', 'm2_S1_ElectricalGrid_data.txt');
|
|
|
|
}
|
|
|
|
|
|
|
|
control.set('ForceReload', true);
|
|
|
|
control.save();
|
|
|
|
}.observes('state'),
|
|
|
|
|
2015-10-21 00:22:54 +02:00
|
|
|
actions: {
|
|
|
|
resetData: function() {
|
2015-10-22 07:28:31 -04:00
|
|
|
this.set('state', 1);
|
2015-10-21 00:22:54 +02:00
|
|
|
this.set('dataSet', this.get('dataSetOne'));
|
|
|
|
},
|
|
|
|
|
|
|
|
eventData: function() {
|
2015-10-22 07:28:31 -04:00
|
|
|
this.set('state', 2);
|
2015-10-21 00:22:54 +02:00
|
|
|
this.set('dataSet', this.get('dataSetTwo'));
|
|
|
|
}
|
|
|
|
}
|
2015-10-13 14:12:34 +02:00
|
|
|
});
|