apstrim 4.0.4__tar.gz → 4.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apstrim-4.0.4 → apstrim-4.2.0}/PKG-INFO +3 -3
- {apstrim-4.0.4 → apstrim-4.2.0}/README.md +2 -2
- {apstrim-4.0.4 → apstrim-4.2.0}/apstrim/__main__.py +13 -5
- {apstrim-4.0.4 → apstrim-4.2.0}/apstrim/apstrim.py +53 -18
- apstrim-4.2.0/apstrim/cad_pvaccess.py +154 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/apstrim/scan.py +1 -1
- {apstrim-4.0.4 → apstrim-4.2.0}/apstrim/view.py +3 -5
- apstrim-4.0.4/apstrim_20241111_1916.aps → apstrim-4.2.0/apstrim.aps +0 -0
- apstrim-4.2.0/data/apstrim.aps +0 -0
- apstrim-4.2.0/data/apstrim_100Hz_10Items.aps +0 -0
- apstrim-4.2.0/data/apstrim_100Hz_oneItem.aps +0 -0
- apstrim-4.2.0/data/apstrim_am_simple_array_simple.test.sinM.aps +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/pyproject.toml +1 -1
- apstrim-4.0.4/apstrim/pvplot.py +0 -54
- apstrim-4.0.4/apstrim/view-v400a.py +0 -891
- apstrim-4.0.4/apstrim/view_v141.py +0 -192
- apstrim-4.0.4/apstrim.aps +0 -0
- apstrim-4.0.4/apstrim.egg-info/PKG-INFO +0 -94
- apstrim-4.0.4/apstrim.egg-info/SOURCES.txt +0 -19
- apstrim-4.0.4/apstrim.egg-info/dependency_links.txt +0 -1
- apstrim-4.0.4/apstrim.egg-info/entry_points.txt +0 -3
- apstrim-4.0.4/apstrim.egg-info/requires.txt +0 -2
- apstrim-4.0.4/apstrim.egg-info/top_level.txt +0 -1
- apstrim-4.0.4/build/lib/apstrim/__init__.py +0 -47
- apstrim-4.0.4/build/lib/apstrim/__main__.py +0 -68
- apstrim-4.0.4/build/lib/apstrim/apstrim.py +0 -419
- apstrim-4.0.4/build/lib/apstrim/apview.py +0 -285
- apstrim-4.0.4/build/lib/apstrim/deserializer-v04.py +0 -122
- apstrim-4.0.4/build/lib/apstrim/deserializer.py +0 -113
- apstrim-4.0.4/build/lib/apstrim/liteCNS.py +0 -34
- apstrim-4.0.4/build/lib/apstrim/plot.py +0 -187
- apstrim-4.0.4/build/lib/apstrim/plot1.py +0 -190
- apstrim-4.0.4/build/lib/apstrim/pubEPICS.py +0 -214
- apstrim-4.0.4/build/lib/apstrim/pubLITE.py +0 -692
- apstrim-4.0.4/build/lib/apstrim/scan.py +0 -336
- apstrim-4.0.4/build/lib/apstrim/view.py +0 -233
- apstrim-4.0.4/build/lib/apstrim/view_v141.py +0 -192
- apstrim-4.0.4/docs/daily_downloads.jpg +0 -0
- apstrim-4.0.4/fallback/scan-v200.py +0 -265
- apstrim-4.0.4/fallback/v1.4.1/__init__.py +0 -43
- apstrim-4.0.4/fallback/v1.4.1/__main__.py +0 -69
- apstrim-4.0.4/fallback/v1.4.1/apstrim.py +0 -325
- apstrim-4.0.4/fallback/v1.4.1/liteCNS.py +0 -34
- apstrim-4.0.4/fallback/v1.4.1/pubEPICS.py +0 -214
- apstrim-4.0.4/fallback/v1.4.1/pubLITE.py +0 -692
- apstrim-4.0.4/fallback/v1.4.1/scan.py +0 -233
- apstrim-4.0.4/fallback/v1.4.1/view.py +0 -192
- apstrim-4.0.4/html/apstrim.html +0 -917
- apstrim-4.0.4/html/scan.html +0 -913
- apstrim-4.0.4/pyproject0.toml +0 -6
- {apstrim-4.0.4 → apstrim-4.2.0}/CHANGELOG.md +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/LICENSE +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/apstrim/__init__.py +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/apstrim/helpTxtView.py +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/apstrim/liteCNS.py +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/apstrim/pubEPICS.py +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/config/peaksim_pvp.py +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/docs/_config.yml +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/docs/apstrim.html +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/docs/apstrim_file_format.png +0 -0
- {apstrim-4.0.4 → apstrim-4.2.0}/docs/scan.html +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apstrim
|
|
3
|
-
Version: 4.0
|
|
3
|
+
Version: 4.2.0
|
|
4
4
|
Summary: Logger and extractor of time-series data (e.g. EPICS PVs or liteServer LDOs).
|
|
5
5
|
Project-URL: Homepage, https://github.com/ASukhanov/apstrim
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/ASukhanov/apstrim/issues
|
|
@@ -19,7 +19,7 @@ Description-Content-Type: text/markdown
|
|
|
19
19
|
Logger and extractor of time-series data (e.g. EPICS PVs).
|
|
20
20
|
|
|
21
21
|
- Data are objects, indexed in time order.
|
|
22
|
-
- Supported Control Infrastructures: EPICS, ADO, LITE. Easy extendable.
|
|
22
|
+
- Supported Control Infrastructures: EPICS ChannelAccess+PVAccess, ADO, LITE. Easy extendable.
|
|
23
23
|
- Wide range of data objects: strings, lists, maps, numpy arrays, custom.
|
|
24
24
|
- Data objects could be inhomogeneous and have arbitrary frequency.
|
|
25
25
|
- Self-describing data format, no schema required.
|
|
@@ -34,7 +34,7 @@ Logger and extractor of time-series data (e.g. EPICS PVs).
|
|
|
34
34
|
<img src='/docs/apstrim_file_format.png' width='400'>
|
|
35
35
|
|
|
36
36
|
## Installation
|
|
37
|
-
Dependencies: **msgpack, caproto, lz4framed**.
|
|
37
|
+
Dependencies: **msgpack, caproto, p4p, lz4framed**.
|
|
38
38
|
These packages will be installed using pip:
|
|
39
39
|
|
|
40
40
|
pip3 install apstrim
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Logger and extractor of time-series data (e.g. EPICS PVs).
|
|
3
3
|
|
|
4
4
|
- Data are objects, indexed in time order.
|
|
5
|
-
- Supported Control Infrastructures: EPICS, ADO, LITE. Easy extendable.
|
|
5
|
+
- Supported Control Infrastructures: EPICS ChannelAccess+PVAccess, ADO, LITE. Easy extendable.
|
|
6
6
|
- Wide range of data objects: strings, lists, maps, numpy arrays, custom.
|
|
7
7
|
- Data objects could be inhomogeneous and have arbitrary frequency.
|
|
8
8
|
- Self-describing data format, no schema required.
|
|
@@ -17,7 +17,7 @@ Logger and extractor of time-series data (e.g. EPICS PVs).
|
|
|
17
17
|
<img src='/docs/apstrim_file_format.png' width='400'>
|
|
18
18
|
|
|
19
19
|
## Installation
|
|
20
|
-
Dependencies: **msgpack, caproto, lz4framed**.
|
|
20
|
+
Dependencies: **msgpack, caproto, p4p, lz4framed**.
|
|
21
21
|
These packages will be installed using pip:
|
|
22
22
|
|
|
23
23
|
pip3 install apstrim
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Description = '''Serializer of Process Variables (from EPICS infrastructure)
|
|
2
2
|
or Data Objects from other infrastructures, e.g. ADO or LITE).'''
|
|
3
|
-
__version__ = '
|
|
3
|
+
__version__ = '4.1.0 2025-09-24'# --namespace PVAccess
|
|
4
4
|
|
|
5
5
|
import sys, argparse
|
|
6
6
|
from .apstrim import apstrim, __version__
|
|
@@ -20,8 +20,9 @@ def main():
|
|
|
20
20
|
#'Configuration file')
|
|
21
21
|
parser.add_argument('-o', '--outfile', default='apstrim.aps', help=\
|
|
22
22
|
'Logbook file for storing PVs and data objects')
|
|
23
|
-
parser.add_argument('-n', '--namespace', default='EPICS',
|
|
24
|
-
|
|
23
|
+
parser.add_argument('-n', '--namespace', default='EPICS',
|
|
24
|
+
choices=['EPICS', 'PVAccess', 'ADO', 'LITE'], help=
|
|
25
|
+
'Infrastructure namespace')
|
|
25
26
|
parser.add_argument('-t', '--sectionTime', type=float, default=60., help=\
|
|
26
27
|
'Time interval of writing of sections to logbook')
|
|
27
28
|
parser.add_argument('-T', '--acqTime', type=float, default=99e6, help=\
|
|
@@ -35,11 +36,16 @@ def main():
|
|
|
35
36
|
pargs = parser.parse_args()
|
|
36
37
|
#print(f'pargs:{pargs}')
|
|
37
38
|
|
|
38
|
-
s = pargs.namespace
|
|
39
|
+
s = pargs.namespace
|
|
39
40
|
if s == 'LITE':
|
|
40
41
|
from liteaccess import Access as publisher
|
|
41
42
|
elif s == 'EPICS':
|
|
42
43
|
from .pubEPICS import Access as publisher
|
|
44
|
+
elif s == 'PVAccess':
|
|
45
|
+
from . import cad_pvaccess as publisher
|
|
46
|
+
elif s == 'ADO':
|
|
47
|
+
from cad_io import adoaccess
|
|
48
|
+
publisher = adoaccess.IORequest()
|
|
43
49
|
else:
|
|
44
50
|
print(f'ERROR: Unsupported namespace {s}')
|
|
45
51
|
sys.exit(1)
|
|
@@ -56,12 +62,14 @@ def main():
|
|
|
56
62
|
#print(f'pvNames: {pvNames}')
|
|
57
63
|
|
|
58
64
|
apstrim.Verbosity = pargs.verbose
|
|
65
|
+
if pargs.acqTime < pargs.sectionTime:
|
|
66
|
+
pargs.sectionTime = pargs.acqTime
|
|
59
67
|
aps = apstrim(publisher, pvNames, pargs.sectionTime, compress=pargs.compress
|
|
60
68
|
#, quiet=pargs.quiet, use_single_float=not pargs.doublePrecision)
|
|
61
69
|
, quiet=pargs.quiet)
|
|
62
70
|
aps.start(pargs.outfile, howLong=pargs.acqTime)
|
|
63
71
|
|
|
64
|
-
txt = f'for {round(pargs.acqTime/60.,
|
|
72
|
+
txt = f'for {round(pargs.acqTime/60., 3)} minutes' if pargs.acqTime<99e6 else 'endlessly'
|
|
65
73
|
print(f'Streaming started {txt}, press Ctrl/C to stop.')
|
|
66
74
|
apstrim._eventStop.wait()
|
|
67
75
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
#
|
|
7
7
|
# https://github.com/ASukhanov/apstrim/blob/main/LICENSE
|
|
8
8
|
#
|
|
9
|
-
__version__ = '
|
|
9
|
+
__version__ = '4.2.0 2025-10-13' # Support of sliced arrays
|
|
10
10
|
|
|
11
11
|
import sys, time, string, copy
|
|
12
12
|
import os, pathlib, datetime
|
|
@@ -174,8 +174,25 @@ class apstrim():
|
|
|
174
174
|
self.compress = None
|
|
175
175
|
abstract['compression'] = 'None'
|
|
176
176
|
printi(f'Abstract section: {self.abstractSection}')
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
|
|
178
|
+
# create par2Index map
|
|
179
|
+
#self.par2Index = [p:(i,pslice) for p in enumerate(self.devPars)]
|
|
180
|
+
#self.par2Index = [p for p in self.devPars]
|
|
181
|
+
self.par2Index = {}
|
|
182
|
+
for idx,dp in enumerate(self.devPars):
|
|
183
|
+
nameRange = dp.rsplit('[')
|
|
184
|
+
_name = nameRange[0]
|
|
185
|
+
if len(nameRange) == 1:
|
|
186
|
+
pslice = None
|
|
187
|
+
else:
|
|
188
|
+
if nameRange[1][-1] != ']':
|
|
189
|
+
printe(f'PV syntax error: {dp}')
|
|
190
|
+
sys.exit(1)
|
|
191
|
+
pslice = [int(i) for i in nameRange[1][:-1].split(':')]
|
|
192
|
+
if len(pslice) == 1:
|
|
193
|
+
pslice = pslice[0],pslice[0]+1
|
|
194
|
+
self.par2Index[_name]= idx,pslice
|
|
195
|
+
|
|
179
196
|
if len(self.par2Index) == 0:
|
|
180
197
|
printe(f'Could not build the list of parameters')
|
|
181
198
|
sys.exit()
|
|
@@ -185,23 +202,35 @@ class apstrim():
|
|
|
185
202
|
self._create_logSection()
|
|
186
203
|
|
|
187
204
|
# subscribe to parameters
|
|
188
|
-
#for pname in self.par2Index.keys():
|
|
189
205
|
for pname in self.par2Index:
|
|
206
|
+
idx,pslice = self.par2Index[pname]
|
|
190
207
|
if apstrim.EventExit.is_set():
|
|
191
208
|
sys.exit(1)
|
|
192
209
|
devPar = tuple(pname.rsplit(':',1))
|
|
193
210
|
# check if PV is alive
|
|
211
|
+
printv(f'check if PV {devPar} is alive')
|
|
194
212
|
try:
|
|
195
213
|
r = self.publisher.get(devPar)
|
|
196
214
|
if isinstance(r,str):
|
|
197
215
|
raise IOError(r)
|
|
216
|
+
if 'error' in r[devPar]:
|
|
217
|
+
raise IOError(r[devPar])
|
|
198
218
|
self.publisher.subscribe(self._delivered, devPar)
|
|
199
219
|
except Exception as e:
|
|
200
220
|
printe(f'Could not subscribe for {pname}: {e}')
|
|
221
|
+
sys.exit(1)
|
|
201
222
|
continue
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
223
|
+
printv(f'Subscribed: {devPar}')
|
|
224
|
+
|
|
225
|
+
# Create the Index section
|
|
226
|
+
pvlist = []
|
|
227
|
+
for pvname,value in self.par2Index.items():
|
|
228
|
+
idx,pslice = value
|
|
229
|
+
if pslice is not None:
|
|
230
|
+
pvname = f'{pvname}[{pslice[0]}:{pslice[1]}]'
|
|
231
|
+
pvlist.append(pvname)
|
|
232
|
+
self.indexSection = encoderDump({'index':pvlist})
|
|
233
|
+
printi(f'IndexSection: {self.indexSection}')
|
|
205
234
|
|
|
206
235
|
def start(self, fileName='apstrim.aps', howLong=99e6):
|
|
207
236
|
"""Start the streaming of the data objects to the logbook file.
|
|
@@ -261,14 +290,17 @@ class apstrim():
|
|
|
261
290
|
args is a map of delivered objects."""
|
|
262
291
|
if apstrim.Verbosity > 0:
|
|
263
292
|
printvv(f'delivered: {args}')
|
|
264
|
-
#self.timestampedMap = {}
|
|
265
293
|
with self.lock:
|
|
266
294
|
for devPar,props in args[0].items():
|
|
267
295
|
#print(croppedText(f'devPar: {devPar,props}'))
|
|
268
296
|
try:
|
|
269
297
|
if isinstance(devPar, tuple):
|
|
270
298
|
# EPICS and ADO packing
|
|
271
|
-
|
|
299
|
+
if len(devPar) > 1:
|
|
300
|
+
dev,par = devPar
|
|
301
|
+
devpar = devPar[0]+':'+devPar[1]
|
|
302
|
+
else:
|
|
303
|
+
devpar = devPar[0]
|
|
272
304
|
value = props['value']
|
|
273
305
|
timestamp = props.get('timestamp')# valid in EPICS and LITE
|
|
274
306
|
if timestamp == None:# decode ADO timestamp
|
|
@@ -280,9 +312,12 @@ class apstrim():
|
|
|
280
312
|
# Timestamp is wrong, discard the parameter
|
|
281
313
|
printv(f'timestamp is wrong {timestamp, MinTimestamp}')
|
|
282
314
|
continue
|
|
283
|
-
skey = self.par2Index
|
|
315
|
+
skey,pslice = self.par2Index[devpar]
|
|
284
316
|
self.timestamp = int(timestamp*Nano)
|
|
285
317
|
self.sectionPars[skey][SPTime].append(timestamp)
|
|
318
|
+
if pslice is not None:
|
|
319
|
+
_slice = slice(*pslice)
|
|
320
|
+
value = value[_slice]
|
|
286
321
|
self.sectionPars[skey][SPVal].append(value)
|
|
287
322
|
elif devPar == 'ppmuser':# ADO has extra item, skip it.
|
|
288
323
|
continue
|
|
@@ -301,7 +336,7 @@ class apstrim():
|
|
|
301
336
|
if timestamp < MinTimestamp:
|
|
302
337
|
# Timestamp is wrong, discard the parameter
|
|
303
338
|
continue
|
|
304
|
-
skey = self.par2Index
|
|
339
|
+
skey,pslice = self.par2Index[dev+':'+par]
|
|
305
340
|
# add to parameter list
|
|
306
341
|
self.timestamp = int(timestamp*Nano)
|
|
307
342
|
self.sectionPars[skey][SPTime].append(timestamp)
|
|
@@ -311,9 +346,6 @@ class apstrim():
|
|
|
311
346
|
except Exception as e:
|
|
312
347
|
printw(f'exception in unpacking: {e}')
|
|
313
348
|
continue
|
|
314
|
-
#try: ts = self.timestamp
|
|
315
|
-
#except: ts = '?'
|
|
316
|
-
#print(f'served timestamp: {ts}')
|
|
317
349
|
#print(croppedText(f'section: {self.section}'))
|
|
318
350
|
|
|
319
351
|
def _create_logSection(self):
|
|
@@ -333,9 +365,10 @@ class apstrim():
|
|
|
333
365
|
periodic_update = time.time()
|
|
334
366
|
statistics = [0, 0, 0, 0, 0.]#
|
|
335
367
|
NSections, NParLists, BytesRaw, BytesFinal, LogTime = 0,1,2,3,4
|
|
336
|
-
maxSections = self.howLong
|
|
368
|
+
maxSections = 0 if self.howLong == self.sectionInterval\
|
|
369
|
+
else self.howLong//self.sectionInterval
|
|
337
370
|
printv(f'serialize_sections started.')
|
|
338
|
-
|
|
371
|
+
try:
|
|
339
372
|
while statistics[NSections] <= maxSections\
|
|
340
373
|
and not self._eventStop.is_set():
|
|
341
374
|
self._eventStop.wait(self.sectionInterval)
|
|
@@ -424,7 +457,7 @@ class apstrim():
|
|
|
424
457
|
f' {statistics[NParLists]} parLists,'
|
|
425
458
|
f' {statistics[BytesFinal]/1000.} KBytes,'
|
|
426
459
|
f' {round(statistics[BytesRaw]/statistics[LogTime]/1e6,1)} MB/s')
|
|
427
|
-
|
|
460
|
+
except Exception as e:
|
|
428
461
|
printe(f'Exception in serialize_sections: {e}')
|
|
429
462
|
|
|
430
463
|
# logging is finished
|
|
@@ -440,8 +473,10 @@ class apstrim():
|
|
|
440
473
|
msg += f' Compression ratio:{round(statistics[BytesRaw]/statistics[BytesFinal],2)}'
|
|
441
474
|
print(msg)
|
|
442
475
|
self.logbook.close()
|
|
476
|
+
_safeExit()
|
|
443
477
|
|
|
444
|
-
def _safeExit(_signo, _stack_frame):
|
|
478
|
+
def _safeExit(_signo=None, _stack_frame=None):
|
|
445
479
|
print('safeExit')
|
|
446
480
|
apstrim._eventStop.set()
|
|
447
481
|
apstrim.EventExit.set()
|
|
482
|
+
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"""Basic EPICS PVAccess API using p4p python wrapper.
|
|
2
|
+
The API is similar to cad_io.
|
|
3
|
+
The devPar argument is tuple (deviceName,parameterName).
|
|
4
|
+
|
|
5
|
+
For example: pvaccess.get(('simScope1','NoiseAmplitude')) returns:
|
|
6
|
+
{('simScope1', 'NoiseAmplitude'): {'value': 3.0, 'timestampSeconds': 1735615833, 'timestampNanoSeconds': 822335958}}
|
|
7
|
+
|
|
8
|
+
To set NoiseAmplitude to 1.:
|
|
9
|
+
pvaccess.set(('simScope1','NoiseAmplitude',1.))
|
|
10
|
+
"""
|
|
11
|
+
__version__ = 'v0.1.2 2025-01-05'# _pvname()
|
|
12
|
+
|
|
13
|
+
import time
|
|
14
|
+
#from time import perf_counter as timer
|
|
15
|
+
from functools import partial
|
|
16
|
+
from p4p.client.thread import Context
|
|
17
|
+
from p4p.nt.enum import ntenum
|
|
18
|
+
|
|
19
|
+
_dbg = False
|
|
20
|
+
_Ctx = Context()# provides only PV values
|
|
21
|
+
_CtxRaw = Context(unwrap=False)# provides PV properties
|
|
22
|
+
_PVInfo = {}# cache of PVs
|
|
23
|
+
_Subscriptions = []# list of EPICS PV subscriptions
|
|
24
|
+
|
|
25
|
+
def _printd(msg):
|
|
26
|
+
if _dbg:
|
|
27
|
+
print(f'CPAccess:{msg}')
|
|
28
|
+
def printTime(): return time.strftime("%m%d:%H%M%S")
|
|
29
|
+
def printi(msg): print(f'inf_PVA@{printTime()}: {msg}')
|
|
30
|
+
def printw(msg): print(f'WAR_PVA@{printTime()}: {msg}')
|
|
31
|
+
def printe(msg): print(f'ERR_PVA@{printTime()}: {msg}')
|
|
32
|
+
def init():
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
def _pvname(devPar:tuple):
|
|
36
|
+
return ':'.join(devPar)
|
|
37
|
+
|
|
38
|
+
def info(devPar:tuple):
|
|
39
|
+
"""Abridged PV info"""
|
|
40
|
+
pvName = _pvname(devPar)
|
|
41
|
+
v = _CtxRaw.get(pvName)
|
|
42
|
+
#print(f'v of {pvName}: {v.todict()}')
|
|
43
|
+
r = {devPar:{'value':v.value,
|
|
44
|
+
'timestampSeconds': v.timeStamp.secondsPastEpoch,
|
|
45
|
+
'timestampNanoSeconds': v.timeStamp.nanoseconds
|
|
46
|
+
}}
|
|
47
|
+
|
|
48
|
+
# With p4p it is impossible to detect if parameter is writable
|
|
49
|
+
r[devPar]['features'] = 'RWE'
|
|
50
|
+
|
|
51
|
+
try: r[devPar]['desc'] = v.display.description
|
|
52
|
+
except: pass
|
|
53
|
+
try: r[devPar]['units'] = v.display.units
|
|
54
|
+
except: pass
|
|
55
|
+
try:
|
|
56
|
+
if not (v.display.limitLow == v.display.limitHigh == 0.0):
|
|
57
|
+
r[devPar]['opLow'] = v.display.limitLow
|
|
58
|
+
r[devPar]['opHigh'] = v.display.limitHigh
|
|
59
|
+
except: pass
|
|
60
|
+
try: r[devPar]['units'] = v.display.units
|
|
61
|
+
except: pass
|
|
62
|
+
try:
|
|
63
|
+
r[devPar]['legalValues'] = v.value['choices']
|
|
64
|
+
r[devPar]['value'] = v.value['choices'][v.value['index']]
|
|
65
|
+
except: pass
|
|
66
|
+
_PVInfo[devPar] = r
|
|
67
|
+
#print(f'info of {pvName}: {r}')
|
|
68
|
+
return r
|
|
69
|
+
|
|
70
|
+
#``````````````````PVCache methods````````````````````````````````````````````
|
|
71
|
+
def _cachedInfo(devPar:tuple):
|
|
72
|
+
pvinfo = _PVInfo.get(devPar)
|
|
73
|
+
if pvinfo is None:
|
|
74
|
+
pvinfo = info(devPar)[devPar]
|
|
75
|
+
print(f'register pvinfo {devPar}: {pvinfo}')
|
|
76
|
+
_PVInfo[devPar] = pvinfo
|
|
77
|
+
return pvinfo
|
|
78
|
+
|
|
79
|
+
def get(devPar:tuple, *args, **kwargs):
|
|
80
|
+
"""Returns devPar-keyed map of PV properties: {'value','timestamp'...}"""
|
|
81
|
+
pvName = _pvname(devPar)
|
|
82
|
+
v = _CtxRaw.get(pvName)
|
|
83
|
+
#print(f'got {pvName}: {v.todict()}')
|
|
84
|
+
try: value = v.value['choices'][v.value['index']]
|
|
85
|
+
except: value = v.value
|
|
86
|
+
try: #to interpret it as NTENum
|
|
87
|
+
idx = value.index
|
|
88
|
+
value = value.choices[idx]
|
|
89
|
+
except: pass
|
|
90
|
+
rDict = {devPar:{'value':value,
|
|
91
|
+
'timestampSeconds': v.timeStamp.secondsPastEpoch,
|
|
92
|
+
'timestampNanoSeconds': v.timeStamp.nanoseconds
|
|
93
|
+
}}
|
|
94
|
+
return rDict
|
|
95
|
+
|
|
96
|
+
def set(devParValue:tuple):
|
|
97
|
+
"""Sets the PV value. The devParValue is (deviceName, ParameterName, value)
|
|
98
|
+
"""
|
|
99
|
+
dev, par, value = devParValue
|
|
100
|
+
info = _cachedInfo((dev,par))
|
|
101
|
+
#print(f'>set({dev,par,type(value),value, info})')
|
|
102
|
+
try:
|
|
103
|
+
if value < info['opLow']:
|
|
104
|
+
printw(f'Value {value} is lower than opLow of {dev,par}')
|
|
105
|
+
return False
|
|
106
|
+
except: pass
|
|
107
|
+
try:
|
|
108
|
+
if value > info['opHigh']:
|
|
109
|
+
printw(f'Value {value} is higher than opHigh of {dev,par}')
|
|
110
|
+
return False
|
|
111
|
+
except: pass
|
|
112
|
+
try:
|
|
113
|
+
if value not in info['legalValues']:
|
|
114
|
+
printw(f'Value {value} is not in legalValues of {dev,par}')
|
|
115
|
+
return False
|
|
116
|
+
value = info['legalValues'][value]
|
|
117
|
+
except: pass
|
|
118
|
+
pvName = _pvname((dev,par))
|
|
119
|
+
try:
|
|
120
|
+
_Ctx.put(pvName, value)
|
|
121
|
+
except Exception as e:
|
|
122
|
+
printw(f'Set {dev, par, value}: {e}')
|
|
123
|
+
return False
|
|
124
|
+
return True
|
|
125
|
+
|
|
126
|
+
def _callback(callback, devPar, value):
|
|
127
|
+
vr = value.raw
|
|
128
|
+
#print(f'>_callback: {devPar}, {vr}')#{pvData})')
|
|
129
|
+
if isinstance(value, ntenum):
|
|
130
|
+
d = vr.value.todict()
|
|
131
|
+
v = d['choices'][d['index']]
|
|
132
|
+
else:
|
|
133
|
+
v = vr.value
|
|
134
|
+
r = {devPar:{'value':v,
|
|
135
|
+
'timestampSeconds':vr.timeStamp.secondsPastEpoch,
|
|
136
|
+
'timestampNanoSeconds':vr.timeStamp.nanoseconds,
|
|
137
|
+
}}
|
|
138
|
+
#print(f'cb {devPar,r}')
|
|
139
|
+
callback(r)
|
|
140
|
+
|
|
141
|
+
def subscribe(callback:callable, devPar:tuple):
|
|
142
|
+
"""Subscribe callback method to changes of PVs, defined by devPar"""
|
|
143
|
+
pvName = _pvname(devPar)
|
|
144
|
+
subscription = _Ctx.monitor(pvName, partial(_callback, callback, devPar))
|
|
145
|
+
_Subscriptions.append((subscription,callback))
|
|
146
|
+
|
|
147
|
+
def unsubscribe():
|
|
148
|
+
"""Unsubscribe all subscriptions"""
|
|
149
|
+
global _Subscriptions
|
|
150
|
+
for subs,cb in _Subscriptions:
|
|
151
|
+
#print(f'>pvaccess close subs: {subs}')
|
|
152
|
+
subs.close()
|
|
153
|
+
_Subscriptions = []
|
|
154
|
+
|
|
@@ -331,7 +331,7 @@ class APScan():
|
|
|
331
331
|
|
|
332
332
|
if APScan.Verbosity >= 1:
|
|
333
333
|
print(f'SectionTime: {[round(i/nSections,6) for i in sectionTime]}')
|
|
334
|
-
print(f'Deserialized {round(toRead/1e6,
|
|
334
|
+
print(f'Deserialized {round(toRead/1e6,3)} MB, {nSections} sections from {self.logbookName}')
|
|
335
335
|
print(f'Sets/Parameter: {parameterStatistics}')
|
|
336
336
|
ttime = timer()-timerTotal
|
|
337
337
|
mbps = (f' {round(toRead/1e6/extractionTime,1)} MB/s'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""Plot data from the apstrim-generated files."""
|
|
2
|
-
__version__ = 'v4.0
|
|
2
|
+
__version__ = 'v4.2.0 2025-10-13'# minor fixes
|
|
3
3
|
#TODO: Cellname did not change on plot after changing it in dataset options
|
|
4
4
|
#TODO: data acquisition stops when section is dumped to disk. Is writing really buffered?
|
|
5
5
|
#TODO: interactive works only for one file
|
|
@@ -674,8 +674,9 @@ items = header0['Index']
|
|
|
674
674
|
printv(f'Items in first logobook: {items}')
|
|
675
675
|
|
|
676
676
|
def hsvToRgb(idx, maxColors, offset=2/3):
|
|
677
|
-
# stepping
|
|
677
|
+
# stepping through hsv color space, starting from offset (2/3 is blue).
|
|
678
678
|
return list(pg.hsvColor((offset+idx/maxColors)%1.).getRgb())
|
|
679
|
+
|
|
679
680
|
for i,item in enumerate(items):
|
|
680
681
|
cell = item.rsplit(':',1)[1]
|
|
681
682
|
lcolor = hsvToRgb(i, len(items))
|
|
@@ -799,9 +800,6 @@ for fileName in pargs.files:
|
|
|
799
800
|
allExtracted.append(extracted)
|
|
800
801
|
if APScan.Verbosity >= 2:
|
|
801
802
|
printvv(_croppedText(f'allEextracted: {allExtracted}'))
|
|
802
|
-
|
|
803
|
-
if pargs.header != '':
|
|
804
|
-
exit()
|
|
805
803
|
|
|
806
804
|
#````````````````````````````Plot objects`````````````````````````````````````
|
|
807
805
|
pg.setConfigOption('background', 'w')
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
apstrim-4.0.4/apstrim/pvplot.py
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"""Plot data from the aplog-generated files using pvplot"""
|
|
2
|
-
__version__ = 'v3.1.1 2024-11-11'##
|
|
3
|
-
|
|
4
|
-
import sys,os
|
|
5
|
-
from . import pvplot
|
|
6
|
-
|
|
7
|
-
def main():
|
|
8
|
-
import argparse
|
|
9
|
-
global pargs
|
|
10
|
-
parser = argparse.ArgumentParser(description=__doc__
|
|
11
|
-
,formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
|
12
|
-
,epilog=(f'pvplot: {pvplot.__version__}'))
|
|
13
|
-
parser.add_argument('-a', '--prefix', default='', help=\
|
|
14
|
-
"Prefix, which will be added to all data objects, e.g: 'L:localhost:dev1:'")
|
|
15
|
-
#TODO:parser.add_argument('-H', '--histogram', help=\
|
|
16
|
-
# 'Plot the space-separated parameters as histograms')
|
|
17
|
-
parser.add_argument('-c','--configDir',default='/operations/app_store/pvplot',
|
|
18
|
-
help='Configuration directory')
|
|
19
|
-
parser.add_argument('-f', '--file', help=
|
|
20
|
-
'Configuration file')
|
|
21
|
-
parser.add_argument('-l', '--limit', type=int, default=1048576,
|
|
22
|
-
help='Upper limit for number of points to store')
|
|
23
|
-
parser.add_argument('-s', '--sleepTime', type=float, default=0.1,
|
|
24
|
-
help='sleep time between data delivery [s]')
|
|
25
|
-
parser.add_argument('-v', '--verbose', action='count', default=0, help=\
|
|
26
|
-
'Show more log messages (-vv: show even more).')
|
|
27
|
-
parser.add_argument('-x', '--xscale', help=\
|
|
28
|
-
'Parameter, which provides dynamic scale for X-axis')
|
|
29
|
-
parser.add_argument('-X', '--xrange', help=\
|
|
30
|
-
'Fixed range of X axis, e.g: -x10:20')
|
|
31
|
-
parser.add_argument('-y', '--yscale', help=\
|
|
32
|
-
'Parameter, which provides dynamic scale for Y-axis')
|
|
33
|
-
parser.add_argument('-Y', '--yrange', help=\
|
|
34
|
-
'Fixed range of Y axis, e.g: -y1000:4095')
|
|
35
|
-
parser.add_argument('-z', '--zoomin', type=float, default=1., help=\
|
|
36
|
-
'Zoom the application window by a factor')
|
|
37
|
-
parser.add_argument('-#','--dock', action='append', nargs='*',
|
|
38
|
-
help='''Plot a specified dock, i.e: to plot two scrolling plots in lower
|
|
39
|
-
dock and correlation plot in upper dock:
|
|
40
|
-
pvplot -a'L:localhost:dev1:' -#0'yMax yMin' -#1'yMax,yMin' ''')
|
|
41
|
-
parser.add_argument('parms', nargs = '?', default='yMax yMin',
|
|
42
|
-
help='''For stripchart: space-separated list, for correlation plot: comma-separated list of data objects.''')
|
|
43
|
-
pargs = parser.parse_args()
|
|
44
|
-
PVPlot = pvplot.PVPlot
|
|
45
|
-
PVPlot.pargs = pargs
|
|
46
|
-
|
|
47
|
-
#``````````````arrange keyboard interrupt to kill the program from terminal.
|
|
48
|
-
import signal
|
|
49
|
-
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
50
|
-
|
|
51
|
-
PVPlot.start()
|
|
52
|
-
|
|
53
|
-
if __name__ == "__main__":
|
|
54
|
-
main()
|