Last active
October 3, 2015 12:34
-
-
Save mliszcz/14ef9b14da69b5676aec to your computer and use it in GitHub Desktop.
tangojs-demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
let tangojs = require('tangojs') | |
let connector = require('tangojs-connector-local') | |
let testmodel = require('./node_modules/tangojs-connector-local/lib/tangojs-connector-local-testmodel') | |
let model = testmodel.createModel() | |
let conn = new connector.LocalConnector(model) | |
tangojs.setConnector(conn) | |
let devProxy = new tangojs.DeviceProxy('tangojs/test/1') | |
let attrProxy = devProxy.createDeviceAttribute('number_scalar') | |
let cmdProxy = devProxy.createDeviceCommand('double') | |
let sync = true | |
let value = 32 | |
devProxy.readAttributesList() | |
.then(attributes => | |
console.log('Attributes:', attributes) | |
) | |
.then(() => attrProxy.readValue()) | |
.then(response => { | |
console.log(`Reading value: ${response.argout}`) | |
console.log(`Writing value: ${value} (sync)`) | |
}) | |
.then(() => attrProxy.writeValue(value, sync)) | |
.then(response => | |
console.log(`Stored value: ${response.argout}`) | |
) | |
.then(() => cmdProxy.execute(value, sync)) | |
.then(response => | |
console.log(`Command 'double': 2*${value} is ${response.argout}`) | |
) | |
.catch(console.log) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"tangojs": "^0.1.0", | |
"tangojs-connector-local": "^0.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment