bookies free bets online bookies sign up bonus from oddstake.com online bookies bonus codes

Posts Tagged ‘ web services

SCDL and Web Services

My Dad has been having fun hacking with single-board computers and has been sending me a lot of links. This review of the of the Raspberry Pi Model A looks interesting: A quick Model A show and tell from Adafruit

I spent years working as an embedded systems engineer and have a love of these small and inexpensive single-board computers. As a side note my Leap Motion Leap should arrive soon and I want to try connecting it to a Raspberry Pi for some recreational hacking.

The general idea is that I would use a small HTTP server on the Raspberry Pi to communicate with a fancy-pants HTML5 application running in the browser to monitor the Leap and control routing of Leap data out to various other peripheral devices connected to the Raspberry Pi. The details aren’t important. But what is interesting is how I think I can leverage SCDL in this project.

Soft Circuit Description Language  (SCDL) is a JSON object model for “soft circuits.” Soft circuits are system design artifacts conceptually analogous to digital circuit schematics.

As SCDL is JSON you can send it around conveniently. Maybe you have a web service API defined on your embedded web server that accepts a SCDL JSON parameter as input for example. Now consider what our little embedded web service might do with the SCDL it just received.

Recalling that SCDL is used to model program specifications, one particularly interesting thing our little embedded web server might do is transform the program specification into something it can actually execute, execute it, and return the results of the program execution to the caller as the request response.

Let that sink in for a minute. We just defined a single trivial web service API that can be implemented with widely available technology that effectively eliminates application logic as we know from the server (client too but we’ll get to that).

Rather than server-side routing tables and lots of carefully written routines here and there, we have a single simple web service that will essentially re-wire itself dynamically to service requests.

We can apply the same logic to the client as well and application logic as we know it starts to magically evaporate. Yet the functionality remains. There’s actually no magic. Just some clever factoring. But it’s weird. So let’s dig a bit deeper.

Think of a JSON-encoded SCDL message sent from point A to point B as a request and response protocol.

Request input comprises: a SCDL catalogue in JSON format, optionally some other JSON-encoded data objects that will be used as input to the program described by the SCDL catalogue.

Request output comprises: a JSON string (possibly containing another SCDL catalogue to be processed by the caller).

Bringing this back to the Raspberry Pi and our little embedded web server example, consider that upon receipt of a SCDL catalogue from the client, the embedded webserver unpacks the SCDL and uses the “soft circuit” schematic diagram it represents to:

  • instantiate the described program using a library of native plug-ins installed on the Raspberry Pi
  • “execute” this program (effectively a dynamically created web service)
  • return the results to the caller in JSON format (data + possibly more SCDL…)

Here the simple web service has absolutely no idea what the semantics of the request are.

And, this is why I say that there’s no hard-wired application logic on the server. In fact there is application logic on the server. It’s just expressed in a very pure and compact.

Our server-side deployment consists of (a) a collection of  low-level plug-ins and (b) a SCDL catalogue that specifies the “parts” that a client can use in a “soft circuit” to form a request.

In essence, this static SCDL catalogue is your application logic. It defines a grammar of possible requests and maps each to a concrete web service, built on-the-fly, via program transformation.

I like this idea because I’m lazy. I don’t want to figure out how to talk to my Leap device when it’s plugged into the USB port on my Raspberry Pi.

Rather, I want to browse a catalogue of Leap modules, select one for Raspberry Pi, stick it in my deployment package, and then expose it via my server’s SCDL catalogue. That way if a client wants to open a web socket to read a live telemetry stream of Leap data, it can send the server a SCDL request containing a little “soft circuit” that connects the Leap module to a web socket module.

Client-side, I’ve got the server’s SCDL catalog. I see the server has a Leap module and a web socket module and I know that the server knows how to connect the two somehow. I also know how I can ask the server to connect the these two resources for me.

We’ll come back to this topic later. That’s enough to think about for today :)