コード例 #1
0
    def __init__(self, **kwargs):
        if _debug: RandomAnalogValueObject._debug("__init__ %r", kwargs)
        AnalogValueObject.__init__(self, **kwargs)

register_object_type(RandomAnalogValueObject)

#
#   __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=('device', int(args.ini.objectidentifier)),
        maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
        segmentationSupported=args.ini.segmentationsupported,
        vendorIdentifier=int(args.ini.vendoridentifier),
        )

    # make a sample application
    this_application = BIPSimpleApplication(this_device, args.ini.address)

    # get the services supported
コード例 #2
0
ファイル: event_detection.py プロジェクト: zoopp/bacpypes
            if _debug: SampleEventDetection._debug("    - parameter match")
        else:
            if _debug: SampleEventDetection._debug("    - parameter mismatch")


bacpypes_debugging(SampleEventDetection)

#
#
#

# parse the command line arguments
parser = ArgumentParser(usage=__doc__)
args = parser.parse_args()

if _debug: _log.debug("initialization")
if _debug: _log.debug("    - args: %r", args)

# analog value 1
av1 = AnalogValueObject(
    objectIdentifier=('analogValue', 1),
    presentValue=75.3,
)
if _debug: _log.debug("    - av1: %r", av1)

# add a very simple monitor
av1._property_monitors['presentValue'].append(
    partial(something_changed, "av1"), )

# test it
av1.presentValue = 45.6
コード例 #3
0
    def __init__(self, **kwargs):
        if _debug: RandomAnalogValueObject._debug("__init__ %r", kwargs)
        AnalogValueObject.__init__(self, **kwargs)


register_object_type(RandomAnalogValueObject)

#
#   __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=('device', int(args.ini.objectidentifier)),
        maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
        segmentationSupported=args.ini.segmentationsupported,
        vendorIdentifier=int(args.ini.vendoridentifier),
    )

    # make a sample application
    this_application = BIPSimpleApplication(this_device, args.ini.address)

    # get the services supported
コード例 #4
0
                            type=argparse.FileType('wb'),
                            help="Optional output file for configuration",
                            default=sys.stdout)

    arg_parser.add_argument(
        "--max_range_report",
        nargs='?',
        type=float,
        help=
        'Affects how very large numbers are reported in the "Unit Details" column of the output. '
        'Does not affect sMap driver behavior.',
        default=1.0e+20)

    args = arg_parser.parse_args()

    _log.debug("initialization")
    _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),
    )

    # make a simple application
    this_application = SynchronousApplication(this_device, args.ini.address)

    _log.debug("starting build")
コード例 #5
0
#
#   __main__
#

# parse the command line arguments
parser = ArgumentParser(description=__doc__)
parser.add_argument("-s", "--source", nargs="?", type=str, help="source address")
parser.add_argument(
    "-d", "--destination", nargs="?", type=str, help="destination address"
)
parser.add_argument("--host", nargs="?", type=str, help="source or destination")
parser.add_argument("pcap", nargs="+", type=str, help="pcap file(s)")
args = parser.parse_args()

if _debug:
    _log.debug("initialization")
if _debug:
    _log.debug("    - args: %r", args)

# interpret the arguments
if args.source:
    filterSource = Address(args.source)
    if _debug:
        _log.debug("    - filterSource: %r", filterSource)
if args.destination:
    filterDestination = Address(args.destination)
    if _debug:
        _log.debug("    - filterDestination: %r", filterDestination)
if args.host:
    filterHost = Address(args.host)
    if _debug:
コード例 #6
0
ファイル: HTTPServer.py プロジェクト: cbergmiller/bacpypes
#
#   __main__
#

try:
    # parse the command line arguments
    parser = ConfigArgumentParser(description=__doc__)

    # add an option to override the port in the config file
    parser.add_argument('--port', type=int,
        help="override the port in the config file to PORT",
        default=9000,
        )
    args = 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),
        )

    # make a simple application
    this_application = BIPSimpleApplication(this_device, args.ini.address)

    # local host, special port
