Module: Device

Device

Device Provider
Author:
  • Marco Lehmann <marco.lehmann (at) kiwigrid.com>
Source:

Classes

Device
DeviceInstance
ketaDeviceProvider

Methods

<inner> $delete() → {promise}

Deletes a remote DeviceInstance from local one the method is called on.

Source:
Returns:
promise promise
Example
angular.module('exampleApp', ['keta.services.Device'])
    .controller('ExampleController', function(ketaDevice) {
        var device = ketaDevice.create({
            guid: 'guid'
        });
        device.$delete()
            .then(function(reply) {
                // success handler
                // ...
            }, function(reply) {
                // error handler
                // ...
            });
    });

<inner> $reset() → {undefined}

Resets a DeviceInstance to it's $pristine state.

Source:
Returns:
undefined nothing
Example
angular.module('exampleApp', ['keta.services.Device'])
    .controller('ExampleController', function(ketaDevice) {
        var device = ketaDevice.create({
            guid: 'guid',
            tagValues: {
                IdName: {
                    name: 'IdName',
                    value: 'Device',
                    oca: 0,
                    timestamp: 123456789
                }
            }
        });
        device.tagValues.IdName.value = 'Modified Device';
        device.$update()
            .then(function(reply) {
                // success handler
                // ...
            }, function(reply) {
                // error handler
                device.$reset();
            });
    });

<inner> $update() → {promise}

Updates a remote DeviceInstance from local one the method is called on.

Only value changes in tagValues property will be recognized as changes.

Source:
Returns:
promise promise
Example
angular.module('exampleApp', ['keta.services.Device'])
    .controller('ExampleController', function(ketaDevice) {
        var device = ketaDevice.create({
            guid: 'guid',
            tagValues: {
                IdName: {
                    name: 'IdName',
                    value: 'Device',
                    oca: 0,
                    timestamp: 123456789
                }
            }
        });
        device.tagValues.IdName.value = 'Modified Device';
        device.$update()
            .then(function(reply) {
                // success handler
                // ...
            }, function(reply) {
                // error handler
                // ...
            });
    });

<inner> create(eventBus, properties) → {DeviceInstance}

Creates a DeviceInstance with given EventBus instance and properties.

Parameters:
Name Type Description
eventBus EventBus EventBus instance to use for communication
properties Object Properties to set upon DeviceInstance creation
Source:
Returns:
DeviceInstance DeviceInstance created
Example
angular.module('exampleApp', ['keta.services.Device'])
    .controller('ExampleController', function(ketaDevice) {
        var device = ketaDevice.create(eventBus, {
            tagValues: {
                IdName: {
                    name: 'IdName',
                    value: 'Device',
                    oca: 0,
                    timestamp: 123456789
                }
            }
        });
    });