Skip to content

Commit ae8b34a

Browse files
committed
reverting python changes back to pre-release
1 parent 3b8272d commit ae8b34a

File tree

13 files changed

+3916
-3922
lines changed

13 files changed

+3916
-3922
lines changed

python/pyrogue/_Block.py

Lines changed: 283 additions & 207 deletions
Large diffs are not rendered by default.

python/pyrogue/_Command.py

Lines changed: 347 additions & 285 deletions
Large diffs are not rendered by default.

python/pyrogue/_DataReceiver.py

Lines changed: 77 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,90 @@
1-
# -----------------------------------------------------------------------------
1+
#-----------------------------------------------------------------------------
22
# Company : SLAC National Accelerator Laboratory
3-
# -----------------------------------------------------------------------------
3+
#-----------------------------------------------------------------------------
44
# Description:
55
# PyRogue base module - Data Receiver Device
6-
# -----------------------------------------------------------------------------
6+
#-----------------------------------------------------------------------------
77
# This file is part of the rogue software platform. It is subject to
88
# the license terms in the LICENSE.txt file found in the top-level directory
99
# of this distribution and at:
1010
# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
1111
# No part of the rogue software platform, including this file, may be
1212
# copied, modified, propagated, or distributed except according to the terms
1313
# contained in the LICENSE.txt file.
14-
# -----------------------------------------------------------------------------
15-
import numpy
16-
17-
import pyrogue as pr
14+
#-----------------------------------------------------------------------------
1815
import rogue.interfaces.stream as ris
19-
from numpy import ndarray
16+
import pyrogue as pr
17+
import numpy
2018

2119

22-
class DataReceiver(pr.Device, ris.Slave):
20+
class DataReceiver(pr.Device,ris.Slave):
2321
"""Data Receiver Devicer."""
2422

25-
def __init__(
26-
self,
27-
typeStr: str = "UInt8[np]",
28-
hideData: bool = True,
29-
value: ndarray = numpy.zeros(shape=1, dtype=numpy.uint8, order="C"),
30-
enableOnStart: bool = True,
31-
**kwargs,
32-
):
23+
def __init__(self,
24+
typeStr='UInt8[np]',
25+
hideData=True,
26+
value=numpy.zeros(shape=1, dtype=numpy.uint8, order='C'),
27+
enableOnStart=True,
28+
**kwargs):
29+
3330
pr.Device.__init__(self, **kwargs)
3431
ris.Slave.__init__(self)
3532

3633
self._enableOnStart = enableOnStart
3734

38-
self.add(
39-
pr.LocalVariable(name="RxEnable", value=True, description="Frame Rx Enable")
40-
)
41-
42-
self.add(
43-
pr.LocalVariable(
44-
name="FrameCount",
45-
value=0,
46-
mode="RO",
47-
pollInterval=1,
48-
description="Frame Rx Counter",
49-
)
50-
)
51-
52-
self.add(
53-
pr.LocalVariable(
54-
name="ErrorCount",
55-
value=0,
56-
mode="RO",
57-
pollInterval=1,
58-
description="Frame Error Counter",
59-
)
60-
)
61-
62-
self.add(
63-
pr.LocalVariable(
64-
name="ByteCount",
65-
value=0,
66-
mode="RO",
67-
pollInterval=1,
68-
description="Byte Rx Counter",
69-
)
70-
)
71-
72-
self.add(
73-
pr.LocalVariable(
74-
name="Updated",
75-
value=False,
76-
mode="RW",
77-
description="Data has been updated flag. Set in the TRUE in DataReceiver and reset to zero by application",
78-
)
79-
)
80-
81-
self.add(
82-
pr.LocalVariable(
83-
name="Data",
84-
typeStr=typeStr,
85-
disp="",
86-
groups=["NoState", "NoStream", "NoConfig"],
87-
value=value,
88-
hidden=hideData,
89-
description="Data Frame Container",
90-
)
91-
)
92-
93-
def countReset(self) -> None:
35+
self.add(pr.LocalVariable(name='RxEnable',
36+
value=True,
37+
description='Frame Rx Enable'))
38+
39+
self.add(pr.LocalVariable(name='FrameCount',
40+
value=0,
41+
mode = 'RO',
42+
pollInterval=1,
43+
description='Frame Rx Counter'))
44+
45+
self.add(pr.LocalVariable(name='ErrorCount',
46+
value=0,
47+
mode = 'RO',
48+
pollInterval=1,
49+
description='Frame Error Counter'))
50+
51+
self.add(pr.LocalVariable(name='ByteCount',
52+
value=0,
53+
mode = 'RO',
54+
pollInterval=1,
55+
description='Byte Rx Counter'))
56+
57+
self.add(pr.LocalVariable(name='Updated',
58+
value=False,
59+
mode = 'RW',
60+
description='Data has been updated flag. Set in the TRUE in DataReceiver and reset to zero by application'))
61+
62+
self.add(pr.LocalVariable(name='Data',
63+
typeStr=typeStr,
64+
disp='',
65+
groups=['NoState','NoStream', 'NoConfig'],
66+
value=value,
67+
hidden=hideData,
68+
description='Data Frame Container'))
69+
70+
def countReset(self):
9471
""" """
9572
self.FrameCount.set(0)
9673
self.ErrorCount.set(0)
9774
self.ByteCount.set(0)
9875
super().countReset()
9976

