SlideShare uma empresa Scribd logo
1 de 10
Baixar para ler offline
Smart-M3 hands
on training
Hannu Laine
<hannu.e.laine@nokia.com>
Jukka Honkola
<jukka.honkola@nokia.com>

1   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL
Outline
• Smart-M3 Qt Core API
• Exercise Ontology
• Exercise 1:
      • Discover available SmartSpaces
      • Join/Leave
• Exercise 2:
      • Subscription
• Exercise 3:
      • Insert/remove information




Company Confidential
2   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL
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
      • Python




Company Confidential
3   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL
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 information


Company Confidential
4   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL
Hello world ontology
                                                                   “light”

                                                                   “sky”

                                                                   “land”

                                                                   “sea”
                                       Space                 has
                                                                   “sun”

                                                                   “moon”

                                                                   “stars”

       “World”                                                      “animals”

                                                                     “man_and_woman”

Company Confidential
5   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL
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 SmartSpace

Company Confidential
6   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL
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 QtCreator


Company Confidential
7   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL
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 results



Company Confidential
8   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL
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 items


Company Confidential
9   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL
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 SmartSpace




Company Confidential
10   © 2008 Nokia   Smart-M3 hands on.ppt / 2009-11-05 / HL

Mais conteúdo relacionado

Semelhante a SOFIA - Smart M3 hands-on Training. NOKIA

Devoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTDevoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTBenjamin Cabé
 
Go at Swiss Post for Automation and Testing
Go at Swiss Post for Automation and TestingGo at Swiss Post for Automation and Testing
Go at Swiss Post for Automation and Testingphilipsahli
 
Real-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache StormReal-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache StormDavorin Vukelic
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIICS
 
Dynatrace - Red Hat workshop : Monolith to Microservices
Dynatrace - Red Hat workshop : Monolith to MicroservicesDynatrace - Red Hat workshop : Monolith to Microservices
Dynatrace - Red Hat workshop : Monolith to MicroservicesSteve Caron
 
The Ring programming language version 1.10 book - Part 83 of 212
The Ring programming language version 1.10 book - Part 83 of 212The Ring programming language version 1.10 book - Part 83 of 212
The Ring programming language version 1.10 book - Part 83 of 212Mahmoud Samir Fayed
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3ICS
 
Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Anthony Dahanne
 
Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key conceptsICS
 
Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)Mike Milinkovich
 
CloudMan workshop
CloudMan workshopCloudMan workshop
CloudMan workshopEnis Afgan
 
5 Painless Demos to Get You Started with Kubernetes
5 Painless Demos to Get You Started with Kubernetes5 Painless Demos to Get You Started with Kubernetes
5 Painless Demos to Get You Started with KubernetesAmartus
 
GCC 2014 scriptable workshop
GCC 2014 scriptable workshopGCC 2014 scriptable workshop
GCC 2014 scriptable workshopEnis Afgan
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev introVonbo
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone developmentVonbo
 
Java design patterns
Java design patternsJava design patterns
Java design patternsShawn Brito
 

Semelhante a SOFIA - Smart M3 hands-on Training. NOKIA (20)

Devoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTDevoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoT
 
Go at Swiss Post for Automation and Testing
Go at Swiss Post for Automation and TestingGo at Swiss Post for Automation and Testing
Go at Swiss Post for Automation and Testing
 
Real-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache StormReal-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache Storm
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part III
 
Dynatrace - Red Hat workshop : Monolith to Microservices
Dynatrace - Red Hat workshop : Monolith to MicroservicesDynatrace - Red Hat workshop : Monolith to Microservices
Dynatrace - Red Hat workshop : Monolith to Microservices
 
Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2
 
The Ring programming language version 1.10 book - Part 83 of 212
The Ring programming language version 1.10 book - Part 83 of 212The Ring programming language version 1.10 book - Part 83 of 212
The Ring programming language version 1.10 book - Part 83 of 212
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3
 
Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !
 
Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key concepts
 
Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)Eclipse IoT Talk (Montreal JUG)
Eclipse IoT Talk (Montreal JUG)
 
