-
Notifications
You must be signed in to change notification settings - Fork 1
/
customblocks.py
33 lines (26 loc) · 976 Bytes
/
customblocks.py
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
import crappy
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.widgets
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from typing import NoReturn, Optional, Tuple
# from matplotlib.widgets import Button
class YBlock(crappy.blocks.Block):
def __init__(self, cmd_labels = None, out_labels = None, freq = 50):
super().__init__()
self.cmd_labels = cmd_labels if cmd_labels is not None else out_labels
self.out_labels = out_labels
self.freq = freq
def prepare(self):
self.output = {}
def loop(self):
for link in self.inputs:
recv_dict = link.recv_last()
if recv_dict is not None:
for label in recv_dict:
self.output[label] = recv_dict[label]
# if self.output == {} :
# self.output["sortie_charge_transformee"] = 0.0
# self.output["consigne"] = 0.0
# self.output["t(s)"] = 0.0
self.send(self.output)