Skip to content

Commit

Permalink
[raspberrypi] string actuator added
Browse files Browse the repository at this point in the history
  • Loading branch information
yhjo8478 committed Jul 19, 2016
1 parent 6e34320 commit 10c4cdf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
21 changes: 17 additions & 4 deletions raspberrypi/grovePi-starter-kit/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var jsonrpc = require('jsonrpc-tcp'),
log4js = require('log4js');

var Lcd = require('./grovePiLcd'),
String = require('./string'),
StringSensor = require('./string-sensor'),
StringActuator = require('./string-actuator'),
grovePiSensors = require('./grovePiSensors');

//log4js.configure(__dirname + '/logger_cfg.json', {
Expand Down Expand Up @@ -114,7 +115,13 @@ DEVICES = [{
{
id: [device0Id, 'string'].join('-'),
type: 'string',
name: 'string',
name: 'stringSensor',
notification: false
},
{
id: [device0Id, 'stringActuator'].join('-'),
type: 'stringActuator',
name: 'stringActuator',
notification: false
},
{ // actuator
Expand All @@ -128,7 +135,8 @@ DEVICES = [{

var sensorNames = [];
var grovePiLcd = new Lcd();
var stringSensor = new String();
var stringSensor = new StringSensor();
var stringActuator = new StringActuator();

// util function: find target sensor from DEVICES
function getSensorInfo(cond) {
Expand Down Expand Up @@ -156,6 +164,8 @@ var Sensor = {

if (target.name === 'lcd') {
grovePiLcd.doCommand(target.name, cmd, options);
} else if (target.name === 'stringActuator') {
stringActuator.doCommand(target.name, cmd, options);
} else {
grovePiSensors.doCommand(target.name, cmd, options);
}
Expand All @@ -181,7 +191,10 @@ var Sensor = {
if (target.name === 'lcd') {
sensorData = grovePiLcd.getData(target.name);
}
else if (target.name === 'string') {
else if (target.name === 'stringActuator') {
sensorData = stringActuator.getValue(target.name);
}
else if (target.name === 'stringSensor') {
sensorData = stringSensor.getValueSync();
}
else {
Expand Down
15 changes: 15 additions & 0 deletions raspberrypi/grovePi-starter-kit/string-actuator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function StringActuator() {
}

StringActuator.prototype.doCommand = function(name, cmd, options) {
if (options.text) {
console.log('YOUR TEXT IS');
console.log(options.text);
}
};

StringActuator.prototype.getValue = function (name) {
return {status: 'on'};
};

module.exports = StringActuator;
File renamed without changes.

0 comments on commit 10c4cdf

Please sign in to comment.