下面是一个例子。
#!/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,