Skip to content

Commit 5fbc0cb

Browse files
committed
[tutorial] add python T14-Hold tutorial
1 parent 019e72f commit 5fbc0cb

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
@Author: Chunel
3+
@Contact: chunel@foxmail.com
4+
@File: MyHoldNode
5+
@Time: 2025/3/4 00:08
6+
@Desc:
7+
"""
8+
9+
from PyCGraph import GNode, CStatus
10+
11+
from MyParams.MyParam import MyParam
12+
13+
class MyHoldNode(GNode):
14+
param_key = 'hold-param'
15+
def init(self):
16+
return self.createGParam(MyParam(), self.param_key)
17+
18+
def run(self):
19+
param: MyParam = self.getGParam(self.param_key)
20+
param.value += 1
21+
print('current value is {0}'.format(param.value))
22+
return CStatus()
23+
24+
def isHold(self):
25+
param: MyParam = self.getGParam(self.param_key)
26+
print('enter hold path, value is {0}'.format(param.value))
27+
return param.value < 5

python/tutorial/T14-Hold.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
@Author: Chunel
3+
@Contact: chunel@foxmail.com
4+
@File: T14-Hold
5+
@Time: 2025/3/4 00:15
6+
@Desc:
7+
"""
8+
9+
from PyCGraph import GPipeline, CStatus
10+
11+
from MyGNode.MyHoldNode import MyHoldNode
12+
from MyGNode.MyNode1 import MyNode1
13+
14+
15+
def tutorial_hold():
16+
pipeline = GPipeline()
17+
a, b = MyHoldNode(), MyNode1()
18+
19+
pipeline.registerGElement(a, set(), 'myHold')
20+
pipeline.registerGElement(b, {a}, 'nodeA')
21+
pipeline.process(3)
22+
23+
24+
if __name__ == '__main__':
25+
tutorial_hold()
26+

0 commit comments

Comments
 (0)