コード例 #7
0
    ]

    def __init__(self, **kwargs):
        if _debug: MyScheduleObject._debug("__init__ %r", kwargs)
        ScheduleObject.__init__(self, **kwargs)


#
#
#

# parse the command line arguments
parser = ArgumentParser(usage=__doc__)
args = parser.parse_args()

if _debug: _log.debug("initialization")
if _debug: _log.debug("    - args: %r", args)

# create a schedule object
mso = MyScheduleObject(
    objectIdentifier=('schedule', 1),
    objectName="myScheduleObject",
    weeklySchedule=[],
    priorityForWriting=1,
)

print("getting value")
print(mso.priorityForWriting)
print("")

print("setting value")
コード例 #8
0
import sys
import logging
from ConfigParser import ConfigParser
from bacpypes.debugging import Logging, ModuleLogger
from bacpypes.consolelogging import ConsoleLogHandler
from bacpypes.core import run

from bacpypes.app import BIPSimpleApplication
from bacpypes.object import LocalDeviceObject

#debugging
_debug = 0
_log = ModuleLogger(globals())

#_main_

try: 
	_log.debug("initialization")

	_log.debug("running")

except Exception, e:
	_log.exception("an error has occured: %s", e)

finally:
	_log.debug("finally")
コード例 #9
0
        # count the packets in the slot
        counter[slot] += 1


#
#   __main__
#

try:
    if ('--debug' in sys.argv):
        indx = sys.argv.index('--debug')
        for i in range(indx + 1, len(sys.argv)):
            ConsoleLogHandler(sys.argv[i])
        del sys.argv[indx:]

    if _debug: _log.debug("initialization")

    # check for a custom interval
    if ('--interval' in sys.argv):
        i = sys.argv.index('--interval')
        interval = int(sys.argv[i + 1])
        if _debug: _log.debug("    - interval: %r", interval)
        del sys.argv[i:i + 2]
    else:
        interval = 60

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [PDUsPerMinuteTracer])

    # print some stats at the end
コード例 #10
0
    if ('--buggers' in sys.argv):
        loggers = logging.Logger.manager.loggerDict.keys()
        loggers.sort()
        for loggerName in loggers:
            sys.stdout.write(loggerName + '\n')
        sys.exit(0)

    if ('--debug' in sys.argv):
        indx = sys.argv.index('--debug')
        i = indx + 1
        while (i < len(sys.argv)) and (not sys.argv[i].startswith('--')):
            ConsoleLogHandler(sys.argv[i])
            i += 1
        del sys.argv[indx:i]

    _log.debug("initialization")

    # create a lock for the cache
    cache_lock = Lock()

    # console
    MyCacheCmd()

    # build a list of update threads
    cache_threads = []
    for url in sys.argv[1:]:
        cache_thread = MyCacheThread(url)
        _log.debug("    - cache_thread: %r", cache_thread)

        cache_threads.append(cache_thread)
コード例 #11
0
        # return where the 'writing' actually started
        return start_position


register_object_type(LocalStreamAccessFileObject)

#
#   __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),
    )

    # make a sample application
    this_application = BIPSimpleApplication(this_device, args.ini.address)
コード例 #12
0
    maxApduLengthAccepted=1024,
    segmentationSupported='segmentedBoth',
    vendorIdentifier=15,
)

# make a test address
test_address = Address(1)

# create a client state machine, trapped server, and bind them together
test_application = TestApplication(test_device, test_address)

print("objects: " + str(test_application.objectIdentifier))

# get the services supported
services_supported = test_application.get_services_supported()
if _debug: _log.debug("    - services_supported: %r", services_supported)

# let the device object know
test_device.protocolServicesSupported = services_supported.value

# include a application decoder
test_asap = ApplicationServiceAccessPoint()

# pass the device object to the state machine access point so it
# can know if it should support segmentation
test_smap = StateMachineAccessPoint(test_device)

