# Generated by Django 5.2.3 on 2025-07-15 08:45

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='device',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('device_type', models.CharField(default='ADC', max_length=100)),
                ('brend', models.CharField(default='Picoscope', max_length=100)),
                ('serial_model', models.CharField(default='PS400A', max_length=100)),
                ('proto', models.CharField(default='TCP', max_length=100)),
                ('proto_interface', models.CharField(default='adc_default', max_length=100)),
                ('time_creation', models.DateTimeField(default=django.utils.timezone.now)),
                ('time_publication', models.DateTimeField(blank=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='device_state',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('status', models.CharField(default='', max_length=100)),
                ('code', models.BigIntegerField(default=0)),
            ],
        ),
        migrations.CreateModel(
            name='measurement',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ],
        ),
        migrations.CreateModel(
            name='adc_params',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('srate', models.PositiveIntegerField()),
                ('points', models.JSONField(blank=True, default=list, help_text='Массив целых чисел в формате JSON', null=True)),
                ('n_channels', models.PositiveIntegerField()),
                ('channel_ranges', models.JSONField(blank=True, default=list, help_text='Массив целых чисел в формате JSON', null=True)),
                ('n_triggers', models.PositiveIntegerField()),
                ('trigger_channel', models.PositiveIntegerField()),
                ('threshold', models.IntegerField()),
                ('trig_direction', models.IntegerField()),
                ('auto_measure_time', models.PositiveIntegerField()),
                ('enabled', models.BooleanField(default=True)),
                ('device', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='adc_params', to='spectrometer.device')),
            ],
        ),
        migrations.CreateModel(
            name='gra_params',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('ip', models.GenericIPAddressField(default='127.0.0.1')),
                ('file', models.CharField()),
                ('enabled', models.BooleanField(default=True)),
                ('device', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='gra_params', to='spectrometer.device')),
            ],
        ),
        migrations.CreateModel(
            name='measurement_data',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('data_num', models.IntegerField(default=0)),
                ('measurement', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='measurement_data1', to='spectrometer.measurement')),
            ],
        ),
        migrations.CreateModel(
            name='channel_data',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('channel_num', models.IntegerField(default=0)),
                ('channel_data', models.TextField(default='')),
                ('measurement_data', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='measurement_data1', to='spectrometer.measurement_data')),
            ],
        ),
        migrations.CreateModel(
            name='measurement_info',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('infostr', models.CharField(default='str', max_length=100)),
                ('time', models.DateTimeField(default=django.utils.timezone.now)),
                ('iadc', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='measurement_info6', to='spectrometer.adc_params')),
                ('igrax', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='measurement_info3', to='spectrometer.gra_params')),
                ('igray', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='measurement_info2', to='spectrometer.gra_params')),
                ('igraz', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='measurement_info1', to='spectrometer.gra_params')),
            ],
        ),
        migrations.AddField(
            model_name='measurement',
            name='info',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='measurement2', to='spectrometer.measurement_info'),
        ),
        migrations.CreateModel(
            name='sdr_params',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('srate', models.PositiveIntegerField(default=2000000)),
                ('freq', models.PositiveIntegerField(default=3000000)),
                ('gain', models.PositiveIntegerField(default=35)),
                ('ampl', models.BooleanField(default=True)),
                ('file', models.CharField()),
                ('device', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='sdr_params', to='spectrometer.device')),
            ],
        ),
        migrations.AddField(
            model_name='measurement_info',
            name='isdr',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='measurement_info4', to='spectrometer.sdr_params'),
        ),
        migrations.CreateModel(
            name='state',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('id_measurement', models.IntegerField(default=0)),
                ('status', models.CharField(default='default', max_length=100)),
                ('code', models.BigIntegerField(default=0)),
                ('data_ready', models.BooleanField(default=False)),
                ('adc', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state6', to='spectrometer.device_state')),
                ('grax', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state3', to='spectrometer.device_state')),
                ('gray', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state2', to='spectrometer.device_state')),
                ('graz', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state1', to='spectrometer.device_state')),
                ('sdr', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state4', to='spectrometer.device_state')),
                ('sync', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='state5', to='spectrometer.device_state')),
            ],
        ),
        migrations.AddField(
            model_name='measurement',
            name='state',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='measurement1', to='spectrometer.state'),
        ),
        migrations.CreateModel(
            name='sync_params',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('file', models.CharField(default='Sync_params.xml', max_length=100)),
                ('port', models.IntegerField(default=7)),
                ('device', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='sync_params', to='spectrometer.device')),
            ],
        ),
        migrations.AddField(
            model_name='measurement_info',
            name='isync',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='measurement_info5', to='spectrometer.sync_params'),
        ),
    ]
