| 16 | using namespace CGraph; |
| 17 | |
| 18 | void tutorial_daemon() { |
| 19 | GPipelinePtr pipeline = GPipelineFactory::create(); // 创建一个pipeline,用于执行图框架信息 |
| 20 | GElementPtr a, b = nullptr; |
| 21 | |
| 22 | pipeline->registerGElement<MyNode1>(&a, {}, "nodeA"); |
| 23 | pipeline->registerGElement<MyWriteParamNode>(&b, {a}, "writeParamNodeB"); // writeParamNodeB中的值,每隔1s改变一次 |
| 24 | |
| 25 | MyConnParam connParam; |
| 26 | connParam.ip_ = "127.0.0.1"; |
| 27 | connParam.port_ = 6666; |
| 28 | |
| 29 | /** 添加两个daemon信息,随pipeline执行 */ |
| 30 | pipeline->addGDaemon<MyMonitorDaemon>(4000) // 间隔4s执行 |
| 31 | ->addGDaemon<MyParamDaemon, MyConnParam>(3500, &connParam) // 间隔3500ms执行,并且传入参数 |
| 32 | ->addGDaemon<MyTemplateDaemon<int>>(2750, 300); // 添加模板daemon信息 |
| 33 | |
| 34 | /** 长时间执行,观察守护器执行状态 */ |
| 35 | pipeline->process(20); |
| 36 | GPipelineFactory::remove(pipeline); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | int main() { |