Пример #1
0
    def getDeviceName(self):
        """Return the name of this Phidget.
        
        This is a string that describes the device. For example, a PhidgetInterfaceKit 
        could be described as "Phidget InterfaceKit 8/8/8", or "Phidget InterfaceKit 0/0/4", among others, depending on the specific device.
        
        This lets you determine the specific type of a Phidget, within the broader classes of Phidgets, such as PhidgetInterfaceKit, or PhidgetServo.
        
        Returns:
            The name of the device <string>.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this phidget is not opened or attached.
        """
        ptr = c_char_p()

        try:
            result = PhidgetLibrary.getDll().CPhidget_getDeviceName(self.handle, byref(ptr))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return prepOutput(ptr)
Пример #2
0
    def getServerAddress(self):
        """Returns the Address of a Phidget Webservice.
        
        Returns the Address of a Phidget Webservice when this Phidget was opened as remote.
        This may be an IP Address or a hostname.
        
        Returns:
            The Address of the Webservice <string>.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: if this Phidget was open opened as a remote Phidget.
        """
        serverAddr = c_char_p()
        port = c_int()

        try:
            result = PhidgetLibrary.getDll().CPhidget_getServerAddress(self.handle, byref(serverAddr), byref(port))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return prepOutput(serverAddr)
Пример #3
0
 def getDeviceName(self):
     """Return the name of this Phidget.
     
     This is a string that describes the device. For example, a PhidgetInterfaceKit 
     could be described as "Phidget InterfaceKit 8/8/8", or "Phidget InterfaceKit 0/0/4", among others, depending on the specific device.
     
     This lets you determine the specific type of a Phidget, within the broader classes of Phidgets, such as PhidgetInterfaceKit, or PhidgetServo.
     
     Returns:
         The name of the device <string>.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this phidget is not opened or attached.
     """
     ptr = c_char_p()
     
     try:
         result = PhidgetLibrary.getDll().CPhidget_getDeviceName(self.handle, byref(ptr))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return prepOutput(ptr)
Пример #4
0
 def getServerAddress(self):
     """Returns the Address of a Phidget Webservice.
     
     Returns the Address of a Phidget Webservice when this Phidget was opened as remote.
     This may be an IP Address or a hostname.
     
     Returns:
         The Address of the Webservice <string>.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: if this Phidget was open opened as a remote Phidget.
     """
     serverAddr = c_char_p()
     port = c_int()
     
     try:
         result = PhidgetLibrary.getDll().CPhidget_getServerAddress(self.handle, byref(serverAddr), byref(port))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return prepOutput(serverAddr)
Пример #5
0
 def getErrorDescription(self, code):
     """
     """
     description = c_char_p()
     
     try:
         result = self.dll.CPhidget_getErrorDescription(c_int(code), byref(description))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return prepOutput(description)
Пример #6
0
    def getErrorDescription(self, code):
        """
        """
        description = c_char_p()

        try:
            result = self.dll.CPhidget_getErrorDescription(
                c_int(code), byref(description))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return prepOutput(description)
Пример #7
0
 def __init__(self, code):
     if sys.platform == 'win32':
         self.dll = windll.LoadLibrary("phidget21.dll")
     elif sys.platform == 'darwin':
         self.dll = cdll.LoadLibrary("/Library/Frameworks/Phidget21.framework/Versions/Current/Phidget21")
     elif sys.platform == 'linux2':
         self.dll = cdll.LoadLibrary("libphidget21.so.0")
     else:
         self.dll = None
         print("Platform not supported")
     
     if(self.dll != None):
         self.code = code
         description = c_char_p()
         result = self.dll.CPhidget_getErrorDescription(c_int(code), byref(description))
         self.details = prepOutput(description)
Пример #8
0
    def __init__(self, code):
        if sys.platform == 'win32':
            self.dll = windll.LoadLibrary("phidget21.dll")
        elif sys.platform == 'darwin':
            self.dll = cdll.LoadLibrary(
                "/Library/Frameworks/Phidget21.framework/Versions/Current/Phidget21"
            )
        elif sys.platform == 'linux2':
            self.dll = cdll.LoadLibrary("libphidget21.so.0")
        else:
            self.dll = None
            print("Platform not supported")

        if (self.dll != None):
            self.code = code
            description = c_char_p()
            result = self.dll.CPhidget_getErrorDescription(
                c_int(code), byref(description))
            self.details = prepOutput(description)
