-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from clavay/master
Update to Django 3
- Loading branch information
Showing
286 changed files
with
16,717 additions
and
3,429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
Use Grafana | ||
=========== | ||
|
||
Mysql | ||
----- | ||
Add user and give SELECT rights : sudo mysql -uroot -p -e "GRANT SELECT ON PyScada_db.* TO 'Grafana-user'@'localhost' IDENTIFIED BY 'Grafana-user-password';" | ||
|
||
Nginx | ||
----- | ||
Add in /etc/nginx/nginx.conf after http { ... } : | ||
:: | ||
include /etc/nginx/grafana-access.conf; | ||
Create /etc/nginx/grafana-access.conf with : | ||
:: | ||
stream { | ||
# MySQL server | ||
server { | ||
listen 3305; | ||
proxy_pass 127.0.0.1:3306; | ||
proxy_timeout 60s; | ||
proxy_connect_timeout 30s; | ||
} | ||
} | ||
Restart Nginx : | ||
:: | ||
sudo systemctl restart nginx | ||
|
||
Grafana | ||
------- | ||
Add DB : | ||
- Host : | ||
- Local : /run/mysqld/mysqld.sock | ||
- Remote : remote_ip:3305 | ||
- Database : PyScada_db | ||
- User : Grafana-user | ||
- Password : Grafana-user-password | ||
|
||
Import the exported dashboard (json file in extras directory). | ||
|
||
Or for example, add theses variables : set refresh on dashboard load, multi-value and all option : | ||
- Add mysql datasource variable (type Datasource). | ||
- Add variables with type query using $Datasource : | ||
- Protocols : SELECT protocol AS __text, id AS __value FROM pyscada_deviceprotocol | ||
- Devices : SELECT d.short_name AS __text, d.id AS __value FROM pyscada_device d WHERE d.protocol_id IN (${Protocols}) AND d.active = 1 | ||
- Units : SELECT u.unit AS __text, u.id AS __value FROM pyscada_unit u | ||
- Variables : SELECT v.name AS __text, v.id AS __value FROM pyscada_variable v WHERE v.device_id IN (${Devices}) AND v.unit_id IN (${Units}) AND v.active = 1 | ||
- Time group (type Interval) : 1s,10s,1m,10m,30m,1h,6h,12h,1d,7d,14d,30d,1M | ||
- Null as (type custom) : 0, NULL, previous | ||
|
||
Example query : | ||
:: | ||
SELECT | ||
$__timeGroupAlias(r.date_saved,$time_group), | ||
avg(IFNULL(r.value_float64, 0.0) + IFNULL(r.value_int64, 0.0) + IFNULL(r.value_int32, 0.0) + IFNULL(r.value_int16, 0.0) + IFNULL(r.value_boolean, 0.0)), | ||
v.name AS metric | ||
FROM pyscada_recordeddata as r | ||
JOIN pyscada_variable v ON r.variable_id = v.id | ||
WHERE | ||
$__timeFilter(r.date_saved) AND | ||
r.variable_id IN (${Variables}) | ||
GROUP BY time, metric | ||
ORDER BY $__timeGroup(r.date_saved,$time_group,$null_as) | ||
|
||
Embed in pyscada HMI | ||
-------------------- | ||
Edit Grafana config file: | ||
:: | ||
sudo nano /etc/grafana/grafana.ini | ||
|
||
Find and set : | ||
- allow_embedding = true | ||
- For localhost grafana : root_url = http://localhost:3000/grafana/ | ||
|
||
For localhost grafana add in /etc/nginx/sites-enabled/pyscada.conf : | ||
:: | ||
location /grafana/ { | ||
proxy_pass http://127.0.0.1:3000/; | ||
} | ||
Restart Grafana server: | ||
:: | ||
sudo systemctl restart grafana-server.service | ||
Create a custom html panel with the code from a dashboard or a panel from sharing options in grafana | ||
|
||
Other | ||
----- | ||
use ssl : http://www.turbogeek.co.uk/2020/09/30/grafana-how-to-configure-ssl-https-in-grafana/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Installation | ||
============ | ||
Phant Installation | ||
================== | ||
|
||
add the following line to the urls.py: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Raspberry Pi OS Installation | ||
============================ | ||
|
||
Download last Lite image from `here <https://www.raspberrypi.com/software/operating-systems/>`__ | ||
|
||
Copy the image on the SD card using (change the name of the zip file and the path to the sd card):: | ||
|
||
unzip -p the_zip_file.zip | sudo dd of=/dev/sdX bs=4M conv=fsync | ||
|
||
More informations `here <https://www.raspberrypi.com/documentation/computers/getting-started.html>`__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Discover VISA devices | ||
===================== | ||
|
||
To discover GPIB/USB(/LXI?) devices run: | ||
|
||
:: | ||
|
||
sudo python3 | ||
import pyvisa | ||
rm=pyvisa.ResourceManager('@py') | ||
rm.list_resources() # example : ('ASRL/dev/ttyAMA0::INSTR', 'USB0::1689::1032::C023569::0::INSTR', 'USB0::1689::851::1525638::0::INSTR') | ||
inst=rm.open_resource('USB0::1689::851::1525638::0::INSTR'') | ||
inst.query('*IDN?') # example : 'TEKTRONIX,AFG1022,1525638,SCPI:99.0 FV:V1.1.2\n' |
Oops, something went wrong.