|
@@ -81,6 +81,54 @@ void loadConfig(std::string szFile,Config& config)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void DataEngine::startup_DataAlarm(DeviceInfo di)
|
|
|
+{
|
|
|
+ DeviceController* pControler = new DeviceController();
|
|
|
+ pControler->regConsumer(this);
|
|
|
+ pControler->CreateDevice(di);
|
|
|
+
|
|
|
+ std::list<std::string> lstTopics;
|
|
|
+ std::vector<Setting>::iterator itr;
|
|
|
+ for( itr = di.ModuleInfo.vSettings.begin(); itr != di.ModuleInfo.vSettings.end(); ++itr )
|
|
|
+ {
|
|
|
+ std::string topic = itr->Name;
|
|
|
+
|
|
|
+ lstTopics.push_back(topic);
|
|
|
+ m_mpDevControler[topic].push_back(pControler);
|
|
|
+ }
|
|
|
+ if( lstTopics.begin() != lstTopics.end())
|
|
|
+ {
|
|
|
+ m_pTDengine->Subscribe(lstTopics);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void DataEngine::startup_CommAlarm(DeviceInfo di)
|
|
|
+{
|
|
|
+ DeviceController* pControler = new DeviceController();
|
|
|
+ pControler->regConsumer(this);
|
|
|
+ pControler->CreateDevice(di);
|
|
|
+
|
|
|
+ std::list<std::string> lstTopics;
|
|
|
+ std::vector<Setting>::iterator itr;
|
|
|
+ for( itr = di.ModuleInfo.vSettings.begin(); itr != di.ModuleInfo.vSettings.end(); ++itr )
|
|
|
+ {
|
|
|
+ Setting oSet = *itr;
|
|
|
+ QJsonDocument jsonDoc(QJsonDocument::fromJson(oSet.qValue.toString().toLocal8Bit()));
|
|
|
+ QJsonArray json = jsonDoc.array();
|
|
|
+ for(auto i : json)
|
|
|
+ {
|
|
|
+ std::string topic = i.toString().toLocal8Bit().toStdString();
|
|
|
+
|
|
|
+ lstTopics.push_back(topic);
|
|
|
+ m_mpDevControler[topic].push_back(pControler);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( lstTopics.begin() != lstTopics.end())
|
|
|
+ {
|
|
|
+ m_pTDengine->Subscribe(lstTopics);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void DataEngine::Startup()
|
|
|
{
|
|
|
// merge file name
|
|
@@ -121,6 +169,8 @@ void DataEngine::Startup()
|
|
|
|
|
|
m_pTDengine = new TDAgent();
|
|
|
m_pTDengine->Connect(mpConfig["tdengine"]); // td
|
|
|
+ qRegisterMetaType<std::string>("std::string");
|
|
|
+ connect(m_pTDengine,SIGNAL(sigEvent(const std::string, const std::string)),this,SLOT(sltSubData(const std::string, const std::string)));
|
|
|
|
|
|
m_pMqtt = new MQTTAgent();
|
|
|
m_pMqtt->Connect(mpConfig["mqtt"]); // mqtt
|
|
@@ -128,36 +178,9 @@ void DataEngine::Startup()
|
|
|
// server.id
|
|
|
DeviceManagerProxy dm(m_pRedis);
|
|
|
DeviceInfo da = dm.loadDataAlarm("alarmrule", "plugins/AlarmRecognition.dll");
|
|
|
- DeviceInfo ca = dm.loadCommAlarm("alarmruledevicestatus", "plugins/CommRecognition.dll");
|
|
|
-
|
|
|
- std::list<DeviceInfo> lstDevices;
|
|
|
- lstDevices.push_back(da);
|
|
|
- lstDevices.push_back(ca);
|
|
|
-
|
|
|
- std::list<DeviceInfo>::iterator itr;
|
|
|
- for( itr = lstDevices.begin();itr!= lstDevices.end();++itr)
|
|
|
- {
|
|
|
- DeviceInfo di = *itr;
|
|
|
- DeviceController* pControler = new DeviceController();
|
|
|
- pControler->regConsumer(this);
|
|
|
- pControler->CreateDevice(di);
|
|
|
-
|
|
|
- std::list<std::string> lstTopics;
|
|
|
- std::vector<Setting>::iterator itrT;
|
|
|
- for( itrT = di.ModuleInfo.vSettings.begin(); itrT != di.ModuleInfo.vSettings.end(); ++itrT )
|
|
|
- {
|
|
|
- std::string topic = itrT->Name;
|
|
|
+ startup_DataAlarm(da);
|
|
|
|
|
|
- lstTopics.push_back(topic);
|
|
|
- m_mpDevControler[topic].push_back(pControler);
|
|
|
-
|
|
|
- qRegisterMetaType<std::string>("std::string");
|
|
|
- connect(m_pTDengine,SIGNAL(sigEvent(const std::string, const std::string)),this,SLOT(sltSubData(const std::string, const std::string)));
|
|
|
- }
|
|
|
- if( lstTopics.begin() != lstTopics.end())
|
|
|
- {
|
|
|
- m_pTDengine->Subscribe(lstTopics);
|
|
|
- }
|
|
|
- }
|
|
|
+ DeviceInfo ca = dm.loadCommAlarm("alarmruledevicestatus", "plugins/CommRecognition.dll");
|
|
|
+ startup_CommAlarm(ca);
|
|
|
}
|
|
|
|