Successfully reported this slideshow.

SOFIA - Smart M3 hands-on Training. NOKIA

606 views

Published on

  • Be the first to comment

  • Be the first to like this

SOFIA - Smart M3 hands-on Training. NOKIA

  1. 1. Smart-M3 handson trainingHannu Laine<hannu.e.laine@nokia.com>Jukka Honkola<jukka.honkola@nokia.com>1 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  2. 2. Outline• Smart-M3 Qt Core API• Exercise Ontology• Exercise 1: • Discover available SmartSpaces • Join/Leave• Exercise 2: • Subscription• Exercise 3: • Insert/remove informationCompany Confidential2 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  3. 3. Smart-M3 “Hello World” exercise• Consists of three Knowledge Processors • Creator: inserts creatable things into the Space • Observer: observes which things exist and based on that information updates information whether the world exists or not • Greeter: monitors whether the world exists and says “Hello World”• Exercise: Develop Observer KP application with using Qt and Smart-M3 Qt Core API• Creator and Greeter KPs exist • GLib • PythonCompany Confidential3 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  4. 4. Smart-M3 Qt Core API• Currently supports Linux and Maemo platforms• Shared library that can be used by Qt applications• Utilizes Qt‟s signals and slots mechanism• QSibDiscovery QObject class • Discovery of available SmartSpaces (=SIBs in today‟s context)• QWhiteBoardNode QObject class • Information access to selected SmartSpace • Insert/remove/update triples• Query/Subscribe classes • Bound to selected QWhiteBoardNode instance • Template query • WQL queries• Triple class • Container for informationCompany Confidential4 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  5. 5. Hello world ontology “light” “sky” “land” “sea” Space has “sun” “moon” “stars” “World” “animals” “man_and_woman”Company Confidential5 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  6. 6. Exercise 1: Discovery and Join/Leave• SmartSpace discovery • Include q_sib_discovery.h and q_sib_info.h header files • Create QSibDiscovery instance • Connect sibList(const QList<QSibInfo *> &list) signal to a slot function (and implement the slot function) • Start discovery by calling getSibs() method of the QSibDiscovery instance • QSibDiscovery instance emits sibList( const QList<QSibInfo *> &list) signal (List contains all entries) • Use uri() method of the QSibInfo class to get the URI of the SmartSpace• Information access to a selected SmartSpace • Include q_whiteboard_node.h header • Create instance of QWhiteBoardNode class • Connect joinComplete(int status) signal to a slot function (and implement the slot function) • Call join(QString smartSpaceUri) method of the QWhiteBoardNode instance to join the selected SmartSpaceCompany Confidential6 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  7. 7. Exercise 1 (cont.)• Skeleton project fruct_ex1 • Open fruct_ex1.pro with QtCreator • Or type “qmake –unix –o Makefile fruct_ex1.pro” on a terminal window • Contains QListWidget to show list available SmartSpaces • Fill the list in sibList(const QList<QSibInfo *> &list) slot • Double-click or button press creates the QWhiteBoardNode instance and joins the selected SmartSpace (or leaves if already joined) . • Update state (non-member/member) in joinComplete(int success) slot • Failure: success < 0• Running • Open three terminal windows • export PIGLET_HOME=„pwd‟; rm $PIGLET_HOME/X; sibd • sib-tcp • whiteboardd (after starting whiteboardd wait approx. 5 secs before starting your app)• Run or debug your application in QtCreatorCompany Confidential7 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  8. 8. Exercise 2: Create subscription• Subscription is a persistent query• Subscribe to information what items Space has. • Include <templatesubscription.h> • Include <triple.h> • Create a triple with wildcard URI ssMATCH_ANY as an element for the unknown field • Triple::Triple( TripleElement subject, TripleElement predicate, TripleElement object) • TripleElement::TripleElement( QString node, TripleElement::ElementType type) • Append the triple into a QList<Triple *> structure• Create instance of TemplateSubscription class • Pointer to joined SmartSpace (QWhiteBoardNode *) given to constructor• Connect signals indication() and finished(int success) of the TemplateSubscription class to slot functions (and implement the slot functions) • Start the subscription with subscribe(QList<Triple *> list) method of the TemplateSubscription class • Each time results for the query changes the subscription class emits indication() signal • Use resultsAdded() and resultsObsolete() functions of the TemplateSubscription class to get changed resultsCompany Confidential8 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  9. 9. Exercise 2 (cont.)• Skeleton project fruct_ex2 • Open fruct_ex2.pro with QtCreator • Or type “qmake –unix –o Makefile fruct_ex2.pro” on a terminal window • In addition to Exercise 1 solution contains • QPushButton to subscribe/unsubscribe and QLabel to show the subscription state • QListWidget to show items that the Space has • Create subscription or unsubscribe in on_startButton_clicked() slot • Update contents of the QListWidget in indication() slot• Test your subscription with hello_world/trunk/src/play_creator • Command line application to create/delete items that the world constitutes of • Run in a terminal window (sibd, sib-tcp, whiteboardd must be running) • Press enter to get list of SmartSpaces and select one of them • The application shows what items exist in the Space • Use c1 c2 … to create items • Use d3 d4 … to remove itemsCompany Confidential9 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  10. 10. Exercise 3: Insert/Remove information• Monitor the subscription results and check are all items that constitute the world existing• Create a triple (Space, isA, “World”)• Based on that information either insert the triple or remove it from the SmartSpace• Testing • Use setup from Exercise 2 • In addition, run hello_world application in an terminal window • Similarly with play_creator join the SmartSpaceCompany Confidential10 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL

×