首先,我必须说,在Python和BAC0库方面,我是一个绝对的初学者。
我想用我的python脚本创建一个Bacnet模拟值,这个脚本应该被发送到另一个(物理)Bacnet设备。目前,我只使用bacnet = BAC0.lite()
命令“创建”了一个Bacnet设备。虽然不多,但很管用。
我花了很多时间浏览文档,但是我找不到让我的脚本发送模拟值的正确方法。
有人能帮忙吗?
背景:我有一个设备可以很容易地将一个模拟值(0 .10V)发送到MQTT。现在,我想让Raspi接收到这个模拟值,并将其“转换”为Bacnet模拟值。此Bacnet模拟值将被发送到DDC以控制泵的功率。为此,我需要在python脚本中“创建”Bacnet模拟值的正确命令/代码。
发布于 2021-10-19 11:46:19
以下是一个例子:
#!/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
https://stackoverflow.com/questions/66716404
复制