0313界面对接

This commit is contained in:
2026-03-13 21:04:19 +08:00
parent 6e74eaf206
commit 8aeaffa885
33 changed files with 1541 additions and 419 deletions

View File

@ -18,8 +18,8 @@ from busisness.models import ArtifactInfoModel,PDRecordModel
class FeedingControlSystem:
def __init__(self):
print('FeedingControlSystem初始化')
self.pd_record_bll=PDRecordBll()
print('派单测试初始化')
# self.pd_record_bll=PDRecordBll()
def send_pd_data(self):
@ -56,7 +56,7 @@ class FeedingControlSystem:
print(f'接口数据异常')
return False
def get_fact_volumn(self,mould_code:str,block_number:str='',_weight:float=0) -> float:
def get_fact_volumn(self,block_number:str='') -> float:
"""获取实际派单发量"""
_now_volumn=0
_pd_volumn=0

100
tests/test_example.py Normal file
View File

@ -0,0 +1,100 @@
#!/usr/bin/env python3
"""
pytest 测试示例
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import pytest
import time
from core.system_state import SystemState
from core.system import FeedingControlSystem
from busisness.models import ArtifactInfo,FreqRecordModel
from busisness.blls import FreqRecordBll
system=FeedingControlSystem()
system.state.current_mould=ArtifactInfo(MouldCode="SHR2B3-5")
def test_pd_record_send():
"""测试派单记录发送"""
system.send_pd_data()
def test_api_process():
system._process_api_db()
def test_freq_record_send():
"""测试频率记录发送"""
bll=FreqRecordBll()
record_id=bll.insert_freq_record(FreqRecordModel(ArtifactID='12',ArtifactActionID=1,MouldCode="SHR2B3-5",Freq=100.0))
assert record_id > 0
def add(a, b):
"""简单的加法函数"""
return a + b
def test_add():
"""测试加法函数"""
assert add(1, 2) == 4
assert add(0, 0) == 0
assert add(-1, 1) == 0
assert add(100, 200) == 300
def multiply(a, b):
"""简单的乘法函数"""
return a * b
def test_multiply():
"""测试乘法函数"""
assert multiply(2, 3) == 6
assert multiply(0, 5) == 0
assert multiply(-2, 3) == -6
assert multiply(10, 10) == 100
class Calculator:
"""简单的计算器类"""
def add(self, a, b):
return a + b
def subtract(self, a, b):
return a - b
def test_calculator():
"""测试计算器类"""
calc = Calculator()
assert calc.add(1, 2) == 3
assert calc.subtract(5, 2) == 3
assert calc.subtract(2, 5) == -3
@pytest.mark.parametrize("a, b, expected", [
(1, 2, 3),
(0, 0, 0),
(-1, 1, 0),
(100, 200, 300)
])
def test_add_parametrized(a, b, expected):
"""参数化测试加法函数"""
assert add(a, b) == expected
if __name__ == "__main__":
# 运行所有测试
system.opcua_client_feed.start()
system.start_opc_queue_thread()
test_pd_record_send()
# pytest.main([f'{__file__}::test_api_process'])
# pytest.main([f'{__file__}::test_freq_record_send'])
while True:
time.sleep(1)

View File

@ -1,8 +1,8 @@
# 读取原始数据文件
import datetime
input_file = r"C:\Users\fujin\Desktop\fsdownload\weight.txt" # 原始数据文件路径
output_file = r"C:\Users\fujin\Desktop\fsdownload\filtered_B_records.txt" # 输出结果文件路径 (使用原始字符串避免Unicode转义错误)
input_file = r"C:\Users\xj-robot\Desktop\weight.txt" # 原始数据文件路径
output_file = r"C:\Users\xj-robot\Desktop\filtered_B_records.txt" # 输出结果文件路径 (使用原始字符串避免Unicode转义错误)
# 存储包含"B"标记的记录
filtered_records = []