mirror of
https://github.com/3minbe/DBC_Converter.git
synced 2026-05-17 01:23:58 +09:00
shutil 모듈 추가 및 DBC 파일 복사 기능 구현, 날짜 및 시간 형식 변경, 채널 정보 업데이트 주석 수정
This commit is contained in:
parent
3a3736f85d
commit
8a4385e407
@ -4,6 +4,7 @@ from PyQt5 import QtWidgets, QtGui, QtCore
|
||||
from datetime import datetime
|
||||
import json
|
||||
import subprocess
|
||||
import shutil # 파일 복사를 위해 shutil 모듈 추가
|
||||
|
||||
class MainView(QtWidgets.QMainWindow):
|
||||
def __init__(self):
|
||||
@ -239,7 +240,7 @@ class MainView(QtWidgets.QMainWindow):
|
||||
for item in selected_items:
|
||||
index = self.tree.indexOfTopLevelItem(item)
|
||||
file_path = os.path.join(item.text(1), item.text(0))
|
||||
self.removeChannelInfo(file_path) # 추가된 부분
|
||||
self.removeChannelInfo(file_path) # 채널 정보 제거
|
||||
self.tree.takeTopLevelItem(index)
|
||||
self.file_paths = [self.tree.topLevelItem(i).text(1) + '/' + self.tree.topLevelItem(i).text(0) for i in range(self.tree.topLevelItemCount())]
|
||||
self.updateAlertText(f"파일 삭제 완료", deleted_files)
|
||||
@ -254,7 +255,7 @@ class MainView(QtWidgets.QMainWindow):
|
||||
for i in range(self.tree.topLevelItemCount()):
|
||||
item = self.tree.topLevelItem(i)
|
||||
file_path = os.path.join(item.text(1), item.text(0))
|
||||
self.removeChannelInfo(file_path) # 추가된 부분
|
||||
self.removeChannelInfo(file_path) # 채널 정보 제거
|
||||
self.tree.clear()
|
||||
self.file_paths = []
|
||||
self.updateAlertText(f"모든 파일 삭제 완료", deleted_files)
|
||||
@ -359,7 +360,7 @@ class MainView(QtWidgets.QMainWindow):
|
||||
fsize = format_file_size(os.path.getsize(file_path))
|
||||
item = QtWidgets.QTreeWidgetItem([file, directory, self.channel_options[0], fsize])
|
||||
self.tree.addTopLevelItem(item)
|
||||
self.updateChannelInfo(directory, file, self.channel_options[0]) # Set default channel to 0
|
||||
self.updateChannelInfo(directory, file, self.channel_options[0]) # 기본 채널을 0으로 설정
|
||||
self.file_paths = [self.tree.topLevelItem(i).text(1) + '/' + self.tree.topLevelItem(i).text(0) for i in range(self.tree.topLevelItemCount())]
|
||||
self.saveSettings()
|
||||
|
||||
@ -379,15 +380,19 @@ class MainView(QtWidgets.QMainWindow):
|
||||
self.progress_bar.setVisible(True)
|
||||
self.progress_bar.setValue(0)
|
||||
total_files = len(self.file_paths)
|
||||
timestamp = datetime.now().strftime("%y-%m-%d")
|
||||
timestamp = datetime.now().strftime("%y-%m-%d-%a-%H-%M-%S") # 날짜 및 시간 형식 변경
|
||||
base_output_dir = os.path.join(self.default_save_path, "DBC 변환", timestamp)
|
||||
for index, file_path in enumerate(self.file_paths):
|
||||
file_name = os.path.splitext(os.path.basename(file_path))[0]
|
||||
rx_output_dir = os.path.join(self.default_save_path, "DBC 변환", timestamp, file_name, "RX")
|
||||
tx_output_dir = os.path.join(self.default_save_path, "DBC 변환", timestamp, file_name, "TX")
|
||||
rx_output_dir = os.path.join(base_output_dir, file_name, "RX")
|
||||
tx_output_dir = os.path.join(base_output_dir, file_name, "TX")
|
||||
dbc_output_dir = os.path.join(base_output_dir, "#DBC") # DBC 파일 저장 경로 설정
|
||||
os.makedirs(rx_output_dir, exist_ok=True)
|
||||
os.makedirs(tx_output_dir, exist_ok=True)
|
||||
os.makedirs(dbc_output_dir, exist_ok=True) # DBC 파일 저장 경로 생성
|
||||
channel_info = self.settings.get("channel_info", {}).get(os.path.basename(file_path), "CH0")
|
||||
try:
|
||||
shutil.copy(file_path, dbc_output_dir) # DBC 파일 복사
|
||||
subprocess.run(["python", "DBC_to_C_RX.py", file_path, rx_output_dir, json.dumps({os.path.basename(file_path): channel_info})], check=True)
|
||||
subprocess.run(["python", "DBC_to_C_TX.py", file_path, tx_output_dir, json.dumps({os.path.basename(file_path): channel_info})], check=True)
|
||||
self.updateAlertText(f"변환 성공", [file_path])
|
||||
@ -440,7 +445,7 @@ class MainView(QtWidgets.QMainWindow):
|
||||
|
||||
def applyChannelSelection(self, item, combo, dialog):
|
||||
item.setText(2, combo.currentText())
|
||||
self.updateChannelInfo(item.text(1), item.text(0), combo.currentText()) # 추가된 부분
|
||||
self.updateChannelInfo(item.text(1), item.text(0), combo.currentText()) # 채널 정보 업데이트
|
||||
dialog.close()
|
||||
|
||||
def updateChannelInfo(self, directory, filename, channel):
|
||||
|
||||
@ -1,7 +1,25 @@
|
||||
{
|
||||
"theme": "light",
|
||||
"default_save_path": "C:/Users/MSI/Desktop",
|
||||
"file_paths": [],
|
||||
"file_paths": [
|
||||
"C:/Users/MSI/SynologyDrive/3min_be/한자연/!사업/초안전/#Debug/DBC/240321_PHM.dbc",
|
||||
"C:/Users/MSI/SynologyDrive/3min_be/한자연/!사업/초안전/#Debug/DBC/240724_LOCAL_HyperSafe4.dbc",
|
||||
"C:/Users/MSI/SynologyDrive/3min_be/한자연/!사업/초안전/#Debug/DBC/240906_VCU_SCU_RWS.dbc",
|
||||
"C:/Users/MSI/SynologyDrive/3min_be/한자연/!사업/초안전/#Debug/DBC/241007_primary_HyperSafe4.dbc",
|
||||
"C:/Users/MSI/SynologyDrive/3min_be/한자연/!사업/초안전/#Debug/DBC/CAN_2023WRS_RG3EV_231123_VCU_EMB.dbc",
|
||||
"C:/Users/MSI/SynologyDrive/3min_be/한자연/!사업/초안전/#Debug/DBC/CAN_2023WRS_RG3EV_240626_VCU_BCU.dbc",
|
||||
"C:/Users/MSI/SynologyDrive/3min_be/한자연/!사업/초안전/#Debug/DBC/CANFD_SAFETY_v7.dbc",
|
||||
"C:/Users/MSI/SynologyDrive/3min_be/한자연/!사업/초안전/#Debug/DBC/IMU_SBW_20240826.dbc"
|
||||
],
|
||||
"last_opened_dir": "C:/Users/MSI/SynologyDrive/3min_be/한자연/!사업/초안전/#Debug/DBC",
|
||||
"channel_info": {}
|
||||
"channel_info": {
|
||||
"240321_PHM.dbc": "CH0",
|
||||
"240724_LOCAL_HyperSafe4.dbc": "CH0",
|
||||
"240906_VCU_SCU_RWS.dbc": "CH0",
|
||||
"241007_primary_HyperSafe4.dbc": "CH0",
|
||||
"CAN_2023WRS_RG3EV_231123_VCU_EMB.dbc": "CH0",
|
||||
"CAN_2023WRS_RG3EV_240626_VCU_BCU.dbc": "CH0",
|
||||
"CANFD_SAFETY_v7.dbc": "CH0",
|
||||
"IMU_SBW_20240826.dbc": "CH0"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user