Has anyone built multiple virtual local devices with bacnet4j on a BACnet server? What has to be done, to achieve this?
Is this basically possible at all?
My recommendation would be to consider the use of the loopback address, or rather (not commonly known) the lookback address range.
In other words, as much as many people are familiar that the IP(v4) address of 127.0.0.1 is the loopback address, not many people know/stop to realise that it's a Class A address, in other words there are many (local) IP(v4) addresses that you can use/that are available within this 127.x.y.z loopback range, e.g. 127.0.0.2/etc in addition to the typical/default 127.0.0.1 address - both (/all addresses within the range) will (/should) resolve to your local machine, therefore allowing all your (virtual) devices to have the same (BACnet) port # but all have assigned/use a unique IP address.
Yes you can create a BACnet server using bacnet4j. The following example shows how to set up a device with an analog value BACnet object:
Note that you have to ensure that the object identifier (analog value 1 in the example) is unique on the device.