How to use the bacpypes.debugging.ModuleLogger function in bacpypes

To help you get started, we’ve selected a few bacpypes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JoelBender / bacpypes / tests / test_objects / test_PositiveIntegerValueObject.py View on Github external
LockStatus, LogMultipleRecord, LogRecord, LogStatus, LoggingType, \
    Maintenance, NetworkSecurityPolicy, NodeType, NotifyType, \
    ObjectPropertyReference, ObjectTypesSupported, OptionalCharacterString, \
    Polarity, PortPermission, Prescale, PriorityArray, ProcessIdSelection, \
    ProgramError, ProgramRequest, ProgramState, PropertyAccessResult, \
    PropertyIdentifier, Recipient, Reliability, RestartReason, Scale, \
    SecurityKeySet, SecurityLevel, Segmentation, ServicesSupported, \
    SetpointReference, ShedLevel, ShedState, SilencedState, SpecialEvent, \
    StatusFlags, TimeStamp, VTClass, VTSession, WriteStatus
from bacpypes.errors import ConfigurationError, ExecutionError
from bacpypes.apdu import EventNotificationParameters, ReadAccessSpecification, \
    ReadAccessResult

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

@bacpypes_debugging
class Test_PositiveIntegerValueObject(unittest.TestCase, TestObjectHelper):
    """
    This test will verify that the object created has good number of properties
    Will test that each property is correct datatype
    Will test that only Writable property can be written
    Will test that all properties can be read
    """
    def setUp(self):
        if _debug: Test_PositiveIntegerValueObject._debug("Test_PositiveIntegerValueObject")
        self.obj = PositiveIntegerValueObject()
        self.objType = 'positiveIntegerValue'
        self.identifiers = self.build_list_of_identifiers(self.obj.properties)
        self.numberOfPropertiesRequired = 29
        self.writeValue = 0
