-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edited OERCONE ioc to boot using lua, calling scripts from the utilities support modules #433
Merged
Alistair-McGann-Tessella
merged 6 commits into
master
from
Ticket4288_oercone_ioc_to_lua
Nov 5, 2019
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f2ec61a
Edited OERCONE ioc to boot using lua, calling scripts from the utilit…
JamesKingWork e6191d2
Removed unsused c code
JamesKingWork d3c9138
Removed unused cmd code
JamesKingWork 3c477ca
Removed unnecessary files, tidying up st.cmd and st-common.lua
JamesKingWork cbbb20d
Conformed to luacheck guidelines using local, changed use of port macro
JamesKingWork 12f9377
Changed the st-common boot script to be in a function to restrict the…
JamesKingWork File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,6 @@ | ||
epicsEnvSet "STREAM_PROTOCOL_PATH" "$(OERCONE)/data" | ||
epicsEnvSet "DEVICE" "L0" | ||
# Set up lua paths for access in the lua shell | ||
epicsEnvSet("LUA_PATH", "${UTILITIES}/lua") | ||
epicsEnvSet("LUA_SCRIPT_PATH","${TOP}/iocBoot/${IOC}") | ||
|
||
##ISIS## Run IOC initialisation | ||
< $(IOCSTARTUP)/init.cmd | ||
|
||
## Device simulation mode IP configuration | ||
$(IFDEVSIM) drvAsynIPPortConfigure("$(DEVICE)", "localhost:$(EMULATOR_PORT=57677)") | ||
|
||
## For recsim: | ||
$(IFRECSIM) drvAsynSerialPortConfigure("$(DEVICE)", "$(PORT=NUL)", 0, 1, 0, 0) | ||
|
||
## For real device: | ||
$(IFNOTDEVSIM) $(IFNOTRECSIM) drvAsynSerialPortConfigure("$(DEVICE)", "$(PORT=NO_PORT_MACRO)", 0, 0, 0, 0) | ||
$(IFNOTDEVSIM) $(IFNOTRECSIM) asynSetOption("$(DEVICE)", -1, "baud", "$(BAUD=9600)") | ||
$(IFNOTDEVSIM) $(IFNOTRECSIM) asynSetOption("$(DEVICE)", -1, "bits", "$(BITS=8)") | ||
$(IFNOTDEVSIM) $(IFNOTRECSIM) asynSetOption("$(DEVICE)", -1, "parity", "$(PARITY=none)") | ||
$(IFNOTDEVSIM) $(IFNOTRECSIM) asynSetOption("$(DEVICE)", -1, "stop", "$(STOP=1)") | ||
## Hardware flow control off | ||
$(IFNOTDEVSIM) $(IFNOTRECSIM) asynSetOption("$(DEVICE)", 0, "clocal", "Y") | ||
$(IFNOTDEVSIM) $(IFNOTRECSIM) asynSetOption("$(DEVICE)",0,"crtscts","N") | ||
## Software flow control off | ||
$(IFNOTDEVSIM) $(IFNOTRECSIM) asynSetOption("$(DEVICE)",0,"ixon","N") | ||
$(IFNOTDEVSIM) $(IFNOTRECSIM) asynSetOption("$(DEVICE)",0,"ixoff","N") | ||
|
||
## Load record instances | ||
|
||
##ISIS## Load common DB records | ||
< $(IOCSTARTUP)/dbload.cmd | ||
|
||
## Load our record instances | ||
dbLoadRecords("$(OERCONE)/db/oercone.db","PVPREFIX=$(MYPVPREFIX),P=$(MYPVPREFIX)$(IOCNAME):,RECSIM=$(RECSIM=0),DISABLE=$(DISABLE=0),PORT=$(DEVICE)") | ||
dbLoadRecords("$(OERCONE)/db/unit_setter.db","P=$(MYPVPREFIX)$(IOCNAME):") | ||
|
||
|
||
##ISIS## Stuff that needs to be done after all records are loaded but before iocInit is called | ||
< $(IOCSTARTUP)/preiocinit.cmd | ||
|
||
cd "${TOP}/iocBoot/${IOC}" | ||
iocInit | ||
|
||
## Start any sequence programs | ||
#seq sncxxx,"user=ltu34219" | ||
|
||
##ISIS## Stuff that needs to be done after iocInit is called e.g. sequence programs | ||
< $(IOCSTARTUP)/postiocinit.cmd | ||
# Call into the lua shell to boot the ioc | ||
luash("st-common.lua") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
-- ## Import lua utility functions | ||
|
||
package.path = package.path .. ';' .. os.getenv("UTILITIES") .. '/lua/luaUtils.lua;' | ||
local utils = require("luaUtils") | ||
local getMacroValue = utils.getMacroValue | ||
local setAsynOptions = utils.setAsynOptions | ||
local setHardwareFlowControl = utils.setHardwareFlowControl | ||
local setSoftwareFlowControl = utils.setSoftwareFlowControl | ||
|
||
function oercone_stcommon_main() | ||
|
||
-- ## Get required macros and related vars | ||
local oercone = getMacroValue{macro="OERCONE"} | ||
local iocstartup = getMacroValue{macro="IOCSTARTUP"} | ||
local emulator_port = getMacroValue{macro="EMULATOR_PORT", default="57677"} | ||
|
||
-- ## Set EPICS environment vars | ||
iocsh.epicsEnvSet("STREAM_PROTOCOL_PATH", string.format("%s/data", oercone)) | ||
local device = "L0" | ||
iocsh.epicsEnvSet("DEVICE", device) | ||
|
||
-- ##ISIS## Run IOC initialisation | ||
iocsh.iocshLoad(string.format("%s/init.cmd", iocstartup)) | ||
|
||
-- Get macros required and related vars that required init.cmd to run | ||
local recsim = getMacroValue{macro="RECSIM", default="0"} | ||
local isRecsim = recsim == "1" | ||
local isDevsim = getMacroValue{macro="DEVSIM", default="0"} == "1" | ||
local disable = getMacroValue{macro="DISABLE", default="0"} | ||
local iocname = getMacroValue{macro="IOCNAME"} | ||
local pvprefix = getMacroValue{macro="MYPVPREFIX"} | ||
|
||
-- ## Device simulation mode IP configuration | ||
if (isDevsim) then | ||
iocsh.drvAsynIPPortConfigure(device, string.format("localhost:%s", emulator_port)) | ||
end | ||
|
||
-- ## For recsim: | ||
if (isRecsim) then | ||
local port = getMacroValue{macro="PORT", default="NUL"} | ||
iocsh.drvAsynSerialPortConfigure(device, port, 0, 1 ,0 ,0) | ||
end | ||
|
||
-- ## For real device: | ||
if (not isRecsim and not isDevsim) then | ||
local port = getMacroValue{macro="PORT", default="NO_PORT_MACRO"} | ||
local baud = getMacroValue{macro="BAUD", default="9600"} | ||
local bits = getMacroValue{macro="BITS", default="8"} | ||
local parity = getMacroValue{macro="PARITY", default="none"} | ||
local stop = getMacroValue{macro="STOP", default="1"} | ||
setAsynOptions(device, port, baud, bits, parity, stop) | ||
-- Hardware flow control off | ||
local flowControlOn = false | ||
setHardwareFlowControl(device, flowControlOn) | ||
-- Software flow control off | ||
setSoftwareFlowControl(device, flowControlOn) | ||
end | ||
|
||
-- ## Load record instances | ||
|
||
-- ##ISIS## Load common DB records | ||
iocsh.iocshLoad(string.format("%s/dbload.cmd", iocstartup)) | ||
|
||
-- ## Load our record instances | ||
iocsh.dbLoadRecords( | ||
string.format("%s/db/oercone.db",oercone), | ||
string.format("PVPREFIX=%s,P=%s%s:,RECSIM=%s,DISABLE=%s,PORT=%s", | ||
pvprefix, pvprefix, iocname, recsim, disable, device) | ||
) | ||
iocsh.dbLoadRecords( | ||
string.format("%s/db/unit_setter.db", oercone), | ||
string.format("P=%s%s:", pvprefix, iocname) | ||
) | ||
|
||
-- ##ISIS## Stuff that needs to be done after all records are loaded but before iocInit is called | ||
iocsh.iocshLoad(string.format("%s/preiocinit.cmd", iocstartup)) | ||
|
||
iocsh.iocInit() | ||
|
||
-- ##ISIS## Stuff that needs to be done after iocInit is called e.g. sequence programs | ||
iocsh.iocshLoad(string.format("%s/postiocinit.cmd", iocstartup)) | ||
end | ||
|
||
oercone_stcommon_main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, remove unused code in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed