当前位置: 首页>>代码示例>>Python>>正文


Python apdu.ReadPropertyRequest类代码示例

本文整理汇总了Python中bacpypes.apdu.ReadPropertyRequest的典型用法代码示例。如果您正苦于以下问题:Python ReadPropertyRequest类的具体用法?Python ReadPropertyRequest怎么用?Python ReadPropertyRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ReadPropertyRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: next_request

    def next_request(self):
        if _debug: ReadPointListApplication._debug("next_request")

        # check to see if we're done
        if not self.point_queue:
            if _debug: ReadPointListApplication._debug("    - done")
            stop()
            return

        # get the next request
        addr, obj_type, obj_inst, prop_id = self.point_queue.popleft()

        # build a request
        request = ReadPropertyRequest(
            objectIdentifier=(obj_type, obj_inst),
            propertyIdentifier=prop_id,
            )
        request.pduDestination = Address(addr)
        if _debug: ReadPointListApplication._debug("    - request: %r", request)

        # make an IOCB
        iocb = IOCB(request)

        # set a callback for the response
        iocb.add_callback(self.complete_request)
        if _debug: ReadPointListApplication._debug("    - iocb: %r", iocb)

        # send the request
        this_application.request_io(iocb)
开发者ID:DemandLogic,项目名称:bacpypes,代码行数:29,代码来源:MultipleReadProperty.py

示例2: test_readProperty

    def test_readProperty(self):

        request = ReadPropertyRequest(objectIdentifier=('analogInput', 14), propertyIdentifier=85)
        request.apduMaxResp = 1024
        request.apduInvokeID = 101
        apdu = APDU()
        request.encode(apdu)
        pdu = PDU()
        apdu.encode(pdu)
        buf_size = 1024
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.sendto(pdu.pduData, ('127.0.0.1', self.bacnet_server.server.server_port))
        data = s.recvfrom(buf_size)

        received_data = data[0]

        expected = ReadPropertyACK()
        expected.pduDestination = GlobalBroadcast()
        expected.apduInvokeID = 101
        expected.objectIdentifier = 14
        expected.objectName = 'AI 01'
        expected.propertyIdentifier = 85
        expected.propertyValue = Any(Real(68.0))

        exp_apdu = APDU()
        expected.encode(exp_apdu)
        exp_pdu = PDU()
        exp_apdu.encode(exp_pdu)

        self.assertEquals(exp_pdu.pduData, received_data)
开发者ID:jlthames2,项目名称:conpot,代码行数:30,代码来源:test_bacnet_server.py

示例3: create_ReadPropertyRequest

def create_ReadPropertyRequest(args):
    """
    Create a ReadPropertyRequest from a string
    """
    args = args.split()
    addr, obj_type, obj_inst, prop_id = args[:4]
    print(addr)

    if obj_type.isdigit():
        obj_type = int(obj_type)
    elif not get_object_class(obj_type):
        raise ValueError("unknown object type")

    obj_inst = int(obj_inst)

    datatype = get_datatype(obj_type, prop_id)
    if not datatype:
        raise ValueError("invalid property for object type")

    # build a request
    request = ReadPropertyRequest(
        objectIdentifier=(obj_type, obj_inst),
        propertyIdentifier=prop_id,
    )
    request.pduDestination = Address(addr)

    if len(args) == 5:
        request.propertyArrayIndex = int(args[4])

    return request
开发者ID:duck-hunt,项目名称:BAC0,代码行数:30,代码来源:test_ReadProperty.py

示例4: do_read

    def do_read(self, args):
        """read <addr> <type> <inst> <prop> [ <indx> ]"""
        args = args.split()
        if _debug: ReadWritePropertyConsoleCmd._debug("do_read %r", args)

        try:
            addr, obj_type, obj_inst, prop_id = args[:4]

            if obj_type.isdigit():
                obj_type = int(obj_type)
            elif not get_object_class(obj_type):
                raise ValueError, "unknown object type"

            obj_inst = int(obj_inst)

            datatype = get_datatype(obj_type, prop_id)
            if not datatype:
                raise ValueError, "invalid property for object type"

            # build a request
            request = ReadPropertyRequest(
                objectIdentifier=(obj_type, obj_inst),
                propertyIdentifier=prop_id,
                )
            request.pduDestination = Address(addr)

            if len(args) == 5:
                request.propertyArrayIndex = int(args[4])
            if _debug: ReadWritePropertyConsoleCmd._debug("    - request: %r", request)

            # give it to the application
            this_application.request(request)

        except Exception, e:
            ReadWritePropertyConsoleCmd._exception("exception: %r", e)
