DeviceControl
is a tool to provide unified interface to control and measure data in specific cultivation device.
We recommend reading wiki to get started with the tool
and documentation to get more details about the implementation.
DeviceControl
runs in a Docker
container with locally installed database.
The reason for installation of database locally is to make data more persistent and prone to unintentional deletion.
-
Before we start, it is necessary to install
mySQL
database anddocker
:sudo scripts/install_dependencies.sh
-
Then we need to set up the database:
sudo scripts/setup_database.sh "<username>" "<password>"
-
Set environment variable to DATABASE to your local IP address - this is used by
docker
to access the databaseDATABASE=$(/sbin/ifconfig <interface> | sed -En -e 's/.*inet ([0-9.]+).*/\1/p')
-
Enable connections to your
mySQL
database from outside oflocalhost
(might even require opening firewall for port 3306) -
Download docker and start the
docker
:docker run -d --privileged -v /dev/serial/by-port/:/dev/serial/by-port/ -p 0.0.0.0:5000:5000 --restart unless-stopped --add-host="database:$DATABASE" --env-file DB_CONFIG --name "devicecontrol" bioarineo/devicecontrol:latest-<platform>
where
<platform>
is eitheramd
orarm
. Theby-port
is mapped todocker
file system to access devices connected to I/O ports.
DeviceControl
is running and ready to be used.
Inspect and execute scripts/example_run.py
to see demonstration of tool's usability on a simulated device.
Assuming DeviceControl
is properly installed and running, follow these steps to quickly setup a device and execute a measurement:
import requests
# device configuration
test_PBR_device = {
'device_id': PBR_id,
'device_class': 'test',
'device_type': 'PBR',
'address': 'null',
}
# register the device
requests.post('http://localhost:5000/device', json=test_PBR_device)
# configuration of a command for measurement of temperature
cmd = {'device_id': PBR_id,
'command_id': '2',
'await': True
}
response = requests.post('http://localhost:5000/command', json=cmd)
print("The current temperature is", response.json()['data']['temp'])