111 lines
2.6 KiB
Python
111 lines
2.6 KiB
Python
# -*- encoding:utf-8 -*-
|
||
|
||
'''
|
||
@Author : dingjiawen
|
||
@Date : 2023/5/16 21:51
|
||
@Usage :
|
||
@Desc :测试
|
||
'''
|
||
|
||
import numpy as np
|
||
import pandas as pd
|
||
from datetime import datetime
|
||
import json
|
||
import os
|
||
|
||
####TODO 测试CMS数据读取
|
||
|
||
root = r"E:\data\cmsDemo/"
|
||
now_time = datetime.now()
|
||
|
||
def loadData():
|
||
file_name = os.listdir(root)
|
||
dataList=[]
|
||
for file in file_name:
|
||
if file.startswith("华能三塘湖"):
|
||
read_name = os.path.join(root + file)
|
||
# print(read_name)
|
||
data = pd.read_csv(read_name, encoding='utf-8',header=None)
|
||
total_data = data.values[0]
|
||
name = file.split("_")
|
||
data = {
|
||
"windfarm": name[0],
|
||
"wt_no": 5,
|
||
"realtime": file.split(".")[0].split("_")[-1],
|
||
"location": name[2]+"_"+name[3],
|
||
"g": 3,
|
||
"RPM": 14.41,
|
||
"freq": name[4],
|
||
"x": [],
|
||
"time": now_time.strftime("%Y%m%d%H%M%S")
|
||
}
|
||
dataList.append((data,total_data))
|
||
|
||
return dataList
|
||
|
||
pass
|
||
|
||
dataList = loadData()
|
||
|
||
print(dataList)
|
||
|
||
cms_data_path = r"E:\data\cmsDemo\华能三塘湖项目(一期)_D3-29_Shaft2_径向_25600_加速度g_14.41RPM_20180618003450.csv"
|
||
cms_data_df = pd.read_csv(cms_data_path, encoding='gbk', header=None)
|
||
|
||
|
||
x = list(cms_data_df)
|
||
|
||
send_data = list(cms_data_df.values[0])
|
||
print(send_data)
|
||
print(type(send_data))
|
||
|
||
data = {
|
||
"windfarm": "华能三塘湖(一期)",
|
||
"wt_no": 5,
|
||
"realtime": "20180618003450",
|
||
"location": "shaft_径向",
|
||
"g": 3,
|
||
"RPM": 14.41,
|
||
"freq": 25600,
|
||
"x": send_data[:3],
|
||
"time": now_time.strftime("%Y%m%d%H%M%S")
|
||
}
|
||
|
||
print(data)
|
||
# print(type(data))
|
||
data_send = json.dumps(data).encode("gbk")
|
||
print(data_send)
|
||
|
||
|
||
####TODO 测试燃机数据读取
|
||
# now_time = datetime.now()
|
||
# data_path = r"E:\data\Historian(1)\historian_data_demo\2023_01_02.npy"
|
||
# total_data = np.load(data_path)
|
||
# print(total_data)
|
||
# print(len(total_data))
|
||
#
|
||
# # # 获得行值
|
||
# rows = np.unique(total_data[:, 2])
|
||
# rows = np.insert(rows, 0, "Time")
|
||
# # 排序操作,升序排序,按照第一列进行排序,
|
||
# data_sorted = total_data[total_data[:, 2].argsort()]
|
||
# # 获得列值
|
||
# columns = np.unique(data_sorted[:, 0])
|
||
# # 获得集合,在此基础上进行添加
|
||
# values = rows[:, np.newaxis]
|
||
# print("==================")
|
||
# print(data_sorted)
|
||
|
||
|
||
|
||
# single_data = total_data[1, :]
|
||
# print(single_data)
|
||
# data = {
|
||
# "tagName": single_data[0],
|
||
# "value": single_data[1],
|
||
# "realtime": single_data[2],
|
||
# "time": now_time.strftime("%Y%m%d%H%M%S")
|
||
# }
|
||
|
||
# print(data)
|