diff --git a/auto_realtime.py b/auto_realtime.py index 4ca2cb9..b64c19d 100644 --- a/auto_realtime.py +++ b/auto_realtime.py @@ -5,7 +5,7 @@ import schedule import time from influxdb_client import InfluxDBClient, BucketsApi, WriteApi, OrganizationsApi, Point, QueryApi import simulation - +import influxdb_info # 2025/02/01 def get_next_time() -> str: @@ -108,9 +108,9 @@ def realtime_task() -> None: if __name__ == "__main__": - url = "http://localhost:8086" # 替换为你的InfluxDB实例地址 - token = "Z4UZj9HuLwLlwoApywvT2nGVP3bwLy18y-sJQ7enzZlJd8YMzMWbBA6F-q4gBiZ-7-IqdxR5aR9LvicKiSNmnA==" # 替换为你的InfluxDB Token - org_name = "beibei" # 替换为你的Organization名称 + url = influxdb_info.url + token = influxdb_info.token + org_name = influxdb_info.org client = InfluxDBClient(url=url, token=token) diff --git a/auto_store_non_realtime_SCADA_data.py b/auto_store_non_realtime_SCADA_data.py index 403f274..ad20bd8 100644 --- a/auto_store_non_realtime_SCADA_data.py +++ b/auto_store_non_realtime_SCADA_data.py @@ -4,6 +4,7 @@ from datetime import datetime, timedelta, timezone import schedule import time from influxdb_client import InfluxDBClient, BucketsApi, WriteApi, OrganizationsApi, Point, QueryApi +import influxdb_info # 2025/02/06 @@ -69,9 +70,9 @@ def store_non_realtime_SCADA_data_task() -> None: if __name__ == "__main__": - url = "http://localhost:8086" # 替换为你的InfluxDB实例地址 - token = "Z4UZj9HuLwLlwoApywvT2nGVP3bwLy18y-sJQ7enzZlJd8YMzMWbBA6F-q4gBiZ-7-IqdxR5aR9LvicKiSNmnA==" # 替换为你的InfluxDB Token - org_name = "beibei" # 替换为你的Organization名称 + url = influxdb_info.url + token = influxdb_info.token + org_name = influxdb_info.org client = InfluxDBClient(url=url, token=token) diff --git a/auto_store_realtime_SCADA_data.py b/auto_store_realtime_SCADA_data.py index 1f19fff..5eba6cf 100644 --- a/auto_store_realtime_SCADA_data.py +++ b/auto_store_realtime_SCADA_data.py @@ -4,6 +4,7 @@ from datetime import datetime, timedelta, timezone import schedule import time from influxdb_client import InfluxDBClient, BucketsApi, WriteApi, OrganizationsApi, Point, QueryApi +import influxdb_info # 2025/02/01 @@ -49,9 +50,9 @@ def store_realtime_SCADA_data_task() -> None: if __name__ == "__main__": - url = "http://localhost:8086" # 替换为你的InfluxDB实例地址 - token = "Z4UZj9HuLwLlwoApywvT2nGVP3bwLy18y-sJQ7enzZlJd8YMzMWbBA6F-q4gBiZ-7-IqdxR5aR9LvicKiSNmnA==" # 替换为你的InfluxDB Token - org_name = "beibei" # 替换为你的Organization名称 + url = influxdb_info.url + token = influxdb_info.token + org_name = influxdb_info.org client = InfluxDBClient(url=url, token=token) diff --git a/influxdb_api.py b/influxdb_api.py index 1dca474..1bb84b3 100644 --- a/influxdb_api.py +++ b/influxdb_api.py @@ -12,11 +12,12 @@ from tjnetwork import * import schedule import threading import globals +import influxdb_info # influxdb数据库连接信息 -url = "http://localhost:8086" # 替换为你的InfluxDB实例地址 -token = "Z4UZj9HuLwLlwoApywvT2nGVP3bwLy18y-sJQ7enzZlJd8YMzMWbBA6F-q4gBiZ-7-IqdxR5aR9LvicKiSNmnA==" # 替换为你的InfluxDB Token -org_name = "beibei" # 替换为你的Organization名称 +url = influxdb_info.url +token = influxdb_info.token +org_name = influxdb_info.org client = InfluxDBClient(url=url, token=token, org=org_name) # # 所有实时更新数据的SCADA设备的ID @@ -1303,9 +1304,9 @@ def query_curve_by_ID_property_daterange(ID: str, type: str, property: str, star # 示例调用 if __name__ == "__main__": - url = "http://localhost:8086" # 替换为你的InfluxDB实例地址 - token = "Z4UZj9HuLwLlwoApywvT2nGVP3bwLy18y-sJQ7enzZlJd8YMzMWbBA6F-q4gBiZ-7-IqdxR5aR9LvicKiSNmnA==" # 替换为你的InfluxDB Token - org_name = "beibei" # 替换为你的Organization名称 + url = influxdb_info.url + token = influxdb_info.token + org_name = InfluxDBClient.org client = InfluxDBClient(url=url, token=token) diff --git a/influxdb_info.py b/influxdb_info.py new file mode 100644 index 0000000..a15613d --- /dev/null +++ b/influxdb_info.py @@ -0,0 +1,4 @@ +# influxdb数据库连接信息 +url = "http://localhost:8086" # 替换为你的InfluxDB实例地址 +token = "xGDM5RZqRJAuzAGS-otXUdC2NFdY75qJAjRLqAB4p5WcIIAlIUpOpT8_yA16AOHmJWerwQ_08gwb84sy42jnZQ==" # 替换为你的InfluxDB Token +org = "TJWATERORG" # 替换为你的Organization名称 \ No newline at end of file diff --git a/online_Analysis.py b/online_Analysis.py index bbaf20d..63910af 100644 --- a/online_Analysis.py +++ b/online_Analysis.py @@ -19,8 +19,19 @@ import chardet # burst analysis 01 ############################################################ -def burst_analysis(prj_name, date_time, burst_ID: list | str, - burst_size: list | float | int = None, duration=900, pump_control=None, valve_closed=None) -> str: +def burst_analysis(prj_name, date_time, burst_ID: list | str, burst_size: list | float | int = None, duration=900, pump_control=None, valve_closed=None) -> str: + ''' + burst 分析 + :param prj_name: + :param date_time: + :param burst_ID: + :param burst_siz: + :param duration: + :param pump_control: + :param valve_closed: + :return: + ''' + print(datetime.now(pytz.timezone('Asia/Shanghai')).strftime("%Y-%m-%d %H:%M:%S") + " -- Start Analysis.") new_name = f'burst_Anal_{prj_name}' diff --git a/setup_server.md b/setup_server.md index 9b09de5..2020604 100644 --- a/setup_server.md +++ b/setup_server.md @@ -19,3 +19,10 @@ pg 信息 Port: 5432 (默认) User: 就是Windows的用户名,这台机器也就是 Administrator Password: 密码为空 + +influx db 信息 + # influxdb数据库连接信息 + influx_url = "http://localhost:8086" # 替换为你的InfluxDB实例地址 + influx_token = "xGDM5RZqRJAuzAGS-otXUdC2NFdY75qJAjRLqAB4p5WcIIAlIUpOpT8_yA16AOHmJWerwQ_08gwb84sy42jnZQ==" # 替换为你的InfluxDB Token + influx_org_name = "TJWATERORG" # 替换为你的Organization名称 + influx_client = InfluxDBClient(url=influx_url, token=influx_token, org=influx_org_name)