# Generated by Django 3.2 on 2023-01-13 08:14

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('pyscada', '0098_alter_device_polling_interval'),
    ]

    operations = [
        migrations.CreateModel(
            name='ExtendedMeterBusDevice',
            fields=[
            ],
            options={
                'verbose_name': 'MeterBus Device',
                'verbose_name_plural': 'MeterBus Devices',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('pyscada.device',),
        ),
        migrations.CreateModel(
            name='ExtendedMeterBusVariable',
            fields=[
            ],
            options={
                'verbose_name': 'MeterBus Variable',
                'verbose_name_plural': 'MeterBus Variables',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('pyscada.variable',),
        ),
        migrations.CreateModel(
            name='MeterBusVariable',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('storage_number', models.PositiveSmallIntegerField(default=0, help_text="Look at the <a href='https://m-bus.com/documentation-wired/06-application-layer'>M-Bus documentation</a>")),
                ('function', models.PositiveSmallIntegerField(choices=[(meterbus.core_objects.FunctionType['INSTANTANEOUS_VALUE'], 0), (meterbus.core_objects.FunctionType['MAXIMUM_VALUE'], 1), (meterbus.core_objects.FunctionType['MINIMUM_VALUE'], 2), (meterbus.core_objects.FunctionType['ERROR_STATE_VALUE'], 3), (meterbus.core_objects.FunctionType['SPECIAL_FUNCTION'], 4), (meterbus.core_objects.FunctionType['SPECIAL_FUNCTION_FILL_BYTE'], 5), (meterbus.core_objects.FunctionType['MORE_RECORDS_FOLLOW'], 6)], default=0)),
                ('type', models.PositiveSmallIntegerField(choices=[(meterbus.core_objects.VIFUnit['ENERGY_WH'], 7), (meterbus.core_objects.VIFUnit['ENERGY_J'], 15), (meterbus.core_objects.VIFUnit['VOLUME'], 23), (meterbus.core_objects.VIFUnit['MASS'], 31), (meterbus.core_objects.VIFUnit['ON_TIME'], 35), (meterbus.core_objects.VIFUnit['OPERATING_TIME'], 39), (meterbus.core_objects.VIFUnit['POWER_W'], 47), (meterbus.core_objects.VIFUnit['POWER_J_H'], 55), (meterbus.core_objects.VIFUnit['VOLUME_FLOW'], 63), (meterbus.core_objects.VIFUnit['VOLUME_FLOW_EXT'], 71), (meterbus.core_objects.VIFUnit['VOLUME_FLOW_EXT_S'], 79), (meterbus.core_objects.VIFUnit['MASS_FLOW'], 87), (meterbus.core_objects.VIFUnit['FLOW_TEMPERATURE'], 91), (meterbus.core_objects.VIFUnit['RETURN_TEMPERATURE'], 95), (meterbus.core_objects.VIFUnit['TEMPERATURE_DIFFERENCE'], 99), (meterbus.core_objects.VIFUnit['EXTERNAL_TEMPERATURE'], 103), (meterbus.core_objects.VIFUnit['PRESSURE'], 107), (meterbus.core_objects.VIFUnit['DATE'], 108), (meterbus.core_objects.VIFUnit['DATE_TIME_GENERAL'], 109), (meterbus.core_objects.VIFUnit['UNITS_FOR_HCA'], 110), (meterbus.core_objects.VIFUnit['RES_THIRD_VIFE_TABLE'], 111), (meterbus.core_objects.VIFUnit['AVG_DURATION'], 115), (meterbus.core_objects.VIFUnit['ACTUALITY_DURATION'], 119), (meterbus.core_objects.VIFUnit['FABRICATION_NO'], 120), (meterbus.core_objects.VIFUnit['IDENTIFICATION'], 121), (meterbus.core_objects.VIFUnit['ADDRESS'], 122), (meterbus.core_objects.VIFUnit['FIRST_EXT_VIF_CODES'], 251), (meterbus.core_objects.VIFUnit['VARIABLE_VIF'], 252), (meterbus.core_objects.VIFUnit['VIF_FOLLOWING'], 124), (meterbus.core_objects.VIFUnit['SECOND_EXT_VIF_CODES'], 253), (meterbus.core_objects.VIFUnit['THIRD_EXT_VIF_CODES_RES'], 239), (meterbus.core_objects.VIFUnit['ANY_VIF'], 126), (meterbus.core_objects.VIFUnit['MANUFACTURER_SPEC'], 127), (meterbus.core_objects.VIFUnitExt['CURRENCY_CREDIT'], 3), (meterbus.core_objects.VIFUnitExt['CURRENCY_DEBIT'], 7), (meterbus.core_objects.VIFUnitExt['ACCESS_NUMBER'], 8), (meterbus.core_objects.VIFUnitExt['MEDIUM'], 9), (meterbus.core_objects.VIFUnitExt['MANUFACTURER'], 10), (meterbus.core_objects.VIFUnitExt['PARAMETER_SET_ID'], 11), (meterbus.core_objects.VIFUnitExt['MODEL_VERSION'], 12), (meterbus.core_objects.VIFUnitExt['HARDWARE_VERSION'], 13), (meterbus.core_objects.VIFUnitExt['FIRMWARE_VERSION'], 14), (meterbus.core_objects.VIFUnitExt['SOFTWARE_VERSION'], 15), (meterbus.core_objects.VIFUnitExt['CUSTOMER_LOCATION'], 16), (meterbus.core_objects.VIFUnitExt['CUSTOMER'], 17), (meterbus.core_objects.VIFUnitExt['ACCESS_CODE_USER'], 18), (meterbus.core_objects.VIFUnitExt['ACCESS_CODE_OPERATOR'], 19), (meterbus.core_objects.VIFUnitExt['ACCESS_CODE_SYSTEM_OPERATOR'], 20), (meterbus.core_objects.VIFUnitExt['ACCESS_CODE_DEVELOPER'], 21), (meterbus.core_objects.VIFUnitExt['PASSWORD'], 22), (meterbus.core_objects.VIFUnitExt['ERROR_FLAGS'], 23), (meterbus.core_objects.VIFUnitExt['ERROR_MASKS'], 24), (meterbus.core_objects.VIFUnitExt['RESERVED'], 25), (meterbus.core_objects.VIFUnitExt['DIGITAL_OUTPUT'], 26), (meterbus.core_objects.VIFUnitExt['DIGITAL_INPUT'], 27), (meterbus.core_objects.VIFUnitExt['BAUDRATE'], 28), (meterbus.core_objects.VIFUnitExt['RESPONSE_DELAY'], 29), (meterbus.core_objects.VIFUnitExt['RETRY'], 30), (meterbus.core_objects.VIFUnitExt['RESERVED_2'], 31), (meterbus.core_objects.VIFUnitExt['FIRST_STORAGE_NR'], 32), (meterbus.core_objects.VIFUnitExt['LAST_STORAGE_NR'], 33), (meterbus.core_objects.VIFUnitExt['SIZE_OF_STORAGE_BLOCK'], 34), (meterbus.core_objects.VIFUnitExt['RESERVED_3'], 35), (meterbus.core_objects.VIFUnitExt['STORAGE_INTERVAL'], 39), (meterbus.core_objects.VIFUnitExt['STORAGE_INTERVAL_MONTH'], 40), (meterbus.core_objects.VIFUnitExt['STORAGE_INTERVAL_YEARS'], 41), (meterbus.core_objects.VIFUnitExt['DURATION_SINCE_LAST_READOUT'], 47), (meterbus.core_objects.VIFUnitExt['START_OF_TARIFF'], 48), (meterbus.core_objects.VIFUnitExt['PERIOD_OF_TARIFF'], 55), (meterbus.core_objects.VIFUnitExt['PERIOD_OF_TARIFF_MONTH'], 56), (meterbus.core_objects.VIFUnitExt['PERIOD_OF_TARIFF_YEARS'], 57), (meterbus.core_objects.VIFUnitExt['DIMENSIONLESS'], 58), (meterbus.core_objects.VIFUnitExt['VOLTS'], 79), (meterbus.core_objects.VIFUnitExt['AMPERE'], 95), (meterbus.core_objects.VIFUnitExt['RESET_COUNTER'], 96), (meterbus.core_objects.VIFUnitExt['CUMULATION_COUNTER'], 97), (meterbus.core_objects.VIFUnitExt['CONTROL_SIGNAL'], 98), (meterbus.core_objects.VIFUnitExt['DAY_OF_WEEK'], 99), (meterbus.core_objects.VIFUnitExt['WEEK_NUMBER'], 100), (meterbus.core_objects.VIFUnitExt['TIME_POINT_OF_DAY_CHANGE'], 101), (meterbus.core_objects.VIFUnitExt['STATE_OF_PARAMETER_ACTIVATION'], 102), (meterbus.core_objects.VIFUnitExt['SPECIAL_SUPPLIER_INFORMATION'], 103), (meterbus.core_objects.VIFUnitExt['DURATION_SINCE_LAST_CUMULATION'], 107), (meterbus.core_objects.VIFUnitExt['OPERATING_TIME_BATTERY'], 111), (meterbus.core_objects.VIFUnitExt['DATEAND_TIME_OF_BATTERY_CHANGE'], 112), (meterbus.core_objects.VIFUnitExt['RSSI'], 113), (meterbus.core_objects.VIFUnitSecExt['RELATIVE_HUMIDITY'], 26)])),
                ('unit', models.CharField(choices=[(meterbus.core_objects.MeasureUnit['KWH'], 'kWh'), (meterbus.core_objects.MeasureUnit['WH'], 'Wh'), (meterbus.core_objects.MeasureUnit['J'], 'J'), (meterbus.core_objects.MeasureUnit['M3'], 'm^3'), (meterbus.core_objects.MeasureUnit['L'], 'l'), (meterbus.core_objects.MeasureUnit['KG'], 'kg'), (meterbus.core_objects.MeasureUnit['W'], 'W'), (meterbus.core_objects.MeasureUnit['J_H'], 'J/h'), (meterbus.core_objects.MeasureUnit['M3_H'], 'm^3/h'), (meterbus.core_objects.MeasureUnit['M3_MIN'], 'm^3/min'), (meterbus.core_objects.MeasureUnit['M3_S'], 'm^3/s'), (meterbus.core_objects.MeasureUnit['KG_H'], 'kg/h'), (meterbus.core_objects.MeasureUnit['C'], 'C'), (meterbus.core_objects.MeasureUnit['K'], 'K'), (meterbus.core_objects.MeasureUnit['BAR'], 'bar'), (meterbus.core_objects.MeasureUnit['DATE'], 'date'), (meterbus.core_objects.MeasureUnit['TIME'], 'time'), (meterbus.core_objects.MeasureUnit['DATE_TIME'], 'date time'), (meterbus.core_objects.MeasureUnit['DATE_TIME_S'], 'date time to second'), (meterbus.core_objects.MeasureUnit['SECONDS'], 'seconds'), (meterbus.core_objects.MeasureUnit['MINUTES'], 'minutes'), (meterbus.core_objects.MeasureUnit['HOURS'], 'hours'), (meterbus.core_objects.MeasureUnit['DAYS'], 'days'), (meterbus.core_objects.MeasureUnit['NONE'], 'none'), (meterbus.core_objects.MeasureUnit['V'], 'V'), (meterbus.core_objects.MeasureUnit['A'], 'A'), (meterbus.core_objects.MeasureUnit['HCA'], 'H.C.A'), (meterbus.core_objects.MeasureUnit['CURRENCY'], 'Currency unit'), (meterbus.core_objects.MeasureUnit['BAUD'], 'Baud'), (meterbus.core_objects.MeasureUnit['BIT_TIMES'], 'Bittimes'), (meterbus.core_objects.MeasureUnit['PERCENT'], '%'), (meterbus.core_objects.MeasureUnit['DBM'], 'dBm')], max_length=50)),
                ('order', models.PositiveSmallIntegerField(default=0, help_text='Item order in data if various items with the same description')),
                ('meterbus_variable', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='pyscada.variable')),
            ],
        ),
        migrations.CreateModel(
            name='MeterBusDevice',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('address', models.PositiveSmallIntegerField(default=0)),
                ('address_type', models.PositiveSmallIntegerField(choices=[(1, 'primary'), (2, 'secondary')], default=1)),
                ('port', models.CharField(default='/dev/ttyUSB0', help_text='enter serial port (/dev/pts/13))', max_length=400)),
                ('baudrate', models.PositiveIntegerField(default=9600, help_text='Serial connection baudrate')),
                ('timeout', models.PositiveIntegerField(default=1, help_text='Serial connection timeout')),
                ('retries', models.PositiveIntegerField(default=5, help_text='Serial connection retries')),
                ('read_and_ignore_echo', models.BooleanField(default=False, help_text='Read and ignore echoed data from target')),
                ('instrument_handler', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='pyscada.devicehandler')),
                ('meterbus_device', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='pyscada.device')),
            ],
        ),
    ]