github JoelBender / bacpypes / tests / test_primitive_data / test_double.py View on Github external
Test Primitive Data Double
--------------------------
"""

import unittest
import struct
import math

from bacpypes.debugging import bacpypes_debugging, ModuleLogger, xtob

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

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


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

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

    return tag


@bacpypes_debugging
def double_encode(obj):
github JoelBender / bacpypes / samples / ReadPropertyMultiple.py View on Github external
from bacpypes.pdu import Address
from bacpypes.object import get_datatype

from bacpypes.apdu import ReadPropertyMultipleRequest, PropertyReference, \
    ReadAccessSpecification, ReadPropertyMultipleACK
from bacpypes.primitivedata import Unsigned, ObjectIdentifier
from bacpypes.constructeddata import Array
from bacpypes.basetypes import PropertyIdentifier

from bacpypes.app import BIPSimpleApplication
from bacpypes.local.device import LocalDeviceObject

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

# globals
this_application = None

#
#   ReadPropertyMultipleConsoleCmd
#

@bacpypes_debugging
class ReadPropertyMultipleConsoleCmd(ConsoleCmd):

    def do_read(self, args):
        """read  (  (  [  ] )... )..."""
        args = args.split()
        if _debug: ReadPropertyMultipleConsoleCmd._debug("do_read %r", args)
github JoelBender / bacpypes / samples / ReadWriteProperty.py View on Github external
from bacpypes.pdu import Address
from bacpypes.object import get_datatype

from bacpypes.apdu import SimpleAckPDU, \
    ReadPropertyRequest, ReadPropertyACK, WritePropertyRequest
from bacpypes.primitivedata import Null, Atomic, Boolean, Unsigned, Integer, \
    Real, Double, OctetString, CharacterString, BitString, Date, Time, ObjectIdentifier
from bacpypes.constructeddata import Array, Any, AnyAtomic

from bacpypes.app import BIPSimpleApplication
from bacpypes.local.device import LocalDeviceObject

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

# globals
this_application = None

#
#   ReadWritePropertyConsoleCmd
#

@bacpypes_debugging
class ReadWritePropertyConsoleCmd(ConsoleCmd):

    def do_read(self, args):
        """read    [  ]"""
        args = args.split()
        if _debug: ReadWritePropertyConsoleCmd._debug("do_read %r", args)
github JoelBender / bacpypes / sandbox / local_schedule_object_t1.py View on Github external
from bacpypes.app import BIPSimpleApplication
from bacpypes.local.object import CurrentPropertyListMixIn
from bacpypes.local.device import LocalDeviceObject

### testing
import time

sys.path[:0] = ['.']
from tests.time_machine import TimeMachine, reset_time_machine, run_time_machine, xdatetime
global timemachine
###

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

### testing
schedule_objects = []

@bacpypes_debugging
def setup_module(module=None):
    if _debug: setup_module._debug("setup_module %r", module)
    global time_machine

    # this is a singleton
    time_machine = TimeMachine()

    # make sure this is the same one referenced by the functions
    assert time_machine is reset_time_machine.__globals__['time_machine']
    assert time_machine is run_time_machine.__globals__['time_machine']
github JoelBender / bacpypes / samples / WhoIsRouter.py View on Github external
from bacpypes.consolelogging import ConfigArgumentParser
from bacpypes.consolecmd import ConsoleCmd

from bacpypes.core import run, enable_sleeping

from bacpypes.pdu import Address
from bacpypes.npdu import (
    WhoIsRouterToNetwork, IAmRouterToNetwork,
    InitializeRoutingTable, InitializeRoutingTableAck,
    )

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)
github JoelBender / bacpypes / sandbox / local_schedule_object_t2.py View on Github external
from bacpypes.app import Application
from bacpypes.local.object import CurrentPropertyListMixIn
from bacpypes.local.device import LocalDeviceObject

### testing
import time

sys.path[:0] = ['.']
from tests.time_machine import TimeMachine, reset_time_machine, run_time_machine, xdatetime
global timemachine
###

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

### testing
@bacpypes_debugging
def setup_module(module=None):
    if _debug: setup_module._debug("setup_module %r", module)
    global time_machine

    # this is a singleton
    time_machine = TimeMachine()

    # make sure this is the same one referenced by the functions
    assert time_machine is reset_time_machine.__globals__['time_machine']
    assert time_machine is run_time_machine.__globals__['time_machine']


@bacpypes_debugging
github JoelBender / bacpypes / samples / RandomAnalogValueSleep.py View on Github external
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser

from bacpypes.core import run

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

from bacpypes.app import BIPSimpleApplication
from bacpypes.local.device import LocalDeviceObject

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

# settings
SLEEP_TIME = float(os.getenv('SLEEP_TIME', 0.1))
RANDOM_OBJECT_COUNT = int(os.getenv('RANDOM_OBJECT_COUNT', 10))

# globals
args = None

#
#   RandomValueProperty
#

class RandomValueProperty(Property):

    def __init__(self, identifier):
        if _debug: RandomValueProperty._debug("__init__ %r", identifier)
github JoelBender / bacpypes / samples / Discover.py View on Github external
NetworkNumberIs,
    )

# IPv4 virtual link layer
from bacpypes.bvllservice import BIPSimple, AnnexJCodec, UDPMultiplexer

# basic objects
from bacpypes.local.device import LocalDeviceObject

# basic services
from bacpypes.service.device import WhoIsIAmServices
from bacpypes.service.object import ReadWritePropertyServices

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

# globals
args = None
this_device = None
this_application = None
snapshot = None

# print statements just for interactive
interactive = sys.stdin.isatty()

#
#   Snapshot
#

@bacpypes_debugging
class Snapshot:
github JoelBender / bacpypes / samples / ThreadedReadProperty.py View on Github external
from bacpypes.core import run, stop, deferred
from bacpypes.iocb import IOCB

from bacpypes.pdu import Address
from bacpypes.object import get_datatype

from bacpypes.apdu import ReadPropertyRequest
from bacpypes.primitivedata import Unsigned, ObjectIdentifier
from bacpypes.constructeddata import Array

from bacpypes.app import BIPSimpleApplication
from bacpypes.local.device import LocalDeviceObject

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

# globals
this_application = None

# point list, set according to your devices
point_list = [
    ('10.0.1.14', [
        ('analogValue:1', 'presentValue'),
        ('analogValue:2', 'presentValue'),
        ]),
    ('10.0.1.15', [
        ('analogValue:1', 'presentValue'),
        ('analogValue:2', 'presentValue'),
        ]),
    ]