CloudMan workshop
CloudMan workshopCloudMan workshop
CloudMan workshop
 
Qt for beginners
Qt for beginnersQt for beginners
Qt for beginners
 
5 Painless Demos to Get You Started with Kubernetes
5 Painless Demos to Get You Started with Kubernetes5 Painless Demos to Get You Started with Kubernetes
5 Painless Demos to Get You Started with Kubernetes
 
GCC 2014 scriptable workshop
GCC 2014 scriptable workshopGCC 2014 scriptable workshop
GCC 2014 scriptable workshop
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev intro
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone development
 
cpp-2013 #18 Qt Part 2
cpp-2013 #18 Qt Part 2cpp-2013 #18 Qt Part 2
cpp-2013 #18 Qt Part 2
 
Java design patterns
Java design patternsJava design patterns
Java design patterns
 
Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1
 

Mais de Sofia Eu

SOFIA Project Brochure Pilots Set
SOFIA Project Brochure Pilots Set SOFIA Project Brochure Pilots Set
SOFIA Project Brochure Pilots Set Sofia Eu
 
SOFIA Poster ATC 2012
SOFIA Poster ATC 2012SOFIA Poster ATC 2012
SOFIA Poster ATC 2012Sofia Eu
 
SOFIA ATC 2011_artemis_magazine
SOFIA ATC 2011_artemis_magazineSOFIA ATC 2011_artemis_magazine
SOFIA ATC 2011_artemis_magazineSofia Eu
 
SOFIA INDRA Presentation to AICIA
SOFIA INDRA  Presentation to AICIASOFIA INDRA  Presentation to AICIA
SOFIA INDRA Presentation to AICIASofia Eu
 
SOFIA INDRA ATC2011 Virtual Wall Poster
SOFIA INDRA ATC2011 Virtual Wall PosterSOFIA INDRA ATC2011 Virtual Wall Poster
SOFIA INDRA ATC2011 Virtual Wall PosterSofia Eu
 
SOFIA project INDRA NEO Publication
SOFIA project INDRA NEO PublicationSOFIA project INDRA NEO Publication
SOFIA project INDRA NEO PublicationSofia Eu
 
Cross-project collaboration leaflet: SOFIA/SMARCOS/CHIRON
Cross-project collaboration leaflet: SOFIA/SMARCOS/CHIRONCross-project collaboration leaflet: SOFIA/SMARCOS/CHIRON
Cross-project collaboration leaflet: SOFIA/SMARCOS/CHIRONSofia Eu
 
SOFIA/SMARCOS/CHIRON Poster ARTEMIS & ITEA2 Co-Summit 2011
SOFIA/SMARCOS/CHIRON Poster ARTEMIS & ITEA2 Co-Summit 2011SOFIA/SMARCOS/CHIRON Poster ARTEMIS & ITEA2 Co-Summit 2011
SOFIA/SMARCOS/CHIRON Poster ARTEMIS & ITEA2 Co-Summit 2011Sofia Eu
 
SOFIA Pilots Brochure Final Set
SOFIA Pilots Brochure Final SetSOFIA Pilots Brochure Final Set
SOFIA Pilots Brochure Final SetSofia Eu
 
Smart LED Lighting for Power Management in a Building
Smart LED Lighting for Power Management in a BuildingSmart LED Lighting for Power Management in a Building
Smart LED Lighting for Power Management in a BuildingSofia Eu
 
SOFIA Vvirtual Wall Pilot Poster
SOFIA Vvirtual Wall Pilot PosterSOFIA Vvirtual Wall Pilot Poster
SOFIA Vvirtual Wall Pilot PosterSofia Eu
 
SOFIA Pilots Set Brochure
SOFIA Pilots Set BrochureSOFIA Pilots Set Brochure
SOFIA Pilots Set BrochureSofia Eu
 
SOFIA PILOTS POSTER 8th European ITS Congress, Lyon - France
SOFIA PILOTS POSTER 8th European ITS Congress, Lyon - France SOFIA PILOTS POSTER 8th European ITS Congress, Lyon - France
SOFIA PILOTS POSTER 8th European ITS Congress, Lyon - France Sofia Eu
 