# state machine
test_server = MatchingStateMachine()

# bind everything together
コード例 #13
0
        if self.pParameter == self.pSetPoint:
            if _debug: SampleEventDetection._debug("    - parameter match")
        else:
            if _debug: SampleEventDetection._debug("    - parameter mismatch")

bacpypes_debugging(SampleEventDetection)

#
#
#

# parse the command line arguments
parser = ArgumentParser(usage=__doc__)
args = parser.parse_args()

if _debug: _log.debug("initialization")
if _debug: _log.debug("    - args: %r", args)

# analog value 1
av1 = AnalogValueObject(
    objectIdentifier=('analogValue', 1),
    presentValue=75.3,
    )
if _debug: _log.debug("    - av1: %r", av1)

# add a very simple monitor
av1._property_monitors['presentValue'].append(
    partial(something_changed, "av1"),
    )

# test it
コード例 #14
0
ファイル: UDPConsole.py プロジェクト: gitter-badger/bacpypes
try:
    # parse the command line arguments
    parser = ArgumentParser(description=__doc__)
    parser.add_argument("address",
        help="address of socket",
        )
    parser.add_argument("--nobroadcast",
        action="store_true",
        dest="noBroadcast",
        default=False,
        help="do not create a broadcast socket",
        )

    args = parser.parse_args()

    if _debug: _log.debug("initialization")
    if _debug: _log.debug("    - args: %r", args)

    if args.address == "any":
        local_unicast_tuple = ('', 47808)
        local_broadcast_tuple = ('255.255.255.255', 47808)

    elif args.address.startswith("any:"):
        port = int(args.address[4:])
        local_unicast_tuple = ('', port)
        local_broadcast_tuple = ('255.255.255.255', port)

    else:
        address = Address(args.address)
        if _debug: _log.debug("    - local_address: %r", address)
コード例 #15
0
ファイル: WhoIsIAm.py プロジェクト: matthewhelt/bacpypes
        network_list = [int(arg) for arg in args[1:]]

        # pass along to the service access point
        this_application.nsap.add_router_references(adapter, router_address, network_list)

bacpypes_debugging(WhoIsIAmConsoleCmd)

#
#   __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
コード例 #16
0
    if ('--buggers' in sys.argv):
        loggers = logging.Logger.manager.loggerDict.keys()
        loggers.sort()
        for loggerName in loggers:
            sys.stdout.write(loggerName + '\n')
        sys.exit(0)

    if ('--debug' in sys.argv):
        indx = sys.argv.index('--debug')
        i = indx + 1
        while (i < len(sys.argv)) and (not sys.argv[i].startswith('--')):
            ConsoleLogHandler(sys.argv[i])
            i += 1
        del sys.argv[indx:i]

    _log.debug("initialization")

    # read in a configuration file
    config = ConfigParser()
    if ('--ini' in sys.argv):
        indx = sys.argv.index('--ini')
        ini_file = sys.argv[indx + 1]
        if not config.read(ini_file):
            raise RuntimeError, "configuration file %r not found" % (
                ini_file, )
        del sys.argv[indx:indx + 2]
    elif not config.read('BACpypes.ini'):
        raise RuntimeError, "configuration file not found"

    # get the address from the config file
    foreign_bbmd = config.get('BACpypes', 'foreignBBMD')
コード例 #17
0
                requests[key] = 1


#
#   __main__
#

try:
    if "--debug" in sys.argv:
        indx = sys.argv.index("--debug")
        for i in range(indx + 1, len(sys.argv)):
            ConsoleLogHandler(sys.argv[i])
        del sys.argv[indx:]

    if _debug:
        _log.debug("initialization")

    # check for src
    if "--src" in sys.argv:
        i = sys.argv.index("--src")
        filterSource = Address(sys.argv[i + 1])
        if _debug:
            _log.debug("    - filterSource: %r", filterSource)
        del sys.argv[i : i + 2]

    # check for dest
    if "--dest" in sys.argv:
        i = sys.argv.index("--dest")
        filterDestination = Address(sys.argv[i + 1])
        if _debug:
            _log.debug("    - filterDestination: %r", filterDestination)
