an operating system for the home

40
An Operating System for the Home

Upload: ruth-solomon

Post on 03-Jan-2016

25 views

Category:

Documents


0 download

DESCRIPTION

An Operating System for the Home. HomeOS: An OS for the home. HomeStore. Video r ecording. Remote unlock. Climate c ontrol. HomeOS. Z-Wave, DLNA, UPnP, etc. HomeOS logically centralizes all devices. Users interact with HomeOS, not individual devices. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: An Operating System for the Home

An Operating System for the Home

Page 2: An Operating System for the Home

HomeOS: An OS for the home

HomeOS

Video recording

Remote unlock

Climate control

HomeStore

Z-Wave, DLNA, UPnP, etc.

HomeOS logically centralizes all

devices

Users interact with HomeOS, not

individual devices

HomeStore helps find compatible

devices and apps

Page 3: An Operating System for the Home

HomeOS architecture

Application layer

Management layer

Device functionality layer (DFL)

Device connectivity layer (DCL)

Tasks

Control

Device

Topological

Heterogeneity source handled

Page 4: An Operating System for the Home

DCL and DFL (Drivers)

DCL provides basic connectivity to devices– Discovery– Abstract differences in protocols– Connectivity

DFL exports device functionality as a service– Services are protocol-independent– Exposed as roles and operations– Kernel does not parse or understand services– Allows subscriptions (e.g. when light is toggled)– Applications do not require changes

App layerMgmt layer

DFLDCL

Page 5: An Operating System for the Home

Application layer

Apps compose abstract rules from DFL

Management layer interposes on accesses

Manifests help with compatibility testing– Lists of mandatory and optional features– E.g., mandatory: {TV, SonyTV}, {MediaServer}

optional : {Bass Speaker}

App layerMgmt layer

DFLDCL

Page 6: An Operating System for the Home

Interaction between Apps and Drivers

Drivers

Device (camera, thermostat)

Core Platform

Exports Ports

Exposes Ports

Applications

Page 7: An Operating System for the Home

What are ports (classical definition)

Hardware portssockets that a device can plug intoe.g., printer ports, mouse ports?

Software portslocations/addresses that processes rune.g., Http (port 80), ssh (port 22)processes can read and write from ports

Page 8: An Operating System for the Home

Ports in Home Lab (HomeHub)Ports are uses as a communication abstraction between Drivers Platform (kernel) Applications

All modules (drivers, kernel, applications) can read/write using ports

HomeHub ports are associated with Roles

Read/write data Read/write data

Driver platform Applications

Page 9: An Operating System for the Home

What are Roles?

Roles define service and capabilities that a device offers

Example role for a pan-tilt-zoom video camera: up, down, left, right, getImages

Roles may be shared between devicessame roles can be provided by multiple devicese.g. getTemperature() is a role that can be

provided by a temperature sensor and a thermostat

Page 10: An Operating System for the Home

Interaction between Apps and Drivers

Drivers

Device (camera, thermostat)

Core Platform

Exports Ports with Roles

Exposes Ports with Roles

Applications

Bind Ports Invoke Roles

implements roles

Page 11: An Operating System for the Home

How would a camera device work?

Drivers

Pan/Tilt/Zoom Camera

Core Platform

Port roles (CameraRoles: move camera up, down,Left, right)

Scan for ports that exports a CamerRole

Camera Viewer Application

Bind Ports Invoke Roles

implements roles

Invoke the roles exported by CameraRole

Page 12: An Operating System for the Home

How would you implement different components like kernel, drives, and apps

Design goalsyou want isolation between the kernel, drivers,

and applicationsSandbox execution of different components?

How would you implement something like this?

Page 13: An Operating System for the Home

What are different ways of implementing this?

ProcessesHigh communication overheadHigh overhead for switching processes on and off

Threadssubstantial amount of sharingminimal isolation

Page 14: An Operating System for the Home

.Net provides Application domains to implement this?

Somewhere in between process and threadsThe common language infrastructure runs as a process and the sub processes or applications runs within the CLI processEach application domain has a separate virtual address space

Provides isolationException in one domain does not affect other application domain, each application domain are assigned different access levels, and multiple threads can run in one domain

Page 15: An Operating System for the Home

How would you implement portsUse a framework called .Net Remote

There are two ways to pass Objects from one process to the otherBy object copying and passing object referencesSystem.AddIn.AddIn Attributes provides a fairly complex way of implementing the communication using a similar idea.

App domain 1

App domain 2 proxy

responsible for marshalling/unmarshalling

Page 16: An Operating System for the Home

Implications to Garbage collectionObject passed across boundaries are garbage collection

It is slower than garbage collection inside app domainsEach application domain has a separate virtual address space

Page 17: An Operating System for the Home

Programming Abstraction for HomeHub

Drivers and Apps are modulesExtends ModuleBase class

provides four methods (start, stop, portregistered, portderegistered)

Uses the System.AddIn.AddIn(“Appname”) attributeModules export services and can use serviceDrivers and Apps therefore theoretically can export and use servicesServices are operations defined in roles associated with portsInput and output parameters of operations are of ParamType

