1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-23 00:00:02 +01:00
VILLASweb/app/models/simulation-data.js
Markus Grigull ed6ea99d14 Add time length option to plot widget
Increase simulation-data storage to 1200 entries
2017-02-01 13:33:55 +01:00

45 lines
1.4 KiB
JavaScript

/**
* File: simulation-data.js
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
* Date: 20.07.2016
* Copyright: 2016, Institute for Automation of Complex Power Systems, EONERC
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
* Unauthorized copying of this file, via any medium is strictly prohibited.
**********************************************************************************/
import Ember from 'ember';
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
// import { belongsTo, hasMany } from 'ember-data/relationships';
export default Model.extend({
simulator: Ember.computed.alias('id'),
sequence: attr('number'),
timestamp: attr('number'),
values: attr('array'),
flotValues: Ember.computed('_flotValues', function() {
return this._flotValues;
}),
_flotValues: [],
_updateHistories: Ember.observer('values', function() {
// update flot values
let values = this.get('values');
// add empty arrays for each value
while (this._flotValues.length < values.length) {
this._flotValues.push([]);
}
for (var i = 0; i < values.length; i++) {
this._flotValues[i].push([this.get('timestamp'), values[i]]);
// discard old values
while (this._flotValues[i].length > 1200) {
this._flotValues[i].shift();
}
}
})
});