from djongo import models


# 水肥机基础信息表
class MongoSf_Info(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='')  # 设备id
    device_name = models.CharField(max_length=50, default='')  # 设备id
    eleNum = models.CharField(u'16路要素通道的索引', max_length=200, blank=True, null=True)
    eleName = models.CharField(u'16路要素通道的名称', max_length=200, blank=True, null=True)
    relayNum = models.CharField(u'32路继电器通道的索引', max_length=200, blank=True, null=True)
    relayName = models.CharField(u'32路继电器通道的名称', max_length=200, blank=True, null=True)
    lng = models.CharField(u'经度', max_length=30, blank=True, null=True)
    lat = models.CharField(u'纬度', max_length=30, blank=True, null=True)
    uptime = models.IntegerField(default=0)  # 修改时间

    class Meta:
        db_table = "sa_sf_info"


# 水肥机最新状态表
class MongoSf_Status(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='')  # 设备id
    device_addr = models.CharField(u'设备电磁阀定位', max_length=200, blank=True, null=True)
    device_status = models.CharField(u'当前设备状态', max_length=200, blank=True, null=True)
    uptime = models.IntegerField(default=0)  # 修改时间

    class Meta:
        db_table = "sa_sf_status"


# 水肥机数据表
class MongoSf_Data(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='')  # 设备id
    device_data = models.CharField(u'设备历史数据', max_length=200, blank=True, null=True)
    uptime = models.IntegerField(default=0)  # 修改时间

    class Meta:
        db_table = "sa_sf_data"


# 水肥机操作记录表
class MongoSf_Control_Data(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='')  # 设备id
    user = models.CharField(max_length=50, default='')  # 操作人
    relayNum = models.CharField(u'设备通道操作编号', max_length=200, blank=True, null=True)
    relayState = models.CharField(u'设备操作记录', max_length=200, blank=True, null=True)
    uptime = models.IntegerField(default=0)  # 修改时间

    class Meta:
        db_table = "sa_sf_control_data"
