Skip to content

A collection of accessors for Lab11 and other supporting code.

Notifications You must be signed in to change notification settings

lab11/accessors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Accessors

System Overview

Accessors are a method for abstracting the complicated and diverse input/output interfaces present in real-world devices and systems. Accessors allow for bundling standardized interfaces to common devices (lights, audio equipment, sensors, doors, etc.) with actual code that can access these interfaces. This abstraction allows for higher level applications to interact with the physical world without having to directly interface with the myriad of protocols present in real-world devices.

More concretely, accessors are Javascript files that both describe an interface and supply code to use it. The Javascript is parsed to generate JSON (and XML) objects that express accessor capabilities and requirements. Accessors present an interface much like HTML forms: a series of I/O elements with names.

Dependencies

We highly recommend you use io.js with this project as it has better support for newer Node.js features that we use. Newer versions of Node.js (>=0.11) should work, but will need the --harmony command line flag.

Quick Start

To start using accessors quickly, install the accessor command line tool.

sudo npm install -g accessors.io-cli

You can use it with a public data stream like so:

$ accessors-cli
  -> Select /webquery/Bitcoin
  -> Select "Price"
  =  It will print the current BTC conversion rate in BTC.
  -> Select "Transactions"
  =  It will stream all recent Bitcoin transactions.

Example

Accessors can also be used as a library inside of new or existing applications. For example, to run a Node app that queries a stock price using accessors:

cd runtimes/node
npm install
cd examples
./stock.js

This will print out the Microsoft stock price.

The code looks like this:

var accessors = require('accessors.io');

// First step is to create a live "StockTick" accessor. This will execute
// the accessor so we can interact with it.
accessors.create_accessor('/webquery/StockTick', {}, function (err, accessor) {
  if (err) {
    // Handle any errors that may occur when creating the accessor.
    console.log('Error loading accessor.');
    console.log(error);
    return;
  }

  // To use an accessor we must call init()
  accessor.init(function (err) {
    // The StockTick accessor, has two ports: "StockSymbol" and "Price".
    // To get a quote, we first set the StockSymbol port by writing the
    // port.
    accessor.write('StockSymbol', 'MSFT', function (err) {
      // After that has been set, we read the Price port to get
      // the current price.
      accessor.read('Price', function (err, price) {
        console.log('MSFT stock price: $' + price);
      });
    });
  });
});

The "StockTick" accessor is created, then its two ports are used to set the stock being queried and to read its price.

There are other examples in that folder that you can explore.

Accessors.io

Accessors must be hosted somewhere, and we currently run a hosting server at accessors.io. In a browser, this service will list the existing accessors and show the details of each one. For more information and for running your own hosting server, see the Host Server Readme.

Repository

There is much here to explore. Follow the links below to learn more about what accessors can do.

  1. Applications: Various applications or tools that are part of the accessor ecosystem.
  • Blocks: Application for creating applications with accessors by connecting blocks.
  • Command Line Interface: Download and interact with accessors using a command line interface.
  • Accessor RPC Host: Execute accessors on a server and provide a REST API and GUI for interacting with the accessors.
  1. Runtimes: Execution environments that can run accessors.
  1. Host Server: Server that describes and hosts accessors.

Code Climate

About

A collection of accessors for Lab11 and other supporting code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •