Skip to content
Snippets Groups Projects
Commit f011b0ee authored by jkerdreu's avatar jkerdreu
Browse files

Switch to bulk refresh of attributes request, perhaps I should do the

same w/ the answer

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/fork@1804 b32b6428-25c9-4566-ad07-03861ab6144f
parent 9e43ecf0
Branches
No related tags found
No related merge requests found
......@@ -27,6 +27,13 @@ def query_attributes(sid,addr):
msg = { 'address': dev.address,'attributes':dev.attributes}
socket.emit('event_attributeChanges',msg,room=sid)
@socket.on('refresh_attributes')
def refresh_attributes(sid,addrs):
for addr in addrs:
dev = xaal_core.get_device(str(addr))
msg = { 'address': dev.address,'attributes':dev.attributes}
socket.emit('event_attributeChanges',msg,room=sid)
@socket.on('debug')
def debug(sid):
import pdb;pdb.set_trace()
......
......@@ -49,7 +49,7 @@ function EventBus () {
this.on('sio-connect',function() {
console.log('Event : connected');
this.connected = true;
this.query_attributes();
this.refresh_attributes();
});
this.on('sio-disconnect',function() {
......@@ -60,7 +60,7 @@ function EventBus () {
this.on('tags-mount',function() {
console.log('Event : mounted');
this.mounted = true;
this.query_attributes();
this.refresh_attributes();
});
this.on('visible',function() {
......@@ -69,9 +69,9 @@ function EventBus () {
this.query_attributes();
});
this.query_attributes = function() {
this.refresh_attributes = function() {
if ((this.connected == true) && (this.mounted==true)) {
sio_query_attributes();
sio_refresh_attributes();
msg_cnt = 0;
updateStatusCnt();
}
......@@ -118,16 +118,16 @@ sio.on('event_attributeChanges', function(data) {
//================ SocketIO emit ================================================
function sio_query_attributes() {
console.log('query_attributes');
function sio_refresh_attributes() {
console.log('refresh_attributes');
var addrs = [];
for (t in tags) {
var attrs = tags[t].root.attributes;
if (attrs.hasOwnProperty('xaal_addr')) {
addr = attrs.xaal_addr.value;
//console.log('connecting ' + addr);
sio_query_attribute(addr);
addrs.push(attrs.xaal_addr.value);
}
}
sio.emit('refresh_attributes',addrs);
}
function sio_send_request(addr,action,body) {
......@@ -135,7 +135,7 @@ function sio_send_request(addr,action,body) {
sio.emit('send_request',addr,action,body);
}
function sio_query_attribute(addr) {
function sio_query_attributes(addr) {
//console.log('query '+ addr);
sio.emit('query_attributes',addr);
}
......@@ -155,5 +155,3 @@ if (detectMobile() == true) {
}
_('#messages').innerText = 'no messages';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment