添加SLCP102打包逻辑;

This commit is contained in:
何 泽隆
2024-11-16 18:57:23 +08:00
parent 272b7c68b2
commit 628ce8bf27
4 changed files with 91 additions and 6 deletions

45
resource/Untitled-1.py Normal file
View File

@@ -0,0 +1,45 @@
# %%
from paho.mqtt import client as mqtt_client
broker = '123.249.75.235'
port = 1883
topic = "python/mqtt"
client_id = f'python-mqtt-{random.randint(0, 1000)}'
username = 'TTE0101TC2311000003'
password = 'qh10579lcb7au8o2'
# %%
import random
from paho.mqtt import client as mqtt_client
broker = '123.249.75.235'
port = 1883
topic = "python/mqtt"
client_id = f'python-mqtt-{random.randint(0, 1000)}'
username = 'TTE0101TC2311000003'
password = 'qh10579lcb7au8o2'
# %%
def connect_mqtt():
def on_connect(client, userdata, flags, rc):
# For paho-mqtt 2.0.0, you need to add the properties parameter.
# def on_connect(client, userdata, flags, rc, properties):
if rc == 0:
print("Connected to MQTT Broker!")
else:
print("Failed to connect, return code %d\n", rc)
# Set Connecting Client ID
client = mqtt_client.Client(client_id)
# For paho-mqtt 2.0.0, you need to set callback_api_version.
# client = mqtt_client.Client(client_id=client_id, callback_api_version=mqtt_client.CallbackAPIVersion.VERSION2)
# client.username_pw_set(username, password)
client.on_connect = on_connect
client.connect(broker, port)
return client

39
source/data_analy.py Normal file
View File

@@ -0,0 +1,39 @@
import pandas as pd
from pathlib import Path
from bs4 import BeautifulSoup
# 1. 读取本地HTML文件
file_path = Path(r'D:\WorkingProject\LightStackAdapter\Log\设备测试数据记录-铁塔主站\南和县牧村\Untitled-1.html')
html_content = file_path.read_text()
# 2. 解析HTML文件
soup = BeautifulSoup(html_content, 'html.parser')
# 3. 找到表格元素
table = soup.find_all('table') # 假设页面中只有一个表格,如果有多个表格,可能需要进一步筛选
# 4. 提取表格数据
data = []
headers = []
# 提取表头
header_row = table.find('thead').find('tr')
for header in header_row.find_all('th'):
headers.append(header.text.strip())
# 提取数据行
for row in table.find('tbody').find_all('tr'):
row_data = []
for cell in row.find_all(['td', 'th']):
row_data.append(cell.text.strip())
data.append(row_data)
# 5. 将数据保存为DataFrame
df = pd.DataFrame(data, columns=headers)
# 6. 将DataFrame保存为CSV文件
output_file = 'extracted_table.csv'
df.to_csv(output_file, index=False, encoding='utf-8')
print(f'表格数据已成功提取并保存到 {output_file}')

View File

@@ -3,7 +3,8 @@ from pathlib import Path
from typing import Callable, Any
from device.LaminaAdapter import LaminaAdapter
from device.LaminaAdapter import GeneratePackage_SLCP001_p4a0, GeneratePackage_SLCP101_p460, GeneratePackage_DLSY001_p460
from device.tools.ByteConv import trans_list_to_str
from device.LaminaAdapter import GeneratePackage_SLCP102_p460
from device.tools.ByteConv import trans_list_to_str, trans_str_to_list
def test_communication(time_out=2):
""" 通信成功率测试 """
@@ -140,8 +141,8 @@ if __name__=='__main__':
# 'addr_645': [0x01, 0x02, 0x03, 0x04, 0x05, 0x06],
'frame_print': True,
'time_out': 0.1, 'retry': 1, 'retry_sub': 10},
"HPLC": {'com_name': 'COM10', 'baudrate': 9600, 'parity': 'E', 'bytesize': 8, 'stopbits': 1,
# 'addr_645': [0x33, 0x00, 0x10, 0x03, 0x09, 0x24],
"HPLC": {'com_name': 'COM9', 'baudrate': 9600, 'parity': 'E', 'bytesize': 8, 'stopbits': 1,
# 'addr_645': [0x11, 0x01, 0x18, 0x06, 0x24, 0x02],
'frame_print': True,
'time_out': 3, 'time_gap': 0.1, 'retry': 3, 'retry_sub': 10},
}
@@ -157,7 +158,7 @@ if __name__=='__main__':
# file_hex = Path(r"D:\WorkingProject\LightStackOptimizer\software\lamina_optimizer\lamina_optimizer\Debug\lamina_optimizer.hex")
if not file_hex.exists():
raise Exception("工程编译目标文件不存在.")
file_package = make_Pakeage(file_hex, GeneratePackage_SLCP101_p460)
file_package = make_Pakeage(file_hex, GeneratePackage_SLCP102_p460)
version = "SLCP101_241030_2000_V2.03"
addr = [0x24, 0x09, 0x12, 0x00, 0x00, 0x00]

View File

@@ -204,6 +204,6 @@ if __name__ == "__main__":
path_main = Path(r"D:\WorkingProject\LightStackAdapter\software\lamina_adapter\lamina_adapter\Debug")
# Process0(path_boot1, path_main) # 适配器SLCP001
# Process1(path_boot2, path_main) # 适配器SLCP101
Process1_v2(path_boot2, path_main) # 适配器SLCP102
Process1(path_boot2, path_main) # 适配器SLCP101
# Process1_v2(path_boot2, path_main) # 适配器SLCP102
# Process2()