Polling controllers on various protocols for the VisioBAS system.
- Gateway provides the opportunity to poll devices from various vendors, using various
protocols. Standardization based on
BACnet
protocol. - Supported protocols:
BACnet
,ModbusTCP
,ModbusRTU
,ModbusRTUoverTCP
,SUNAPI
. - Clients:
HTTP
,MQTT
. JSON-RPC 2.0 API
(overHTTP
andMQTT
) to control devices and request info about device.- For processing events related to object's properties you can use verifier class.
- Devices and clients periodically updates.
JSON-RPC 2.0 API
Available on http://host:port/json-rpc
. Also you may use it by MQTT (provide topics for subscribe to use).
curl --header "Content-Type: application/json" \
--request POST \
--data '{"jsonrpc":"2.0","method":"writeSetPoint","params":{"device_id":"35","object_type":"2","object_id":"1","property":"85","priority":"10","index":"-1","tag":"9","value":"40"},"id":""}' \
http://127.0.0.1:7070/json-rpc
curl -sSL https://raw.githubusercontent.com/NPPElement/visiobas-gateway/main/run/install.sh | bash -
It will update the system and download gtw_installer.py
to install VisioBAS Gateway.
Please follow the output instructions to install VisioBAS Gateway in the preferred way.
Application configures via environment variables. Environment variables are provided
via .env
file. Paths to .env
file are specified in docker-compose.yaml
.
Configuration can be changed in file:
config/.env
template
/docs contains JSON-schema definitions for used pydantic
models.
sudo apt-get install minicom # install minicom
dmesg | grep tty # show ports
sudo minicom -s # launch minicom
# Setup serial ports from minicom, then save as dfl.
sudo nano /etc/udev/rules.d/99-serial.rules
# then write line: KERNEL=="ttyUSB[0-9]*",MODE="0666"
# Explanations: https://www.losant.com/blog/how-to-access-serial-devices-in-docker
# Before launch visiobas_gateway, ensure user in the `dialout` group
sudo usermod -a -G dialout username # add to `dialout` group
id username # check user\group info
To launch on the same machine
with VisioBAS system - add
in docker-compose.yaml
the following network settings:
networks:
- backend
and
networks:
backend: # your network name
driver: bridge
Scripts for common actions available:
. run/logs_clear.sh # Clear logs
. run/update.sh # Git pull + build + launch
cd /opt/visiobas-gateway
docker build -t visiobas-gateway .
# docker save -o <path for generated tar file> <image name>
docker save -o /opt/gtw-latest-image.tar.gz visiobas-gateway:latest
# Copy via scp here
# Example: scp /opt/gtw-latest-image.tar.gz user@10.21.80.240:/opt
docker load -i <path to copied image file>
- Make sure you have Poetry installed and up to date.
- Make sure you have a supported Python version (e.g. 3.9) installed and accessible to Poetry (e.g. with pyenv.
- Use
poetry install
in the project directory to create a virtual environment with the relevant dependencies. - Enter a
poetry shell
to make running commands easier.
- Write some code and make sure it's covered by unit tests. All unit tests are in
the
tests
directory and the file structure should mirror the structure of the source code in thevisiobas_gateway
directory. - When in a Poetry shell (
poetry shell
) runtask check
in order to run most of the same checks CI runs. This will auto-reformat the code, check type annotations, run unit tests, check code coverage, and lint the code. - If writing support for a new protocol, regenerate the /docs with
task docs
. It will update JSON-schema definition for usedpydantic
models.
To clean docker:
sudo docker-compose down
sudo docker images
sudo docker rmi -f [image_id]
# OR
sudo docker images -a | xargs -n 1 -I {} sudo docker rmi -f {}
# Delete all containers
sudo docker ps -a -q | xargs -n 1 -I {} sudo docker rm -f {}
# Remove all unused images, not just dangling ones
sudo docker image prune -a -f
# If deleting or stopping the container is hopeless
sudo systemctl daemon-reload
sudo systemctl restart docker