import random
import string

from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser

from bacpypes.core import run

from bacpypes.app import LocalDeviceObject, BIPSimpleApplication
from bacpypes.object import FileObject, register_object_type

from bacpypes.basetypes import ServicesSupported

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

#
#   Local Record Access File Object Type
#

@bacpypes_debugging
class LocalRecordAccessFileObject(FileObject):

    def __init__(self, **kwargs):
        """ Initialize a record accessed file object. """
        if _debug:
            LocalRecordAccessFileObject._debug("__init__ %r",
                kwargs,
                )
        FileObject.__init__(self,
Exemple #2
0
and is a way to create InitializeRoutingTable and WhoIsRouterToNetwork requests.
"""

from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser
from bacpypes.consolecmd import ConsoleCmd

from bacpypes.core import run

from bacpypes.pdu import Address
from bacpypes.npdu import InitializeRoutingTable, WhoIsRouterToNetwork
from bacpypes.app import BIPNetworkApplication

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

# globals
this_application = None
this_console = None

#
#   WhoIsRouterApplication
#

@bacpypes_debugging
class WhoIsRouterApplication(BIPNetworkApplication):

    def __init__(self, *args):
        if _debug: WhoIsRouterApplication._debug("__init__ %r", args)
        BIPNetworkApplication.__init__(self, *args)
Exemple #3
0
from bacpypes.basetypes import ServicesSupported, ErrorType
from bacpypes.apdu import ReadPropertyMultipleACK, ReadAccessResult, ReadAccessResultElement, ReadAccessResultElementChoice
from bacpypes.app import LocalDeviceObject, BIPSimpleApplication
from bacpypes.object import AnalogValueObject, PropertyError, get_object_class
from bacpypes.apdu import Error
from bacpypes.errors import ExecutionError

from csv import DictReader
import logging

#---------------------------------------------------------------------------# 
# configure the service logging
#---------------------------------------------------------------------------# 
# some debugging
_debug = 0
_log = ModuleLogger(globals())

import struct

parser = ArgumentParser(description='Run a test pymodbus driver')
parser.add_argument('config', help='device registry configuration')
parser.add_argument('interface', help='interface address and optionally the port for the device to listen on')
args = parser.parse_args()

MODBUS_REGISTER_SIZE = 2

class Register(object):
    def __init__(self, point_name, instance_number, object_type, property_name, read_only):
        self.read_only = read_only
        self.register_type = "byte"
        self.property_name = property_name
Exemple #4
0
from bacpypes.debugging import ModuleLogger
from bacpypes.consolelogging import ConsoleLogHandler

from bacpypes.core import run
from bacpypes.comm import bind

from bacpypes.pdu import Address

from bacpypes.netservice import NetworkServiceAccessPoint, NetworkServiceElement
from bacpypes.bvllservice import UDPMultiplexer, AnnexJCodec, BIPSimple
from bacpypes.bsllservice import TCPClientMultiplexer, ProxyClientService, UserInformation

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

#
#   Test User
#

test_user = UserInformation(
    username='******',
    password='******',
    allServices=True,
)

#
#   __main__
#
from bacpypes.pdu import Address
from bacpypes.netservice import NetworkServiceAccessPoint, NetworkServiceElement
from bacpypes.bvllservice import BIPBBMD, AnnexJCodec, UDPMultiplexer

from bacpypes.app import LocalDeviceObject, Application
from bacpypes.appservice import StateMachineAccessPoint, ApplicationServiceAccessPoint

from bacpypes.primitivedata import Real
from bacpypes.object import AnalogValueObject, Property

from bacpypes.vlan import Network, Node
from bacpypes.errors import ExecutionError

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

#
#   RandomValueProperty
#

@bacpypes_debugging
class RandomValueProperty(Property):

    def __init__(self, identifier):
        if _debug: RandomValueProperty._debug("__init__ %r", identifier)
        Property.__init__(self, identifier, Real, default=None, optional=True, mutable=False)

    def ReadProperty(self, obj, arrayIndex=None):
        if _debug: RandomValueProperty._debug("ReadProperty %r arrayIndex=%r", obj, arrayIndex)
from bacpypes.consolelogging import ConfigArgumentParser

from bacpypes.core import run

from bacpypes.pdu import Address
from bacpypes.app import LocalDeviceObject, BIPSimpleApplication
from bacpypes.object import get_object_class, get_datatype

from bacpypes.apdu import ReadPropertyRequest, Error, AbortPDU, ReadPropertyACK
from bacpypes.primitivedata import Unsigned
from bacpypes.constructeddata import Array
from bacpypes.basetypes import ServicesSupported

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

# reference a simple application
this_application = None
server = None

#
#   IOCB
#


class IOCB:
    def __init__(self):
        # requests and responses
        self.ioRequest = None
        self.ioResponse = None
from bacpypes.pdu import Address
from bacpypes.core import run, stop
from bacpypes.apdu import WhoIsRequest, IAmRequest, ReadPropertyRequest, ReadPropertyACK
from bacpypes.errors import DecodingError
from bacpypes.task import TaskManager
from bacpypes.object import get_datatype, get_object_class, DeviceObject
from bacpypes.primitivedata import Enumerated, Unsigned, Boolean, Integer, Real, Double
from bacpypes.constructeddata import Array
"""
Simple utility to scrape device registers and write them to a configuration file.
"""

#Make sure the TaskManager singleton exists...
task_manager = TaskManager()
_debug = 0
_log = ModuleLogger(globals())


@bacpypes_debugging
class SynchronousApplication(BIPSimpleApplication):
    def __init__(self, *args):
        SynchronousApplication._debug("__init__ %r", args)
        BIPSimpleApplication.__init__(self, *args)
        self.expect_confirmation = True

    def confirmation(self, apdu):
        self.apdu = apdu
        stop()

    def indication(self, apdu):
        if not self.expect_confirmation:
from bacpypes.consolelogging import ArgumentParser

from bacpypes.pdu import Address
from bacpypes.comm import bind

from bacpypes.apdu import APDU, ReadPropertyRequest, \
    ComplexAckPDU, RejectPDU, AbortPDU

from bacpypes.app import LocalDeviceObject, Application
from bacpypes.appservice import ApplicationServiceAccessPoint, StateMachineAccessPoint

from tests.state_machine import Server, StateMachine

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

# defaults for testing
BACPYPES_TEST = ""
BACPYPES_TEST_OPTION = ""

# parsed test options
test_options = None

#
#   TestApplication
#


@bacpypes_debugging
class TestApplication(Application):
Exemple #9
0
As a router, this does not have an application layer.
"""

from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ArgumentParser

from bacpypes.core import run
from bacpypes.comm import bind

from bacpypes.pdu import Address
from bacpypes.netservice import NetworkServiceAccessPoint, NetworkServiceElement
from bacpypes.bvllservice import BIPSimple, AnnexJCodec, UDPMultiplexer

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

#
#   IP2IPRouter
#


@bacpypes_debugging
class IP2IPRouter:
    def __init__(self, addr1, net1, addr2, net2):
        if _debug:
            IP2IPRouter._debug("__init__ %r %r %r %r", addr1, net1, addr2, net2)

        # a network service access point will be needed
        self.nsap = NetworkServiceAccessPoint()
"""
"""

from functools import partial

from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ArgumentParser

from bacpypes.core import run_once

from bacpypes.service.detect import DetectionAlgorithm, monitor_filter
from bacpypes.object import AnalogValueObject

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

#
#   something_changed
#

def something_changed(thing, old_value, new_value):
    print("%r changed from %r to %r" % (thing, old_value, new_value))

#
#   SampleEventDetection
#

class SampleEventDetection(DetectionAlgorithm):

    def __init__(self, **kwargs):
Exemple #11
0
from bacpypes.core import run, deferred
from bacpypes.iocb import IOCB

from bacpypes.pdu import Address, GlobalBroadcast
from bacpypes.apdu import ReadPropertyRequest, WhoIsRequest
from bacpypes.primitivedata import Unsigned, ObjectIdentifier
from bacpypes.constructeddata import Array

from bacpypes.app import BIPSimpleApplication
from bacpypes.object import get_object_class, get_datatype
from bacpypes.local.device import LocalDeviceObject

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

# settings
HOST = os.getenv("HOST", "")
PORT = int(os.getenv("PORT", 8080))

# reference a simple application
this_application = None
server = None

# favorite icon
favicon = zlib.decompress(
    b"x\x9c\xb5\x93\xcdN\xdb@\x14\x85\x07\x95\x07\xc8\x8amYv\xc9#\xe4\x11x\x04\x96}"
    b'\x8c\x88\x1dl\xa0\x9b\xb6A\xa2)\x0bVTB\xa9"\xa5?*I\x16\xad"\x84d\x84DE\x93'
    b"\x14;v\xc01M\xe2$\x988\xb1l\x9d\xde;v\\\x03\x89TU\xea\xb5N\xe4\xb9\x9a\xef"
    b"\x1c\xcfO\x84X\xa0'\x95\x12\xf4\xbb,\x9e/\n\xb1$\x84xF\xa2\x16u\xc2>WzQ\xfc"
Exemple #12
0
import sys

from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.udp import UDPDirector
from bacpypes.comm import Client, Server, bind
from bacpypes.pdu import Address, PDU
from bacpypes.core import run, stop

from bacpypes.consolelogging import ArgumentParser
from bacpypes.console import ConsoleClient


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

# globals
local_unicast_tuple = None
local_broadcast_tuple = None

#
#   MiddleMan
#

@bacpypes_debugging
class MiddleMan(Client, Server):

    def indication(self, pdu):
        if _debug: MiddleMan._debug('indication %r', pdu)
from bacpypes.consolelogging import ArgumentParser

from bacpypes.pdu import Address
from bacpypes.comm import bind

from bacpypes.apdu import APDU, ReadPropertyRequest, \
    ComplexAckPDU, RejectPDU, AbortPDU

from bacpypes.app import LocalDeviceObject, Application
from bacpypes.appservice import ApplicationServiceAccessPoint, StateMachineAccessPoint

from tests.state_machine import Server, StateMachine

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

# defaults for testing
BACPYPES_TEST = ""
BACPYPES_TEST_OPTION = ""

# parsed test options
test_options = None


#
#   TestApplication
#

@bacpypes_debugging
class TestApplication(Application):
from bacpypes.comm import bind

from bacpypes.pdu import Address
from bacpypes.primitivedata import Real
from bacpypes.object import AnalogValueObject, Property

from bacpypes.vlan import Network, Node
from bacpypes.netservice import NetworkServiceAccessPoint, NetworkServiceElement
from bacpypes.bvllservice import BIPSimple, AnnexJCodec, UDPMultiplexer
from bacpypes.app import LocalDeviceObject, Application
from bacpypes.appservice import StateMachineAccessPoint, ApplicationServiceAccessPoint
from bacpypes.errors import ExecutionError

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

#
#   RandomValueProperty
#


@bacpypes_debugging
class RandomValueProperty(Property):
    def __init__(self, identifier):
        if _debug: RandomValueProperty._debug("__init__ %r", identifier)
        Property.__init__(self,
                          identifier,
                          Real,
                          default=None,
                          optional=True,
Exemple #15
0
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser
from bacpypes.consolecmd import ConsoleCmd

from bacpypes.core import run

from bacpypes.pdu import Address, GlobalBroadcast
from bacpypes.app import LocalDeviceObject, BIPSimpleApplication

from bacpypes.apdu import WhoIsRequest, IAmRequest
from bacpypes.basetypes import ServicesSupported
from bacpypes.errors import DecodingError

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

# globals
this_device = None
this_application = None
this_console = None

#
#   WhoIsIAmApplication
#

class WhoIsIAmApplication(BIPSimpleApplication):

    def __init__(self, *args):
        if _debug: WhoIsIAmApplication._debug("__init__ %r", args)
        BIPSimpleApplication.__init__(self, *args)
from bacpypes.debugging import Logging, function_debugging, ModuleLogger
from bacpypes.consolelogging import ConsoleLogHandler

from bacpypes.pdu import Address
from bacpypes.analysis import trace, strftimestamp, Tracer
from bacpypes.apdu import ConfirmedEventNotificationRequest, SimpleAckPDU

try:
    from CSStat import Statistics
except ImportError:
    Statistics = lambda: None

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

# globals
filterSource = None
filterDestination = None
filterHost = None

# dictionary of pending requests
requests = {}

# all traffic
traffic = []

#
#   Traffic
#
"""
Summarize COV Notifications
"""

import sys

from bacpypes.debugging import Logging, function_debugging, ModuleLogger
from bacpypes.consolelogging import ConsoleLogHandler

from bacpypes.pdu import Address
from bacpypes.analysis import trace, strftimestamp, Tracer
from bacpypes.apdu import UnconfirmedCOVNotificationRequest

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

# globals
filterSource = None
filterDestination = None
filterHost = None

# dictionary of requests
requests = {}

#
#   Match
#


@function_debugging
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")
import sys
from collections import defaultdict

from bacpypes.debugging import Logging, function_debugging, ModuleLogger
from bacpypes.consolelogging import ConsoleLogHandler

from bacpypes.analysis import trace, strftimestamp, Tracer

try:
    from CSStat import Statistics
except ImportError:
    Statistics = lambda: None

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

# globals
counter = defaultdict(int)

#
#   PDUsPerMinuteTracer
#

class PDUsPerMinuteTracer(Tracer, Logging):

    def __init__(self):
        if _debug: PDUsPerMinuteTracer._debug("__init__")
        Tracer.__init__(self, self.Filter)

    def Filter(self, pkt):
Exemple #20
0
import sys
from collections import defaultdict

from bacpypes.debugging import Logging, function_debugging, ModuleLogger
from bacpypes.consolelogging import ConsoleLogHandler

from bacpypes.analysis import trace, strftimestamp, Tracer

try:
    from CSStat import Statistics
except ImportError:
    Statistics = lambda: None

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

# globals
counter = defaultdict(int)

#
#   PDUsPerMinuteTracer
#


class PDUsPerMinuteTracer(Tracer, Logging):
    def __init__(self):
        if _debug: PDUsPerMinuteTracer._debug("__init__")
        Tracer.__init__(self, self.Filter)

    def Filter(self, pkt):
from bacpypes.apdu import Error, AbortPDU, \
    AtomicReadFileRequest, \
        AtomicReadFileRequestAccessMethodChoice, \
            AtomicReadFileRequestAccessMethodChoiceRecordAccess, \
            AtomicReadFileRequestAccessMethodChoiceStreamAccess, \
    AtomicReadFileACK, \
    AtomicWriteFileRequest, \
        AtomicWriteFileRequestAccessMethodChoice, \
            AtomicWriteFileRequestAccessMethodChoiceRecordAccess, \
            AtomicWriteFileRequestAccessMethodChoiceStreamAccess, \
    AtomicWriteFileACK
from bacpypes.basetypes import ServicesSupported

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

# reference a simple application
this_application = None

#
#   TestApplication
#

@bacpypes_debugging
class TestApplication(BIPSimpleApplication):

    def request(self, apdu):
        if _debug: TestApplication._debug("request %r", apdu)

        # save a copy of the request
Exemple #22
0
from bacpypes.core import run

from bacpypes.pdu import Address, GlobalBroadcast
from bacpypes.app import LocalDeviceObject, BIPForeignApplication
from bacpypes.object import get_object_class, get_datatype

from bacpypes.apdu import WhoIsRequest, IAmRequest, ReadPropertyRequest, Error, AbortPDU, ReadPropertyACK
from bacpypes.primitivedata import Unsigned
from bacpypes.constructeddata import Array
from bacpypes.basetypes import ServicesSupported
from bacpypes.errors import DecodingError

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

# globals
this_device = None
this_application = None
this_console = None

#
#   TestApplication
#


@bacpypes_debugging
class TestApplication(BIPForeignApplication):
    def __init__(self, *args):
        if _debug: TestApplication._debug("__init__ %r", args)
Exemple #23
0
"""
Test Primitive Data Octet String
--------------------------------
"""

import unittest
import struct

from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob

from bacpypes.errors import InvalidTag
from bacpypes.primitivedata import OctetString, Tag

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


@bacpypes_debugging
def octet_string_tag(x):
    """Convert a hex string to an octet_string application tag."""
    if _debug: octet_string_tag._debug("octet_string_tag %r", x)

    b = xtob(x)
    tag = Tag(Tag.applicationTagClass, Tag.octetStringAppTag, len(b), b)
    if _debug: octet_string_endec._debug("    - tag: %r", tag)

    return tag


@bacpypes_debugging
Exemple #24
0
from bacpypes.debugging import bacpypes_debugging, ModuleLogger

from bacpypes.pdu import Address
from bacpypes.object import get_object_class, get_datatype
from bacpypes.apdu import PropertyReference, ReadAccessSpecification, \
    ReadPropertyRequest, ReadPropertyMultipleRequest
from bacpypes.basetypes import PropertyIdentifier

from queue import Queue, Empty

from .IOExceptions import ReadPropertyException, ReadPropertyMultipleException

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


@bacpypes_debugging
class ReadProperty():
    """
    This class defines functions to read bacnet messages.
    It handles readProperty, readPropertyMultiple
    Data exchange is made via a Queue object
    A timeout of 2 seconds allow detection of invalid device or communciation
    errors.
    """
    _TIMEOUT = 2

    def __init__(self):
        """ This function is a fake one so spyder can see local variables
"""
This sample application provides a single MultiState Value Object to test
reading and writing its various properties.
"""

from bacpypes.debugging import ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser

from bacpypes.core import run

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

# some debugging
_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)
from bacpypes.pdu import Address, GlobalBroadcast
from bacpypes.core import run, stop
from bacpypes.apdu import WhoIsRequest, IAmRequest, ReadPropertyRequest, ReadPropertyACK, UnconfirmedRequestSequence
from bacpypes.errors import DecodingError
from bacpypes.task import TaskManager
from bacpypes.object import get_datatype, get_object_class, DeviceObject
from bacpypes.primitivedata import Enumerated, Unsigned, Boolean, Integer, Real, Double
from bacpypes.constructeddata import Array
"""
Simple utility to scrape device registers and write them to a configuration file.
"""

#Make sure the TaskManager singleton exists...
task_manager = TaskManager()
_debug = 0
_log = ModuleLogger(globals())


@bacpypes_debugging
class SynchronousApplication(BIPSimpleApplication):
    def __init__(self, *args):
        SynchronousApplication._debug("__init__ %r", args)
        BIPSimpleApplication.__init__(self, *args)
        self.expect_confirmation = True

    def confirmation(self, apdu):
        self.apdu = apdu
        stop()

    def indication(self, apdu):
        #We only care about indications if we sent out a who is request.
"""
Who-Is and I-Am Device Filter
"""

import sys

from bacpypes.debugging import Logging, function_debugging, ModuleLogger
from bacpypes.consolelogging import ConsoleLogHandler

from bacpypes.pdu import Address
from bacpypes.analysis import trace, strftimestamp, Tracer
from bacpypes.apdu import WhoIsRequest, IAmRequest

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

# globals
filterSource = None
filterDestination = None
filterHost = None
filterDevice = None

#
#   Match
#

@function_debugging
def Match(addr1, addr2):
    """Return true iff addr1 matches addr2."""
    if _debug: Match._debug("Match %r %r", addr1, addr2)
import time
import socket

from bacpypes.debugging import ModuleLogger, bacpypes_debugging
from bacpypes.consolelogging import ArgumentParser

from bacpypes.pdu import PDU
from bacpypes.bvll import BVLPDU, bvl_pdu_types, ForwardedNPDU, \
    DistributeBroadcastToNetwork, OriginalUnicastNPDU, OriginalBroadcastNPDU
from bacpypes.npdu import NPDU, npdu_types
from bacpypes.apdu import APDU, apdu_types, confirmed_request_types, unconfirmed_request_types, complex_ack_types, error_types, \
    ConfirmedRequestPDU, UnconfirmedRequestPDU, SimpleAckPDU, ComplexAckPDU, SegmentAckPDU, ErrorPDU, RejectPDU, AbortPDU

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

# protocol map
_protocols = {
    socket.IPPROTO_TCP: 'tcp',
    socket.IPPROTO_UDP: 'udp',
    socket.IPPROTO_ICMP: 'icmp',
}

#
#   _hexify
#


def _hexify(s, sep='.'):
    return sep.join('%02X' % ord(c) for c in s)
as the other filters, and accepts the debugging options of other BACpypes
applications.
"""

from collections import defaultdict

from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ArgumentParser

from bacpypes.pdu import Address
from bacpypes.analysis import trace, Tracer
from bacpypes.apdu import WhoIsRequest, IAmRequest

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

# globals
filterSource = None
filterDestination = None
filterHost = None

# dictionaries of requests
whoIsTraffic = defaultdict(int)
iAmTraffic = defaultdict(int)

#
#   Match
#

Exemple #30
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")
import random

from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser

from bacpypes.core import run

from bacpypes.primitivedata import Real
from bacpypes.app import LocalDeviceObject, BIPSimpleApplication
from bacpypes.object import AnalogValueObject, Property, register_object_type
from bacpypes.errors import ExecutionError

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

# globals
this_device = None
this_application = None

#
#   RandomValueProperty
#

@bacpypes_debugging
class RandomValueProperty(Property):

    def __init__(self, identifier):
        if _debug: RandomValueProperty._debug("__init__ %r", identifier)
        Property.__init__(self, identifier, Real, default=None, optional=True, mutable=False)
Exemple #32
0
and is a way to create InitializeRoutingTable and WhoIsRouterToNetwork requests.
"""

from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser
from bacpypes.consolecmd import ConsoleCmd

from bacpypes.core import run

from bacpypes.pdu import Address
from bacpypes.npdu import InitializeRoutingTable, WhoIsRouterToNetwork
from bacpypes.app import BIPNetworkApplication

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

# globals
this_application = None
this_console = None

#
#   WhoIsRouterApplication
#


@bacpypes_debugging
class WhoIsRouterApplication(BIPNetworkApplication):
    def __init__(self, *args):
        if _debug: WhoIsRouterApplication._debug("__init__ %r", args)
        BIPNetworkApplication.__init__(self, *args)
"""

from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser

from bacpypes.core import run
from bacpypes.errors import ExecutionError

from bacpypes.app import LocalDeviceObject, BIPSimpleApplication
from bacpypes.object import AnalogValueObject, DateValueObject
from bacpypes.primitivedata import Null
from bacpypes.basetypes import PriorityValue, PriorityArray

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

# globals
this_device = None
this_application = None

#
#   CommandableMixin
#

@bacpypes_debugging
class CommandableMixin(object):

    def __init__(self, init_value, **kwargs):
        if _debug: CommandableMixin._debug("__init__ %r, %r", init_value, kwargs)
        super(CommandableMixin, self).__init__(**kwargs)
Exemple #34
0
"""
This sample application provides a single MultiState Value Object to test
reading and writing its various properties.
"""

from bacpypes.debugging import ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser

from bacpypes.core import run

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

# some debugging
_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)
from bacpypes.pdu import Address
from bacpypes.core import run, stop
from bacpypes.apdu import WhoIsRequest, IAmRequest, ReadPropertyRequest, ReadPropertyACK
from bacpypes.errors import DecodingError
from bacpypes.task import TaskManager
from bacpypes.object import get_datatype, get_object_class, DeviceObject
from bacpypes.primitivedata import Enumerated, Unsigned, Boolean, Integer, Real, Double

"""
Simple utility to scrape device registers and write them to a configuration file.
"""

#Make sure the TaskManager singleton exists...
task_manager = TaskManager()
_debug = 0
_log = ModuleLogger(globals())

@bacpypes_debugging
class SynchronousApplication(BIPSimpleApplication):
    def __init__(self, *args):
        SynchronousApplication._debug("__init__ %r", args)
        BIPSimpleApplication.__init__(self, *args)

    def confirmation(self, apdu):
        self.apdu = apdu
        stop()
        
    def indication(self, apdu):
        self.apdu = apdu
        stop()
Exemple #36
0
#/usr/bin/python

import sys
import logging
from ConfigParser import ConfigParser

from bacpypes.debugging import Logging, ModuleLogger
from bacpypes.consolelogging import ConsoleLogHandler

from bacpypes.core import run

# debug global vars
_debug = 0;
_log = ModuleLogger(globals())

# main function
def main():
try:
	_log.debug("initialiation")
	_log.debug("running")

except Exception, e:
	_log.exception("error", e)
finally:
	_log.debug("finally")

if('--buggers' in sys.argv):
	loggers = logging.Logger.manager.loggerDict.keys();
	loggers.sort();
	for loggerName in loggers:
		sys.stdout.write(lggername + '\n')