From 9924553441e6f7bc767de52ad918e0b3b8fe36dc Mon Sep 17 00:00:00 2001 From: Gregor Kendzierski Date: Thu, 30 Jan 2020 16:59:38 +0100 Subject: [PATCH] fix --- README.rst | 8 +++- pyscada/sml/admin.py | 6 +-- pyscada/sml/migrations/0001_initial.py | 16 ++++---- .../migrations/0002_add_device_protocol.py | 2 +- .../sml/migrations/0003_auto_20200124_1226.py | 37 ------------------- .../sml/migrations/0003_auto_20200130_1550.py | 36 ++++++++++++++++++ .../sml/migrations/0004_auto_20200124_1250.py | 18 --------- pyscada/sml/models.py | 21 ++--------- setup.py | 2 +- 9 files changed, 59 insertions(+), 87 deletions(-) delete mode 100644 pyscada/sml/migrations/0003_auto_20200124_1226.py create mode 100644 pyscada/sml/migrations/0003_auto_20200130_1550.py delete mode 100644 pyscada/sml/migrations/0004_auto_20200124_1250.py diff --git a/README.rst b/README.rst index f973678..37da424 100644 --- a/README.rst +++ b/README.rst @@ -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 :: diff --git a/pyscada/sml/admin.py b/pyscada/sml/admin.py index 459ce8b..96f6f54 100644 --- a/pyscada/sml/admin.py +++ b/pyscada/sml/admin.py @@ -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 diff --git a/pyscada/sml/migrations/0001_initial.py b/pyscada/sml/migrations/0001_initial.py index 9682196..020a8c1 100644 --- a/pyscada/sml/migrations/0001_initial.py +++ b/pyscada/sml/migrations/0001_initial.py @@ -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)), diff --git a/pyscada/sml/migrations/0002_add_device_protocol.py b/pyscada/sml/migrations/0002_add_device_protocol.py index afb708d..ebba18d 100644 --- a/pyscada/sml/migrations/0002_add_device_protocol.py +++ b/pyscada/sml/migrations/0002_add_device_protocol.py @@ -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 diff --git a/pyscada/sml/migrations/0003_auto_20200124_1226.py b/pyscada/sml/migrations/0003_auto_20200124_1226.py deleted file mode 100644 index 32eb603..0000000 --- a/pyscada/sml/migrations/0003_auto_20200124_1226.py +++ /dev/null @@ -1,37 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-24 12:26 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('sml', '0002_add_protocol_id'), - ] - - operations = [ - migrations.RemoveField( - model_name='smlvariable', - name='address', - ), - 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, default=None, help_text='to get advanced data from device'), - ), - migrations.AddField( - model_name='smlvariable', - name='obis_code', - field=models.CharField(default='', help_text='Obis Kennziffer: `1-0.1.8.0*255`', max_length=400), - ), - migrations.AlterField( - model_name='smlvariable', - name='sensor_type', - field=models.CharField(choices=[('MT175', 'MT175 Elektronischer EDL-Dreiphasen-Wirkverbrauchzähler'), ('Q3MA', 'Q3MA Elektronischer Haushaltszähler')], default='', max_length=10), - ), - ] diff --git a/pyscada/sml/migrations/0003_auto_20200130_1550.py b/pyscada/sml/migrations/0003_auto_20200130_1550.py new file mode 100644 index 0000000..7b72d2a --- /dev/null +++ b/pyscada/sml/migrations/0003_auto_20200130_1550.py @@ -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), + ), + ] diff --git a/pyscada/sml/migrations/0004_auto_20200124_1250.py b/pyscada/sml/migrations/0004_auto_20200124_1250.py deleted file mode 100644 index 462da40..0000000 --- a/pyscada/sml/migrations/0004_auto_20200124_1250.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-24 12:50 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('sml', '0003_auto_20200124_1226'), - ] - - operations = [ - migrations.AlterField( - model_name='smldevice', - name='pin', - field=models.IntegerField(blank=True, help_text='to get advanced data from device', null=True), - ), - ] diff --git a/pyscada/sml/models.py b/pyscada/sml/models.py index 8b906b3..471eda1 100644 --- a/pyscada/sml/models.py +++ b/pyscada/sml/models.py @@ -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) @@ -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`') @@ -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' - diff --git a/setup.py b/setup.py index ebc35ef..0a6bdfb 100644 --- a/setup.py +++ b/setup.py @@ -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',