100-
def _acceptFrame(self, frame) -> None:
77+
def _acceptFrame(self, frame):
10178
"""
10279
103-
Args:
104-
frame :
10580
106-
Returns: None
81+
Parameters
82+
----------
83+
frame :
84+
85+
86+
Returns
87+
-------
10788
10889
"""
10990
# Do nothing if not yet started or enabled
@@ -112,6 +93,7 @@ def _acceptFrame(self, frame) -> None:
11293

11394
# Lock frame
11495
with frame.lock():
96+
11597
# Drop errored frames
11698
if frame.getError() != 0:
11799
with self.ErrorCount.lock:
@@ -123,49 +105,52 @@ def _acceptFrame(self, frame) -> None:
123105
self.FrameCount.set(self.FrameCount.value() + 1, write=False)
124106

125107
with self.ByteCount.lock:
126-
self.ByteCount.set(
127-
self.ByteCount.value() + frame.getPayload(), write=False
128-
)
108+
self.ByteCount.set(self.ByteCount.value() + frame.getPayload(), write=False)
129109

130110
# User overridable method for data restructuring
131111
self.process(frame)
132112

133-
def process(self, frame) -> None:
113+
114+
def process(self,frame):
134115
"""
135116
The user can use this method to process the data, by default a byte numpy array is generated
136117
This may include separating data, header and other payload sub-fields
137118
This all occurs with the frame lock held
138119
139-
Args:
140-
frame :
120+
Parameters
121+
----------
122+
frame :
123+
141124
125+
Returns
126+
-------
142127
143128
"""
144129

145130
# Get data from frame
146131
fl = frame.getPayload()
147-
dat = frame.getNumpy(0, fl) # uint8
132+
dat = frame.getNumpy(0,fl) # uint8
148133

149134
# Update data
150-
self.Data.set(dat, write=True)
151-
self.Updated.set(True, write=True)
135+
self.Data.set(dat,write=True)
136+
self.Updated.set(True,write=True)
152137

153-
def _start(self) -> None:
138+
def _start(self):
154139
""" """
155140
super()._start()
156141
self.RxEnable.set(value=self._enableOnStart)
157142

158-
def _stop(self) -> None:
143+
def _stop(self):
159144
""" """
160145
self.RxEnable.set(value=False)
161146
super()._stop()
162147

163148
# source >> destination
164-
def __rshift__(self, other) -> type["pr.Device"]:
165-
pr.streamConnect(self, other)
149+
def __rshift__(self,other):
150+
pr.streamConnect(self,other)
166151
return other
167152

168153
# destination << source
169-
def __lshift__(self, other) -> type["pr.Device"]:
170-
pr.streamConnect(other, self)
154+
def __lshift__(self,other):
155+
pr.streamConnect(other,self)
171156
return other

0 commit comments

Comments
 (0)