2025-07-14 10:29:37 +08:00
|
|
|
|
#!/usr/bin/env python
|
2025-04-30 16:57:46 +08:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
Modbus配置模型
|
|
|
|
|
对应modbus_config表
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import datetime
|
2025-07-14 10:29:37 +08:00
|
|
|
|
from sqlalchemy import Column, String, Integer, DateTime, Boolean
|
|
|
|
|
from sqlalchemy.dialects.mysql import LONGTEXT, DATETIME
|
2025-04-30 16:57:46 +08:00
|
|
|
|
from data.models.base import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VWEDModbusConfig(BaseModel):
|
|
|
|
|
"""
|
|
|
|
|
Modbus配置模型
|
|
|
|
|
对应modbus_config表
|
|
|
|
|
功能:存储Modbus通信配置参数,用于PLC等设备的通信连接和数据交换
|
|
|
|
|
"""
|
|
|
|
|
__tablename__ = 'modbus_config'
|
|
|
|
|
|
|
|
|
|
__table_args__ = {
|
|
|
|
|
'mysql_engine': 'InnoDB',
|
|
|
|
|
'mysql_charset': 'utf8mb4',
|
|
|
|
|
'mysql_collate': 'utf8mb4_general_ci',
|
|
|
|
|
'info': {'order_by': 'create_date DESC'}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
id = Column(String(255), primary_key=True, nullable=False, comment='配置记录ID')
|
|
|
|
|
name = Column(String(255), nullable=False, comment='配置名称')
|
|
|
|
|
ip = Column(String(50), nullable=False, comment='设备IP地址')
|
|
|
|
|
port = Column(Integer, nullable=False, comment='通信端口号')
|
|
|
|
|
slave_id = Column(Integer, nullable=False, comment='从站ID')
|
|
|
|
|
address_type = Column(String(10), nullable=False, comment='地址类型')
|
|
|
|
|
address_number = Column(Integer, nullable=False, comment='地址编号')
|
|
|
|
|
task_id = Column(String(255), comment='任务ID')
|
2025-07-14 10:29:37 +08:00
|
|
|
|
task_name = Column(String(255), comment='任务名称')
|
2025-04-30 16:57:46 +08:00
|
|
|
|
target_value = Column(Integer, comment='目标值')
|
2025-07-14 10:29:37 +08:00
|
|
|
|
reset_after_trigger = Column(Boolean, default=False, comment='触发后是否重置')
|
|
|
|
|
reset_signal_address = Column(Integer, comment='重置信号地址')
|
|
|
|
|
reset_value = Column(Integer, comment='重置值')
|
2025-04-30 16:57:46 +08:00
|
|
|
|
remark = Column(String(255), comment='备注')
|
|
|
|
|
status = Column(Integer, default=0, comment='状态(1:启用, 0:禁用)')
|
|
|
|
|
tenant_id = Column(String(255), comment='租户ID')
|
|
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
|
return f"<VWEDModbusConfig(id='{self.id}', name='{self.name}', ip='{self.ip}', port='{self.port}')>"
|