forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathT13-Daemon.cpp
41 lines (33 loc) · 1.37 KB
/
T13-Daemon.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/***************************
@Author: Chunel
@Contact: [email protected]
@File: T13-Daemon.cpp
@Time: 2022/2/3 11:31 上午
@Desc: 本例子主要展示,添加Daemon节点完成对pipeline的实时信息获取
***************************/
#include "MyGDaemon/MyMonitorDaemon.h"
#include "MyGDaemon/MyParamDaemon.h"
#include "MyGNode/MyNode1.h"
#include "MyGNode/MyWriteParamNode.h"
#include "MyGParam/MyConnParam.h"
using namespace CGraph;
void tutorial_daemon() {
GPipelinePtr pipeline = GPipelineFactory::create(); // 创建一个pipeline,用于执行图框架信息
GElementPtr a, b = nullptr;
pipeline->registerGElement<MyNode1>(&a, {}, "nodeA");
pipeline->registerGElement<MyWriteParamNode>(&b, {a}, "writeParamNodeB"); // writeParamNodeB中的值,每隔1s改变一次
MyConnParam connParam;
connParam.ip_ = "127.0.0.1";
connParam.port_ = 6666;
/** 添加两个daemon信息,随pipeline执行 */
pipeline->addGDaemon<MyMonitorDaemon>(4000) // 间隔4s执行
->addGDaemon<MyParamDaemon, MyConnParam>(3500, &connParam) // 间隔3500ms执行,并且传入参数
->addGDaemon<MyParamDaemon>(8500); // 对应不传入参数的分支
/** 长时间执行,观察守护器执行状态 */
pipeline->process(20);
GPipelineFactory::remove(pipeline);
}
int main() {
tutorial_daemon();
return 0;
}