Page 18: An Operating System for the Home

ParamType

Used for transferring data between modules using

ParamType class has two fields MainType: this can be an integer, image, sounds, txt

MainType can be simple of complex object

Value: captures the actual objectExample ParamType (maintype=image, value=byte[])

Page 19: An Operating System for the Home

Helper Functions

Logger classGenerate log messages When a module is instantiated, HomeOS passes a pointer to the log objectRedirect messages to a log or stdoutlogger.log();

SafeThreadFocusses on communication between modules

Page 20: An Operating System for the Home

Example of Using SafeThread

Logic inside the thread

Parameter passed to the threadParameter passed to the thread

Page 21: An Operating System for the Home

Writing Applications

Two main steps for writing applicationsDiscover Interesting portsBuilding application logic

Page 22: An Operating System for the Home

Example (discovering and registering ports)

Port object Gets all the ports that are registered with the HomeOS platform

This serves a dual purpose: (1) callback when a new port is registered (2) determine ports of interest

Finding a port of interest

Page 23: An Operating System for the Home

Making calls to operations in roles

Synchronous invocation

portRole

argumentsOperations

Page 24: An Operating System for the Home

Making calls to operations in roles (Asynchronous)

Page 25: An Operating System for the Home

Putting all of this together lets see an example.

Page 26: An Operating System for the Home

HomeOS apps + Web interface

.Net App Web App

Use WCF (Windows Communication Foundation) Allows communication between .Net and non-.Net entity This is unlike .Net Remote that is between .Net modules

WCF framework

Page 27: An Operating System for the Home

Web app is written in HTML+Javascript

Web App(html, index.html)

Invokes Javascript functions

Calls made into .NET application

Page 28: An Operating System for the Home

How does WCF work

Javascript functions interfaceService class that implements the interface

Interfaces define the contracts contracts are the functionality that the server implements and the client uses has two attributes [ServiceContract] – interface attribute [OperationContract] – function attribute [WebInvoke] --- function attribute stating that the function would be invoked through Javascript/WCF Rest interface

client

server

Page 29: An Operating System for the Home

Every HomeOS app has a index.html

<div class="dashboard_toolbar"> <div class="homeID_title"><a href="../GuiWeb/index.html">Dashboard</a> | Dummy </div> </div> <div class="page"> <div class="row"> <div class="page_title col">Dummy Application</div> </div>

<div><button class="app_button" id="Button1" onclick="ShowDummyPortsInfo()">Update</button></div> <textarea id="DummyList" class="app_form" rows="30" cols="50" wrap="hard"></textarea> <br />

Page 30: An Operating System for the Home

The Javascript function <script>

function ShowDummyPortsInfo() { new PlatformServiceHelper().MakeServiceCall("webapp/GetReceivedMessages", "", GetReceivedMessagesCallback); }

function GetReceivedMessagesCallback(context, result) { var portsInfo = result.GetReceivedMessagesResult; $("#DummyList").html(''); for (i = 0; i < result.GetReceivedMessagesResult.length; i++) { $("#DummyList").append(portsInfo[i] + "<br />"); } }

</script>

Page 31: An Operating System for the Home

How to instantiate the service from the server

DummyService dummyService = new DummyService(logger, this); serviceHost = new SafeServiceHost(logger,typeof(IDummyContract), dummyService , this, Constants.AjaxSuffix, moduleInfo.BaseURL()); serviceHost.Open();

string binarydir = moduleInfo.BinaryDir(); //directory of where the dlls and libraries are string baseurl = moduleInfo.BaseURL(); // baseurl for the application appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);

Start the server service

Page 32: An Operating System for the Home

Lets take a look at the implementation of the service class

Page 33: An Operating System for the Home

Writing Drivers

Five steps for writing applicationsInstantiating RolesInstantiating PortsBinding roles to portsRegistering the port with the platformImplementing functions for handling operation invocations

Page 34: An Operating System for the Home

Roles Data Structure

Base class: Role (Your role will extend Role)e.g.: DummyRole:RoleRoles have Operation

Operation (name, arguments, returnvalue)name: :dummy:->echo (Name, function name)arguments, returnvalue of type ParamType List<VParamType> args = new

List<VParamType>() { new ParamType(0) };

Page 35: An Operating System for the Home

Writing Drivers (setting up Roles)

Page 36: An Operating System for the Home

Writing Drivers (instantiating ports)

portInfo = GetPortInfoFromPlatform(name)InitPort(portInfo)BindRoles(port, RoleList)

Page 37: An Operating System for the Home

Writing Drivers logic (synchronous)

Page 38: An Operating System for the Home

Putting all of this together lets see an example.

Page 39: An Operating System for the Home

Scouts

Scouts are used for discovering devicesDiscovers devices in the environmentMakes the core platform aware of the devicesUser can query the platform for discovered devices that are not part of the platformDevice setup is performed through HTML pages

Initial page enables setting up the configurations

Page 40: An Operating System for the Home

What do Scouts do

Discover devices and report to the platformHost the UI for custom device configurationHand over control to the platform by pointing to the generic device addition page