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

ENH: implement flutter detection #88

Merged
merged 6 commits into from
May 16, 2024
Merged

Conversation

nrwslac
Copy link
Contributor

@nrwslac nrwslac commented Mar 19, 2024

Description

  • Implement a function FB_FlutterDetection to detect a boolean changing from high to low a given amount of times within a certain time window.
  • Can detect a boolen flipping state number of cycles - 1 times.
  • Add two tests:
  • TestFlutterReset
  • TestFlutterResolution
  • Reorg tests into one central location.

Motivation and Context

How Has This Been Tested?

  • Two tests run and passed. Although, the actions I expected to happen on a particular cycle did not line up exactly. This means there's probably + 30 ms of uncertainty in how long it takes to reset the flutter detection and maybe +10 ms in flutter detection. I don't anticipate this level of performance being needed atm.

Where Has This Been Documented?

Pre-merge checklist

  • Code works interactively
  • Code contains descriptive comments
  • Test suite passes locally
  • Libraries are set to Always Newest version (Library, *)
  • Committed with pre-commit or ran pre-commit run --all-files

@nrwslac nrwslac marked this pull request as ready for review May 10, 2024 20:48
@nrwslac nrwslac requested a review from ZLLentz May 10, 2024 20:48
Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

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

I think this looks solid 👍
I followed the logic for the FB and for the tests
I had one comment about the dev library rename

@@ -17,7 +17,7 @@
<CombineIds>false</CombineIds>
<Company>SLAC</Company>
<Released>false</Released>
<Title>LCLS General</Title>
<Title>LCLS General-nrw</Title>
Copy link
Member

Choose a reason for hiding this comment

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

Need to switch back before merge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

switched back to original project name.


nCycleTime := _TaskInfo[GETCURTASKINDEXEX()].CycleTime;
nCycleTime := nCycleTime / 10000; //convert to ms
nCalcCycleTime := UDINT_TO_TIME(nCycleTime * 4);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I missed setting this magic 4 to nNumCycles

Copy link
Member

Choose a reason for hiding this comment

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

If the tests are really precise in what they're expecting we might get different behavior if we switch target PLCs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaced 4 with variable.

Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

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

I'm fully 👍 on this, good job!

@nrwslac nrwslac merged commit 81d2ddc into pcdshub:master May 16, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants