otsdaq_utilities  v2_05_02_indev
comms.js
1 var Comms = function(table){
2  this.table = table;
3 };
4 
5 
6 Comms.prototype.getConnections = function(selectors){
7  var self = this,
8  connections = [],
9  connection;
10 
11  connection = Tabulator.prototype.comms.lookupTable(selectors);
12 
13  connection.forEach(function(con){
14  if(self.table !== con){
15  connections.push(con);
16  }
17  });
18 
19  return connections;
20 };
21 
22 Comms.prototype.send = function(selectors, module, action, data){
23  var self = this,
24  connections = this.getConnections(selectors);
25 
26  connections.forEach(function(connection){
27  connection.tableComms(self.table.element, module, action, data);
28  });
29 
30  if(!connections.length && selectors){
31  console.warn("Table Connection Error - No tables matching selector found", selectors);
32  }
33 };
34 
35 
36 Comms.prototype.receive = function(table, module, action, data){
37  if(this.table.modExists(module)){
38  return this.table.modules[module].commsReceived(table, action, data);
39  }else{
40  console.warn("Inter-table Comms Error - no such module:", module);
41  }
42 };
43 
44 
45 Tabulator.prototype.registerModule("comms", Comms);