Post on 07-Aug-2015
Orion Context Broker Exercises(PART I)
Contact twitter @marivibriz
Contact emailmariavirtudes.brizruiz@telefonica.com
Outline
• CB-1. Create entities using standard ops• CB-2. Query entities using standard ops• CB-3. Update entity using standard ops• CB-4. Create entities using conv ops• CB-5. Query entities using conv ops• CB-6. Update entity using conv ops• CB-7. Browsing entity types• CB-8. Basic subscription/notifications
2
CB-1. Create entities using standard ops
• Steps– Create the following entities in your Orion
instance• See table in next slide
• Hints– Orion User Manual section 3.3.1.1
(UpdateContext & APPEND)
Easy
CB-1 . Create entities using standard ops Easy
Entity Entity Type
Bedroom1 Room
Bedroom2 Room
Kitchen Room
Frontdoor Door
Backdoor Door
Entity Type Attr. Name Attr. Type Example value
Room Temperature float 27.8
Presence boolean true
Status string OK
Door Locked boolean false
Closed boolean false
CB-2. Query entities using standard ops
• Prerequisites– Exercise CB-1
• Steps– Write a program (or web/mobile application) that does the
following queries and prints the result• Obtain all attributes of Bedroom1 entity• Obtain only the Temperature attribute of Kitchen entity• Obtain all attributes of Kitchen and Bedroom2 entities in one
query• Obtain all attributes of entities that match the pattern Bedroom.*• Find out whether the doors are closed using the pattern .*door
and the Closed attribute
– Run and test your program/application
• Hints– Orion User Manual section 3.3.1.2(queryContext)
Easy
CB-3. Update entity using standard ops
• Prerequisites– Exercise CB-2
• Steps– Write a program (or web/mobile application) that
• Asks for user input (one value)• Updates Looked attribute of Frontdoor entity using
that input• Queries the entity and check the result
– Run and test your program/application
• Hints– Orion User Manual section 3.3.1.2 and 3.3.1.3(updateContext & UPDATE)
Easy
CB-4. Create entities using conv ops
• Prerequisites– Exercise CB-3
• Steps– Create the following entities in your Orion
instance• See table in next slide
• Hints– Similar to exercise CB-2 in the standard ops set– Orion User Manual section 3.3.2.1(contextEntities/entityID)
Easy
CB-4. Create entities using conv ops Easy
Entity Entity Type
Garage Room
Bathroom Room
Light1 Light
Light2 Light
Light3 Light
Entity Type Attr. Name Attr. Type Example value
Room Temperature float 27.8
Presence boolean true
Status string OK
Light Intensity Percent 0.25
CB-5. Query entities using conv ops
• Prerequisites– Exercise CB-4
• Steps– Write a program (or web/mobile application) that does the
following queries using convenience operations and print the result• Obtain all attributes of the Garage entity• Find out whether there is anyone in the Bathroom entity• Obtain all entities created so far• Obtain all entities of type Room• Obtain the temperature attribute of all entities of type Room
– Run and test your program/application
• Hints– Similar to exercise CB-2 in the standard ops set– To get all entities of a given type, you can use the
“contextEntityType” resource– Orion User Manual section 3.3.2.2(contextEntities/entityID and contextEntities/type/XX/id/XX)
Easy
CB-6. Update entity using conv ops
• Prerequisites– Exercise CB-5
• Steps– Write a program (or web/mobile application) that
• Asks for user input (one value)• Updates Intensity attribute of Light1 entity using that
input using a convenience operation• Queries the entity and check the result
– Run and test your program/application
• Hints– Similar to exercise CB-3 in the std ops set– Orion User Manual section 3.3.2.2 and 3.3.2.3(contextEntities/entityID and contextEntities/type/XX/id/XX)
Easy
CB-7. Browsing entity types
• Prerequisites– Exercise CB-6
• Steps– Write a program (or web/mobile application)
that• Lists all entity types• Provides detailed information of type Door
– Run and test your program/application
• Hints– Orion User Manual section 3.5.6(contextTypes)
Easy
CB-8. Basic subscription/notifications
• Prerequisites– Exercise CB-7
• Steps– Write a program that
• Starts a REST server to receive notifications from Orion• Prints the value of the Temperature attribute of Bedroom1 entity
each time a notification is received
– Subscribe your program to changes in the Temperature attribute of Bedroom1 entity
– Update the Temperature attribute of Bedroom1 entity and check that your program prints the updated value
• Hints– Orion User Manual section 3.3.1.4 (specially subsection on
ONCHANGE, i.e. 3.3.1.4.2)– Your program has to run in a VM to which your Orion instance
may send notifications (e.g. the same VM in which Orion is running)
Medium
HOMEWORK!
Orion Context Broker Exercises(PART II)
Contact twitter @marivibriz
Contact emailmariavirtudes.brizruiz@telefonica.com
Outline
• CB-1. Pagination• CB-2. Geolocation (factory)• CB-3. Compound attributes• CB-4. Query entities with compound attributes• CB-5. Update entities with compound attributes• CB-6. Custom metadata
14
CB-1. Pagination
• Prerequisites– Access to Orion instance running in
workshop.tidnode.cl port 1026
• Steps– Check how many entities of type Sensor are stored
in that Orion instance– Write a program (or web/mobile application) that
• Asks for a limit and a page number• Returns the name IDs the entities of type Sensor in the
corresponding page
– Run and test your program/application
• Hints– Orion User Manual section 3.5.1(queryContext?limit=100&details=on)
Medium
CB-2. Geolocation (factory)
• Prerequisites– Access to Orion instance running in
workshop.tidnode.cl port 1026
• Steps– Write a program (or web/mobile application)
that• Gets all existing types• Gets all entities of each type in areas Red, Green and
Blue (see next slide), printing entity IDs and their attributes which their values
– Run and test your program/application
• Hints– Orion User Manual section 3.5.20
Medium
17
-33.596620, -70.666825
-33.607682, -70.670730
-33.6100089, -70.643231
-33.599194, -70.640200
CB-2. Geolocation (factory) Medium
18
-33.596620, -70.666825
-33.607682, -70.670730
-33.6100089, -70.643231
-33.599194, -70.640200
-33.603458, -70.652788
-33.606123, -70.653790
-33.604231, -70.646032
-33.607108, -70.646781
-33.602391, -70.661781
x
200m
CB-2. Geolocation (factory) Medium
CB-3. Compound attributes
• Prerequisites– Exercise CB-1
• Steps– Create the following entities in your Orion
instance• See table in next slide
• Hints– Orion User Manual section 3.5.19
Medium
HOMEWORK!
CB-3. Compound attributes
Entity Type Attr. Name Attr. Type Example value
Character Name string Fooy
Hitpoints integer 110
Class string Barbarian
Abilities compound { "STR": "2", "DEX": "4", "CON": "3", "INT": "1", "WIS": "1", "CHA": "2"}
Inventory compound { "weapons": [ "sword", "dagger" ], "potions": { "life": "1", "mana": "0" }, "other": ["shield"]}
Entity name Entity Type
Gandalf Character
Aragorn Character
Frodo Character
Medium
HOMEWORK!
CB-4. Query entities with compound attributes
• Prerequisites– Exercise CB-1
• Steps– Write a program (or web/mobile application)
that does the following queries and print the result
• Obtain all attributes of Aragorn entity• Obtain only the Abilities attribute of Frodo
entity
– Run and test your program/application
• Hints– Orion User Manual section 3.5.19
Medium
HOMEWORK!
CB-5. Update entities with compound attributes
• Prerequisites– Exercise CB-1
• Steps– Write a program (or web/mobile application) that
• Asks for an object name (e.g. “staff”, “hat”, etc.)• Updates Gandalf's Inventory attribute to reflect
that he now has a that object test your program
– Run and test your program/application• Query the Gandalf's Inventory after that, in order to
check that the object has been successfully added
• Hints– Orion User Manual section 3.5.19
Medium
HOMEWORK!
CB-6. Custom metadata Medium
• Prerequisites– Exercise CB-1
• Steps– Update the Gandalf entity so that the
inventory attribute has two new metadatas:• name="Weight", type="float", value="1.2"• name="MaxWeight", type="float", value="20"
– Query Gandalf again to see the new metadata atached to the corresponding attribute
• Hints– Orion User Manual section 3.5.7
HOMEWORK!