Improve limit checking for motor records (fixes #29)#39
Open
nariox wants to merge 1 commit into
Open
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, before a scan executes, the
sscanRecordchecks the low and high limits of the positioners to make sure the scan range is within those limits. If the limit is set to 0, the limit is ignored (see here. This introduces two problems:aoRecord.cchecks ifDRVH > DRVLto decide on whether to enforce the limits (see here. This means that if a positioner has limits 0 to 100 (for example, a percentage of something), the sscan record will completely ignore the lower limit, and allow a scan from -100 to 100, for example. Of course, when the command to the positioner is sent, the positioner itself will refuse to go below 0, but I think the check was meant to capture exactly these cases.sscanrecord refuses the scan. This is because when the limits are not initialized, the dial limits are set to 0, but the user limits are set toOFF(since the user values are simply the dial values shifted byOFF). Because of that, we tend to set theLLMandHLMfields to very large negative and positive values respectively (-9999and+9999typically), but that is just a workaround.In this PR, I solve the issue in one way. I simply compare the low and high limits to each other. If they are equal, I ignored the limits, otherwise the limits are enforced. I would be open to modify it so that we replace the
!=with<like it is done inaoRecord.c, which would be more consistent with epics-base, but, at least in the case ofmotorrecords, would still not execute a scan, as the motor record still enforces the low and high limits, even ifHLM < LLM(in this case, the motor refuses to move completely), so I think my approach is superior as it would still display the message as to why the scan did not execute properly. The only case where I think it might be overly restricting is if the positioner is linked to a record that ignores limits when the upper limit is smaller than the lower limit (likeaorecords), but I find that this case is fairly unusual (why set lower limit higher than the upper limit?*) and even then it is still less restricting than the current implementation (as it would allow us to continue to use user values on the motors, which currently don't work) and fixes the situation where one of the limits is 0, but it is not an ignorable 0 (as I described in case 1).I am open to better alternatives, but I believe this change would be helpful in most cases I can think of.