Phidgets.Dictionary (version 2.1.9, July 14 2010)
index
 

Copyright 2010 Phidgets Inc.
This work is licensed under the Creative Commons Attribution 2.5 Canada License. 
To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ca/

 
Modules
       
sys
threading

 
Classes
       
Dictionary
DictionaryKeyChangeReason
KeyListener

 
class Dictionary
    This class represents the Phidget Dictionary.
 
The Phidget Dictionary is a service provided by the Phidget Webservice.
The Webservice maintains a centralized dictionary of key-value pairs that can be accessed and changed from any number of clients.
 
Note that the Webservice uses this dictionary to control access to Phidgets through the openRemote and openRemoteIP interfaces,
and as such, you should never add or modify a key that starts with /PSK/ or /PCK/, unless you want to explicitly modify Phidget
specific data -- and this is highly discouraged, as it's very easy to break things. Listening to these keys is fine if so desired.
 
The intended use for the dictionary is as a central repository for communication and persistent storage of data between several
client applications. As an example - a higher level interface exposed by one application -- which controls the Phidgets,
for others to access -- rather then every client talking directly to the Phidgets themselves.
 
The dictionary makes use of extended regular expressions for key matching.
 
  Methods defined here:
__del__(self)
__init__(self)
The Constructor Method for the Dictionary Class
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: If this Phidget is not opened.
addKey(self, key, value, persist=True)
Adds a new key to the Dictionary, or modifies the value of an existing key.
 
The key can only contain numbers, letters, "/", ".", "-", "_", and must begin with a letter, "_" or "/".
The value can contain any value.
 
The persistent value controls whether a key will stay in the dictionary after the client that created it disconnects.
If persist == False, the key is removed when the connection closes. Otherwise the key remains in the dictionary until it is explicitly removed.
 
Specifying the persist parameter is optional and will default to True if not provided when calling this method.
 
Parameters:
    key<string>: The key to add to the Dictionary.
    value<string>: The value to be associated with the key in the Dictionary.
    persist<boolean>: Flag to specify whether to make this Dictionary entry persistent or not.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: if the Phidget Webservice cannot be contacted
closeDictionary(self)
Closes this Dictionary.
 
This will shut down all threads dealing with this Dictionary and you won't recieve any more events.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: If this Dictionary is not opened.
getKey(self, key)
Gets the value for the provided key from the dictionary. If more then one key matches, only the first value is returned.
 
Parameters:
    key<string>: The key for the intry in the dictionary.
 
 Returns:
    The value from the entry in the dictionary.
 
Exceptions:
    RuntimeError: If current platform is not supported/phidget c dll cannot be found.
    PhidgetException: if this Dictionary was not opened, or the server is not connected.
getServerAddress(self)
Returns the Address of a Phidget Webservice when this Dictionary was opened as remote.
 
This may be an IP Address or a hostname.
 
Returns:
    The server address for the webservice <string>.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: if this Dictionary was not opened.
getServerID(self)
Returns the Server ID of a Phidget Webservice when this Dictionary was opened as remote.
 
This is an arbitrary server identifier, independant of IP address and Port.
 
Returns:
    The ServerID for the webservice <string>.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: if this Dictionary was not opened.
getServerPort(self)
Returns the Port of a Phidget Webservice when this Dictionary was opened as remote.
 
Returns:
    The server port for the webservice.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: if this Dictionary was not opened.
isAttachedToServer(self)
Gets the attached status of this Dictionary.
 
Returns:
    The attached status of this Dictionary <boolean>.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: if this Dictionary was not opened.
openRemote(self, serverID, password='')
Open this Dictionary remotely using a Server ID, and securely using a password.
 
This password can be set as a parameter when starting the Phidget Webservice.
The use of a password is optional and calling the function without providing a password will
connect normally.
 
Parameters:
    serverID<string>: ServerID of the Phidget Webservice.
    password<string>: The secure password for the Phidget Webservice.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: if the Phidget Webservice cannot be contacted
openRemoteIP(self, IPAddress, port, password='')
Open this Dictionary remotely using an IP Address and port, and securely using a password.
 
This password can be set as a parameter when starting the Phidget Webservice.
The use of a password is optional and calling the function without providing a password will
connect normally.
 
Parameters:
    IPAddress<string>: IP Address or hostname of the Phidget Webservice
    port<int>: Port of the Phidget Webservice
    password<string>: The secure password for the Phidget Webservice
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: if the Phidget Webservice cannot be contacted
removeKey(self, pattern)
Removes a key, or set of keys, from the Dictionary.
 
