1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Add bar-chart

This commit is contained in:
Markus Grigull 2015-10-26 14:56:29 -04:00
parent e6c842e983
commit c4dc0c6e76
4 changed files with 64 additions and 36 deletions

View file

@ -23,7 +23,7 @@ export default Ember.Component.extend({
if (element && element.id) {
if (this.data) {
// chart options
var options = { xaxis: {} };
var options = { xaxis: { show: false }, yaxis: {} };
if (this.get('minValue') !== '') {
options.yaxis.min = this.get('minValue');

View file

@ -9,7 +9,6 @@ export default Ember.Component.extend({
minValue: '',
maxValue: '',
label: '',
updateTime: 100,
height: '100%',
useLabel: true,
@ -19,10 +18,6 @@ export default Ember.Component.extend({
didInsertElement: function() {
this._drawPlot();
Ember.run.later(this, function() {
this._drawPlot();
}, this.updateTime);
},
style: function() {
@ -32,7 +27,7 @@ export default Ember.Component.extend({
_drawPlot: function() {
var element = this.get('element');
if (element && element.id) {
if (this.data) {
if (this.data && this.data.length > 0) {
var values = this.data[0].data;
if (values.length > 0) {

View file

@ -8,8 +8,9 @@ export default Ember.Controller.extend({
freq575Value: 0,
voltage203937: [],
loadGenProfiles: [],
totalPValue: [],
_waitForStateUpdate: false,
_freezeState: false,
initState: function() {
return this.get('state') === 1;
@ -19,38 +20,48 @@ export default Ember.Controller.extend({
return this.get('state') === 2;
}.property('state'),
initButtonState: function() {
return this.get('state') === 1 || this.get('state') === 0;
}.property('state'),
eventButtonState: function() {
return this.get('state') === 2 || this.get('state') === 0;
}.property('state'),
_updateController: function() {
// update attribute values
this._updateAttributes();
// get new data file control state from store
var control = this.store.peekRecord('data-file-control', 'DataFileControl');
var updated = false;
if (this._freezeState === false) {
var control = this.store.peekRecord('data-file-control', 'DataFileControl');
if (control.get('Filename') === '/share/data/m1_S1_ElectricalGrid_data.txt') {
if (this.get('state') !== 1) {
this.set('state', 1);
}
} else {
if (this.get('state') !== 2) {
this.set('state', 2);
}
}
if (control.get('Status') === 'EOF') {
if (this.get('state') === 1) {
control.set('ForceReload', true);
if (control.get('Filename') === '/share/data/m1_S1_ElectricalGrid_data.txt') {
// state 1
if (this.get('state') !== 1) {
this.set('state', 1);
}
} else {
control.set('Filename', '/share/data/m1_S1_ElectricalGrid_data.txt');
// state 2
if (this.get('state') !== 2) {
this.set('state', 2);
}
}
updated = true;
if (control.get('Status') === 'EOF' && control.get('ForceReload') === false) {
if (this.get('state') === 1) {
control.set('ForceReload', true);
} else {
control.set('Filename', '/share/data/m1_S1_ElectricalGrid_data.txt');
this.set('state', 1);
}
control.save();
Ember.debug('update control: ' + control.get('Filename') + ', ' + control.get('ForceReload'));
}
}
if (updated) {
control.save();
}
Ember.run.later(this, this._updateController, 100);
}.on('init'),
@ -69,14 +80,16 @@ export default Ember.Controller.extend({
var properties = entity.get('properties');
if (!properties) {
Ember.debug('controller properties not found');
return false;
}
// update attributes
var attr_freq575 = properties.findBy('name', 'Freq_575');
if (attr_freq575) {
Ember.debug('controller freq575 not found');
if (attr_freq575) {
this.set('freq575Value', attr_freq575.get('currentValue'));
} else {
Ember.debug('controller freq575 not found');
}
var attr_voltage203937 = properties.findBy('name', 'Voltage203937');
@ -96,7 +109,7 @@ export default Ember.Controller.extend({
var attr_genProfile = properties.findBy('name', 'GenProfile');
if (attr_loadProfile && attr_genProfile) {
this.set('loadGenProfile', [
this.set('loadGenProfiles', [
{
label: 'Total consumption [MW]',
data: attr_loadProfile.get('values'),
@ -112,6 +125,19 @@ export default Ember.Controller.extend({
Ember.debug('controller loadGenProfile not found');
}
var attr_totalP = properties.findBy('name', 'TotalP_DS');
if (attr_totalP) {
this.set('totalPValue', [
{
bars: { show: true },
data: [[0, attr_totalP.get('currentValue')]],
label: 'Total DS absorb [MW]'
}
]);
} else {
Ember.debug('controller totalP not found');
}
return true;
},
@ -120,10 +146,17 @@ export default Ember.Controller.extend({
if (state === 1) {
control.set('Filename', '/share/data/m1_S1_ElectricalGrid_data.txt');
this.set('state', 1);
} else {
control.set('Filename', '/share/data/m2_S1_ElectricalGrid_data.txt');
this.set('state', 2);
}
this._freezeState = true;
Ember.run.later(this, function() {
this._freezeState = false;
}, 1000);
console.log("changed data control");
control.set('ForceReload', true);
control.save();

View file

@ -76,10 +76,10 @@
</td>
<td style="width: 50%" colspan="2">
<div style="position: relative; top: 15%; left: 30%">
<button {{action 'resetData'}} disabled={{initState}} id="init-button">NORMAL<br />sunny + low demand</button>
<button {{action 'resetData'}} disabled={{initButtonState}} id="init-button">NORMAL<br />sunny + low demand</button>
</div>
<div style="position: relative; top: 30%; left: 30%">
<button {{action 'eventData'}} disabled={{eventState}} id="event-button">ABNORMAL<br />cloudy + high demand</button>
<button {{action 'eventData'}} disabled={{eventButtonState}} id="event-button">ABNORMAL<br />cloudy + high demand</button>
</div>
<div style="position: relative; top: 48%; left: 76%">
<a class="link-button" href="/technical/" target="_blank">Technical</a>
@ -113,14 +113,14 @@
</tr>
<tr>
<td colspan="2">
{{bar-chart width='200px' height='250px'}}
<p style="padding-top: 25px;">
<p style="padding-top: 25px; padding-bottom: 30px">
Turin - Piedmont - Italy<br />
<ul>
<li>Medium Voltage lines derived from Stura HV/MV</li>
<li>Total length of lines: 38,54 km</li>
</ul>
</p>
{{bar-chart data=totalPValue width='200px' height='250px' maxValue=25}}
</td>
</tr>
</table>