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

Add time scaled data

Data is send in arrays with timestamp for each value. The X-Axis
on the chart now displays the real time of the data.
This commit is contained in:
Markus Grigull 2015-10-12 17:36:34 +02:00
parent f382dc9e8b
commit b7c8a47611
6 changed files with 37 additions and 14 deletions

View file

@ -13,8 +13,10 @@ export default DS.RESTAdapter.extend({
entities: [
{
type: 'ElectricalGridMonitoring',
isPattern: true,
id: 'S?_ElectricalGrid'
/*isPattern: true,
id: 'S?_ElectricalGrid'*/
isPattern: false,
id: 'S3_ElectricalGrid'
}
]
};
@ -41,6 +43,6 @@ export default DS.RESTAdapter.extend({
},
updateRecord: function(store, type, snapshot) {
}
});

View file

@ -44,10 +44,24 @@ export default Ember.Component.extend({
},
});*/
var firstTimestamp = this.data[0][0];
var lastTimestamp = this.data[this.data.length - 1][0];
var diff = lastTimestamp - firstTimestamp;
var diffValue = this.xaxisLength * 100;
if (diff > diffValue) {
firstTimestamp = lastTimestamp - diffValue;
} else {
lastTimestamp = +firstTimestamp + +diffValue;
}
$.plot('#' + element.id, [this.data], {
xaxis: {
mode: 'time',
timeformat: '%H:%M:%S'
timeformat: '%M:%S',
min: firstTimestamp,
max: lastTimestamp
}
});

View file

@ -2,10 +2,9 @@ import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
value: DS.attr('number'),
type: DS.attr('string'),
values: DS.attr(),
timestamp: DS.attr('date'),
history: DS.attr(),
visible: DS.attr('boolean', { defaultValue: false }),
entity: DS.belongsTo('entity'),
category: DS.belongsTo('category')

View file

@ -80,7 +80,7 @@ export default DS.RESTSerializer.extend({
if (item.contextElement.attributes) {
item.contextElement.attributes.forEach(function(attribute) {
if (attribute.type !== 'category') {
// find timestamp
// find timestamp data
var timestamp = 0;
attribute.metadatas.forEach(function(metadata) {
@ -96,10 +96,9 @@ export default DS.RESTSerializer.extend({
attributes: {
name: attribute.name,
type: attribute.type,
value: attribute.value,
timestamp: timestamp,
date: timestamp,
visible: false,
history: [[timestamp, attribute.value]]
values: []
},
relationships: {
entity: {
@ -108,6 +107,13 @@ export default DS.RESTSerializer.extend({
}
}
// add values
if (attribute.value) {
attribute.value.forEach(function (value) {
property.attributes.values.push(value);
});
}
entity.relationships.properties.data.push({ type: 'property', id: property.id });
handleItem(property);
@ -145,8 +151,10 @@ export default DS.RESTSerializer.extend({
var record = this.store.peekRecord('property', item.id);
if (record) {
if (record.timestamp !== item.attributes.timestamp) {
record.get('history').push([record.get('timestamp'), record.get('value')]);
record.set('value', item.attributes.value);
item.attributes.values.forEach(function (value) {
record.get('values').push(value);
});
record.set('timestamp', item.attributes.timestamp);
}
} else {

View file

@ -1 +1 @@
{{line-chart data=model.history xaxisLength=600}}
{{line-chart data=model.values xaxisLength=600}}

View file

@ -19,7 +19,7 @@ module.exports = function(defaults) {
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
app.import('bower_components/flot/jquery.flot.time.js')
app.import('bower_components/flot/jquery.flot.time.js');
return app.toTree();
};