Пример #9
0
    def getServerID(self):
        """Returns the Server ID of a Phidget Webservice.
        
        Returns the Server ID of a Phidget Webservice when this Phidget was opened as remote.
        This is an arbitrary server identifier, independant of IP address and Port.
        
        Returns:
            The ServerID of the Webservice <string>.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: if this Phidget was open opened as a remote Phidget.
        """
        serverID = c_char_p()

        try:
            result = PhidgetLibrary.getDll().CPhidget_getServerID(self.handle, byref(serverID))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return prepOutput(serverID)
Пример #10
0
    def getLibraryVersion(self):
        """Returns the library version.
        
        This is the library version of the underlying phidget21 C library and not the version of the Python wrapper module implementation.
        The version is retured as a string which contains the version number and build date.
        
        Returns:
            The Library Version <string>.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened and attached.
        """
        libVer = c_char_p()

        try:
            result = PhidgetLibrary.getDll().CPhidget_getLibraryVersion(byref(libVer))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return prepOutput(libVer)
Пример #11
0
    def getDeviceType(self):
        """Return the device type of this Phidget.
        
        This is a string that describes the device as a class of devices. For example, all PhidgetInterfaceKit Phidgets
        will returns the String "PhidgetInterfaceKit".
        
        Returns:
            The Device Type <string>.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If there is no Phidget attached.
        """
        ptr = c_char_p()

        try:
            result = PhidgetLibrary.getDll().CPhidget_getDeviceType(self.handle, byref(ptr))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return prepOutput(ptr)
Пример #12
0
    def getDeviceLabel(self):
        """Gets the label associated with this Phidget.
        
        This label is a String - up to ten digits - that is stored in the Flash memory of newer Phidgets.
        This label can be set programatically (see setDeviceLabel), and is non-volatile - so it is remembered even if the Phidget is unplugged.
        
        Returns:
            The label associated with this Phidget <string>.
        
        Exceptions:
            RuntimeError - If current platform is not supported/phidget c dll cannot be found
            PhidgetException: If this Phidget is not opened and attached, or if this Phidget does not support labels.
        """
        label = c_char_p()

        try:
            result = PhidgetLibrary.getDll().CPhidget_getDeviceLabel(self.handle, byref(label))
        except RuntimeError:
            raise

        if result > 0:
            raise PhidgetException(result)
        else:
            return prepOutput(label)
Пример #13
0
 def getServerID(self):
     """Returns the Server ID of a Phidget Webservice.
     
     Returns the Server ID of a Phidget Webservice when this Phidget was opened as remote.
     This is an arbitrary server identifier, independant of IP address and Port.
     
     Returns:
         The ServerID of the Webservice <string>.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: if this Phidget was open opened as a remote Phidget.
     """
     serverID = c_char_p()
     
     try:
         result = PhidgetLibrary.getDll().CPhidget_getServerID(self.handle, byref(serverID))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return prepOutput(serverID)
Пример #14
0
 def getLibraryVersion(self):
     """Returns the library version.
     
     This is the library version of the underlying phidget21 C library and not the version of the Python wrapper module implementation.
     The version is retured as a string which contains the version number and build date.
     
     Returns:
         The Library Version <string>.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached.
     """
     libVer = c_char_p()
     
     try:
         result = PhidgetLibrary.getDll().CPhidget_getLibraryVersion(byref(libVer))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return prepOutput(libVer)
Пример #15
0
 def getDeviceType(self):
     """Return the device type of this Phidget.
     
     This is a string that describes the device as a class of devices. For example, all PhidgetInterfaceKit Phidgets
     will returns the String "PhidgetInterfaceKit".
     
     Returns:
         The Device Type <string>.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If there is no Phidget attached.
     """
     ptr = c_char_p()
     
     try:
         result = PhidgetLibrary.getDll().CPhidget_getDeviceType(self.handle, byref(ptr))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return prepOutput(ptr)
Пример #16
0
 def getDeviceLabel(self):
     """Gets the label associated with this Phidget.
     
     This label is a String - up to ten digits - that is stored in the Flash memory of newer Phidgets.
     This label can be set programatically (see setDeviceLabel), and is non-volatile - so it is remembered even if the Phidget is unplugged.
     
     Returns:
         The label associated with this Phidget <string>.
     
     Exceptions:
         RuntimeError - If current platform is not supported/phidget c dll cannot be found
         PhidgetException: If this Phidget is not opened and attached, or if this Phidget does not support labels.
     """
     label = c_char_p()
     
     try:
         result = PhidgetLibrary.getDll().CPhidget_getDeviceLabel(self.handle, byref(label))
     except RuntimeError:
         raise
     
     if result > 0:
         raise PhidgetException(result)
     else:
         return prepOutput(label)