Skip to content

BACnet Simulator Guide

About

The BACnet simulator can run as a BACnet/IP or BACnet/MSTP device. It can be configured and modified via a Lua script, which allows for the creation of and interaction with various different BACnet object instances and their properties.

Running

Environment Variables

As the simulator can run in either IP or MSTP modes, an environment variable, RUN_MODE must be set to specify which mode to run in.

Option Expected Values Description
RUN_MODE IP / MSTP Controls whether the simulator will run as an IP or MSTP device

Note

If this is not set, the device will default to IP

Server Options

Several arguments can be included when running the simulator which are described below.

Option Arguments Description Example Default if not Set
--instance instance - Instance ID of the device Set the BACnet instance ID of the device on the network --instance 1234 1234
--name name - Name of the device Sets the device object name --name BACnetSimulator SimpleServer
--script script - Path to the lua script Passes a lua script to the simulator which is used to create a simulated device --script script.lua Populate the simulator with 1 instance of every object
--populate populate - Number of instances of each object Creates n instances of each type of bacnet object. Used to pad out the sim with a large amount of object instances. --populate 10 Populate the simulator with 1 instance of every object

Note

The arguments populate and script should not be used as the same time

Download the Docker image

docker pull iotechsys/bacnet-server:2.0 

Simple Run

The simulator can be run with no configuration. This will run the IP version and populate the device with 1 instance of every object. The default network ID and device object name are described the table above.

docker run --rm --name bacnet-sim iotechsys/bacnet-server:2.0

Lua Scripting

To run the simulator with one of the example lua scripts thats included in the container, a command is provided. As can be seen, both the BACnet instance ID and device name are both set along with the path to the lua script.

docker run --rm --name bacnet-sim -e RUN_MODE=IP/MSTP iotechsys/bacnet-server:2.0 --instance 1234 --name BACnetSimulator --script /example-scripts/device-service-example.lua

The script used will run the simulator with 2 instances of the objects Analog Input, Analog Output and Analog Value. The present value properties of Analog Input and Analog Value objects will update every 5 seconds with a random value between 1 and 1000.

There are a number of other example scripts provided within the docker container under the directory /example-scripts/. See Lua Scripting Examples.

To create and use your own lua script, See Lua Scripting.

Populate with Object Instances

If script driven changes to properties are not required, the populate argument can be used instead of script. This option will populate the device with n number of instances of every object type the simulator supports.

This can be an easy way create a device with a very large number of object instances. An example command is provided.

docker run --rm --name bacnet-sim -e RUN_MODE=IP/MSTP iotechsys/bacnet-server:2.0 --instance 1234 --name BACnetSimulator --populate 100

As can be seen both the BACnet instance ID and device name are both set along with number of object instances to populate the device with.

Networking Configuration

IP

If the IP version of the simulator is being run on a separate host from the BACnet device service, the following flag must be included in the docker run command:

--network=host

If the IP version simulator is running on the same host as the BACnet device service, run the simulator as instructed. Once running find the IP of the docker container with the following command:

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' bacnet-sim

Using this IP set the BBMDAddress driver option within the BACnet device service configuration file.

MSTP

To connect to the MSTP version of the simulator on the same host as the BACnet device service, run the simulator as instructed. Once running find the IP of the docker container with the following command:

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' bacnet-sim

With socat, create a serial connection to the container using its IP and set the port to /tmp/virtualport

socat pty,link=/tmp/virtualport,raw,echo=0 tcp:<IP_of_containter>:55000

Using this virtual port, set it as the SerialInterface driver option within the BACnet device service configuration file.

Back to top