BCDA-APS / apstools

various tools for use with Bluesky at the APS
https://bcda-aps.github.io/apstools/latest/
Other
16 stars 9 forks source link

synApps luascript record as ophyd Device #532

Closed prjemian closed 2 years ago

prjemian commented 3 years ago

The EPICS lua module has support for the luascript record. Build a Device for the luascript record.

synApps lua

prjemian commented 3 years ago

The INPA --> A field structures look like one of the userCalcs.

prjemian commented 3 years ago

Note the docker xxxx IOC (synApps 6.2) already has 20 of these luascript records (2 sets of 10):

root@zap:/opt/iocxxx# less /opt/synApps/support/lua-R3-0-1/luaApp/Db/luascripts10.db
root@zap:/opt/iocxxx# grep set1 dbl-all.txt 
gp:set1:userScriptEnable
gp:set1:EnableUserScripts
gp:set1:DisableUserScripts
gp:Slit1Vset1
gp:Slit1Hset1
gp:set1:userScript0
gp:set1:userScript1
gp:set1:userScript2
gp:set1:userScript3
gp:set1:userScript4
gp:set1:userScript5
gp:set1:userScript6
gp:set1:userScript7
gp:set1:userScript8
gp:set1:userScript9
root@zap:/opt/iocxxx# grep set2 dbl-all.txt 
gp:set2:userScriptEnable
gp:set2:EnableUserScripts
gp:set2:DisableUserScripts
gp:set2:userScript0
gp:set2:userScript1
gp:set2:userScript2
gp:set2:userScript3
gp:set2:userScript4
gp:set2:userScript5
gp:set2:userScript6
gp:set2:userScript7
gp:set2:userScript8
gp:set2:userScript9
root@zap:/opt/iocxxx# 
prjemian commented 3 years ago
root@zap:/opt/iocxxx# grep lua *
common.iocsh:dbLoadRecords("$(LUA)/luaApp/Db/luascripts10.db", "P=$(PREFIX), R=set1:")
common.iocsh:dbLoadRecords("$(LUA)/luaApp/Db/luascripts10.db", "P=$(PREFIX), R=set2:")
envPaths:epicsEnvSet("LUA","/opt/synApps/support/lua-R3-0-1")
settings.iocsh:# search path for lua scripts
prjemian commented 3 years ago

Not needed immediately, pushing to next milestone.

Needs example lua script to use for testing and example. @keenanlang Can you provide an example?

prjemian commented 2 years ago

lua support

prjemian commented 2 years ago

Examples:

prjemian commented 2 years ago

test.lua from above example:

    -- defines a factorial function
    function fact (n)
      if n == 0 then
        return 1
      else
        return n * fact(n-1)
      end
    end
prjemian commented 2 years ago

From the luascript record's documentation:

The CODE expression can also be used to reference a file containing the description of at least a single lua function. If the CODE field starts with the symbol @ followed by the name of said file, the luascript record will search through a list of directories given by the environment variable LUA_SCRIPT_PATH (default: current directory) for the given file. A space character and then the name of a function defined in the file lets the luascript record know what function to call when the record processes. Optionally, a set of parameters can be provided that the function will be called with each processing by including a comma separated list enclosed by parentheses.