|
@@ -0,0 +1,74 @@
|
|
|
|
+#include "DataSubscribe.h"
|
|
|
|
+#include <QVariant>
|
|
|
|
+#include "LibraryLoader.h"
|
|
|
|
+#include "Publisher.h"
|
|
|
|
+
|
|
|
|
+DataSubscribe::DataSubscribe()
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void DataSubscribe::run()
|
|
|
|
+{
|
|
|
|
+ while(!isInterruptionRequested()){
|
|
|
|
+ if(shares.sem->tryAcquire(1, 500)){
|
|
|
|
+ shares.mutex->lock();
|
|
|
|
+ shares.commandList.dequeue();
|
|
|
|
+ shares.mutex->unlock();
|
|
|
|
+ dataConsumer->OnData(QString(dataName.c_str()), "time", QVariant());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void DataSubscribe::Setup(ModuleInfo &mi)
|
|
|
|
+{
|
|
|
|
+ std::string assemblyName = mi.AssemblyName;
|
|
|
|
+ std::string className = mi.ClassName;
|
|
|
|
+
|
|
|
|
+ BaseModule* pModule = nullptr;// = (BaseModule)Assembly.LoadFile(Path.GetFullPath(@".\" + assemblyName)).CreateInstance(className);
|
|
|
|
+ pModule = LibraryLoader::load<BaseModule>(assemblyName);
|
|
|
|
+ if( pModule == nullptr )
|
|
|
|
+ {
|
|
|
|
+ // qCritical() << LOG_HEADER << " load " << szPlugin.c_str() << " failed.";
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if( pModule == nullptr )
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ qCritical() << __FILE__ << __LINE__ << " " << assemblyName.c_str() << " load failed.";
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ Publisher* runable = dynamic_cast<Publisher*>(pModule);
|
|
|
|
+ runable->shares(shares);
|
|
|
|
+ runable->Run();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+std::string DataSubscribe::getTypeList()
|
|
|
|
+{
|
|
|
|
+ return "DataStorage::RunnableModule";
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void DataSubscribe::setLoader(QLibrary *)
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void DataSubscribe::regConsumer(DataConsumer *dc)
|
|
|
|
+{
|
|
|
|
+ dataConsumer = dc;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void DataSubscribe::Run()
|
|
|
|
+{
|
|
|
|
+ start();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|