|
@@ -0,0 +1,74 @@
|
|
|
+
|
|
|
+#include "acq_vendor.h"
|
|
|
+#include <communications/communication.h>
|
|
|
+#include <json/json.h>
|
|
|
+#include <settings/config_parser.h>
|
|
|
+
|
|
|
+static vendor::MyOpt myOpts_[] = {
|
|
|
+ {"help", no_argument, 'h', "[options] [documents] [IPaddress][:port]..." },
|
|
|
+ {"auth", required_argument, 0, "User and role configuration" },
|
|
|
+ {"debug", no_argument, 0, "Run in debug mode" },
|
|
|
+ {"home", required_argument, 0, "Change to directory to run" },
|
|
|
+ {"log", required_argument, 0, "logFile:level, Log to file file at verbosity level"},
|
|
|
+ {"route", required_argument, 0, "route file" },
|
|
|
+ {"port", required_argument, 0, "set port, default: 8880" },
|
|
|
+ {"delay", required_argument, 0, "delay secs to quit" },
|
|
|
+ {"document", required_argument, 0, "document" },
|
|
|
+ {"verbose", required_argument, 0, "Same as --log stderr:2" },
|
|
|
+ {"version", no_argument, 0, "version information" }
|
|
|
+};
|
|
|
+
|
|
|
+namespace iot_acq {
|
|
|
+AcqVendor::AcqVendor():
|
|
|
+ acqTask_(new AcqTask())
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+AcqVendor::~AcqVendor()
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+int AcqVendor::ParseCmdline(const std::string &optname, const std::string &optarg)
|
|
|
+{
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+vendor::MyOpt *AcqVendor::GetOpts()
|
|
|
+{
|
|
|
+ return myOpts_;
|
|
|
+}
|
|
|
+
|
|
|
+int AcqVendor::GetOptSize()
|
|
|
+{
|
|
|
+ return sizeof(myOpts_) / sizeof(myOpts_[0]);
|
|
|
+}
|
|
|
+
|
|
|
+void sigHandler(int sig)
|
|
|
+{
|
|
|
+ HTELINK_LOG_DEBUG("sigHandler, %d", sig);
|
|
|
+}
|
|
|
+
|
|
|
+int AcqVendor::Run()
|
|
|
+{
|
|
|
+ std::vector<settings::ConfigParser::DataCenter> dataCenters = configParser_.GetDataCenter();
|
|
|
+ for(settings::ConfigParser::DataCenter &dc: dataCenters) {
|
|
|
+ std::shared_ptr<leoyun::YunRpc> rpc = leoyun::YunRpc::GetRpcInstance(dc.yunID);
|
|
|
+ rpc->SetDataCenter(dc);
|
|
|
+ acqTask_->PushRpc(dc.name, rpc);
|
|
|
+ }
|
|
|
+ timerCheck_ = AppendTimerEvent(100, acqTask_);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+std::string AcqVendor::Name()
|
|
|
+{
|
|
|
+ return "iot-acq";
|
|
|
+}
|
|
|
+
|
|
|
+void AcqVendor::Stop(int signal)
|
|
|
+{
|
|
|
+ HTELINK_LOG_INFO("acq exit, signal = %d", signal);
|
|
|
+ StopEvent(timerCheck_);
|
|
|
+}
|
|
|
+} // namespace iot_acq
|