コード例 #18
0
    for object_index in xrange(1,objectCount+1):
        _log.debug('object_device_index = ' + repr(object_index))
        
        bac_object = read_prop(this_application, 
                                target_address, 
                                "device", 
                                device_id, 
                                list_property,
                                index=object_index)
        
        obj_type, index = bac_object

        try:
            process_object(this_application, target_address, obj_type, index, args.max_range_report, config_writer)
        except:
            _log.debug("Unexpected error processing object: {} {}".format(obj_type, index))
            _log.debug(traceback.format_exc())
        
        
        
try:
    main()
except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
    _log.debug("finally")
    

    

コード例 #19
0
ファイル: HTTPServer.py プロジェクト: mcarignan/bacpypes
#
#   __main__
#

try:
    # parse the command line arguments
    parser = ConfigArgumentParser(description=__doc__)

    # add an option for the server host
    parser.add_argument("--host", type=str, help="server host", default=HOST)
    # add an option for the server port
    parser.add_argument("--port", type=int, help="server port", default=PORT)
    args = parser.parse_args()

    if _debug:
        _log.debug("initialization")
    if _debug:
        _log.debug("    - args: %r", args)

    # make a device object
    this_device = LocalDeviceObject(ini=args.ini)
    if _debug:
        _log.debug("    - this_device: %r", this_device)

    # make a simple application
    this_application = BIPSimpleApplication(this_device, args.ini.address)

    # local host, special port
    server = ThreadedTCPServer((args.host, args.port),
                               ThreadedHTTPRequestHandler)
    if _debug:
コード例 #20
0
_debug = 0
_log = ModuleLogger(globals())

# globals
this_device = None
this_application = None

#
#   __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),
    )

    # make a sample application
    this_application = BIPSimpleApplication(this_device, args.ini.address)

    # get the services supported
コード例 #21
0
                del requests[key]
            else:
                if _debug: ReadPropertySummary._debug("    - unmatched")

#
#   __main__
#

try:
    if ('--debug' in sys.argv):
        indx = sys.argv.index('--debug')
        for i in range(indx+1, len(sys.argv)):
            ConsoleLogHandler(sys.argv[i])
        del sys.argv[indx:]

    if _debug: _log.debug("initialization")

    # check for src
    if ('--src' in sys.argv):
        i = sys.argv.index('--src')
        filterSource = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterSource: %r", filterSource)
        del sys.argv[i:i+2]

    # check for dest
    if ('--dest' in sys.argv):
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i+2]
コード例 #22
0
        # count the packets in the slot
        counter[slot] += 1

#
#   __main__
#

try:
    if ('--debug' in sys.argv):
        indx = sys.argv.index('--debug')
        for i in range(indx+1, len(sys.argv)):
            ConsoleLogHandler(sys.argv[i])
        del sys.argv[indx:]

    if _debug: _log.debug("initialization")

    # check for a custom interval
    if ('--interval' in sys.argv):
        i = sys.argv.index('--interval')
        interval = int(sys.argv[i+1])
        if _debug: _log.debug("    - interval: %r", interval)
        del sys.argv[i:i+2]
    else:
        interval = 60

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [PDUsPerMinuteTracer])

    # print some stats at the end
コード例 #23
0
ファイル: bacnet.py プロジェクト: FraunhoferCSE/volttron
            if _debug: ReadPropertyMultipleApplication._debug("    - read_access_result: %r", read_access_result)

            # add it to the list
            read_access_result_list.append(read_access_result)

        # this is a ReadPropertyMultiple ack
        if not resp:
            resp = ReadPropertyMultipleACK(context=apdu)
            resp.listOfReadAccessResults = read_access_result_list
            if _debug: ReadPropertyMultipleApplication._debug("    - resp: %r", resp)

        # return the result
        self.response(resp)

