- Copyright:
 - Kiwigrid GmbH 2014-2015
 
- Source:
 
Classes
Methods
- <inner> create(eventBus) → {DeviceSetInstance}
 - <inner> filter(filter) → {DeviceSetInstance}
 - <inner> get(set, index) → {DeviceInstance}
 - <inner> getAll(set) → {Array}
 - <inner> indexOf(set, device) → {number}
 - <inner> length(set) → {number}
 - <inner> live() → {promise}
 - <inner> paginate(pagination) → {DeviceSetInstance}
 - <inner> project(projection) → {DeviceSetInstance}
 - <inner> query() → {promise}
 - <inner> sort(sorting) → {DeviceSetInstance}
 - <inner> sync(set, event, eventBus) → {void}
 
- 
    
<inner> create(eventBus) → {DeviceSetInstance}
 - 
    
    
    
Creates a DeviceSetInstance with given EventBus instance.
Parameters:
Name Type Description eventBusEventBus EventBus instance to use for communication - Source:
 
Returns:
DeviceSetInstance DeviceSetInstance createdExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { var deviceSet = ketaDeviceSet.create(eventBus); }); - 
    
<inner> filter(filter) → {DeviceSetInstance}
 - 
    
    
    
Adds a filter before DeviceSet query is sent to EventBus.
Parameters:
Name Type Description filterObject filter to use - Source:
 
Returns:
DeviceSetInstance DeviceSetInstance to chainExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus) .filter({ guid: 'guid' }) .query() .then(function(reply) { // success handler // ... }, function(reply) { // error handler // ... }); }); - 
    
<inner> get(set, index) → {DeviceInstance}
 - 
    
    
    
Returns device in given DeviceSet by specified index.
Parameters:
Name Type Description setDeviceSetInstance DeviceSetInstance to search in indexnumber Index of device to return - Source:
 
Returns:
DeviceInstance DeviceInstance retrieved from setExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus).query() .then(function(reply) { // device equals first item after the call var device = ketaDeviceSet.get(reply, 0); }); }); - 
    
<inner> getAll(set) → {Array}
 - 
    
    
    
Returns all devices in given DeviceSet.
Parameters:
Name Type Description setDeviceSetInstance DeviceSetInstance to search in - Source:
 
Returns:
Array All DeviceInstances retrieved from setExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus).query() .then(function(reply) { var devices = ketaDeviceSet.getAll(reply); }); }); - 
    
<inner> indexOf(set, device) → {number}
 - 
    
    
    
Returns index of given Device in DeviceSet by comparing GUIDs.
Parameters:
Name Type Description setDeviceSetInstance DeviceSetInstance to search in deviceDeviceInstance DeviceInstance to search for - Source:
 
Returns:
number indexExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus).query() .then(function(reply) { // index equals 0 after the call var index = ketaDeviceSet.indexOf(reply, reply.result.items[0]); }); }); - 
    
<inner> length(set) → {number}
 - 
    
    
    
Returns number of devices in given DeviceSet.
Parameters:
Name Type Description setDeviceSetInstance DeviceSetInstance to search in - Source:
 
Returns:
number number of devicesExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus).query() .then(function(reply) { // length equals number of devices in DeviceSet var length = ketaDeviceSet.length(reply); }); }); - 
    
<inner> live() → {promise}
 - 
    
    
    
Adds live update capabilities by registering a DeviceSetListener.
- Source:
 
Returns:
promise DeviceSetInstance to chainExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus) .live() .query() .then(function(reply) { // success handler // ... }, function(reply) { // error handler // ... }); - 
    
<inner> paginate(pagination) → {DeviceSetInstance}
 - 
    
    
    
Adds a pagination before DeviceSet query is sent to EventBus.
Parameters:
Name Type Description paginationObject pagination to use - Source:
 
Returns:
DeviceSetInstance DeviceSetInstance to chainExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus) .paginate({ offset: 0, limit: 50 }) .query() .then(function(reply) { // success handler // ... }, function(reply) { // error handler // ... }); }); - 
    
<inner> project(projection) → {DeviceSetInstance}
 - 
    
    
    
Adds a projection before DeviceSet query is sent to EventBus.
Parameters:
Name Type Description projectionObject projection to use - Source:
 
Returns:
DeviceSetInstance DeviceSetInstance to chainExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus) .project({ guid: 1, tagValues: { IdName: 1 } }) .query() .then(function(reply) { // success handler // ... }, function(reply) { // error handler // ... }); }); - 
    
<inner> query() → {promise}
 - 
    
    
    
Finally executes DeviceSet query by sending it to the associated EventBus instance.
- Source:
 
Returns:
promise Promise which is resolved when query is returnedExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus) .query() .then(function(reply) { // success handler // ... }, function(reply) { // error handler // ... }); }); - 
    
<inner> sort(sorting) → {DeviceSetInstance}
 - 
    
    
    
Adds a sorting before DeviceSet query is sent to EventBus.
Parameters:
Name Type Description sortingObject sorting to use - Source:
 
Returns:
DeviceSetInstance DeviceSetInstance to chainExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet) { ketaDeviceSet.create(eventBus) .sort({ 'tagValue.IdName.value': 1 }) .query() .then(function(reply) { // success handler // ... }, function(reply) { // error handler // ... }); }); - 
    
<inner> sync(set, event, eventBus) → {void}
 - 
    
    
    
Synchronizes given DeviceSet with given DeviceEvent.
Parameters:
Name Type Description setDeviceSetInstance DeviceSetInstance to sync eventDeviceEventInstance DeviceEventInstance to process eventBusEventBus EventBus instance to use for communication - Source:
 
Returns:
void returns nothingExample
angular.module('exampleApp', ['keta.services.DeviceSet']) .controller('ExampleController', function(ketaDeviceSet, ketaDeviceEvent, ketaDevice) { ketaDeviceSet.sync( ketaDeviceSet.create().query(), ketaDeviceEvent.create({ type: ketaDeviceEvent.CREATED, device: ketaDevice.create(eventBus, { guid: 'guid' }); }); ); });