开发者ID:matthewhelt,项目名称:bacpypes,代码行数:35,代码来源:ReadWriteProperty.py

示例5: _do_read

	def _do_read(self, objtype, objinst, propname):

		try:
			addr, obj_type, obj_inst, prop_id = self._remote_addr, objtype, objinst, propname

			if obj_type.isdigit():
				obj_type = int(obj_type)
			elif not get_object_class(obj_type):
				raise ValueError, "unknown object type"

			obj_inst = int(obj_inst)

			datatype = get_datatype(obj_type, prop_id)
			if not datatype:
				raise ValueError, "invalid property for object type"

			# build a request
			request = ReadPropertyRequest(
				objectIdentifier=(obj_type, obj_inst),
				propertyIdentifier=prop_id,
				)
			if self._debug: print("requesting")
			request.pduDestination = Address(addr)

			#if len(args) == 5:
			#	request.propertyArrayIndex = int(args[4])
			#if _debug: ReadPropertyConsoleCmd._debug("	- request: %r", request)

			# give it to the application
			self._app.request(request)

		except Exception, e:
			print "exception:" + repr(e)
开发者ID:johnmoore,项目名称:SeniorDesign,代码行数:33,代码来源:HMIBacNETClient.py

示例6: build_rp_request

    def build_rp_request(self, args, arr_index=None, vendor_id=0, bacoid=None):
        addr, obj_type, obj_inst, prop_id = args[:4]
        vendor_id = vendor_id
        bacoid = bacoid

        if obj_type.isdigit():
            obj_type = int(obj_type)
        elif not get_object_class(obj_type):
            raise ValueError("unknown object type")

        obj_inst = int(obj_inst)

        if prop_id.isdigit():
            prop_id = int(prop_id)
        datatype = get_datatype(obj_type, prop_id, vendor_id=vendor_id)
        if not datatype:
            raise ValueError("invalid property for object type")

        # build a request
        request = ReadPropertyRequest(
            objectIdentifier=(obj_type, obj_inst),
            propertyIdentifier=prop_id,
            propertyArrayIndex=arr_index,
        )
        request.pduDestination = Address(addr)

        if len(args) == 5:
            request.propertyArrayIndex = int(args[4])
        self._log.debug("{:<20} {!r}".format("REQUEST", request))
        return request
开发者ID:ChristianTremblay,项目名称:BAC0,代码行数:30,代码来源:Read.py

示例7: build_rp_request

    def build_rp_request(self, args, arr_index = None):
        addr, obj_type, obj_inst, prop_id = args[:4]

        if obj_type.isdigit():
            obj_type = int(obj_type)
        elif not get_object_class(obj_type):
            raise ValueError("unknown object type")

        obj_inst = int(obj_inst)

        datatype = get_datatype(obj_type, prop_id)
        if not datatype:
            raise ValueError("invalid property for object type")

        # build a request
        request = ReadPropertyRequest(
            objectIdentifier=(obj_type, obj_inst),
            propertyIdentifier=prop_id,
            propertyArrayIndex=arr_index,
        )
        request.pduDestination = Address(addr)

        if len(args) == 5:
            request.propertyArrayIndex = int(args[4])
        log_debug(ReadProperty, "    - request: %r", request)

        return request              
开发者ID:duck-hunt,项目名称:BAC0,代码行数:27,代码来源:Read.py

示例8: do_read

    def do_read(self):
        try:
            # query the present value of 'MLNTZ.PNL.J.DEMAND'
            obj_type = datapoints[point_count]['obj_type']
            obj_inst = datapoints[point_count]['obj_inst']
            prop_id =  datapoints[point_count]['prop_id']
            
            if not get_object_class(obj_type):
                raise ValueError, "unknown object type: " + obj_type

            datatype = get_datatype(obj_type, prop_id)
            if not datatype:
                raise ValueError, "invalid property for object type: " + prop_id

            # build a request
            request = ReadPropertyRequest(
                objectIdentifier=(obj_type, obj_inst),
                propertyIdentifier=prop_id,
                )
            request.pduDestination = Address(self.foreign_addr)

            # give it to the application
            self.app.request(request)

        except Exception, e:
            _log.exception("exception: %r", e)
