Package: liteaccess
liteAccessAccess to Process Variables, served by liteServerExampleimportliteaccessasLAfrompprintimportpprintHost='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 HostLA.Access.info([LAserver])# Info of all parameters of the serverLA.Access.get([LAserver])# get values of all parameters of the serverLA.Access.get([LAserver,'*','desc'])# get descriptions of all parameters of the server# The commands below assume that the liteScaler server is running on the same host.LA.Access.get([LAdev1,['frequency']])orLA.Access.get([LAdev1,'frequency'])LA.Access.get([LAdev1,['frequency'],'desc'])# get parameter property 'desc'LA.Access.set([LAdev1,['frequency'],1.1])# subscription example:deftestCallback(*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())# settingdev1_frequency=LA.PVs((LAdev1,'frequency'))#TODO#dev1_frequency.set([1.5])#TODO#dev1_frequency.valuedev1_multiple_parameters=LA.PVs([LAdev1,('frequency','coordinate')])dev1_multiple_parameters.get()#TODO#dev1_multiple_parameters.set([8.,[3.,4.]])# subscribingldo=LA.PVs([LAdev1,'cycle'])ldo.subscribe()# it will print image data periodicallyldo.unsubscribe()# cancel the subscruption# test for timeout, should timeout in 10s:#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#``````````````````Observations````````````````````````````````````````````````TimingofAccess.getusingipythononlocalhost.fromliteserverimportliteAccessasLAHost='localhost'LAdev1=Host+':dev1'%timeitimage=LA.Access.get((LAdev1,['image']))145µs±1.95µsperloop(mean±std.dev.of7runs,10000loopseach)forversion3.2.0:317µs±5.53µsperloop(mean±std.dev.of7runs,1,000loopseach)image[(LAdev1,'image')]['value'].shape(120,160,3)Retrievingtimeof57600values(120*160*3)is145µs,whichcorrespondsto400mValues/sRetrievingtimeof57600values(120*160*3)220µs,whichcorrespondsto260MValues/s(onentry-levelworkstation).Itwas400MValues/sontop-levelworkstation.Note:Msgpackwas4%faster.#``````````````````Tips````````````````````````````````````````````````````````# To enable debugging: LA.PVs.Dbg = True# To enable transaction timing: LA.Channel.Perf = True