# This is an auto-generated Django model module.
# python manage.py inspectdb device_count --database=counter
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey has `on_delete` set to the desired behavior.
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models


class DeviceCount(models.Model):
    device_id = models.CharField(max_length=45, blank=True, null=True, verbose_name='设备ID')
    csq = models.CharField(max_length=45, blank=True, null=True, verbose_name='信号强度')
    count = models.CharField(max_length=45, blank=True, null=True, verbose_name='蚊子计数')
    vol = models.CharField(max_length=45, blank=True, null=True, verbose_name='电量')
    data_time = models.DateTimeField(blank=True, null=True, verbose_name='计数时间')
    longitude = models.FloatField(blank=True, null=True, verbose_name='经度')
    latitude = models.FloatField(blank=True, null=True, verbose_name='维度')

    class Meta:
        managed = False
        db_table = 'device_count'
        app_label = 'counter'
        verbose_name = '设备数据'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.device_id


class DeviceInfo(models.Model):
    device_id = models.CharField(primary_key=True, max_length=16, verbose_name='设备ID')
    device_name = models.CharField(max_length=100, blank=True, null=True, verbose_name='设备名称')
    chip_type = models.CharField(max_length=30, blank=True, null=True, verbose_name='芯片类型')
    chip_id = models.CharField(max_length=50, blank=True, null=True, verbose_name='芯片ID')
    compile_time = models.DateTimeField(blank=True, null=True, verbose_name='编译时间')
    main_server_ip = models.CharField(max_length=15, blank=True, null=True, verbose_name='主服务器IP')
    main_server_port = models.IntegerField(blank=True, null=True, verbose_name='主服务器端口')
    maintain_server_ip = models.CharField(max_length=15, blank=True, null=True, verbose_name='备用服务器IP')
    maintain_server_port = models.IntegerField(blank=True, null=True, verbose_name='备用服务器端口')
    last_connect = models.DateTimeField(blank=True, null=True, verbose_name='最后连接时间')
    online = models.IntegerField(verbose_name='是否在线')
    session_id = models.CharField(max_length=36, blank=True, null=True)
    last_offline_time = models.DateTimeField(blank=True, null=True, verbose_name='上次离线时间')

    class Meta:
        managed = False
        db_table = 'device_info'
        app_label = 'counter'
        verbose_name = '设备信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.device_name
