UI_Chart

import os
import pygame
import pandas as pd
import glob
import logging

# 配置日志记录
log_path = r'D:\Tim_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 = "Pump PHM"
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'C:\Users\Administrator\Desktop\Great_Data\Data\Send'

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

if not csv_files:
    print("未找到CSV文件,请检查目录路径是否正确。")
else:
    # 用于绘制图表的数据
    data = []

    # 定义处理时间戳的函数
    def process_timestamp(ts):
        try:
            if ':' in ts:
                ts, microseconds = ts.rsplit(':', 1)
                microseconds = microseconds.ljust(3, '0')
                ts += '.' + microseconds
            else:
                ts += '.000'
        except Exception as e:
            logging.error(f"Failed to process timestamp {ts}: {e}")
            ts = ts + '.000'
        return ts

    # 遍历每个CSV文件
    for csv_file in csv_files:
        logging.info("Reading CSV file...")
        df = pd.read_csv(csv_file, delimiter=',', header=None,
                         names=['aX_ICM_1'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值