← back to the blog


DeviceJS is Javascript for the Physical World

Why JavaScript?

JavaScript is by far the most widely used language in the open source community. It’s easy to write simple scripts and it’s powerful enough to do complex tasks. Most importantly, it’s very well known by many programmers.

One script, execute it everywhere

Real world, complex sensor networks and automated systems often span multiple locations. In traditional systems, this means maintaining multiple controllers and managing programs which run on these different systems, ensuring they can talk to one-another. DeviceJS let’s you write a single program and distribute it over multiple controllers in different locations transparently. This means from a developer’s or maintainer’s viewpoint, the system can be much simpler. DeviceJS can distribute a script across any relay capable of running the DeviceJS run-time.

More: How it works

Patterns you already know

DeviceJS aims to enable developers familiar with client side web development libraries to easily make things happen dynamically in the physical world.

Selectors

A simple example is the selector pattern, seen in frameworks like jQuery and d3.js.

Turn all paragraph text to red in jQuery:

$("p").css("color","red");

The same thing in d3.js:

d3.selectAll("p").style("color","red");

A similar pattern in DeviceJS – turn all lighting in a location red:

dev$.byLocation("kitchen").setColor("red");

Events

In jQuery this would pop-up an alert dialog box on a ‘click’:

$('#foo').on('click',function(){
    alert($(this).text());});

In the physical world, we could handle things similarly with DeviceJS:

dev$.byDeviceAlias('hallway-sensor').trigger('motion',function(){
    dev$.byLocation('hallway').setOn();});

DeviceJS also allows trigger evaluation functions, which can help determine whether a sensor event issignficant.

More information will be available when DeviceJS is released on github and the API is published.

 


Please Sign In to leave a comment.