def __init__(self, *args): BIPSimpleApplication.__init__(Mock()) self.elementService = Mock() #self.ResponseQueue = Mock() #self.ResponseQueue.get.return_value = ([21, 'degreesCelcius'], Event()) iocb = IOCB() apdu = ReadPropertyMultipleACK(listOfReadAccessResults=[ ReadAccessResult( objectIdentifier=('analogValue', 1), listOfResults=[ ReadAccessResultElement( propertyIdentifier='presentValue', readResult=ReadAccessResultElementChoice( propertyValue=Any(Real(21.0)), )), ReadAccessResultElement( propertyIdentifier='units', readResult=ReadAccessResultElementChoice( propertyValue=Any(Enumerated(62)), )), ], ) ]) iocb.complete(apdu) self.request = Mock() self.request.return_value = iocb
def ReadPropertyToResultElement(obj, propertyIdentifier, propertyArrayIndex=None): """Read the specified property of the object, with the optional array index, and cast the result into an Any object.""" if _debug: ReadPropertyToResultElement._debug( "ReadPropertyToResultElement %s %r %r", obj, propertyIdentifier, propertyArrayIndex) # save the result in the property value read_result = ReadAccessResultElementChoice() try: read_result.propertyValue = ReadPropertyToAny(obj, propertyIdentifier, propertyArrayIndex) if _debug: ReadPropertyToResultElement._debug(" - success") except PropertyError as error: if _debug: ReadPropertyToResultElement._debug(" - error: %r", error) read_result.propertyAccessError = ErrorType( errorClass='property', errorCode='unknownProperty') except ExecutionError as error: if _debug: ReadPropertyToResultElement._debug(" - error: %r", error) read_result.propertyAccessError = ErrorType( errorClass=error.errorClass, errorCode=error.errorCode) # make an element for this value read_access_result_element = ReadAccessResultElement( propertyIdentifier=propertyIdentifier, propertyArrayIndex=propertyArrayIndex, readResult=read_result, ) if _debug: ReadPropertyToResultElement._debug( " - read_access_result_element: %r", read_access_result_element) # fini return read_access_result_element
read_result = ReadAccessResultElementChoice() try: read_result.propertyValue = ReadPropertyToAny(obj, propertyIdentifier, propertyArrayIndex) if _debug: ReadPropertyToResultElement._debug(" - success") except PropertyError, error: if _debug: ReadPropertyToResultElement._debug(" - error: %r", error) read_result.propertyAccessError = ErrorType(errorClass='property', errorCode='unknownProperty') except ExecutionError, error: if _debug: ReadPropertyToResultElement._debug(" - error: %r", error) read_result.propertyAccessError = ErrorType(errorClass=error.errorClass, errorCode=error.errorCode) # make an element for this value read_access_result_element = ReadAccessResultElement( propertyIdentifier=propertyIdentifier, propertyArrayIndex=propertyArrayIndex, readResult=read_result, ) if _debug: ReadPropertyToResultElement._debug(" - read_access_result_element: %r", read_access_result_element) # fini return read_access_result_element # # ReadPropertyMultipleApplication # @bacpypes_debugging class ReadPropertyMultipleApplication(BIPSimpleApplication): def __init__(self, *args, **kwargs):