#
#   __main__
#

try:
    abstraction = DeviceAbstraction(args.interface, args.config)
    application = abstraction.get_server_application()

    _log.debug("running")

    run()

except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
    _log.debug("finally")
コード例 #24
0
    if ('--debug' in sys.argv):
        indx = sys.argv.index('--debug')
        i = indx + 1
        while (i < len(sys.argv)) and (not sys.argv[i].startswith('--')):
            ConsoleLogHandler(sys.argv[i])
            i += 1
        del sys.argv[indx:i]

    if ('--config' in sys.argv):
        indx = sys.argv.index('--config')
        configFileName = sys.argv[indx + 1]
        del sys.argv[indx:indx + 2]
    else:
        configFileName = 'BACpypes.ini'

    _log.debug("initialization")

    # read in the configuration file
    if not os.path.isfile(configFileName):
        raise RuntimeError, "No config file: '%s'" % (configFileName, )
    config = ConfigParser()
    config.read(configFileName)

    # maybe use a different port
    addr = config.get('BACpypes', 'address')
    if '--port' in sys.argv:
        indx = sys.argv.index('--port')
        addr += ':' + sys.argv[indx + 1]
        del sys.argv[indx:indx + 2]
    _log.debug("    - addr: %r", addr)
コード例 #25
0
import logging

from bacpypes.debugging import Logging, ModuleLogger
from bacpypes.consolecmd import ConsoleCmd

from bacpypes.core import run

# some debugging
_debug = 0
_log = ModuleLogger(globals())

#
#   __main__
#

try:
    _log.debug("initialization")

    # console
    ConsoleCmd()

    _log.debug("running")

    # run until stopped
    run()

except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
    _log.debug("finally")
コード例 #26
0
      )

# add an argument for interval
parser.add_argument('addr2', type=str,
      help='address of second network',
      )

# add an argument for interval
parser.add_argument('net2', type=int,
      help='network number of second network',
      )

# now parse the arguments
args = parser.parse_args()

if _debug: _log.debug("initialization")
if _debug: _log.debug("    - args: %r", args)

local_address = Address(args.addr1)
local_network = args.net1
vlan_address = Address(args.addr2)
vlan_network = args.net2

# create the VLAN router, bind it to the local network
router = VLANRouter(local_address, local_network)

# create a VLAN
vlan = Network()

# create a node for the router, address 1 on the VLAN
router_node = Node(Address(1))
コード例 #27
0
            resp = ReadPropertyMultipleACK(context=apdu)
            resp.listOfReadAccessResults = read_access_result_list
            if _debug: ReadPropertyMultipleApplication._debug("    - resp: %r", resp)

        # return the result
        self.response(resp)

#
#   __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
コード例 #28
0
ファイル: bacnet.py プロジェクト: tpktang/volttron
            resp = ReadPropertyMultipleACK(context=apdu)
            resp.listOfReadAccessResults = read_access_result_list
            if _debug:
                ReadPropertyMultipleApplication._debug("    - resp: %r", resp)

        # return the result
        self.response(resp)


#
#   __main__
#

try:
    abstraction = DeviceAbstraction(args.interface, args.config)

    #Create the deamon as soon as we've loaded the device configuration.
    if not args.no_daemon:
        createDaemon()

    application = abstraction.get_server_application()

    _log.debug("running")

    run()

except Exception as e:
    _log.exception("an error has occurred: %s", e)
finally:
    _log.debug("finally")
コード例 #29
0
@bacpypes_debugging
class CommandableDateValueObject(CommandableMixin, DateValueObject):
    def __init__(self, **kwargs):
        if _debug: CommandableDateValueObject._debug("__init__ %r", kwargs)
        CommandableMixin.__init__(self, False, **kwargs)


#
#   __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),
    )

    # make a sample application
    this_application = BIPSimpleApplication(this_device, args.ini.address)

    # make a commandable analog value object, add to the device
