summaryrefslogtreecommitdiff
path: root/gr-blocks/examples/py_snippets_demo.grc
blob: ebf070b4aaea03388979a541306a484d0759f603 (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
options:
  parameters:
    author: Josh Morman
    catch_exceptions: 'True'
    category: '[GRC Hier Blocks]'
    cmake_opt: ''
    comment: ''
    copyright: Copyright 2020
    description: Show simple examples of Python Snippets inserted into flowgraph
    gen_cmake: 'On'
    gen_linking: dynamic
    generate_options: qt_gui
    hier_block_src_path: '.:'
    id: snippets_demo
    max_nouts: '0'
    output_language: python
    placement: (0,0)
    qt_qss_theme: ''
    realtime_scheduling: ''
    run: 'True'
    run_command: '{python} -u {filename}'
    run_options: prompt
    sizing_mode: fixed
    thread_safe_setters: ''
    title: Python Snippets Example Flowgraph
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [8, 8]
    rotation: 0
    state: enabled

blocks:
- name: samp_rate
  id: variable
  parameters:
    comment: ''
    value: '32000'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [184, 12]
    rotation: 0
    state: enabled
- name: foo_mod
  id: epy_module
  parameters:
    alias: ''
    comment: ''
    source_code: "# this module will be imported in the into your flowgraph\n\ndef\
      \ add(a,b):\n    return a+b\n"
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [850, 264]
    rotation: 0
    state: true
- name: head_block
  id: blocks_head
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    maxoutbuf: '0'
    minoutbuf: '0'
    num_items: '12'
    type: float
    vlen: '1'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [937, 351]
    rotation: 0
    state: true
- name: s0
  id: snippet
  parameters:
    alias: ''
    code: 's = ''After start - 500 priority''

      print(s)'
    comment: ''
    priority: '500'
    section: main_after_start
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [263, 115]
    rotation: 0
    state: true
- name: s1
  id: snippet
  parameters:
    alias: ''
    code: 's = ''After start - 200 priority''

      print(s)'
    comment: ''
    priority: '200'
    section: main_after_start
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [264, 208]
    rotation: 0
    state: true
- name: s2
  id: snippet
  parameters:
    alias: ''
    code: 's = ''After start - negative priority''

      print(s)'
    comment: ''
    priority: '-400'
    section: main_after_start
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [267, 298]
    rotation: 0
    state: true
- name: s3
  id: snippet
  parameters:
    alias: ''
    code: 's = ''After start - 0 priority''

      print(s)'
    comment: ''
    priority: '0'
    section: main_after_start
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [270, 371]
    rotation: 0
    state: true
- name: s4
  id: snippet
  parameters:
    alias: ''
    code: 's = ''After Init - 100 priority''

      print(s)'
    comment: ''
    priority: '100'
    section: main_after_init
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [549, 88]
    rotation: 0
    state: true
- name: s5
  id: snippet
  parameters:
    alias: ''
    code: 'x = 4

      y = foo_mod.add(x,x)

      print(y)

      s = ''After init - 200 priority''

      print(s)'
    comment: "This snippet shows how to call a \nmethod from an embedded python \n\
      module"
    priority: '200'
    section: main_after_init
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [550, 209]
    rotation: 0
    state: true
- name: s6
  id: snippet
  parameters:
    alias: ''
    code: 's = ''After Stop - 500 priority''

      print(s)'
    comment: ''
    priority: '500'
    section: main_after_stop
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [865, 52]
    rotation: 0
    state: true
- name: s7
  id: snippet
  parameters:
    alias: ''
    code: 's = ''After Stop - 200 priority''

      print(s)

      print(self.vsink.data())'
    comment: 'This snippet shows an example of calling

      a method on another block from within the

      flowgraph - (use at your own risk)'
    priority: '200'
    section: main_after_stop
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [1120, 55]
    rotation: 0
    state: true
- name: throttle_block
  id: blocks_throttle
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    ignoretag: 'True'
    maxoutbuf: '0'
    minoutbuf: '0'
    samples_per_second: samp_rate
    type: float
    vlen: '1'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [752, 384]
    rotation: 0
    state: enabled
- name: vsink
  id: blocks_vector_sink_x
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    reserve_items: '1024'
    type: float
    vlen: '1'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [1118, 337]
    rotation: 0
    state: true
- name: vsrc
  id: blocks_vector_source_x
  parameters:
    affinity: ''
    alias: ''
    comment: ''
    maxoutbuf: '0'
    minoutbuf: '0'
    repeat: 'True'
    tags: '[]'
    type: float
    vector: list(range(10))
    vlen: '1'
  states:
    bus_sink: false
    bus_source: false
    bus_structure: null
    coordinate: [531, 390]
    rotation: 0
    state: true

connections:
- [head_block, '0', vsink, '0']
- [throttle_block, '0', head_block, '0']
- [vsrc, '0', throttle_block, '0']

metadata:
  file_format: 1