forked from iti-framework/iTi-Flask
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.4 KiB
Python
61 lines
2.4 KiB
Python
from iti.applications.extensions import db
|
|
from iti.applications.common.crud import TimeModelMixin
|
|
from iti.applications.common.utils import BaseSchema
|
|
from apiflask.fields import String, Integer, DateTime, Nested
|
|
|
|
|
|
class IotNode(db.Model, TimeModelMixin):
|
|
"""
|
|
节点信息表
|
|
"""
|
|
|
|
__tablename__ = "iot_node"
|
|
id = db.Column(
|
|
db.Integer,
|
|
primary_key=True,
|
|
autoincrement=True,
|
|
comment="标识",
|
|
)
|
|
endpoint_id = db.Column(db.Integer, nullable=False, default=0, unique=True, comment="采集端ID")
|
|
title = db.Column(db.String(255), nullable=False, unique=True, comment="节点ID")
|
|
mark = db.Column(db.String(255), nullable=False, comment="采集标识")
|
|
mark_type = db.Column(db.Integer, nullable=True, comment="采集类型 1:只读 2:只写 3:读写")
|
|
tag_label = db.Column(db.String(255), nullable=False, comment="变量别名,用于数据存储标记")
|
|
data_type = db.Column(db.String(255), nullable=False, comment="值类型 text: 文本 int: 整型 float: 浮点型 boolean:布尔型")
|
|
is_warning = db.Column(db.Integer, nullable=False, comment="预警类型 0:无预警 1:预警")
|
|
warning_effective_config = db.Column(db.String(255), nullable=False, comment="预警触发表达式")
|
|
is_calling = db.Column(db.Integer, nullable=False, comment="报警类型 0:无报警 1:报警")
|
|
calling_effective_config = db.Column(db.String(255), nullable=False, comment="报警触发表达式")
|
|
method_content = db.Column(db.String(255), nullable=False, comment="方法节点")
|
|
status = db.Column(db.Integer, nullable=False, default=0, comment="状态 0:禁用 1:启用")
|
|
#关系
|
|
endpoint = db.relationship(
|
|
"IotEndpoint",
|
|
primaryjoin="foreign(IotNode.endpoint_id) == IotEndpoint.id",
|
|
)
|
|
|
|
|
|
class IotNodeSchema(BaseSchema):
|
|
"""
|
|
节点信息表响应结构
|
|
"""
|
|
class Meta:
|
|
name = "IotNode"
|
|
|
|
id = Integer()
|
|
endpoint_id = Integer()
|
|
title = String()
|
|
mark = String()
|
|
mark_type = Integer()
|
|
tag_label = String()
|
|
data_type = String()
|
|
is_warning = Integer()
|
|
warning_effective_config = String()
|
|
is_calling = Integer()
|
|
calling_effective_config = String()
|
|
method_content = String()
|
|
status = Integer()
|
|
created_at = DateTime(format="%Y-%m-%d %H:%M:%S")
|
|
updated_at = DateTime(format="%Y-%m-%d %H:%M:%S")
|
|
#关系
|
|
endpoint = Nested("IotEndpointSimpleSchema") |