How to use the bacpypes.primitivedata.Real 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_LightingOutputObject.py View on Github external
, (ReadableProperty,'trackingValue', Real)
        , (WritableProperty,'lightingCommand', LightingCommand)
        , (ReadableProperty,'inProgress', LightingInProgress)
        , (ReadableProperty,'statusFlags', StatusFlags)
        , (OptionalProperty,'reliability', Reliability)
        , (ReadableProperty,'outOfService', Boolean)
        , (ReadableProperty,'blinkWarnEnable', Boolean)
        , (ReadableProperty,'egressTime', Unsigned)
        , (ReadableProperty,'egressActive', Boolean)
        , (ReadableProperty,'defaultFadeTime', Unsigned)
        , (ReadableProperty,'defaultRampRate', Real)
        , (ReadableProperty,'defaultStepIncrement', Real)
        , (OptionalProperty,'transition', LightingTransition)
        , (OptionalProperty,'feedbackValue', Real)
        , (ReadableProperty,'priorityArray', PriorityArray)
        , (ReadableProperty,'relinquishDefault', Real)
        , (OptionalProperty,'power', Real)
        , (OptionalProperty,'instantaneousPower', Real)
        , (OptionalProperty,'minActualValue', Real)
        , (OptionalProperty,'maxActualValue', Real)
        , (ReadableProperty,'lightingCommandDefaultPriority', Unsigned)
        , (OptionalProperty,'covIncrement', Real)
        , (OptionalProperty,'reliabilityEvaluationInhibit', Boolean)
        ]
github JoelBender / bacpypes / tests / test_primitive_data / test_real.py View on Github external
def real_decode(tag):
    """Decode an real application tag into an real."""
    if _debug: real_decode._debug("real_decode %r", tag)

    obj = Real(tag)
    if _debug: real_decode._debug("    - obj: %r, %r", obj, obj.value)

    return obj
github JoelBender / bacpypes / tests / test_primitive_data / test_real.py View on Github external
def test_real_real(self):
        if _debug: TestReal._debug("test_real_real")

        obj = Real(1.0)
        assert obj.value == 1.0
        assert str(obj) == "Real(1)"

        obj = Real(73.5)
        assert obj.value == 73.5
        assert str(obj) == "Real(73.5)"
github JoelBender / bacpypes / tests / test_primitive_data / test_real.py View on Github external
def real_endec(v, x):
    """Pass the value to Real, construct a tag from the hex string,
    and compare results of encode and decoding each other."""
    if _debug: real_endec._debug("real_endec %r %r", v, x)

    tag = real_tag(x)
    if _debug: real_endec._debug("    - tag: %r, %r", tag, tag.tagData)

    obj = Real(v)
    if _debug: real_endec._debug("    - obj: %r, %r", obj, obj.value)

    assert real_encode(obj) == tag
    if _debug: real_endec._debug("    - tags match")

    if math.isnan(v):
        assert math.isnan(real_decode(tag).value)
        if _debug: real_endec._debug("    - both NaN")
    else:
        assert real_decode(tag) == obj
        if _debug: real_endec._debug("    - objects match")
