本文整理汇总了Python中bacpypes.apdu.ReadPropertyRequest.propertyArrayIndex方法的典型用法代码示例。如果您正苦于以下问题:Python ReadPropertyRequest.propertyArrayIndex方法的具体用法?Python ReadPropertyRequest.propertyArrayIndex怎么用?Python ReadPropertyRequest.propertyArrayIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bacpypes.apdu.ReadPropertyRequest
的用法示例。
在下文中一共展示了ReadPropertyRequest.propertyArrayIndex方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_rp_request
# 需要导入模块: from bacpypes.apdu import ReadPropertyRequest [as 别名]
# 或者: from bacpypes.apdu.ReadPropertyRequest import propertyArrayIndex [as 别名]
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
示例2: do_read
# 需要导入模块: from bacpypes.apdu import ReadPropertyRequest [as 别名]
# 或者: from bacpypes.apdu.ReadPropertyRequest import propertyArrayIndex [as 别名]
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)
示例3: build_rp_request
# 需要导入模块: from bacpypes.apdu import ReadPropertyRequest [as 别名]
# 或者: from bacpypes.apdu.ReadPropertyRequest import propertyArrayIndex [as 别名]
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
示例4: create_ReadPropertyRequest
# 需要导入模块: from bacpypes.apdu import ReadPropertyRequest [as 别名]
# 或者: from bacpypes.apdu.ReadPropertyRequest import propertyArrayIndex [as 别名]
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
示例5: do_read
# 需要导入模块: from bacpypes.apdu import ReadPropertyRequest [as 别名]
# 或者: from bacpypes.apdu.ReadPropertyRequest import propertyArrayIndex [as 别名]
def do_read(self, args):
"""read <addr> <type> <inst> <prop> [ <indx> ]"""
args = args.split()
if _debug: ReadPropertyConsoleCmd._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: ReadPropertyConsoleCmd._debug(" - request: %r", request)
# make an IOCB
iocb = IOCB(request)
if _debug: ReadPropertyConsoleCmd._debug(" - iocb: %r", iocb)
# give it to the application
this_application.request_io(iocb)
# wait for it to complete
iocb.wait()
# do something for success
if iocb.ioResponse:
apdu = iocb.ioResponse
# should be an ack
if not isinstance(apdu, ReadPropertyACK):
if _debug: ReadPropertyConsoleCmd._debug(" - not an ack")
return
# find the datatype
datatype = get_datatype(apdu.objectIdentifier[0], apdu.propertyIdentifier)
if _debug: ReadPropertyConsoleCmd._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: ReadPropertyConsoleCmd._debug(" - value: %r", value)
sys.stdout.write(str(value) + '\n')
if hasattr(value, 'debug_contents'):
value.debug_contents(file=sys.stdout)
sys.stdout.flush()
# do something for error/reject/abort
if iocb.ioError:
sys.stdout.write(str(iocb.ioError) + '\n')
except Exception, error:
ReadPropertyConsoleCmd._exception("exception: %r", error)
示例6: do_read
# 需要导入模块: from bacpypes.apdu import ReadPropertyRequest [as 别名]
# 或者: from bacpypes.apdu.ReadPropertyRequest import propertyArrayIndex [as 别名]
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, VendorAVObject.vendor_id):
raise ValueError("unknown object type")
if _debug: ReadWritePropertyConsoleCmd._debug(" - obj_type: %r", obj_type)
obj_inst = int(obj_inst)
if _debug: ReadWritePropertyConsoleCmd._debug(" - obj_inst: %r", obj_inst)
if prop_id.isdigit():
prop_id = int(prop_id)
if _debug: ReadWritePropertyConsoleCmd._debug(" - prop_id: %r", prop_id)
datatype = get_datatype(obj_type, prop_id, VendorAVObject.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,
)
request.pduDestination = Address(addr)
if len(args) == 5:
request.propertyArrayIndex = int(args[4])
if _debug: ReadWritePropertyConsoleCmd._debug(" - request: %r", request)
# make an IOCB
iocb = IOCB(request)
if _debug: ReadWritePropertyConsoleCmd._debug(" - iocb: %r", iocb)
# give it to the application
this_application.request_io(iocb)
# wait for it to complete
iocb.wait()
# do something for success
if iocb.ioResponse:
apdu = iocb.ioResponse
# peek at the value tag
value_tag = apdu.propertyValue.tagList.Peek()
if _debug: ReadWritePropertyConsoleCmd._debug(" - value_tag: %r", value_tag)
# make sure that it is application tagged
if value_tag.tagClass != Tag.applicationTagClass:
sys.stdout.write("value is not application encoded\n")
else:
# find the datatype
datatype = Tag._app_tag_class[value_tag.tagNumber]
if _debug: ReadWritePropertyConsoleCmd._debug(" - datatype: %r", datatype)
if not datatype:
raise TypeError("unknown datatype")
# cast out the value
value = apdu.propertyValue.cast_out(datatype)
if _debug: ReadWritePropertyConsoleCmd._debug(" - value: %r", value)
sys.stdout.write("%s (%s)\n" % (value, datatype))
sys.stdout.flush()
# do something for error/reject/abort
if iocb.ioError:
sys.stdout.write(str(iocb.ioError) + '\n')
except Exception as error:
ReadWritePropertyConsoleCmd._exception("exception: %r", error)
示例7: read
# 需要导入模块: from bacpypes.apdu import ReadPropertyRequest [as 别名]
# 或者: from bacpypes.apdu.ReadPropertyRequest import propertyArrayIndex [as 别名]
def read(self, args):
""" This function build a read request wait for the answer and
return the value
:param args: String with <addr> <type> <inst> <prop> [ <indx> ]
:returns: data read from device (str representing data like 10 or True)
*Example*::
import BAC0
myIPAddr = '192.168.1.10'
bacnet = BAC0.ReadWriteScript(localIPAddr = myIPAddr)
bacnet.read('2:5 analogInput 1 presentValue')
will read controller with a MAC address of 5 in the network 2
Will ask for the present Value of analog input 1 (AI:1)
"""
if not self._started: raise Exception('App not running, use startApp() function')
args = args.split()
self.this_application.value == None
print_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])
print_debug(" - request: %r", request)
# give it to the application
self.this_application.request(request)
except ReadPropertyException as error:
ReadProperty._exception("exception: %r", error)
# Share response with Queue
data = None
while True:
try:
data, evt = self.this_application.ResponseQueue.get(timeout=self._TIMEOUT)
evt.set()
return data
except Empty:
print('No response from controller')
return None