开发者ID:wentaoshang,项目名称:ndn-sensor,代码行数:26,代码来源:publish_bacnet.py

示例9: get_state_async

 def get_state_async(self, bac_app, address):
     request = ReadPropertyRequest(
             objectIdentifier=(self.object_type, self.instance_number),
             propertyIdentifier=self.property)        
     request.pduDestination = address
     iocb = IOCB(request)
     bac_app.request(iocb)
     return iocb.ioDefered
开发者ID:StephenCzarnecki,项目名称:volttron,代码行数:8,代码来源:bacnet.py

示例10: read_property

 def read_property(self, target_address, object_type, instance_number, property_name, property_index=None):
     request = ReadPropertyRequest(
         objectIdentifier=(object_type, instance_number),
         propertyIdentifier=property_name,
         propertyArrayIndex=property_index)
     request.pduDestination = Address(target_address)
     iocb = self.iocb_class(request)
     self.this_application.submit_request(iocb)
     bacnet_results = iocb.ioResult.get(10)
     return bacnet_results
开发者ID:schandrika,项目名称:volttron,代码行数:10,代码来源:agent.py

示例11: run

    def run(self):
        if _debug: ReadPointListThread._debug("run")
        global this_application

        # loop through the points
        for addr, obj_type, obj_inst, prop_id in self.point_queue:
            # build a request
            request = ReadPropertyRequest(
                objectIdentifier=(obj_type, obj_inst),
                propertyIdentifier=prop_id,
                )
            request.pduDestination = Address(addr)
            if _debug: ReadPointListThread._debug("    - request: %r", request)

            # make an IOCB
            iocb = IOCB(request)
            if _debug: ReadPointListThread._debug("    - iocb: %r", iocb)

            # give it to the application
            this_application.request_io(iocb)

            # wait for the response
            iocb.wait()

            if iocb.ioResponse:
                apdu = iocb.ioResponse

                # find the datatype
                datatype = get_datatype(apdu.objectIdentifier[0], apdu.propertyIdentifier)
                if _debug: ReadPointListThread._debug("    - datatype: %r", datatype)
                if not datatype:
                    raise TypeError("unknown datatype")

                # special case for array parts, others are managed by cast_out
                if issubclass(datatype, Array) and (apdu.propertyArrayIndex is not None):
                    if apdu.propertyArrayIndex == 0:
                        value = apdu.propertyValue.cast_out(Unsigned)
                    else:
                        value = apdu.propertyValue.cast_out(datatype.subtype)
                else:
                    value = apdu.propertyValue.cast_out(datatype)
                if _debug: ReadPointListThread._debug("    - value: %r", value)

                # save the value
                self.response_values.append(value)

            if iocb.ioError:
                if _debug: ReadPointListThread._debug("    - error: %r", iocb.ioError)
                self.response_values.append(iocb.ioError)

        # done
        stop()
开发者ID:DemandLogic,项目名称:bacpypes,代码行数:52,代码来源:MultipleReadPropertyThreaded.py

示例12: read

def read(device, portObject): 
    global this_application
    request_addr = device.getRequestAddress()    
    obj_type = portObject.getType()
    port = portObject.getPortNum()
    prop_id = portObject.getProp()
    maximumWait = 6  #seconds
    
    try: 

        #Jordan Trying to open thread in application

        #--------------------------read property request
        #verify datatype
       # print "Reading..."
        print request_addr, obj_type, port, prop_id
        
        if obj_type.isdigit():
            obj_type = int(obj_type)
        elif not get_object_class(obj_type):
            raise ValueError, "unknown object type"
            
                
        datatype = get_datatype(obj_type, prop_id)
        if not datatype:
            print ValueError, ": invalid property for object type"
        
        port = int(port)
        
        #build request
        request = ReadPropertyRequest(
            objectIdentifier=(obj_type, port),
            propertyIdentifier=prop_id,
            )
        request.pduDestination = Address(request_addr)
        time.sleep(.01)  #I dont know why, but this makes the code work correctly.
        #submit request
        this_application.request(request)
  #      print "Waiting for reply..."
        
        #wait for request
        wait = 0
        while this_application._Application__response_value == None and wait <= maximumWait:
            wait = wait + .01
            time.sleep(.01)
        returnVal = this_application._Application__response_value
    except Exception, e:
        returnVal = None
        print 'An error has happened (CPLRW 126): ' + str(e) + "\n"