コード例 #30
0
_debug = 0
_log = ModuleLogger(globals())

# globals
this_device = None
this_application = None

#
#   __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),
        )

    # make a sample application
    this_application = BIPSimpleApplication(this_device, args.ini.address)

    # make a multistate value object
コード例 #31
0
ファイル: bacnet_scan.py プロジェクト: NREL/volttron
    # parse the command line arguments
    arg_parser = ConfigArgumentParser(description=__doc__)

    arg_parser.add_argument("--address", 
                            help="Target only device(s) at <address> for request" )

    arg_parser.add_argument("--range", type=int, nargs=2, metavar=('LOW', 'HIGH'),
                            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
コード例 #32
0
ファイル: WhoIsRouter.py プロジェクト: matthewhelt/bacpypes
        except:
            print "invalid arguments"
            return

        # give it to the application
        this_application.request(this_application.nsap.adapters[0], request)

#
#   __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 simple application
    this_application = WhoIsRouterApplication(args.ini.address)
    if _debug: _log.debug("    - this_application: %r", this_application)

    # make a console
    this_console = WhoIsRouterConsoleCmd()
    if _debug: _log.debug("    - this_console: %r", this_console)

    _log.debug("running")

    run()

except Exception, e:
コード例 #33
0
@bacpypes_debugging
class CommandableDateValueObject(CommandableMixin, DateValueObject):

    def __init__(self, **kwargs):
        if _debug: CommandableDateValueObject._debug("__init__ %r", kwargs)
        CommandableMixin.__init__(self, False, **kwargs)

#
#   __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),
        )

    # make a sample application
    this_application = BIPSimpleApplication(this_device, args.ini.address)

    # make a commandable analog value object, add to the device
コード例 #34
0
                    pkt._index + 1, strftimestamp(pkt._timestamp),
                    pkt.pduSource, pkt.pduDestination,
                    )

#
#   __main__
#

try:
    if ('--debug' in sys.argv):
        indx = sys.argv.index('--debug')
        for i in range(indx+1, len(sys.argv)):
            ConsoleLogHandler(sys.argv[i])
        del sys.argv[indx:]

    if _debug: _log.debug("initialization")

    # check for src
    if ('--src' in sys.argv):
        i = sys.argv.index('--src')
        filterSource = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterSource: %r", filterSource)
        del sys.argv[i:i+2]

    # check for dest
    if ('--dest' in sys.argv):
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i+2]
コード例 #35
0
    arg_parser = ConfigArgumentParser(description=__doc__)
    
    arg_parser.add_argument("address",
                            help="Address of target device" )
    arg_parser.add_argument("out_file", nargs='?', type=argparse.FileType('wb'),
                            help="Optional output file for configuration",
                            default=sys.stdout )
    
    arg_parser.add_argument("--max_range_report", nargs='?', type=float,
                            help='Affects how very large numbers are reported in the "Unit Details" column of the output. ' 
                            'Does not affect sMap driver behavior.',
                            default=1.0e+20 )
    
    args = arg_parser.parse_args()

    _log.debug("initialization")
    _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),
        )


    # make a simple application
    this_application = SynchronousApplication(this_device, args.ini.address)
コード例 #36
0
    maxApduLengthAccepted=1024,
    segmentationSupported='segmentedBoth',
    vendorIdentifier=15,
    )

# make a test address
test_address = Address(1)

# create a client state machine, trapped server, and bind them together
test_application = TestApplication(test_device, test_address)

print("objects: " + str(test_application.objectIdentifier))

# get the services supported
services_supported = test_application.get_services_supported()
if _debug: _log.debug("    - services_supported: %r", services_supported)

# let the device object know
test_device.protocolServicesSupported = services_supported.value

# include a application decoder
test_asap = ApplicationServiceAccessPoint()

# pass the device object to the state machine access point so it
# can know if it should support segmentation
test_smap = StateMachineAccessPoint(test_device)

# state machine
test_server = MatchingStateMachine()

# bind everything together