自学内容网 自学内容网

MAX 30W


 

import os
import pygame
import pandas as pd
import glob
import logging
from datetime import datetime
import time

# 配置日志记录
log_path = r'D:\_Study\Case\Chart_RealTime\log.txt'
logging.basicConfig(filename=log_path, level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')

# 初始化pygame
pygame.init()

# 设置窗口大小和标题
WINDOW_WIDTH = 1920
WINDOW_HEIGHT = 1080
WINDOW_TITLE = "RT"
screen = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
pygame.display.set_caption(WINDOW_TITLE)

# 定义颜色
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
ORANGE = (255, 165, 0)
PURPLE = (128, 0, 128)
BROWN = (139, 69, 19)  
BLACK = (0, 0, 0)

# 源目录路径
source_dir = r'D:\_Study\pi'

# 查找目录下的所有CSV文件
csv_files = glob.glob(os.path.join(source_dir, '*.csv'))

if not csv_files:
    print("未找到CSV文件,请检查目录路径是否正确。")
else:
    # 主循环
    running = True
    clock = pygame.time.Clock()
    
    # 设置图表的起始和结束位置
    start_x = 50
    end_x = WINDOW_WIDTH - 50
    start_y_a = 250
    end_y_a = (WINDOW_HEIGHT // 2) - 50
    start_y_b = (WINDOW_HEIGHT // 2) + 50
    end_y_b = WINDOW_HEIGHT - 50

    # 初始化变量
    frame_counter = 0
    loop_count = 0  # 循环计数器

    # 无限循环
    while running:
        # 记录循环开始的日志
        logging.info(f"Starting loop {loop_count}")

        # 复位帧计数器
        frame_counter = 0

        # 循环处理CSV文件列表
        for csv_file in csv_files:
            logging.info(f"Readi


原文地址:https://blog.csdn.net/weixin_68067302/article/details/142796857

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!