Skip to main content

liteAccess

Access to Process Variables, served by liteServer

Example

import liteaccess as LA 
from pprint import pprint

Host = 'localhost'
LAserver = Host+':server'
LAdev1   = Host+':dev1'
LAdev2   = Host+':dev2'

#``````````````````Simplified programmatic way`````````````````````````````````
LA.Access.info([Host+':*'])# list of all devices and parameters, hosted by Host
LA.Access.info([LAserver])# Info of all parameters of the server
LA.Access.get([LAserver])# get values of all parameters of the server
LA.Access.get([LAserver,'*','desc'])# get descriptions of all parameters of the server

# The commands below assumes that the liteScaler server is running on the same host.
LA.Access.get([LAdev1,'frequency'])
LA.Access.get([LAdev1,('frequency','number'),'desc'])# get parameter property 'desc' for multiple parameters
LA.Access.set([LAdev1,('frequency','number'),(2.2, 9.2)])# set values of multiple parameters
# subscription example:
def testCallback(*args): print(f'callback args: {args}')
LA.Access.subscribe(testCallback,[LAdev1,'cycle'])
LA.Access.unsubscribe()
#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
#``````````````````Object-oriented way`````````````````````````````````````````
# Advantage: The previuosly created PVs are reused.
allServerParameters = LA.PVs([LAserver])
pprint(allServerParameters.info())
pprint(allServerParameters.get())# get all parameters from device LAserver
# get all readable parameters from device Scaler1:server, which have been 
# modified since last read:
pprint(allServerParameters.read())

allDev1Parameters = LA.PVs([LAdev1])
pprint(allDev1Parameters.info())

server_performance = LA.PVs((LAserver,'perf'))
pprint(server_performance.info())
pprint(server_performance.get())
# simplified get: returns (value,timestamp) of a parameter 'perf' 
pprint(server_performance.value)

server_multiple_parameters = LA.PVs([LAserver,('perf','run')])
pprint(server_multiple_parameters.info())
pprint(server_multiple_parameters.get())

server_multiple_devPars = LA.PVs((LAdev1,['time','frequency']),(LAserver,['statistics','perf']))
pprint(server_multiple_devPars.get())

# setting
dev1_frequency = LA.PVs((LAdev1,'frequency'))
#TODO#dev1_frequency.set([1.5])
#TODO#dev1_frequency.value
dev1_multiple_parameters = LA.PVs([LAdev1,('frequency','coordinate')])
dev1_multiple_parameters.get() 
#TODO#dev1_multiple_parameters.set([8.,[3.,4.]])

# subscribing
ldo = LA.PVs([LAdev1,'cycle'])
ldo.subscribe()# it will print image data periodically
ldo.unsubscribe()# cancel the subscruption

# test for timeout, should timeout in 10s:
#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
#``````````````````Observations````````````````````````````````````````````````
Timing of Access.get using ipython on localhost.
    from liteserver import liteAccess as LA
    Host='localhost'
    LAdev1   = Host+':dev1'
    %timeit image = LA.Access.get((LAdev1,['image']))
    145 µs ± 1.95 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
    for version 3.2.0:
    317 µs ± 5.53 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
    image[(LAdev1,'image')]['value'].shape
    (120, 160, 3)
Retrieving time of 57600 values (120*160*3) is 145 µs,
which corresponds to 400 mValues/s

Retrieving time of 57600 values (120*160*3) 220 µs,
which corresponds to 260 MValues/s (on entry-level workstation). 
It was 400 MValues/s on top-level workstation.
Note: Msgpack was 4% faster.
#``````````````````Tips````````````````````````````````````````````````````````
# To enable debugging: LA.PVs.Dbg = True
# To enable transaction timing: LA.Channel.Perf = True

Metadata

Release files for liteaccess 3.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for liteaccess 3.4.1
File Size Uploaded
liteaccess-3.4.1.tar.gz 13.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for liteaccess 3.4.1
File Interpreter ABI Platform
liteaccess-3.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.3 kB

Release files / liteaccess-3.4.1.tar.gz

Download URL liteaccess-3.4.1.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
52c76a7e5ec3f4f7e17f9dd46cd75302009975f843058fb3987976d85a9d19c6
BLAKE2b-256 checksum
How to use checksums
8a2e66777ec811398b1e5635d0427a0e1b8d60787703c8ede79b22bd2c12eaef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release files / liteaccess-3.4.1-py3-none-any.whl

Download URL liteaccess-3.4.1-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3893a7b7fe0fad4542ca4f432aa11a3171893e1f75f3a1616518008f5a371bd1
BLAKE2b-256 checksum
How to use checksums
654a4ff6087fa7ffdf950d46df982d21ff9245d14138c5381186f55aa52323a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

3.4.1 This release

2 release files

3.3.0

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page