self_example/phm_rotate/PHMWarehouse/utils/RedisUtils.py

49 lines
1021 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- encoding:utf-8 -*-
'''
@Author : dingjiawen
@Date : 2023/6/1 15:14
@Usage :
@Desc : 操作redis的工具类
'''
'''
参考:
[1] https://zhuanlan.zhihu.com/p/374381314
'''
import redis
import numpy as np
import json
import matplotlib.pyplot as plt
import pandas as pd
# 连接池方式 redisPool = redis.ConnectionPool(host='Ding202', port=6379)
redisClient = redis.Redis(host='Ding202', port=6379, decode_responses=True, charset='UTF-8', encoding='UTF-8')
read_name = r'E:\data\cmsDemo\华能三塘湖项目一期_D3-29_Shaft2_径向_25600_加速度g_14.41RPM_20180618003450.csv'
cms = redisClient.get(
r'华能三塘湖项目(一期):5:cmsLTTB')
# cms = np.array(cms)
cms = json.loads(cms)
x = cms.get("x")
print(cms)
print(x)
data = pd.read_csv(read_name, encoding='utf-8', header=None)
total_data = data.values[0]
plt.subplot(2,1,1)
plt.plot(x)
plt.xlabel("X")
plt.ylabel("Y")
plt.legend()
plt.subplot(2,1,2)
plt.plot(total_data)
plt.xlabel("X")
plt.ylabel("Y")
plt.legend()
plt.show()