GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [feat] add python GDaemon · feiyunwill/CGraph@f53ad2d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • python
    • PyCGraph.cpp
    • tutorial
      • MyGDaemon
        • MyMonitorDaemon.py
        • __init__.py
      • T00-HelloCGraph.py
      • T13-Deamon.py
    • wrapper
      • PyWrapperInclude.h
      • PywGAspect.h
      • PywGCondition.h
      • PywGDaemon.h
      • PywGElement.h
      • PywGEvent.h
      • PywGNode.h
      • PywGParam.h
      • PywGPassedParam.h
  • src/GraphCtrl
    • GraphDaemon
      • GDaemon.cpp
      • GDaemon.h
    • GraphPipeline
      • GPipeline.cpp
      • GPipeline.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎python/PyCGraph.cpp‎

Copy file name to clipboardExpand all lines: python/PyCGraph.cpp
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ PYBIND11_MODULE(PyCGraph, m) {
9898
.def("removeGParam", &GAspect::__removeGParam_4py,
9999
py::call_guard<py::gil_scoped_release>());
100100

101+
py::class_<GDaemon, PywGDaemon, std::unique_ptr<GDaemon, py::nodelete> >(m, "GDaemon")
102+
.def(py::init<>())
103+
.def("getInterval", &GDaemon::__getInterval_4py)
104+
.def("createGParam", &GDaemon::__createGParam_4py,
105+
py::call_guard<py::gil_scoped_release>(),
106+
py::keep_alive<1, 2>())
107+
.def("getGParam", &GDaemon::__getGParam_4py)
108+
.def("getGParamWithNoEmpty", &GDaemon::__getGParamWithNoEmpty_4py)
109+
.def("removeGParam", &GDaemon::__removeGParam_4py,
110+
py::call_guard<py::gil_scoped_release>());
111+
101112
py::class_<GEvent, PywGEvent, std::unique_ptr<GEvent, py::nodelete> >(m, "GEvent")
102113
.def(py::init<>())
103114
.def("createGParam", &GEvent::__createGParam_4py,
@@ -120,6 +131,7 @@ PYBIND11_MODULE(PyCGraph, m) {
120131
py::class_<GPassedParam, PywGPassedParam, std::unique_ptr<GPassedParam, py::nodelete> >(m, "GPassedParam")
121132
.def(py::init<>());
122133
m.attr("GElementParam") = m.attr("GPassedParam");
134+
m.attr("GDaemonParam") = m.attr("GPassedParam");
123135

124136
py::class_<PyGPipeline>(m, "GPipeline")
125137
.def(py::init<>())
@@ -143,6 +155,10 @@ PYBIND11_MODULE(PyCGraph, m) {
143155
.def("destroy", &PyGPipeline::destroy)
144156
.def("addGEvent", &PyGPipeline::__addGEvent_4py,
145157
py::keep_alive<1, 2>())
158+
.def("addGDaemon", &PyGPipeline::__addGDaemon_4py,
159+
py::arg("daemon"),
160+
py::arg("ms"),
161+
py::keep_alive<1, 2>())
146162
.def("asyncRun", &PyGPipeline::asyncRun,
147163
py::arg("policy") = std::launch::async,
148164
py::call_guard<py::gil_scoped_release>())
Collapse file

‎python/tutorial/MyGDaemon/MyMonitorDaemon.py‎

Copy file name to clipboard
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
@Author: Chunel
3+
@Contact: [email protected]
4+
@File: MyMonitorDaemon
5+
@Time: 2025/3/30 00:49
6+
@Desc:
7+
"""
8+
9+
from PyCGraph import GDaemon
10+
11+
from MyParams.MyParam import MyParam
12+
13+
class MyMonitorGDaemon(GDaemon):
14+
def daemonTask(self, _):
15+
param: MyParam = self.getGParamWithNoEmpty('param1')
16+
print("----> [MyMonitorDaemon] monitor span is [{0}] ms, count is [{1}]".format(
17+
self.getInterval(), param.count))
Collapse file

‎python/tutorial/MyGDaemon/__init__.py‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""
2+
@Author: Chunel
3+
@Contact: [email protected]
4+
@File: __init__.py
5+
@Time: 2025/3/30 00:48
6+
@Desc:
7+
"""
Collapse file

‎python/tutorial/T00-HelloCGraph.py‎

Copy file name to clipboardExpand all lines: python/tutorial/T00-HelloCGraph.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@Desc:
77
"""
88

9-
from PyCGraph import GNode, GPipeline
9+
from PyCGraph import GPipeline
1010

1111
from MyGNode.HelloCGraphNode import HelloCGraphNode
1212

Collapse file

‎python/tutorial/T13-Deamon.py‎

Copy file name to clipboard
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
@Author: Chunel
3+
@Contact: [email protected]
4+
@File: T13-Deamon
5+
@Time: 2025/3/30 00:46
6+
@Desc:
7+
"""
8+
9+
from PyCGraph import GPipeline
10+
11+
from MyGNode.MyNode1 import MyNode1
12+
from MyGNode.MyWriteParamNode import MyWriteParamNode
13+
from MyGDaemon.MyMonitorDaemon import MyMonitorGDaemon
14+
15+
16+
def tutorial_simple():
17+
pipeline = GPipeline()
18+
a, b = MyNode1(), MyWriteParamNode()
19+
20+
pipeline.registerGElement(a, set(), "nodeA")
21+
pipeline.registerGElement(b, {a}, "writeParamNodeB")
22+
23+
pipeline.addGDaemon(MyMonitorGDaemon(), ms=3333)
24+
25+
pipeline.process(20)
26+
27+
28+
if __name__ == '__main__':
29+
tutorial_simple()
30+
Collapse file

‎python/wrapper/PyWrapperInclude.h‎

Copy file name to clipboardExpand all lines: python/wrapper/PyWrapperInclude.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "PywGParam.h"
2020
#include "PywGAspect.h"
2121
#include "PywGEvent.h"
22+
#include "PywGDaemon.h"
2223
#include "PywGPassedParam.h"
2324

2425
#endif //CGRAPH_PYWRAPPERINCLUDE_H
Collapse file

‎python/wrapper/PywGAspect.h‎

Copy file name to clipboardExpand all lines: python/wrapper/PywGAspect.h
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#include "CGraph.h"
1515

16-
namespace py = pybind11;
17-
1816
class PywGAspect : public CGraph::GAspect {
1917
public:
2018
explicit PywGAspect() = default;
Collapse file

‎python/wrapper/PywGCondition.h‎

Copy file name to clipboardExpand all lines: python/wrapper/PywGCondition.h
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#include "CGraph.h"
1515

16-
namespace py = pybind11;
17-
1816
class PywGCondition : public CGraph::GCondition {
1917
public:
2018
explicit PywGCondition(const CGraph::GElementPtrArr& elements = CGraph::GElementPtrArr{}) {
Collapse file

‎python/wrapper/PywGDaemon.h‎

Copy file name to clipboard
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/***************************
2+
@Author: Chunel
3+
@Contact: [email protected]
4+
@File: PywGDaemon.h
5+
@Time: 2025/3/30 00:13
6+
@Desc:
7+
***************************/
8+
9+
#ifndef CGRAPH_PYWGDAEMON_H
10+
#define CGRAPH_PYWGDAEMON_H
11+
12+
#include "CGraph.h"
13+
14+
class PywGDaemon : public CGraph::GDaemon {
15+
public:
16+
explicit PywGDaemon() = default;
17+
~PywGDaemon() override = default;
18+
19+
protected:
20+
CVoid daemonTask(CGraph::GDaemonParamPtr param) override {
21+
PYBIND11_OVERLOAD_PURE(CVoid, GDaemon, daemonTask, param);
22+
}
23+
24+
CMSec modify(CGraph::GDaemonParamPtr param) override {
25+
PYBIND11_OVERLOAD(CMSec, GDaemon, modify, param);
26+
}
27+
};
28+
29+
#endif //CGRAPH_PYWGDAEMON_H
Collapse file

‎python/wrapper/PywGElement.h‎

Copy file name to clipboardExpand all lines: python/wrapper/PywGElement.h
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#include "CGraph.h"
1515

16-
namespace py = pybind11;
17-
1816
class PywGElement : public CGraph::GElement {
1917
protected:
2018
CStatus run() override {

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.