The key name is a regular expressions pattern, and so care must be taken to only have it match the specific keys you want to remove.
 
Parameters:
    pattern<string>: The regular expression pattern to match to the keys you want to remove from the Dictionary.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: if the Phidget Webservice cannot be contacted
setErrorHandler(self, errorhandler)
Sets the Error Event Handler.
 
Parameters:
    errorhandler: hook to the errorhandler callback function.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException
setServerConnectHandler(self, serverConnectHandler)
Sets the Server Connect event handler.
 
The serverConnect handler is a method that will be called when a connection to a server is made.
 
Parameters:
    serverConnectHandler: hook to the serverConnectHandler callback function.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException
setServerDisconnectHandler(self, serverDisconnectHandler)
Sets the Server Disconnect Event Handler.
 
The serverDisconnect handler is a method that will be called when a connection to a server is terminated.
 
Parameters:
    serverDisconnectHandler: hook to the serverDisconnectHandler callback function.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException

 
class DictionaryKeyChangeReason
    This is an enumeration for the key change reasons to make checks and setting more straightforward and readable
 
  Data and other attributes defined here:
PHIDGET_DICTIONARY_CURRENT_VALUE = 4
PHIDGET_DICTIONARY_ENTRY_ADDED = 2
PHIDGET_DICTIONARY_ENTRY_REMOVING = 3
PHIDGET_DICTIONARY_VALUE_CHANGED = 1

 
class KeyListener
    This class represents a key listener.
 
This key listener is used, along with the Dictionary object,
to set up listener for specific keys, or groups of keys.
Events are available for key add or change, and for key removal.
 
  Methods defined here:
__init__(self, dict, keyPattern)
The Constructor Method for the KeyListener Class
 
Creates a new key listener, for a specific pattern, on a specific dictionary object.
getDictionary(self)
Returns the Dictionary handle that this listener is listening on.
setKeyChangeHandler(self, keyChangeHandler)
Sets the KeyChange event handler.
 
Parameters:
    keyChangeHandler: hook to the keyChangeHandler callback function.
setKeyRemovalListener(self, keyRemovalHandler)
Sets the KeyRemoval event handler.
 
Parameters:
    keyRemovalHandler: hook to the keyRemovalHandler callback function.
start(self)
Start this key listener.
 
This method should not be called until the coresponding dictionary is connected.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: If this Dictionary is not opened.
stop(self)
Stop this key listener.
 
Exceptions:
    RuntimeError - If current platform is not supported/phidget c dll cannot be found
    PhidgetException: If this Dictionary is not opened.

 
Functions
       
FormatError(...)
FormatError([integer]) -> string
 
Convert a win32 error code into a string. If the error code is not
given, the return value of a call to GetLastError() is used.
POINTER(...)
addressof(...)
addressof(C instance) -> integer
Return the address of the C instance internal buffer
alignment(...)
alignment(C type) -> integer
alignment(C instance) -> integer
Return the alignment requirements of a C instance
byref(...)
byref(C instance[, offset=0]) -> byref-object
Return a pointer lookalike to a C instance, only usable
as function argument
get_errno(...)
get_last_error(...)
pointer(...)
resize(...)
Resize the memory buffer of a ctypes instance
set_conversion_mode(...)
set_conversion_mode(encoding, errors) -> (previous-encoding, previous-errors)
 
Set the encoding and error handling ctypes uses when converting
between unicode and strings.  Returns the previous values.
set_errno(...)
set_last_error(...)
sizeof(...)
sizeof(C type) -> integer
sizeof(C instance) -> integer
Return the size in bytes of a C instance

 
Data
        DEFAULT_MODE = 0
GetLastError = <_FuncPtr object at 0x009C4990>
RTLD_GLOBAL = 0
RTLD_LOCAL = 0
__author__ = 'Adam Stelmack'
__date__ = 'July 14 2010'
__package__ = 'Phidgets'
__version__ = '2.1.9'
cdll = <ctypes.LibraryLoader object at 0x00AF68B0>
memmove = <CFunctionType object at 0x009C4A08>
memset = <CFunctionType object at 0x009C4BE8>
oledll = <ctypes.LibraryLoader object at 0x00AF6950>
pydll = <ctypes.LibraryLoader object at 0x00AF68D0>
pythonapi = <PyDLL 'python dll', handle 1e000000 at af68f0>
windll = <ctypes.LibraryLoader object at 0x00AF6910>

 
Author
        Adam Stelmack