def do_ReadPropertyRequest(self, apdu):
        """Return the value of some property of one of our objects."""
        if _debug: ReadWritePropertyServices._debug("do_ReadPropertyRequest %r", apdu)

        # extract the object identifier
        objId = apdu.objectIdentifier

        # check for wildcard
        if (objId == ('device', 4194303)) and self.localDevice is not None:
            if _debug: ReadWritePropertyServices._debug("    - wildcard device identifier")
            objId = self.localDevice.objectIdentifier

        # get the object
        obj = self.get_object_id(objId)
        if _debug: ReadWritePropertyServices._debug("    - object: %r", obj)

        if not obj:
            raise ExecutionError(errorClass='object', errorCode='unknownObject')

        try:
            # get the datatype
            datatype = obj.get_datatype(apdu.propertyIdentifier)
            if _debug: ReadWritePropertyServices._debug("    - datatype: %r", datatype)

            # get the value
            value = obj.ReadProperty(apdu.propertyIdentifier, apdu.propertyArrayIndex)
            if _debug: ReadWritePropertyServices._debug("    - value: %r", value)
            if value is None:
                raise PropertyError(apdu.propertyIdentifier)

            # change atomic values into something encodeable
            if issubclass(datatype, Atomic):
                value = datatype(value)
            elif issubclass(datatype, Array) and (apdu.propertyArrayIndex is not None):
                if apdu.propertyArrayIndex == 0:
                    value = Unsigned(value)
                elif issubclass(datatype.subtype, Atomic):
                    value = datatype.subtype(value)
                elif not isinstance(value, datatype.subtype):
                    raise TypeError("invalid result datatype, expecting %r and got %r" \
                        % (datatype.subtype.__name__, type(value).__name__))
            elif not isinstance(value, datatype):
                raise TypeError("invalid result datatype, expecting %r and got %r" \
                    % (datatype.__name__, type(value).__name__))
            if _debug: ReadWritePropertyServices._debug("    - encodeable value: %r", value)

            # this is a ReadProperty ack
            resp = ReadPropertyACK(context=apdu)
            resp.objectIdentifier = objId
            resp.propertyIdentifier = apdu.propertyIdentifier
            resp.propertyArrayIndex = apdu.propertyArrayIndex

            # save the result in the property value
            resp.propertyValue = Any()
            resp.propertyValue.cast_in(value)
            if _debug: ReadWritePropertyServices._debug("    - resp: %r", resp)

        except PropertyError:
            raise ExecutionError(errorClass='property', errorCode='unknownProperty')

        # return the result
        self.response(resp)
def do_ReadPropertyRequest ( self , apdu ) : if _debug : ReadWritePropertyServices . _debug ( "do_ReadPropertyRequest %r" , apdu ) objId = apdu . objectIdentifier if ( objId == ( 'device' , 4194303 ) ) and self . localDevice is not None : if _debug : ReadWritePropertyServices . _debug ( "    - wildcard device identifier" ) objId = self . localDevice . objectIdentifier obj = self . get_object_id ( objId ) if _debug : ReadWritePropertyServices . _debug ( "    - object: %r" , obj ) if not obj : raise ExecutionError ( errorClass = 'object' , errorCode = 'unknownObject' ) try : datatype = obj . get_datatype ( apdu . propertyIdentifier ) if _debug : ReadWritePropertyServices . _debug ( "    - datatype: %r" , datatype ) value = obj . ReadProperty ( apdu . propertyIdentifier , apdu . propertyArrayIndex ) if _debug : ReadWritePropertyServices . _debug ( "    - value: %r" , value ) if value is None : raise PropertyError ( apdu . propertyIdentifier ) if issubclass ( datatype , Atomic ) : value = datatype ( value ) elif issubclass ( datatype , Array ) and ( apdu . propertyArrayIndex is not None ) : if apdu . propertyArrayIndex == 0 : value = Unsigned ( value ) elif issubclass ( datatype . subtype , Atomic ) : value = datatype . subtype ( value ) elif not isinstance ( value , datatype . subtype ) : raise TypeError ( "invalid result datatype, expecting %r and got %r" % ( datatype . subtype . __name__ , type ( value ) . __name__ ) ) elif not isinstance ( value , datatype ) : raise TypeError ( "invalid result datatype, expecting %r and got %r" % ( datatype . __name__ , type ( value ) . __name__ ) ) if _debug : ReadWritePropertyServices . _debug ( "    - encodeable value: %r" , value ) resp = ReadPropertyACK ( context = apdu ) resp . objectIdentifier = objId resp . propertyIdentifier = apdu . propertyIdentifier resp . propertyArrayIndex = apdu . propertyArrayIndex resp . propertyValue = Any ( ) resp . propertyValue . cast_in ( value ) if _debug : ReadWritePropertyServices . _debug ( "    - resp: %r" , resp ) except PropertyError : raise ExecutionError ( errorClass = 'property' , errorCode = 'unknownProperty' ) self . response ( resp )
Return the value of some property of one of our objects.