Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gkend committed Jan 30, 2020
1 parent 17a7ce1 commit 9924553
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 87 deletions.
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ Add the PyScada sub-app to the installed apps list of Django.
'pyscada.sml',
...
]

Migrate Django Instance

::
cd /var/www/pyscada/PyscadaServer/
sudo -u pyscada python3 manage.py migrate sml

Restart Services

::
Expand Down
6 changes: 3 additions & 3 deletions pyscada/sml/admin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from pyscada.gpio import PROTOCOL_ID
from pyscada.gpio.models import SMLDevice
from pyscada.gpio.models import SMLVariable
from pyscada.sml import PROTOCOL_ID
from pyscada.sml.models import SMLDevice
from pyscada.sml.models import SMLVariable
from pyscada.admin import DeviceAdmin
from pyscada.admin import VariableAdmin
from pyscada.admin import admin_site
Expand Down
16 changes: 7 additions & 9 deletions pyscada/sml/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,31 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name='ExtendedSmlDevice',
name='ExtendedSMLDevice',
fields=[
],
options={
'verbose_name': 'Sml Device',
'verbose_name_plural': 'Sml Devices',
'verbose_name': 'SML Device',
'verbose_name_plural': 'SML Devices',
'proxy': True,
'indexes': [],
'constraints': [],
},
bases=('pyscada.device',),
),
migrations.CreateModel(
name='ExtendedSmlVariable',
name='ExtendedSMLVariable',
fields=[
],
options={
'verbose_name': 'Sml Variable',
'verbose_name_plural': 'Sml Variables',
'verbose_name': 'SML Variable',
'verbose_name_plural': 'SML Variables',
'proxy': True,
'indexes': [],
'constraints': [],
},
bases=('pyscada.variable',),
),
migrations.CreateModel(
name='SmlDevice',
name='SMLDevice',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('port', models.CharField(blank=True, default='/dev/ttyUSB0', help_text='serial port', max_length=400)),
Expand Down
2 changes: 1 addition & 1 deletion pyscada/sml/migrations/0002_add_device_protocol.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2017-02-24 12:49
from __future__ import unicode_literals
from pyscada.gpio import PROTOCOL_ID
from pyscada.sml import PROTOCOL_ID

from django.db import migrations

Expand Down
37 changes: 0 additions & 37 deletions pyscada/sml/migrations/0003_auto_20200124_1226.py

This file was deleted.

36 changes: 36 additions & 0 deletions pyscada/sml/migrations/0003_auto_20200130_1550.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.27 on 2020-01-30 15:50
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('pyscada', '0054_auto_20190411_0749'),
('sml', '0002_add_device_protocol'),
]

operations = [
migrations.CreateModel(
name='SMLVariable',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('obis_code', models.CharField(default='', help_text='Obis Kennziffer: `1-0.1.8.0*255`', max_length=400)),
('sensor_type', models.CharField(choices=[('ISKAR MT175', 'ISKAR MT175'), ('EYS Q3MA', 'EYS Q3MA')], default='', max_length=10)),
('sml_variable', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='pyscada.Variable')),
],
),
migrations.AddField(
model_name='smldevice',
name='device_id',
field=models.CharField(blank=True, help_text='e.g. `1 ISK00 XXXXXXXX`', max_length=400),
),
migrations.AddField(
model_name='smldevice',
name='pin',
field=models.IntegerField(blank=True, help_text='to get advanced data from device', null=True),
),
]
18 changes: 0 additions & 18 deletions pyscada/sml/migrations/0004_auto_20200124_1250.py

This file was deleted.

21 changes: 4 additions & 17 deletions pyscada/sml/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@


@python_2_unicode_compatible
class SmlVariable(models.Model):
class SMLVariable(models.Model):
sml_variable = models.OneToOneField(Variable, on_delete=models.CASCADE)
obis_code = models.CharField(default='', max_length=400, help_text='Obis Kennziffer: `1-0.1.8.0*255`')

sensor_type_choices = (
('MT175', 'MT175'),
('Q3MA', 'Q3MA'),
('ISKAR MT175', 'ISKAR MT175'),
('EYS Q3MA', 'EYS Q3MA'),
)

sensor_type = models.CharField(default='', max_length=10, choices=sensor_type_choices)
Expand All @@ -27,7 +27,7 @@ def __str__(self):


@python_2_unicode_compatible
class SmlDevice(models.Model):
class SMLDevice(models.Model):
sml_device = models.OneToOneField(Device, on_delete=models.CASCADE)
port = models.CharField(default='/dev/ttyUSB0',max_length=400, blank=True, help_text='serial port')
device_id = models.CharField(max_length=400,blank=True, help_text='e.g. `1 ISK00 XXXXXXXX`')
Expand All @@ -38,16 +38,3 @@ def __str__(self):
return self.sml_device.short_name


class ExtendedSmlDevice(Device):
class Meta:
proxy = True
verbose_name = 'Sml Device'
verbose_name_plural = 'Sml Devices'


class ExtendedSmlVariable(Variable):
class Meta:
proxy = True
verbose_name = 'Sml Variable'
verbose_name_plural = 'Sml Variables'

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author=sml.__author__,
author_email=sml.__email__,
name='pyscada-sml',
version=gpio.__version__,
version=sml.__version__,
description='SML extension for PyScada a Python and Django based Open Source SCADA System',
long_description=open(os.path.join(os.path.dirname(__file__), 'README.rst')).read(),
url='http://www.github.com/gkend/PyScada-SML',
Expand Down

0 comments on commit 9924553

Please sign in to comment.