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

Add functions to C library wrapper #23

Merged
merged 11 commits into from Nov 18, 2023
Merged

Conversation

francdoc
Copy link
Contributor

@francdoc francdoc commented Sep 2, 2023

Hi Pete, I'm interested in contributing to your repo. Here are a couple of functions. I would like to check with you if I understood correctly how to wrap them from the C API. Thanks in advance.

acspy/acsc.py Outdated
@@ -277,27 +300,20 @@ def toPointM(hcomm, flags, axes, target, wait=SYNCHRONOUS):
call_acsc(acs.acsc_ToPointM, hcomm, flags, axes_c, target_c, wait)


def enable(hcomm, axis, wait=SYNCHRONOUS):
def enableMotor(hcomm, axis:int, wait=SYNCHRONOUS):
Copy link
Owner

Choose a reason for hiding this comment

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

We shouldn't rename this in case others are depending on it (like some of my apps!) You can create an alias if you'd like, but I've just been mirroring the ACS function names, which here is just enable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Pete, ok! On it. Thanks for your answer.

acspy/acsc.py Outdated Show resolved Hide resolved
Copy link
Owner

@petebachant petebachant left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! A couple things:

  • Existing APIs should be left in place, following the "open/closed principle" (open for extension, closed for change). You can add new functions, but don't delete or change existing ones in ways that could break any code depending on this library.
  • Please run black -l79 on the code. I should automate that with GitHub Actions, but haven't got around to it yet.

@francdoc
Copy link
Contributor Author

francdoc commented Sep 3, 2023

Hi Pete, great. Thanks for the explanation. I'm going to fix this to follow the open/closed principle then.

acspy/acsc.py Outdated
@@ -192,6 +192,11 @@ def setJerk(hcomm, axis: int, jerk: double, wait=SYNCHRONOUS):
call_acsc(acs.acsc_SetJerk, hcomm, axis, double(jerk), wait)


def setRPosition(hcomm, axis: int, rpos: double, wait=SYNCHRONOUS):
Copy link
Owner

Choose a reason for hiding this comment

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

The type hints for these should be Python types, since we convert to ctypes internally

Suggested change
def setRPosition(hcomm, axis: int, rpos: double, wait=SYNCHRONOUS):
def setRPosition(hcomm, axis: int, rpos: float, wait=SYNCHRONOUS):

@petebachant petebachant changed the title adding couple of functions to wrapper Add functions to C library wrapper Nov 18, 2023
@petebachant petebachant merged commit 819007a into petebachant:master Nov 18, 2023
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.

None yet

3 participants