config: 更新服务器IP配置并优化WITS数据发送逻辑
- 将server-ip从192.168.1.41更改为192.168.1.5 - 移除WitsData模型中的actod_label字段 - 修改wits_sender.py中的actcod值为随机生成(1-34范围内) - 更新WITS数据包构建逻辑以使用动态actcod值 - 优化代码格式和错误消息显示 - 移除不必要的空行和导入语句
This commit is contained in:
@@ -8,7 +8,6 @@ from pathlib import Path
|
||||
from config import build_wits_sender_dependencies
|
||||
from model import REQUIRED_TRANSMISSION_CHANNELS, WITS_CHANNEL_MAPPING, WitsData
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
BEGIN_MARK = "&&\r\n"
|
||||
END_MARK = "!!\r\n"
|
||||
@@ -44,6 +43,7 @@ def build_random_wits_data(device_code):
|
||||
weight_on_bit = rand_float(6.0, 12.0)
|
||||
bit_depth = rand_float(199.8, 200.3)
|
||||
block_position = rand_float(5.8, 6.3)
|
||||
actcod = rand_int(1, 34)
|
||||
return WitsData(
|
||||
ts=ts_ms,
|
||||
wellid=device_code or "???1",
|
||||
@@ -53,8 +53,7 @@ def build_random_wits_data(device_code):
|
||||
actual_date=time.strftime("%y%m%d"),
|
||||
actual_time=time.strftime("%H%M%S"),
|
||||
actual_ts=ts_ms,
|
||||
actcod=37,
|
||||
actod_label="AUTO",
|
||||
actcod=actcod,
|
||||
deptbitm=bit_depth,
|
||||
deptbitv=bit_depth - 1.45,
|
||||
deptmeas=bit_depth,
|
||||
@@ -149,7 +148,8 @@ def validate_packet(packet):
|
||||
|
||||
|
||||
def build_wits_packet(data):
|
||||
lines = [f"{channel}{format_wits_value(getattr(data, field_name), kind)}" for channel, field_name, kind in WITS_CHANNEL_MAPPING]
|
||||
lines = [f"{channel}{format_wits_value(getattr(data, field_name), kind)}" for channel, field_name, kind in
|
||||
WITS_CHANNEL_MAPPING]
|
||||
packet = BEGIN_MARK + "\r\n".join(lines) + "\r\n" + END_MARK + RECORD_TERMINATOR
|
||||
validate_packet(packet)
|
||||
return packet
|
||||
@@ -193,7 +193,8 @@ def run_wits_sender(args, deps):
|
||||
interval = args.interval or 2.0
|
||||
|
||||
if not host or not port:
|
||||
raise ValueError("WITS target host/port is empty. Configure wits.host/wits.port or tms.server-ip/tms.server-port")
|
||||
raise ValueError(
|
||||
"WITS target host/port is empty. Configure wits.host/wits.port or tms.server-ip/tms.server-port")
|
||||
|
||||
logger.info(
|
||||
"WITS sender config host=%s port=%s timeout=%ss source_file=%s interval=%ss count=%s",
|
||||
|
||||
@@ -15,7 +15,7 @@ tms:
|
||||
equipment-sn: GJ-304-0088
|
||||
timeout: 10
|
||||
keepalive: 20
|
||||
server-ip: 192.168.1.41
|
||||
server-ip: 192.168.1.5
|
||||
server-port: 9929
|
||||
|
||||
tdengine:
|
||||
|
||||
@@ -47,7 +47,6 @@ class WitsData:
|
||||
actual_time: int
|
||||
actual_ts: int
|
||||
actcod: int
|
||||
actod_label: str
|
||||
deptbitm: float
|
||||
deptbitv: float
|
||||
deptmeas: float
|
||||
|
||||
Reference in New Issue
Block a user