SOFIA PILOTS BROCHURE 8th European ITS Congress, Lyon - France
SOFIA PILOTS BROCHURE 8th European ITS Congress, Lyon - France SOFIA PILOTS BROCHURE 8th European ITS Congress, Lyon - France
SOFIA PILOTS BROCHURE 8th European ITS Congress, Lyon - France Sofia Eu
 
SOFIA Newsletter 1st Issue May 2011
SOFIA Newsletter 1st Issue May 2011SOFIA Newsletter 1st Issue May 2011
SOFIA Newsletter 1st Issue May 2011Sofia Eu
 
SOFIA - Interactive Quality Visualization (IQVis)- VTT
SOFIA - Interactive Quality Visualization (IQVis)- VTTSOFIA - Interactive Quality Visualization (IQVis)- VTT
SOFIA - Interactive Quality Visualization (IQVis)- VTTSofia Eu
 
SOFIA Poster - ARTEMIS & ITEA co-Summit 2010
SOFIA Poster - ARTEMIS & ITEA co-Summit 2010SOFIA Poster - ARTEMIS & ITEA co-Summit 2010
SOFIA Poster - ARTEMIS & ITEA co-Summit 2010Sofia Eu
 
SOFIA - ARTEMIS & ITEA co-Summit 2010
SOFIA - ARTEMIS & ITEA co-Summit 2010SOFIA - ARTEMIS & ITEA co-Summit 2010
SOFIA - ARTEMIS & ITEA co-Summit 2010Sofia Eu
 
SOFIA - M3 Smart Space Infrastructure. VTT/NOKIA
SOFIA - M3 Smart Space Infrastructure. VTT/NOKIASOFIA - M3 Smart Space Infrastructure. VTT/NOKIA
SOFIA - M3 Smart Space Infrastructure. VTT/NOKIASofia Eu
 
SOFIA - Overview Brochure
SOFIA - Overview BrochureSOFIA - Overview Brochure
SOFIA - Overview BrochureSofia Eu
 

Mais de Sofia Eu (20)

SOFIA Project Brochure Pilots Set
SOFIA Project Brochure Pilots Set SOFIA Project Brochure Pilots Set
SOFIA Project Brochure Pilots Set
 
SOFIA Poster ATC 2012
SOFIA Poster ATC 2012SOFIA Poster ATC 2012
SOFIA Poster ATC 2012
 
SOFIA ATC 2011_artemis_magazine
SOFIA ATC 2011_artemis_magazineSOFIA ATC 2011_artemis_magazine
SOFIA ATC 2011_artemis_magazine
 
SOFIA INDRA Presentation to AICIA
SOFIA INDRA  Presentation to AICIASOFIA INDRA  Presentation to AICIA
SOFIA INDRA Presentation to AICIA
 
SOFIA INDRA ATC2011 Virtual Wall Poster
SOFIA INDRA ATC2011 Virtual Wall PosterSOFIA INDRA ATC2011 Virtual Wall Poster
SOFIA INDRA ATC2011 Virtual Wall Poster
 
SOFIA project INDRA NEO Publication
SOFIA project INDRA NEO PublicationSOFIA project INDRA NEO Publication
SOFIA project INDRA NEO Publication
 
Cross-project collaboration leaflet: SOFIA/SMARCOS/CHIRON
Cross-project collaboration leaflet: SOFIA/SMARCOS/CHIRONCross-project collaboration leaflet: SOFIA/SMARCOS/CHIRON
Cross-project collaboration leaflet: SOFIA/SMARCOS/CHIRON
 
SOFIA/SMARCOS/CHIRON Poster ARTEMIS & ITEA2 Co-Summit 2011
SOFIA/SMARCOS/CHIRON Poster ARTEMIS & ITEA2 Co-Summit 2011SOFIA/SMARCOS/CHIRON Poster ARTEMIS & ITEA2 Co-Summit 2011
SOFIA/SMARCOS/CHIRON Poster ARTEMIS & ITEA2 Co-Summit 2011
 
SOFIA Pilots Brochure Final Set
SOFIA Pilots Brochure Final SetSOFIA Pilots Brochure Final Set
SOFIA Pilots Brochure Final Set
 
Smart LED Lighting for Power Management in a Building
Smart LED Lighting for Power Management in a BuildingSmart LED Lighting for Power Management in a Building
Smart LED Lighting for Power Management in a Building
 
SOFIA Vvirtual Wall Pilot Poster
SOFIA Vvirtual Wall Pilot PosterSOFIA Vvirtual Wall Pilot Poster
SOFIA Vvirtual Wall Pilot Poster
 
SOFIA Pilots Set Brochure
SOFIA Pilots Set BrochureSOFIA Pilots Set Brochure
SOFIA Pilots Set Brochure
 
SOFIA PILOTS POSTER 8th European ITS Congress, Lyon - France
SOFIA PILOTS POSTER 8th European ITS Congress, Lyon - France SOFIA PILOTS POSTER 8th European ITS Congress, Lyon - France
SOFIA PILOTS POSTER 8th European ITS Congress, Lyon - France
 
SOFIA PILOTS BROCHURE 8th European ITS Congress, Lyon - France
SOFIA PILOTS BROCHURE 8th European ITS Congress, Lyon - France SOFIA PILOTS BROCHURE 8th European ITS Congress, Lyon - France
SOFIA PILOTS BROCHURE 8th European ITS Congress, Lyon - France
 
SOFIA Newsletter 1st Issue May 2011
SOFIA Newsletter 1st Issue May 2011SOFIA Newsletter 1st Issue May 2011
SOFIA Newsletter 1st Issue May 2011
 
SOFIA - Interactive Quality Visualization (IQVis)- VTT
SOFIA - Interactive Quality Visualization (IQVis)- VTTSOFIA - Interactive Quality Visualization (IQVis)- VTT
SOFIA - Interactive Quality Visualization (IQVis)- VTT
 
SOFIA Poster - ARTEMIS & ITEA co-Summit 2010
SOFIA Poster - ARTEMIS & ITEA co-Summit 2010SOFIA Poster - ARTEMIS & ITEA co-Summit 2010
SOFIA Poster - ARTEMIS & ITEA co-Summit 2010
 
SOFIA - ARTEMIS & ITEA co-Summit 2010
SOFIA - ARTEMIS & ITEA co-Summit 2010SOFIA - ARTEMIS & ITEA co-Summit 2010
SOFIA - ARTEMIS & ITEA co-Summit 2010
 
SOFIA - M3 Smart Space Infrastructure. VTT/NOKIA
SOFIA - M3 Smart Space Infrastructure. VTT/NOKIASOFIA - M3 Smart Space Infrastructure. VTT/NOKIA
SOFIA - M3 Smart Space Infrastructure. VTT/NOKIA
 
SOFIA - Overview Brochure
SOFIA - Overview BrochureSOFIA - Overview Brochure
SOFIA - Overview Brochure
 

SOFIA - Smart M3 hands-on Training. NOKIA

  • 1. Smart-M3 hands on training Hannu 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. Outline • Smart-M3 Qt Core API • Exercise Ontology • Exercise 1: • Discover available SmartSpaces • Join/Leave • Exercise 2: • Subscription • Exercise 3: • Insert/remove information Company Confidential 2 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  • 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 • Python Company Confidential 3 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  • 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 information Company Confidential 4 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  • 5. Hello world ontology “light” “sky” “land” “sea” Space has “sun” “moon” “stars” “World” “animals” “man_and_woman” Company Confidential 5 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  • 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 SmartSpace Company Confidential 6 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  • 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 QtCreator Company Confidential 7 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  • 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 results Company Confidential 8 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  • 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 items Company Confidential 9 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL
  • 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 SmartSpace Company Confidential 10 © 2008 Nokia Smart-M3 hands on.ppt / 2009-11-05 / HL