github JoelBender / bacpypes / tests / test_local / test_local_schedule_2.py View on Github external
# create a writeable analog value object
        avo = WritableAnalogValueObject(
            objectIdentifier=('analogValue', 1),
            objectName='analog value 1',
            presentValue=0.0,
            )
        _log.debug("    - avo: %r", avo)
        this_application.add_object(avo)

        # create a simple daily schedule, actually a weekly schedule with
        # every day identical
        so = LocalScheduleObject(
            objectIdentifier=('schedule', 1),
            objectName='Schedule 1',
            presentValue=Real(-1.0),
            effectivePeriod=DateRange(
                startDate=(0, 1, 1, 1),
                endDate=(254, 12, 31, 2),
                ),
            weeklySchedule=ArrayOf(DailySchedule)([
                DailySchedule(
                    daySchedule=[
                        TimeValue(time=(8,0,0,0), value=Real(8)),
                        TimeValue(time=(14,0,0,0), value=Null()),
                        TimeValue(time=(17,0,0,0), value=Real(42)),
                        ]
                    ),
                ] * 7),
            listOfObjectPropertyReferences=ListOf(DeviceObjectPropertyReference)(
                [
                    DeviceObjectPropertyReference(
github JoelBender / bacpypes / tests / test_local / test_local_schedule_2.py View on Github external
from bacpypes.local.object import CurrentPropertyListMixIn
from bacpypes.local.device import LocalDeviceObject
from bacpypes.local.schedule import LocalScheduleObject

from ..time_machine import reset_time_machine, run_time_machine

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


@register_object_type(vendor_id=999)
class WritableAnalogValueObject(CurrentPropertyListMixIn, AnalogValueObject):

    properties = [
        WritableProperty('presentValue', Real),
        ]


@bacpypes_debugging
class TestLocalSchedule(unittest.TestCase):

    def test_local_schedule(self):
        if _debug: TestLocalSchedule._debug("test_local_schedule")

        # reset the time machine
        reset_time_machine(start_time="1970-01-01")

        # make a device object
        this_device = LocalDeviceObject(
            objectName="device 1",
            objectIdentifier=('device', 1),
github ChristianTremblay / BAC0 / tests / test_ReadProperty.py View on Github external
def __init__(self, *args):
        BIPSimpleApplication.__init__(Mock())
        self.elementService = Mock()
        #self.value = None
        iocb = IOCB()
        
        # Forging apdu response        
        fake_apdu = ReadPropertyACK( 
            objectIdentifier=('analogInput', 0), 
            propertyIdentifier='presentValue', 
            propertyValue=Any(Real(32)), )
        iocb.complete(fake_apdu)
        self.request = Mock()
        self.request.return_value = iocb
github JoelBender / bacpypes / sandbox / local_schedule_object_t2.py View on Github external
TimeValue(time=(14,0,0,0), value=Null()),
                    TimeValue(time=(17,0,0,0), value=Real(42)),
#                   TimeValue(time=(0,0,0,0), value=Null()),
                    ]
                ),
            ] * 7),
        listOfObjectPropertyReferences=[
            DeviceObjectPropertyReference(
                objectIdentifier=('analogValue', 1),
                propertyIdentifier='presentValue',
#               propertyArrayIndex=5,
#               deviceIdentifier=('device', 999),
                ),
            ],
        priorityForWriting=7,
        scheduleDefault=Real(0.0),
        )
    _log.debug("    - so: %r", so)
    this_application.add_object(so)

    # add an analog value object
    avo = WritableAnalogValueObject(
        objectIdentifier=('analogValue', 1),
        objectName='analog value 1',
        presentValue=0.0,
        )
    _log.debug("    - avo: %r", avo)
    this_application.add_object(avo)

    print("{} @ {}".format(so.presentValue.value, Time().now()))

    for i in range(1, 25):
github JoelBender / bacpypes / sandbox / local_schedule_object_t2.py View on Github external
#
    #   Simple daily schedule (actually a weekly schedule with every day
    #   being identical.
    #
    so = LocalScheduleObject(
        objectIdentifier=('schedule', 1),
        objectName='Schedule 1',
        presentValue=Real(-1.0),
        effectivePeriod=DateRange(
            startDate=(0, 1, 1, 1),
            endDate=(254, 12, 31, 2),
            ),
        weeklySchedule=ArrayOf(DailySchedule)([
            DailySchedule(
                daySchedule=[
                    TimeValue(time=(8,0,0,0), value=Real(8)),
                    TimeValue(time=(14,0,0,0), value=Null()),
                    TimeValue(time=(17,0,0,0), value=Real(42)),
#                   TimeValue(time=(0,0,0,0), value=Null()),
                    ]
                ),
            ] * 7),
        listOfObjectPropertyReferences=[
            DeviceObjectPropertyReference(
                objectIdentifier=('analogValue', 1),
                propertyIdentifier='presentValue',
#               propertyArrayIndex=5,
#               deviceIdentifier=('device', 999),
                ),
            ],
        priorityForWriting=7,
        scheduleDefault=Real(0.0),
github JoelBender / bacpypes / samples / ReadWriteProperty.py View on Github external
                    'r': lambda x: Real(float(x)),
                    'd': lambda x: Double(float(x)),