Browse Source

iotdb配置

heshixin 17 hours ago
parent
commit
57788239a8

+ 4 - 4
communication/rocketmq_link.py

@@ -47,7 +47,7 @@ class RocketClient:
                 cls._instance = super(RocketClient, cls).__new__(cls)
         return cls._instance
 
-    def __init__(self, name_server_address, producer_group='alg_cop_result_producer', access_key='', access_secret=''):
+    def __init__(self, name_server_address, producer_group='alg-chiller-temp-result-producer', access_key='', access_secret=''):
         """初始化生产者(仅执行一次)"""
         with self._lock:
             if not self.__class__._producer:
@@ -57,10 +57,10 @@ class RocketClient:
                 self.__class__._producer.set_session_credentials(access_key,access_secret,'')
                 self.__class__._producer.start()
                 logger.critical("========Rocket server {} ========".format(name_server_address))
-                logger.critical("========Rocket cop producer created ========")
+                logger.critical("========Rocket chiller temperature producer created ========")
 
     @classmethod
-    def start_consuming(cls, topic, on_message, consumer_group='alg-req-consumer-group', expression='*'):
+    def start_consuming(cls, topic, on_message, consumer_group='alg-req-chiller-temp-consumer-group', expression='*'):
         """
         创建消费端
         :param topic: 监听的消息主题
@@ -83,7 +83,7 @@ class RocketClient:
         thread.start()
 
     @classmethod
-    def start_consume(cls, topic, on_message, consumer_group='alg-req-consumer-group', expression='*',
+    def start_consume(cls, topic, on_message, consumer_group='alg-chiller-temp-req-consumer-group', expression='*',
                       access_key='', access_secret=''):
         consumer = PushConsumer(consumer_group)
         consumer.set_name_server_address(cls._name_server_address)

+ 6 - 1
config/communication_config.py

@@ -31,4 +31,9 @@ ROCKET_ACCESS_SECRET = configs["rocketmq_config"]["access_secret"]
 ROCKET_CHILLER_TEMP_IN_TOPIC = configs["rocketmq_config"]["topic_chiller_temp_in"]
 ROCKET_CHILLER_TEMP_OUT_TOPIC = configs["rocketmq_config"]["topic_chiller_temp_out"]
 ROCKET_CHILLER_TEMP_IN_TAG = configs["rocketmq_config"]["tag_chiller_temp_in"]
-ROCKET_CHILLER_TEMP_OUT_TAG = configs["rocketmq_config"]["tag_chiller_temp_out"]
+ROCKET_CHILLER_TEMP_OUT_TAG = configs["rocketmq_config"]["tag_chiller_temp_out"]
+
+IOTDB_HOST = configs["iotdb"]["host"]
+IOTDB_PORT = configs["iotdb"]["port"]
+IOTDB_USER = configs["iotdb"]["username"]
+IOTDB_PASSWD = configs["iotdb"]["password"]

+ 8 - 2
config/config.py

@@ -22,12 +22,18 @@ configs = {
         "host": os.getenv("ROCKET_HOST_ADDR","http://192.168.1.70:9876"),
         # "host": os.getenv("ROCKET_HOST_ADDR", "http://172.17.102.51:9876"),
         # 水温算法 触发主题
-        "topic_chiller_temp_in": os.getenv("TOPIC_CHILLER_TEMP_IN", "alg-request"),
+        "topic_chiller_temp_in": os.getenv("TOPIC_CHILLER_TEMP_IN", "alg-chiller-temp-request"),
         "tag_chiller_temp_in": os.getenv("TAG_CHILLER_TEMP_IN", "alg-chiller-req"),
         # 水温算法 响应主题
-        "topic_chiller_temp_out": os.getenv("TOPIC_CHILLER_TEMP_OUT", "alg-response"),
+        "topic_chiller_temp_out": os.getenv("TOPIC_CHILLER_TEMP_OUT", "alg-chiller-temp-response"),
         "tag_chiller_temp_out": os.getenv("TAG_CHILLER_TEMP_OUT", "alg-chiller-resp"),
 
+    },
+    "iotdb":{
+        "host": os.getenv("IOTDB_HOST", "192.168.1.70"),
+        "port": os.getenv("IOTDB_PORT", 6667),
+        "username": os.getenv("IOTDB_USER", "root"),
+        "password": os.getenv("IOTDB_PASSWD", "root")
     }
 
 }

+ 1 - 0
main.py

@@ -22,6 +22,7 @@ def main(data_input):
         dict_results = json.dumps(dict_results, ensure_ascii=False)
         logger.critical("Output: {}".format(dict_results))
         send_data_to_rabbitmq(dict_results)
+        # send_data_to_rocket(dict_results)
 
     except Exception as e:
         result_depict = '异常中断,退出水温智控算法' + "(" + str(e) + ")"

+ 3 - 1
temp_humid_cal/excess_temp_modify.py

@@ -4,6 +4,7 @@ from data_initialize_standard.constant import *
 from communication.iotdb_util import *
 # from logs_conf.logger import *
 from logs.logger import *
+from config import communication_config as communicationConfig
 
 
 class ExcessTempModify(object):
@@ -18,7 +19,8 @@ class ExcessTempModify(object):
         self.sampling_nums = 60/dict_code['samplePeriod']*10   # 根据采样周期进行计算
 
     def get_modify_data(self):
-        IotDbClient('192.168.1.70', username='root', password='root')
+        IotDbClient(communicationConfig.IOTDB_HOST, port=communicationConfig.IOTDB_PORT,
+                    username=communicationConfig.IOTDB_USER, password=communicationConfig.IOTDB_PASSWD)
         org_id = self.chiller_outer['orgId']
         controller_id = self.chiller_outer['controllerId']
         chiller_ids = self.chiller_outer['allChillersInfo']['chillerId']