You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.4 KiB
29 lines
1.4 KiB
from pydantic import BaseModel, Field
|
|
from typing import Optional, List, Dict
|
|
|
|
class PLNKRequest(BaseModel):
|
|
"""PLNK协议请求模型"""
|
|
data: str = Field(..., description="十六进制数据报文")
|
|
timeout: Optional[int] = Field(30, description="响应超时时间(秒)", ge=1)
|
|
wait_response: Optional[bool] = Field(True, description="是否等待响应")
|
|
|
|
class PLNKResponse(BaseModel):
|
|
"""PLNK协议响应模型"""
|
|
success: bool = Field(..., description="执行是否成功")
|
|
sent_data: str = Field(..., description="发送的数据")
|
|
received_data: str = Field(..., description="接收的数据")
|
|
parsed_data: Optional[Dict] = Field(None, description="解析后的数据")
|
|
execution_time: float = Field(..., description="执行时间(秒)")
|
|
|
|
class TCPConnectionInfo(BaseModel):
|
|
"""TCP连接信息模型"""
|
|
host: str = Field(..., description="主机地址")
|
|
port: int = Field(..., description="端口号", ge=1, le=65535)
|
|
timeout: int = Field(30, description="连接超时时间(秒)")
|
|
keep_alive: bool = Field(True, description="保持连接")
|
|
|
|
class PLNKConnectionInfo(BaseModel):
|
|
"""PLNK连接信息模型"""
|
|
connection_type: str = Field(..., description="连接类型: tcp/serial")
|
|
tcp_info: Optional[TCPConnectionInfo] = Field(None, description="TCP连接信息")
|
|
serial_info: Optional[dict] = Field(None, description="串口连接信息")
|