【问题标题】:How to create a BACnet Analog Value witch BAC0 in Python?如何在 Python 中创建 BACnet 模拟值和 BAC0?
【发布时间】:2021-03-19 22:36:54
【问题描述】:

首先,我必须说我是 Python 和 BAC0 库的绝对初学者。

我想用我的 python 脚本创建一个 Bacnet 模拟值,该脚本应该发送到另一个(物理)Bacnet 设备。 现在我只用bacnet = BAC0.lite() 命令“创建”了一个Bacnet 设备。不多,但很管用。

我花了很多时间浏览文档,但找不到让脚本发送模拟值的正确方法。

谁能帮忙?

背景:我有一个能够非常轻松地将模拟值 (0 ... 10 V) 发送到 MQTT 代理的设备。现在我想让 Raspi 接收该模拟值并将其“转换”为 Bacnet 模拟值。这个 Bacnet 模拟值将被发送到 DDC 以控制泵的功率。为此,我需要在 python 脚本中“创建” Bacnet 模拟值的正确命令/代码。

【问题讨论】:

    标签: python bacnet


    【解决方案1】:

    这是一个例子:

    #!/usr/bin/python
    
    import weakref
    import BAC0
    from bacpypes.basetypes import EngineeringUnits, DateTime
    from bacpypes.primitivedata import CharacterString, Date, Time
    
    from BAC0.core.devices.local.models import (
        analog_input,
        datetime_value,
        character_string,
    )
    from BAC0.core.devices.local.object import ObjectFactory
    from BAC0.core.devices.local.models import make_state_text
    
    def start_device():
        print("Starting BACnet device")
        new_device = BAC0.lite(deviceId=10032)
        time.sleep(1)
    
        # Analog Values
        _new_objects = analog_input(
            instance=1,
            name="Current_Temp",
            description="Current Temperature in degC",
            presentValue=0,
            properties={"units": "degreesCelsius"},
        )
        _new_objects = analog_input(
            instance=2,
            name="Current_Pressure",
            description="Current Pressure in kPa",
            presentValue=0,
            properties={"units": "kilopascals"},
        )
    
        # Character Strings
        # _new_objects = character_string(
        #    instance=1,
        #    name="Location",
        #    description="City code for data",
        #    presentValue="on-24",
        #    is_commandable=True,
        # )
    
        _new_objects.add_objects_to_application(new_device)
    return new_device
    

    【讨论】:

      猜你喜欢
      • 2023-01-25
      • 2022-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-08
      相关资源
      最近更新 更多