Skip to content
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
merged 6 commits into from
Nov 5, 2019

Conversation

JamesKingWork
Copy link
Contributor

@JamesKingWork JamesKingWork commented Oct 2, 2019

The OERCONE ioc now boots partially by using lua which is called from the st-common.cmd

Some of the code is messy as I have not had time for cleanup yet, but it is tested and works against the IocTestFramework.

There is a strong code smell in here (dead code) it is up to the reviewer whether they think it important I should get rid of this smell.
The 3 reasons I have not removed the dead code are:

  • For a more complete switch to lua we could call st.lua from the cpp that boots the ioc. The code left in the cpp file and st.lua could be useful for that at a later date (though of course this can all be removed and cleaned up if the reviewer thinks it correct)
  • I have left the original functionality in the st-common.cmd as it both shows the mapping of cmd code to lua code and also if the lua functionality when tested against hardware for whatever reason does not work we can easily switch back to cmd.
  • I haven't had time on this timeboxed friday and could pick this ticket up to make it more elegant (removing dead code) in the next friday, so it may make more sense to leave the extra code in there so I can make easy progress for next time

Description of work

Edited the IOC for OERCONE to boot with lua called in the st-common.cmd

To test

Use the IOCTestFramework to test the oercone and eventually against hardware hopefully.

Ticket: (ISISComputingGroup/IBEX#4288)

Acceptance criteria

  1. IOC st.cmd uses LUA instead
  2. Database is still updated
  3. Devsim and rec sim tests still run in the IOC test framework
  4. Log is still captured as log file and in the database
  5. Errors in missing macros, db files are still reported

Code Review

Functional Tests

  • IOC responds correctly in:
    • Devsim mode
    • Recsim mode
    • Real device, if available
  • Supplementary IOCs (..._0n where n>1) run correctly
  • Log files do not report undefined macros (serach for macLib: macro to find instances of macLib: macro [macro name] is undefined...

Final steps

  • Update the IOC submodule in the main EPICS repo. See Git workflow page for details.
  • Reviewer has moved the release notes entry for this ticket in the "Changes merged into master" section

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good work. As discussed can you remove the unfinished C code and remove the unused *.cmd code. Other minor comments in code.


#include "epicsExit.h"
#include "epicsThread.h"
#include "iocsh.h"
#include "luaShell.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed remove this C code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@@ -1,46 +1,50 @@
epicsEnvSet "STREAM_PROTOCOL_PATH" "$(OERCONE)/data"
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Comment on lines 18 to 19
iocsh.epicsEnvSet("STREAM_PROTOCOL_PATH", string.format("%s/data", oercone))
iocsh.epicsEnvSet("DEVICE", "L0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these variables are not used anywhere other than this file so need to set them externally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to local variables and removed stream protocol path as it is not used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that STREAM_PROTOCOL_PATH and DEVICE epics environment variables are used elsewhere, the tests fail otherwise.

Comment on lines 27 to 28
devsim = getMacroValue{macro="DEVSIM", default="0"}
isDevsim = devsim == "1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually only need isDevsim so can we just do this in one line? Similar for recsim

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to be one line for isDevsim.
recsim variable itself is used in iocsh.dbLoadRecords though, so kept that.

-- ##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))

-- os.execute(string.format("cd %s/iocBoot/%s", getMacroValue{macro="TOP"}, getMacroValue{macro="IOC"}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code, remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Comment on lines 84 to 85
-- ## Start any sequence programs
-- #seq sncxxx,"user=ltu34219"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code, remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed


-- # calling common command file in ioc 01 boot dir
-- # < ${TOP}/iocBoot/iocOERCONE-IOC-01/st-common.cmd
require("st-common.lua")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a new line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The st.lua file is never called so was dead code.
Removed the file.

-- # Increase this if you get <<TRUNCATED>> or discarded messages warnings in your errlog output
iocsh.errlogInit2(65536, 256)

-- # envPaths
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The st.lua file is never called so was dead code.
Removed the file.

-- # envPaths
iocsh.iocshLoad(string.format("%s/dbload.cmd", iocstartup))

-- # cd ${TOP}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The st.lua file is never called so was dead code.
Removed the file.

@JamesKingWork
Copy link
Contributor Author

JamesKingWork commented Oct 17, 2019

There have been some changes since the review due to unforeseen strangeness in the way epics runs Lua. This included moving the script into a function so that local variables don't drop out of scope. Please see documented issues at the bottom of the Lua wiki page. There is also now documentation linked to here for installing and setting up luacheck, and also documentation for how to use our Lua utility functions.

@Alistair-McGann-Tessella Alistair-McGann-Tessella dismissed DominicOram’s stale review November 5, 2019 13:27

Requested changes have been implemented

@Alistair-McGann-Tessella Alistair-McGann-Tessella merged commit 486dab4 into master Nov 5, 2019
@Alistair-McGann-Tessella Alistair-McGann-Tessella deleted the Ticket4288_oercone_ioc_to_lua branch November 5, 2019 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants