ALNotificationManager API¶
NAOqi Core - Overview | API | NotificationInfo
Namespace : AL
#include <alproxies/alnotificationmanagerproxy.h>
Method Group list¶
As any module, this module inherits methods from ALModule API. It also has the following specific methods:
-
class
ALNotificationManagerProxy
¶
Event list¶
-
int
ALNotificationManagerProxy::
add
(const AL::ALValue& notification)¶ Adds a new Notification. As soon as it is added, the event
notificationAdded()
is raised.Parameters: - notification – The notification contained in an ALValue (see NotificationInfo).
Returns: The notification identifier.
#! /usr/bin/env python # -*- encoding: UTF-8 -*- """Example: Use add Method""" import qi import argparse import sys def main(session): """ This example uses the add method. """ # Get the service ALNotificationManager. notif_mng_service = session.service("ALNotificationManager") # Add a notification. notificationId = notif_mng_service.add({"message": "Hello World!", "severity": "info", "removeOnRead": True}) print "Notification ID: " + str(notificationId) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--ip", type=str, default="127.0.0.1", help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.") parser.add_argument("--port", type=int, default=9559, help="Naoqi port number") args = parser.parse_args() session = qi.Session() try: session.connect("tcp://" + args.ip + ":" + str(args.port)) except RuntimeError: print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n" "Please check your script arguments. Run with -h option for help.") sys.exit(1) main(session)
-
void
ALNotificationManagerProxy::
remove
(const int& notificationId)¶ Removes a Notification. As soon as it is removed, the event
notificationRemoved()
is raised.Parameters: - notificationId – Identifier of the notification to remove.
#! /usr/bin/env python # -*- encoding: UTF-8 -*- """Example: Use remove Method""" import qi import argparse import sys def main(session): """ This example uses the remove method. """ # Get the service ALNotificationManager. notif_mng_service = session.service("ALNotificationManager") # Add new notification notificationId = notif_mng_service.add({"message": "Hello World!", "severity": "info", "removeOnRead": True}) print "Notification ID: " + str(notificationId) # Delete the notification notif_mng_service.remove(notificationId) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--ip", type=str, default="127.0.0.1", help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.") parser.add_argument("--port", type=int, default=9559, help="Naoqi port number") args = parser.parse_args() session = qi.Session() try: session.connect("tcp://" + args.ip + ":" + str(args.port)) except RuntimeError: print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n" "Please check your script arguments. Run with -h option for help.") sys.exit(1) main(session)
-
AL::ALValue
ALNotificationManagerProxy::
notification
(const int& notificationId)¶ Returns the NotificationInfo corresponding to the given notification identifier. The notification is represented as an ALValue (see NotificationInfo).
Parameters: - notificationId – Identifier of the notification.
Returns: The notificationInfo of the given notification identifier.
Throw: An ALError, if the identifier doesn’t exist.
-
AL::ALValue
ALNotificationManagerProxy::
notifications
()¶ Returns the list of pending NotificationInfos.
Returns: An array of NotificationInfos contained in an ALValue (see NotificationInfo). #! /usr/bin/env python # -*- encoding: UTF-8 -*- """Example: Use notifications Method""" import qi import argparse import sys def main(session): """ This example uses the notifications method. """ # Get the service ALNotificationManager. notif_mng_service = session.service("ALNotificationManager") # Get the notifications. notifications = notif_mng_service.notifications() for notification in notifications: notifDict = dict(notification) print "Notification ID: " + str(notifDict["id"]) print "\tMessage: " + notifDict["message"] print "\tSeverity: " + notifDict["severity"] print "\tRemove On Read: " + str(notifDict["removeOnRead"]) print "-----------\n" if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--ip", type=str, default="127.0.0.1", help="Robot IP address. On robot or Local Naoqi: use '127.0.0.1'.") parser.add_argument("--port", type=int, default=9559, help="Naoqi port number") args = parser.parse_args() session = qi.Session() try: session.connect("tcp://" + args.ip + ":" + str(args.port)) except RuntimeError: print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n" "Please check your script arguments. Run with -h option for help.") sys.exit(1) main(session)
ALNotificationManagerProxy Events¶
-
Event:callback(std::string eventName, int notificationId, std::string subscriberIdentifier)¶
"notificationAdded"
Raised when a new notification has been added.
Parameters: - eventName (std::string) – “notificationAdded”
- notificationId – The identifier of the added notification.
- subscriberIdentifier (std::string) –
-
Event:callback(std::string eventName, int notificationId, std::string subscriberIdentifier)¶
"notificationRemoved"
Raised when a notification has been removed. It can be discarded either if it is read or not valid anymore.
Parameters: - eventName (std::string) – “notificationRemoved”
- notificationId – The identifier of the removed notification.
- subscriberIdentifier (std::string) –