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:
parent
f382dc9e8b
commit
b7c8a47611
6 changed files with 37 additions and 14 deletions
|
@ -13,8 +13,10 @@ export default DS.RESTAdapter.extend({
|
||||||
entities: [
|
entities: [
|
||||||
{
|
{
|
||||||
type: 'ElectricalGridMonitoring',
|
type: 'ElectricalGridMonitoring',
|
||||||
isPattern: true,
|
/*isPattern: true,
|
||||||
id: 'S?_ElectricalGrid'
|
id: 'S?_ElectricalGrid'*/
|
||||||
|
isPattern: false,
|
||||||
|
id: 'S3_ElectricalGrid'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -41,6 +43,6 @@ export default DS.RESTAdapter.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
updateRecord: function(store, type, snapshot) {
|
updateRecord: function(store, type, snapshot) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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], {
|
$.plot('#' + element.id, [this.data], {
|
||||||
xaxis: {
|
xaxis: {
|
||||||
mode: 'time',
|
mode: 'time',
|
||||||
timeformat: '%H:%M:%S'
|
timeformat: '%M:%S',
|
||||||
|
min: firstTimestamp,
|
||||||
|
max: lastTimestamp
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,9 @@ import DS from 'ember-data';
|
||||||
|
|
||||||
export default DS.Model.extend({
|
export default DS.Model.extend({
|
||||||
name: DS.attr('string'),
|
name: DS.attr('string'),
|
||||||
value: DS.attr('number'),
|
|
||||||
type: DS.attr('string'),
|
type: DS.attr('string'),
|
||||||
|
values: DS.attr(),
|
||||||
timestamp: DS.attr('date'),
|
timestamp: DS.attr('date'),
|
||||||
history: DS.attr(),
|
|
||||||
visible: DS.attr('boolean', { defaultValue: false }),
|
visible: DS.attr('boolean', { defaultValue: false }),
|
||||||
entity: DS.belongsTo('entity'),
|
entity: DS.belongsTo('entity'),
|
||||||
category: DS.belongsTo('category')
|
category: DS.belongsTo('category')
|
||||||
|
|
|
@ -80,7 +80,7 @@ export default DS.RESTSerializer.extend({
|
||||||
if (item.contextElement.attributes) {
|
if (item.contextElement.attributes) {
|
||||||
item.contextElement.attributes.forEach(function(attribute) {
|
item.contextElement.attributes.forEach(function(attribute) {
|
||||||
if (attribute.type !== 'category') {
|
if (attribute.type !== 'category') {
|
||||||
// find timestamp
|
// find timestamp data
|
||||||
var timestamp = 0;
|
var timestamp = 0;
|
||||||
|
|
||||||
attribute.metadatas.forEach(function(metadata) {
|
attribute.metadatas.forEach(function(metadata) {
|
||||||
|
@ -96,10 +96,9 @@ export default DS.RESTSerializer.extend({
|
||||||
attributes: {
|
attributes: {
|
||||||
name: attribute.name,
|
name: attribute.name,
|
||||||
type: attribute.type,
|
type: attribute.type,
|
||||||
value: attribute.value,
|
date: timestamp,
|
||||||
timestamp: timestamp,
|
|
||||||
visible: false,
|
visible: false,
|
||||||
history: [[timestamp, attribute.value]]
|
values: []
|
||||||
},
|
},
|
||||||
relationships: {
|
relationships: {
|
||||||
entity: {
|
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 });
|
entity.relationships.properties.data.push({ type: 'property', id: property.id });
|
||||||
|
|
||||||
handleItem(property);
|
handleItem(property);
|
||||||
|
@ -145,8 +151,10 @@ export default DS.RESTSerializer.extend({
|
||||||
var record = this.store.peekRecord('property', item.id);
|
var record = this.store.peekRecord('property', item.id);
|
||||||
if (record) {
|
if (record) {
|
||||||
if (record.timestamp !== item.attributes.timestamp) {
|
if (record.timestamp !== item.attributes.timestamp) {
|
||||||
record.get('history').push([record.get('timestamp'), record.get('value')]);
|
item.attributes.values.forEach(function (value) {
|
||||||
record.set('value', item.attributes.value);
|
record.get('values').push(value);
|
||||||
|
});
|
||||||
|
|
||||||
record.set('timestamp', item.attributes.timestamp);
|
record.set('timestamp', item.attributes.timestamp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{{line-chart data=model.history xaxisLength=600}}
|
{{line-chart data=model.values xaxisLength=600}}
|
||||||
|
|
|
@ -19,7 +19,7 @@ module.exports = function(defaults) {
|
||||||
// please specify an object with the list of modules as keys
|
// please specify an object with the list of modules as keys
|
||||||
// along with the exports of each module as its value.
|
// 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();
|
return app.toTree();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue