本文整理汇总了Python中bacpypes.app.LocalDeviceObject类的典型用法代码示例。如果您正苦于以下问题:Python LocalDeviceObject类的具体用法?Python LocalDeviceObject怎么用?Python LocalDeviceObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LocalDeviceObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createApplication
def createApplication(device):
global applicationCount, applications
try:
#Defining Device
threadName = 'app_' + str(applicationCount)
localDevice = LocalDeviceObject(
objectName=device.getObjectName(),
objectIdentifier=int(device.getObjectIdentifier()),
maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()),
segmentationSupported=device.getSegmentationSupported(),
vendorIdentifier=int(device.getVendorIdentifier()),
)
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
pss['readProperty'] = 1
pss['writeProperty'] = 1
localDevice.protocolServicesSupported = pss.value
application = Application(localDevice, device.getDeviceAddress())
applications.append(application)
applicationThread = BACpypeThread(threadName)
applicationThread.start()
applicationCount += 1
except Exception, e:
print "Error: doStart()"
ErrorHandler(e,device)
示例2: doStart
def doStart(device):
global this_application, this_device, applicationThread, has_started
has_started = False
try:
# Defining Device
this_device = LocalDeviceObject(
objectName=device.getObjectName(),
objectIdentifier=int(device.getObjectIdentifier()),
maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()),
segmentationSupported=device.getSegmentationSupported(),
vendorIdentifier=int(device.getVendorIdentifier()),
)
pss = ServicesSupported()
pss["whoIs"] = 1
pss["iAm"] = 1
pss["readProperty"] = 1
pss["writeProperty"] = 1
this_device.protocolServicesSupported = pss.value
this_application = Application(this_device, device.getDeviceAddress())
# Start BACpypes Thread
applicationThread = BACpypeThread("BACPYPE-APP")
applicationThread.start()
has_started = True
return has_started
except Exception, e:
ErrorHandler(e, device)
示例3: main
def main():
if _debug: main._debug("initialization")
try:
# parse the command line arguments
args = ConfigArgumentParser(description=__doc__).parse_args()
if _debug: main._debug("initialization")
if _debug: main._debug(" - args: %r", args)
# make a device object
this_device = LocalDeviceObject(
objectName=args.ini.objectname,
objectIdentifier=int(args.ini.objectidentifier),
maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
segmentationSupported=args.ini.segmentationsupported,
vendorIdentifier=vendor_id,
)
# make a sample application
this_application = BIPSimpleApplication(this_device, args.ini.address)
# get the services supported
services_supported = this_application.get_services_supported()
if _debug: _log.debug(" - services_supported: %r", services_supported)
# let the device object know
this_device.protocolServicesSupported = services_supported.value
# make some objects
ravo1 = VendorAVObject(
objectIdentifier=(513, 1), objectName='Random1'
)
if _debug: main._debug(" - ravo1: %r", ravo1)
ravo2 = VendorAVObject(
objectIdentifier=(513, 2), objectName='Random2'
)
if _debug: main._debug(" - ravo2: %r", ravo2)
# add it to the device
this_application.add_object(ravo1)
this_application.add_object(ravo2)
if _debug: main._debug(" - object list: %r", this_device.objectList)
if _debug: main._debug("running")
run()
except Exception as error:
main._exception("an error has occurred: %s", error)
finally:
if _debug: main._debug("finally")
示例4: main
def main():
global this_device, this_application, this_console
# parse the command line arguments
args = ConfigArgumentParser(description=__doc__).parse_args()
if _debug: _log.debug("initialization")
if _debug: _log.debug(" - args: %r", args)
# make a device object
this_device = LocalDeviceObject(
objectName=args.ini.objectname,
objectIdentifier=int(args.ini.objectidentifier),
maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
segmentationSupported=args.ini.segmentationsupported,
vendorIdentifier=int(args.ini.vendoridentifier),
)
if _debug: _log.debug(" - this_device: %r", this_device)
# build a bit string that knows about the bit names
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
pss['readProperty'] = 1
pss['writeProperty'] = 1
# set the property value to be just the bits
this_device.protocolServicesSupported = pss.value
# make a simple application
this_application = WhoIsIAmApplication(
this_device, args.ini.address,
Address(args.ini.foreignbbmd),
int(args.ini.foreignttl),
)
if _debug: _log.debug(" - this_application: %r", this_application)
# get the services supported
services_supported = this_application.get_services_supported()
if _debug: _log.debug(" - services_supported: %r", services_supported)
# let the device object know
this_device.protocolServicesSupported = services_supported.value
# make a console
this_console = WhoIsIAmConsoleCmd()
if _debug: _log.debug(" - this_console: %r", this_console)
_log.debug("running")
run()
_log.debug("finally")
示例5: get_server_application
def get_server_application(self):
if _debug: DeviceAbstraction._debug(" - creating application")
# make a device object
this_device = LocalDeviceObject(
objectName="Betelgeuse",
objectIdentifier=599,
maxApduLengthAccepted=1024,
segmentationSupported="segmentedBoth",
vendorIdentifier=15
)
# build a bit string that knows about the bit names
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
pss['readProperty'] = 1
pss['readPropertyMultiple'] = 1
pss['writeProperty'] = 1
# set the property value to be just the bits
this_device.protocolServicesSupported = pss.value
# make a sample application
this_application = ReadPropertyMultipleApplication(this_device, args.interface)
registers= self.registers[('byte',True)]
#Currently we don't actually enforce read only properties.
for register in registers:
if _debug: DeviceAbstraction._debug(" - creating object of type: %s, %i", register.object_type, register.instance_number)
klass = get_object_class(register.object_type)
ravo = klass(objectIdentifier=(register.object_type, register.instance_number),
objectName=register.point_name)
ravo.WriteProperty("presentValue", 0, direct=True)
this_application.add_object(ravo)
registers= self.registers[('byte',False)]
for register in registers:
if _debug: DeviceAbstraction._debug(" - creating object of type: %s, %i", register.object_type, register.instance_number)
klass = get_object_class(register.object_type)
ravo = klass(objectIdentifier=(register.object_type, register.instance_number),
objectName=register.point_name)
ravo.WriteProperty("presentValue", 0, direct=True)
this_application.add_object(ravo)
return this_application
示例6: setup_device
def setup_device(self, address,
max_apdu_len=1024, seg_supported='segmentedBoth',
obj_id=599, obj_name='sMap BACnet driver',
ven_id=15):
global this_application
#We use a singleton device
if this_application is not None:
return
print 'seg_supported', seg_supported
print 'max_apdu_len', max_apdu_len
print 'obj_id', obj_id
print 'obj_name', obj_name
print 'ven_id', ven_id
#Check to see if they gave a valid apdu length.
if encode_max_apdu_response(max_apdu_len) is None:
raise ValueError('Invalid max_apdu_len: Valid options are 50, 128, 206, 480, 1024, and 1476')
this_device = LocalDeviceObject(
objectName=obj_name,
objectIdentifier=obj_id,
maxApduLengthAccepted=max_apdu_len,
segmentationSupported=seg_supported,
vendorIdentifier=ven_id,
)
# build a bit string that knows about the bit names and leave it empty. We respond to NOTHING.
pss = ServicesSupported()
# set the property value to be just the bits
this_device.protocolServicesSupported = pss.value
this_application = BACnet_application(this_device, address)
#We must use traditional python threads, otherwise the driver will
# hang during startup while trying to scrape actuator values.
# I think this is because the reactor hasn't started before we start trying
# to use the other threads.
#reactor.callInThread(bacpypes.core.run)
#reactor.addSystemEventTrigger("before", "shutdown", bacpypes.core.stop)
server_thread = threading.Thread(target=bacpypes.core.run)
# exit the BACnet App thread when the main thread terminates
server_thread.daemon = True
server_thread.start()
示例7: setup_device
def setup_device(self, async_call, address,
max_apdu_len=1024,
seg_supported='segmentedBoth',
obj_id=599,
obj_name='sMap BACnet driver',
ven_id=15):
_log.info('seg_supported '+str(seg_supported))
_log.info('max_apdu_len '+str(max_apdu_len))
_log.info('obj_id '+str(obj_id))
_log.info('obj_name '+str(obj_name))
_log.info('ven_id '+str(ven_id))
#Check to see if they gave a valid apdu length.
if encode_max_apdu_response(max_apdu_len) is None:
raise ValueError('Invalid max_apdu_len: {} Valid options are 50, 128, 206, 480, 1024, and 1476'.format(max_apdu_len))
this_device = LocalDeviceObject(
objectName=obj_name,
objectIdentifier=obj_id,
maxApduLengthAccepted=max_apdu_len,
segmentationSupported=seg_supported,
vendorIdentifier=ven_id,
)
# build a bit string that knows about the bit names.
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
# set the property value to be just the bits
this_device.protocolServicesSupported = pss.value
def i_am_callback(address, device_id, max_apdu_len, seg_supported, vendor_id):
async_call.send(None, self.i_am, address, device_id, max_apdu_len, seg_supported, vendor_id)
#i_am_callback('foo', 'bar', 'baz', 'foobar', 'foobaz')
self.this_application = BACnet_application(i_am_callback, this_device, address)
server_thread = threading.Thread(target=bacpypes.core.run)
# exit the BACnet App thread when the main thread terminates
server_thread.daemon = True
server_thread.start()
示例8: doStart
def doStart(device):
global this_application, this_device, applicationThread, request_addr, has_started
has_started = True
applicationThread = None
try:
#Defining Device
this_device = LocalDeviceObject(
#objectName="Name",
objectName=device.getObjectName(),
#objectIdentifier=2450,
objectIdentifier=int(device.getObjectIdentifier()),
maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()),
#maxApduLenghtAccepted = int(device.getMaxApduLengthAccepted()),
segmentationSupported=device.getSegmentationSupported(),
#device.getSegmentationSupported(),
vendorIdentifier=int(device.getVendorIdentifier()),
#int(device.getVendorIdentifier()),
)
#request_addr = "192.168.92.68"
request_addr = device.getRequestAddress()
print 'req Add: ' + request_addr
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
pss['readProperty'] = 1
pss['writeProperty'] = 1
this_device.protocolServicesSupported = pss.value
this_application = Application(this_device, device.getDeviceAddress())
print "this Addr:" + str(device.getDeviceAddress())
#Start BACpypes Thread
applicationThread = BACpypeThread('BACPYPE-APP')
applicationThread.start()
except Exception, e:
has_started = False
print 'An error has occured: ' + str(e) + "\n"
示例9: main
def main():
if _debug: main._debug("initialization")
global this_application
try:
# parse the command line arguments
args = ConfigArgumentParser(description=__doc__).parse_args()
if _debug: main._debug("initialization")
if _debug: main._debug(" - args: %r", args)
# make a device object
this_device = LocalDeviceObject(
objectName=args.ini.objectname,
objectIdentifier=int(args.ini.objectidentifier),
maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
segmentationSupported=args.ini.segmentationsupported,
vendorIdentifier=int(args.ini.vendoridentifier),
)
# make a simple application
this_application = ReadPropertyApplication(this_device, args.ini.address)
# get the services supported
services_supported = this_application.get_services_supported()
if _debug: _log.debug(" - services_supported: %r", services_supported)
# let the device object know
this_device.protocolServicesSupported = services_supported.value
# make a console
this_console = ReadWritePropertyConsoleCmd()
main._debug("running")
run()
except Exception as error:
main._exception("an error has occurred: %s", error)
finally:
main._debug("finally")
示例10: main
def main():
if _debug: main._debug("initialization")
global this_application
try:
# parse the command line arguments
args = ConfigArgumentParser(description=__doc__).parse_args()
if _debug: main._debug("initialization")
if _debug: main._debug(" - args: %r", args)
# make a device object
this_device = LocalDeviceObject(
objectName=args.ini.objectname,
objectIdentifier=int(args.ini.objectidentifier),
maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
segmentationSupported=args.ini.segmentationsupported,
vendorIdentifier=int(args.ini.vendoridentifier),
)
# build a bit string that knows about the bit names
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
pss['readProperty'] = 1
pss['writeProperty'] = 1
# set the property value to be just the bits
this_device.protocolServicesSupported = pss.value
# make a simple application
this_application = ReadPropertyApplication(this_device, args.ini.address)
this_console = ReadWritePropertyConsoleCmd()
main._debug("running")
run()
except Exception, e:
main._exception("an error has occurred: %s", e)
示例11: doStart
def doStart(device):
global this_application, this_device, applicationThread, request_addr, has_started
has_started = True
try:
#args = ConfigArgumentParser(description=__doc__).parse_args()
#Defining Device
this_device = LocalDeviceObject(
objectName=device.getObjectName(),
objectIdentifier=int(device.getObjectIdentifier()),
maxApduLengthAccepted=int(device.getMaxApduLengthAccepted()),
segmentationSupported=device.getSegmentationSupported(),
vendorIdentifier=int(device.getVendorIdentifier()),
)
print
request_addr = device.getRequestAddress()
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
pss['readProperty'] = 1
pss['writeProperty'] = 1
this_device.protocolServicesSupported = pss.value
this_application = Application(this_device, device.getDeviceAddress())
print "this Addr:" + str(device.getDeviceAddress())
#Start BACpypes Thread
applicationThread = BACpypeThread('BACPYPE-APP')
applicationThread.start()
except Exception:
has_started = False
finally:
#print "Finally\n"
return has_started
示例12: __init__
def __init__(self, config):
if _debug: BACnetAggregator._debug("__init__ %r", config)
# get local address from the config file
laddr = config.get('BACpypes', 'address')
# make a local device object
local_device = \
LocalDeviceObject( objectName=config.get('BACpypes','objectName')
, objectIdentifier=config.getint('BACpypes','objectIdentifier')
, maxApduLengthAccepted=config.getint('BACpypes','maxApduLengthAccepted')
, segmentationSupported=config.get('BACpypes','segmentationSupported')
, vendorIdentifier=config.getint('BACpypes','vendorIdentifier')
)
# build a bit string that knows about the bit names
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
pss['readProperty'] = 1
pss['writeProperty'] = 1
# set the property value to be just the bits
local_device.protocolServicesSupported = pss.value
# make a simple application
BIPSimpleApplication.__init__(self, local_device, laddr)
# create logger
self.logger = BACnetDataLogger(self, config)
self.loadKey()
# keep track of requests to line up responses
self._request = None
# connect to local repo
self.publisher = RepoSocketPublisher(12345)
self.interval = 5 # in seconds
示例13: setup_device
def setup_device(self, address,
max_apdu_len=1024,
seg_supported='segmentedBoth',
obj_id=599,
obj_name='sMap BACnet driver',
ven_id=15):
print 'seg_supported', seg_supported
print 'max_apdu_len', max_apdu_len
print 'obj_id', obj_id
print 'obj_name', obj_name
print 'ven_id', ven_id
#Check to see if they gave a valid apdu length.
if encode_max_apdu_response(max_apdu_len) is None:
raise ValueError('Invalid max_apdu_len: Valid options are 50, 128, 206, 480, 1024, and 1476')
this_device = LocalDeviceObject(
objectName=obj_name,
objectIdentifier=obj_id,
maxApduLengthAccepted=max_apdu_len,
segmentationSupported=seg_supported,
vendorIdentifier=ven_id,
)
# build a bit string that knows about the bit names and leave it empty. We respond to NOTHING.
pss = ServicesSupported()
# set the property value to be just the bits
this_device.protocolServicesSupported = pss.value
self.this_application = BACnet_application(this_device, address)
server_thread = threading.Thread(target=bacpypes.core.run)
# exit the BACnet App thread when the main thread terminates
server_thread.daemon = True
server_thread.start()
示例14: ConfigArgumentParser
#
# __main__
#
try:
# parse the command line arguments
args = ConfigArgumentParser(description=__doc__).parse_args()
if _debug: _log.debug("initialization")
if _debug: _log.debug(" - args: %r", args)
# make a device object
this_device = LocalDeviceObject(
objectName=args.ini.objectname,
objectIdentifier=int(args.ini.objectidentifier),
maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
segmentationSupported=args.ini.segmentationsupported,
vendorIdentifier=int(args.ini.vendoridentifier),
)
# build a bit string that knows about the bit names
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
pss['readProperty'] = 1
pss['writeProperty'] = 1
# set the property value to be just the bits
this_device.protocolServicesSupported = pss.value
# make a simple application
示例15: LocalDeviceObject
help="Lower and upper limit on device ID in results" )
arg_parser.add_argument("--timeout", type=int, metavar=('SECONDS'),
help="Time, in seconds, to wait for responses. Default: %(default)s",
default = 5)
args = arg_parser.parse_args()
if _debug: _log.debug("initialization")
if _debug: _log.debug(" - args: %r", args)
# make a device object
this_device = LocalDeviceObject(
objectName=args.ini.objectname,
objectIdentifier=int(args.ini.objectidentifier),
maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
segmentationSupported=args.ini.segmentationsupported,
vendorIdentifier=int(args.ini.vendoridentifier),
)
# build a bit string that knows about the bit names
pss = ServicesSupported()
pss['whoIs'] = 1
pss['iAm'] = 1
# set the property value to be just the bits
this_device.protocolServicesSupported = pss.value
# make a simple application
this_application = WhoIsIAmApplication(this_device, args.ini.address)
_log.debug("running")