开发者ID:als0062,项目名称:MECH4240,代码行数:49,代码来源:cplReadWrite.py

示例13: read_prop

def read_prop(app, address, obj_type, obj_inst, prop_id):
    request = ReadPropertyRequest(
                objectIdentifier=(obj_type, obj_inst),
                propertyIdentifier=prop_id)
    request.pduDestination = address
    
    result = this_application.make_request(request)
    if not isinstance(result, ReadPropertyACK):
        result.debug_contents(file=sys.stderr)
        raise TypeError("Error reading property")
    
    # find the datatype
    datatype = get_datatype(obj_type, prop_id)
    
    return result.propertyValue.cast_out(datatype)
开发者ID:StephenCzarnecki,项目名称:volttron,代码行数:15,代码来源:grab_bacnet_config.py

示例14: ReadProperty

def ReadProperty(
    object_type,
    object_instance,
    property_id,
    address,
    ):
    
    global application
    if (application == None):
        local_address = bacpypesip
        routers = None
        application = SynchronousApplication(local_address, routers)
    
    request = ReadPropertyRequest(objectIdentifier=(object_type,
                                  int(object_instance)),
                                  propertyIdentifier=property_id)
    request.pduDestination = Address(address)
    apdu = application.make_request(request)

    if isinstance(apdu, Error):
        sys.stdout.write('error: %s\n' % (apdu.errorCode, ))
        sys.stdout.flush()
        return 'Error!'
    elif isinstance(apdu, AbortPDU):

        apdu.debug_contents()
        return 'Error: AbortPDU'
    elif isinstance(request, ReadPropertyRequest) and isinstance(apdu,
            ReadPropertyACK):

        datatype = get_datatype(apdu.objectIdentifier[0],
                                apdu.propertyIdentifier)
        if not datatype:
            raise TypeError, 'unknown datatype'

        if issubclass(datatype, Array) and apdu.propertyArrayIndex\
             is not None:
            if apdu.propertyArrayIndex == 0:
                value = apdu.propertyValue.cast_out(Unsigned)
            else:
                value = apdu.propertyValue.cast_out(datatype.subtype)
        else:
            value = apdu.propertyValue.cast_out(datatype)
        if(value=="inactive"):
            value=0.0
        if (value=="active"):
            value=1.0
        return value
开发者ID:amarjeet-iiitd,项目名称:IIITD-Pervasive,代码行数:48,代码来源:SmapBacnetUtils.py

示例15: read

def read(obj_type, port, prop_id):

	try: 
		#--------------------------read property request
		#verify datatype
		print "Reading..."
		print obj_type, port, prop_id
		
		if obj_type.isdigit():
		    obj_type = int(obj_type)
		elif not get_object_class(obj_type):
		    raise ValueError, "unknown object type"
		    
		          
		datatype = get_datatype(obj_type, prop_id)
		if not datatype:
			print ValueError, ": invalid property for object type"
		
		port = int(port)	
		
		#build request
		request = ReadPropertyRequest(
		    objectIdentifier=(obj_type, port), 
		    propertyIdentifier=prop_id,
		    )
		request.pduDestination = Address(request_addr)
		
		#submit request
		
		print request.pduDestination
		
		
		this_application.request(request)
		print "Waiting for reply..."
		#wait for request
		wait = 0
		while this_application._Application__response_value == None:
		    wait = wait + .01
		    time.sleep(.01)
		returnVal = this_application._Application__response_value
        
        
	except Exception, e:
		returnVal = None
		print 'An error has happened (CPLRW 127): ' + str(e) + "\n"
开发者ID:adamlblood,项目名称:Russel-Hospital-Senior-Design,代码行数:45,代码来源:cplReadWrite.py


注:本文中的bacpypes.apdu.ReadPropertyRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。