- P&ID 그래프 파이프라인 구현 (py) - pid_geometric_extractor.py: 기하학적 특징 추출 - pid_intelligent_mapper.py: 태그 매핑 - pid_topology_builder.py: 위상 구축 - test_pipeline_phase2.py, test_pipeline_phase3.py: 테스트 - MCP 서버 개선 - server.py: 멀티프로세싱 지원 - pipeline/: 분석, 추출, 매핑, 위상 모듈 추가 - C# P&ID 그래프 서비스 - PidGraphDtos.cs: DTO 정의 - PidGraphService.cs: 비즈니스 로직 - PidGraphController.cs: API 컨트롤러 - OPC UA 서비스 개선 - ExperionOpcServerService.cs - ExperionRealtimeService.cs - ExperionFastService.cs - MCP 클라이언트 및 호스팅 서비스 개선 - McpClient.cs - McpServerHostedService.cs - 웹 UI 개선 - pid_graph_view.html: P&ID 그래프 뷰어 - pid-viewer.js: 뷰어 로직 - app.js: 메인 앱 - pid_graph.css: 스타일 - 프로젝트 설정 업데이트 - ExperionCrawler.csproj - Program.cs
62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
import json
|
|
import sys
|
|
import os
|
|
|
|
# 경로 설정을 위해 현재 파일의 디렉토리를 sys.path에 추가
|
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
sys.path.append(current_dir)
|
|
|
|
from pid_geometric_extractor import PidGeometricExtractor
|
|
from pid_topology_builder import PidTopologyBuilder, analyze_impact
|
|
|
|
def run_pipeline():
|
|
# 1. 경로 설정 (현재 디렉토리 기준 상대 경로)
|
|
input_dxf = os.path.join(current_dir, "No-10_Plant_PID.dxf")
|
|
geo_json_path = os.path.join(current_dir, "shared_geo_data.json")
|
|
graph_json_path = os.path.join(current_dir, "pid_graph_topology.json")
|
|
|
|
print("--- Phase 1: Geometric Extraction ---")
|
|
try:
|
|
extractor = PidGeometricExtractor(input_dxf)
|
|
extractor.extract_and_save(geo_json_path)
|
|
print(f"Geometric data saved to {geo_json_path}")
|
|
except Exception as e:
|
|
print(f"Phase 1 failed: {e}")
|
|
return
|
|
|
|
print("\n--- Phase 2: Topology Modeling ---")
|
|
try:
|
|
with open(geo_json_path, 'r', encoding='utf-8') as f:
|
|
geometric_data = json.load(f)
|
|
|
|
# 테스트를 위해 all_extracted_tags는 빈 리스트로 전달
|
|
# config를 None으로 전달하여 topology_config.json 설정을 사용하도록 함
|
|
builder = PidTopologyBuilder(
|
|
geometric_data=geometric_data,
|
|
all_extracted_tags=[],
|
|
config=None
|
|
)
|
|
builder.build_graph()
|
|
|
|
# 위상 검증
|
|
validation = builder.validate_topology()
|
|
print(f"Topology Validation: {validation}")
|
|
|
|
# 그래프 저장
|
|
builder.save_graph(graph_json_path)
|
|
print(f"Graph topology saved to {graph_json_path}")
|
|
|
|
# 영향도 분석 테스트 (노드가 존재하는 경우)
|
|
if validation['node_count'] > 0:
|
|
sample_node = list(builder.G.nodes())[0]
|
|
impacted = analyze_impact(builder.G, sample_node)
|
|
print(f"Impact analysis for node {sample_node}: {impacted}")
|
|
|
|
except Exception as e:
|
|
print(f"Phase 2 failed: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
if __name__ == "__main__":
|
|
run_pipeline()
|