Skip to content

Instantly share code, notes, and snippets.

@valkjsaaa
Created August 1, 2015 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valkjsaaa/4a3934d2c045858447a9 to your computer and use it in GitHub Desktop.
Save valkjsaaa/4a3934d2c045858447a9 to your computer and use it in GitHub Desktop.
Scenarios and design of IOT programming environment

Targeted scenario

lower the volume around me if there is a phone call notify me

problems about moving around priority of actions

Simple questions: questions about simple facts

How noisy is Gates lounge? How long is HCII's coffee line? Where is Andrew?

Challenges: how to address the problem

Subscribe questions: questions about facts changes

Notify me when Anind's meeting is done Let me know when someone enter the lab

Challenges: how to notify when facts changes

Local actions: actions only related to contextal facts

Turn the lights on when there are people near \ turn off when there is no people Turn the lights on when motion is detected \ turn off when there is no motion Turn the room's light on when at least on people is in the room

Challenges: addressing the the facts related

Global actions: actions related to many facts

Change the room temperature according to my activities

Challenges: Only little actions is belong to this kind

System design

Hardware requirement

Each device require a bluetooth scanner and beacon (proximity) Each device require a Internet connection (control)

Software design

base module: IOT

mode: end-user and virtual device

IOT.getThingByUUID(UUID) get a thing using UUID

IOT.getThingByLocation(location, types) get a thing using location type

IOT.Thing very important type in IOT module

IOT.Thing.init = func(self) append function to the init script of a thing

IOT.Thing.set("var", value) set value of a thing

IOT.Thing.subscribe("var", func(self, var)) subscribe a variable value

IOT.Thing.var sync version of subscribe a variable

IOT.Thing.(function name) = func(self, ...) add a function to the thing

IOT.Thing.func(...) call a certain function

IOT.Thing.nest(obj) let this thing nested in obj

IOT.Thing.nested ThingsList of all the nested devices

IOT.Thing.nesting ThingsList of all the devices the current device is nesting

IOT.Thing.near ThingsList of all near device, discovered by bluewave

IOT.Room a room in IOT environment

IOT.Area a area in IOT environment

IOT.Building a building in IOT environment

IOT.Person a person in IOT environment

IOT.findPerson(str) using str to find a person

IOT.findBuilding(str) using str to find building

IOT.ThingsList.func let all thingslist item receive func call

IOT.ThingsList.select(cond, type) select things based on condition cond and type type

Scripting example

Simple questions: questions about simple facts

How noisy is Gates lounge?

# get Gate's center's location by Google API
gates = IOT.findBuilding("Gate's Center")
gates_lounge = gates.nested.select(Name("lounge"), "Room")
return gates_lounge.sound_volume

How long is HCII's coffee line?

# get NSH's location by Google API
nsh = IOT.findBuilding("Newell Simon Hall")
nsh_coffeeroom = nsh.nested.select("coffee", "room")
return nsh_coffeeroom.people_count()

Where is Andrew?

# programmer should know andrew's uuid
andrew = IOT.findPerson("Andrew")
return andrew.location()

Subscribe questions: questions about facts changes

Notify me when Anind's meeting is done

# programmer should know Anind's uuid
anind = IOT.findPerson("Anind")
anind.subscribe("current_event") = func(self, event):
	if(event == "free"):
		notify()

Let me know when someone enter the lab

# assume we already konws about the room
lastObj
room.subscribe("nested") = func(self, obj):
    newObj = obj.select("people")
    if compare(newObj, lastObj):
        notify()

Local actions: actions only related to contextal facts

Turn the lights on when there are people near \ turn off when there is no people

# assume we are dealing with lights in a room
lights = room.nested.select("lights")
lights.init = func(lightsSelf){
    self.near.select(Nearest, "motion").subscribe("near", func(motionSelf, var):
        if len(var.select("people")) > 0:
            lightsSelf.on()
        else:
            lightsSelf.off()
    )
}

Turn the lights on when motion is detected \ turn off when there is no motion

# assume we are dealing with lights in a room
lights = room.nested.select("lights")
lights.init = func(lightsSelf){
    self.near.select(Nearest, "motion").subscribe("people", func(motionSelf, var):
        if var == True:
            lightsSelf.on()
        else:
            lightsSelf.off()
    )
}

Turn the room's light on when at least on people is in the room

# assume we are dealing with lights in a room
lights = room.nested.select("lights")
lights.init = func(lightsSelf){
    self.nesting.select("room").subscribe("near", func(roomSelf, var):
        if len(var.select("people")) > 0:
            lightsSelf.on()
        else:
            lightsSelf.off()
    )
}

Challenges: addressing the the facts related

Global actions: actions related to many facts

Change the room temperature according to my activities

Challenges: Only little actions is belong to this kind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment