Skip to content

Commit a01ff35

Browse files
authored
Merge pull request #44 from clavay/master
Update to Django 3
2 parents 16c7c01 + 5632f6c commit a01ff35

File tree

286 files changed

+16717
-3429
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

286 files changed

+16717
-3429
lines changed

CHANGELOG.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,43 @@
214214
- fixed re-login after logout (#22)
215215
- added LINK_TARGET option to change the default behaviour of links in view overview (#23)
216216
- Catching exceptions if DB close while pyscada is running
217+
218+
0.7.0rc17, 0.7.0rc18
219+
- add pre_delete signals to stop the background process before deleting a device
220+
- move widget post_save signal to the model to remove the global receiver (not filtering by sender)
221+
- move device handlers to core
222+
- add stop in DAQ Process restart
223+
- move the device and variable protocol specific configuration to core
224+
- add protocol name in device __str__ for the variable js admin file
225+
- add complex events
226+
227+
0.7.0rc19
228+
- add fk_name in admin for bacnet device with 2 ForeignKey to Device model
229+
230+
0.7.0rc20
231+
- add django channels to send informations between processes
232+
233+
0.7.0rc21
234+
- Update docker config file
235+
- Add optional PID_FILE_NAME to settings to allow multiple instances
236+
- Add custom periodic auto caltulated variable
237+
238+
0.7.0rc22
239+
- Add choose_login.html to have multiple login ways
240+
- Add circular gauge to display control items
241+
- Add silent delete option in admin for VariableState and Device to delete a lot of data
242+
- Add grafana doc and config file to use Grafana to display data from a PyScada instance
243+
- Add dictionaries to store string with a key. Allows to store strings for Variables
244+
245+
0.7.0rc23
246+
- Add svg to render ProcessFlowDiagram. Allows to resize to fit the window size
247+
- Add OPC-UA protocol
248+
- close DB connection in scheduler to allow multiple instance on the same DB to run
249+
- Add INT8 and UINT8 variable value class
250+
- change the date range picker JS library
251+
- Add logrotate config file
252+
- Add a slider to change the refresh rate value of data handling
253+
254+
0.7.1rc1
255+
- Update to Django 3
256+
- Update docker config and doc to use pyscada repository

docker/nginx/nginx.conf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@ http {
5252
}
5353

5454
# configuration of the server
55-
server {
56-
listen 80;
57-
listen [::]:80;
58-
server_name _; # substitute your machine's IP address or FQDN
59-
return 301 https://$host$request_uri;
60-
}
55+
#server {
56+
# listen 80;
57+
# listen [::]:80;
58+
# server_name _; # substitute your machine's IP address or FQDN
59+
# return 301 https://$host$request_uri;
60+
#}
6161

6262
server {
63-
listen 443 default_server ssl;
63+
listen 80 default_server;
64+
listen [::]:80;
65+
listen 443 ssl;
6466
listen [::]:443 ssl;
6567

6668
server_name _; # substitute your machine's IP address or FQDN

docker/pyscada/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ WORKDIR /src/pyscada
1818

1919
RUN pip3 install gunicorn
2020
RUN pip3 install mysqlclient
21-
RUN pip3 install https://github.com/trombastic/PyScada/archive/dev/0.7.x.zip
21+
RUN pip3 install https://github.com/pyscada/PyScada/tarball/master
2222
RUN django-admin startproject PyScadaServer /src/pyscada/ --template /src/pyscada/project_template.zip
2323
RUN chmod +x /src/pyscada/pyscada
2424
RUN chmod +x /src/pyscada/pyscada_init

docs/conf.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
# import sys
1717
# sys.path.insert(0, os.path.abspath('.'))
1818

19+
# Django setup
20+
import os
21+
import sys
22+
import django
23+
sys.path.insert(0, os.path.abspath('..'))
24+
sys.path.append("/var/www/pyscada/PyScadaServer/PyScadaServer/")
25+
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
26+
django.setup()
27+
1928

2029
# -- Project information -----------------------------------------------------
2130

@@ -26,7 +35,7 @@
2635
# The short X.Y version
2736
version = ''
2837
# The full version, including alpha/beta/rc tags
29-
release = '0.7.0rc16'
38+
release = '0.7.1rc1'
3039

3140

3241
# -- General configuration ---------------------------------------------------
@@ -39,8 +48,13 @@
3948
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4049
# ones.
4150
extensions = [
51+
'sphinx.ext.autodoc',
52+
'sphinx_js',
4253
]
4354

55+
# Set JavaScript source paths
56+
js_source_path = '../pyscada/hmi/static/pyscada/js/pyscada'
57+
4458
# Add any paths that contain templates here, relative to this directory.
4559
templates_path = ['_templates']
4660

@@ -85,7 +99,7 @@
8599
# Add any paths that contain custom static files (such as style sheets) here,
86100
# relative to this directory. They are copied after the builtin static files,
87101
# so a file named "default.css" will overwrite the builtin "default.css".
88-
html_static_path = ['_static']
102+
#html_static_path = ['_static']
89103

90104
# Custom sidebar templates, must be a dictionary that maps document names
91105
# to template names.

docs/device_protokol.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ Device Protocol IDs
55
- 1: Reserved (Scheduler)
66
- 2: SystemStat
77
- 3: Modbus
8-
- 4: BACNet
8+
- 4: `BACNet <https://github.com/pyscada/PyScada-BACNet>`_
99
- 5: VISA
1010
- 6: 1-Wire
1111
- 7: Phant
1212
- 8: SMBus
1313
- 9: Reserved (Jofra350)
14-
- 10: GPIO
15-
- 11: PT104
16-
- 13: `SML (Smart Meter Language) <https://github.com/gkend/PyScada-SML>`_
14+
- 10: `GPIO <https://github.com/pyscada/PyScada-GPIO>`_
15+
- 11: `Reserved (PT104) <https://github.com/pyscada/PyScada-PT104>`_
16+
- 12: `OPC-UA <https://github.com/clavay/PyScada-OPCUA>`_
17+
- 13: `SML (Smart Meter Language) <https://github.com/gkend/PyScada-SML>`_
1718
- 8X: Custom Worker
18-
- 95: Reserved (Scripting)
19+
- 93 `Reserved (Serial) <https://github.com/clavay/PyScada-Serial>`_
20+
- 94 `Reserved (WebService) <https://github.com/clavay/PyScada-WebService>`_
21+
- 95: `Reserved (Scripting) <https://github.com/pyscada/PyScada-Scripting>`_
1922
- 96: Reserved (Event)
2023
- 97: Reserved (Mail)
2124
- 98: Reserved (Report)

docs/docker.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ Using Git.
1616

1717
::
1818

19-
git clone https://github.com/trombastic/PyScada.git
19+
git clone https://github.com/pyscada/PyScada.git
2020
cd PyScada/docker
2121

2222
Using wget.
2323

2424
::
2525

26-
wget -qO- -O tmp.zip https://github.com/trombastic/PyScada/archive/dev/0.7.x.zip && unzip tmp.zip && rm tmp.zip
27-
cd PyScada-dev-0.7.x/docker
26+
wget -qO- -O tmp.zip https://github.com/pyscada/PyScada/archive/refs/heads/master.zip && unzip tmp.zip && rm tmp.zip
27+
cd PyScada-master/docker
2828

2929

3030
Generating SSL Certificates
@@ -34,6 +34,7 @@ Generate ssl certificates for using ssl.
3434

3535
::
3636

37+
mkdir nginx/ssl
3738
cd nginx/ssl
3839
openssl req -x509 -nodes -days 1780 -newkey rsa:2048 -keyout ./pyscada_server.key -out ./pyscada_server.crt
3940

@@ -60,4 +61,11 @@ The last step is to start the Container.
6061

6162
::
6263

63-
sudo docker-compose up -d
64+
sudo docker-compose up -d
65+
66+
If you have an error or a command is stuck, run :
67+
68+
::
69+
70+
sudo docker-compose down
71+
sudo docker system prune --force --volumes

docs/grafana.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
Use Grafana
2+
===========
3+
4+
Mysql
5+
-----
6+
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';"
7+
8+
Nginx
9+
-----
10+
Add in /etc/nginx/nginx.conf after http { ... } :
11+
::
12+
include /etc/nginx/grafana-access.conf;
13+
Create /etc/nginx/grafana-access.conf with :
14+
::
15+
stream {
16+
# MySQL server
17+
server {
18+
listen 3305;
19+
proxy_pass 127.0.0.1:3306;
20+
proxy_timeout 60s;
21+
proxy_connect_timeout 30s;
22+
}
23+
}
24+
Restart Nginx :
25+
::
26+
sudo systemctl restart nginx
27+
28+
Grafana
29+
-------
30+
Add DB :
31+
- Host :
32+
- Local : /run/mysqld/mysqld.sock
33+
- Remote : remote_ip:3305
34+
- Database : PyScada_db
35+
- User : Grafana-user
36+
- Password : Grafana-user-password
37+
38+
Import the exported dashboard (json file in extras directory).
39+
40+
Or for example, add theses variables : set refresh on dashboard load, multi-value and all option :
41+
- Add mysql datasource variable (type Datasource).
42+
- Add variables with type query using $Datasource :
43+
- Protocols : SELECT protocol AS __text, id AS __value FROM pyscada_deviceprotocol
44+
- 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
45+
- Units : SELECT u.unit AS __text, u.id AS __value FROM pyscada_unit u
46+
- 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
47+
- Time group (type Interval) : 1s,10s,1m,10m,30m,1h,6h,12h,1d,7d,14d,30d,1M
48+
- Null as (type custom) : 0, NULL, previous
49+
50+
Example query :
51+
::
52+
SELECT
53+
$__timeGroupAlias(r.date_saved,$time_group),
54+
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)),
55+
v.name AS metric
56+
FROM pyscada_recordeddata as r
57+
JOIN pyscada_variable v ON r.variable_id = v.id
58+
WHERE
59+
$__timeFilter(r.date_saved) AND
60+
r.variable_id IN (${Variables})
61+
GROUP BY time, metric
62+
ORDER BY $__timeGroup(r.date_saved,$time_group,$null_as)
63+
64+
Embed in pyscada HMI
65+
--------------------
66+
Edit Grafana config file:
67+
::
68+
sudo nano /etc/grafana/grafana.ini
69+
70+
Find and set :
71+
- allow_embedding = true
72+
- For localhost grafana : root_url = http://localhost:3000/grafana/
73+
74+
For localhost grafana add in /etc/nginx/sites-enabled/pyscada.conf :
75+
::
76+
location /grafana/ {
77+
proxy_pass http://127.0.0.1:3000/;
78+
}
79+
Restart Grafana server:
80+
::
81+
sudo systemctl restart grafana-server.service
82+
Create a custom html panel with the code from a dashboard or a panel from sharing options in grafana
83+
84+
Other
85+
-----
86+
use ssl : http://www.turbogeek.co.uk/2020/09/30/grafana-how-to-configure-ssl-https-in-grafana/

docs/index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ A Open Source SCADA System with HTML5 HMI, build using the Django framework. If
2121
frontend
2222
backend
2323
phant
24-
24+
device_protokol
25+
grafana
26+
raspberryPiOS
27+
visa
2528

2629

2730

docs/installation.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,29 @@
88
Installation
99
============
1010

11-
This installation guide covers the installation of PyScada for `Debian 7/8/9 <https://www.debian.org/>`_ ,
12-
`Raspbian <https://www.raspbian.org/>`_, `Fedora 22/23 <https://www.fedoraproject.org/>`_ based Linux systems
11+
This installation guide covers the installation of PyScada for `Debian 10/11 <https://www.debian.org/>`_ ,
12+
`Raspberry Pi OS <https://www.raspberrypi.com/software/>`_, `Fedora 22/23 <https://www.fedoraproject.org/>`_ based Linux systems
1313
using `MySQL <https://www.mysql.com/>`_ / `MariaDB <https://mariadb.com/>`_ or `SQLite <https://www.sqlite.org/>`_ as Database,
1414
`Gunicorn <http://gunicorn.org/>`_ as WSGI HTTP Server and `nginx <http://nginx.org/>`_ as HTTP Server.
1515

16+
Automatic installation using a script
17+
-------------------------------------
18+
19+
On the Raspberry Pi with internet connection run :
20+
21+
::
22+
23+
wget https://raw.githubusercontent.com/clavay/PyScada-Laborem/master/extras/install.sh -O install.sh
24+
sudo chmod a+x install.sh
25+
sudo ./install.sh
26+
1627

1728
Dependencies
1829
------------
1930

2031

2132
Debian 9, Raspbian
22-
^^^^^^^^^^^^^^^^^^^^
33+
^^^^^^^^^^^^^^^^^^
2334

2435
::
2536

docs/phant.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Installation
2-
============
1+
Phant Installation
2+
==================
33

44
add the following line to the urls.py:
55

0 commit comments

Comments
 (0)