-
Notifications
You must be signed in to change notification settings - Fork 938
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
WIP: Sim add actions to setvalues #2255
WIP: Sim add actions to setvalues #2255
Conversation
you have merge conflict, please solve. |
A small number of comments (not a formal review):
|
Your changes as such looks ok, but it is hard to see the details without a usage example. |
the example needs to be documented in doc/source/library/simulator as a new rst file, and amended to one existing. |
Forgot to write: I do not understand the need for "access_type", it seems unneeded. |
Yes, will resolve as part of rebase and squash.
Yes, will provide an example.
Yes, will do this.
Certain function codes such as WriteSingleRegisterRequest (0x06) call both setValues() and getValues(). Providing "access_type" is a way to allow a user action method to choose how to respond to each of these separately. For example, an action method may only want to be invoked once for a WriteSingleRegisterRequest. In this case, the action method can include a condition def custom_action3(_registers, _inx, cell, func_code, access_type):
"""Test action which includes function code and access type as parameters."""
if func_code == 6 and access_type == "set":
cell.value = 0x5555 I'm open to any ideas on how to improve this interface or address this issue. |
Yes we need backward compatibility whenever possible! just make the parameters optional, the existing action should use kwargs if I remember right. |
I understand your explanation of access, but it seems too complex and very theoretical. please do not forget this is a simulator not production. Only a very special user would ever use it, but all users need to deal with the parameter. Users wanting something that special can use e.g. inspect to see from where the action is called. |
Thinking about your example, that can be solved without the extra parameter, something like:
|
If your changes are done and merged in time for v3.7.0 (due next week), then adding the function_code is ok. Otherwise API changes are not allowed until v3.8.0 which are not due for quite some time. |
Your feedback is very helpful, thank you.
This solves the problem nicely. After some thought, another option would be to define a function attribute following the function definition. def custom_action3(_registers, _inx, cell, func_code):
"""Test action without access type as parameter."""
if func_code == 6:
if custom_action3.action_done:
custom_action3.action_done = False
else:
cell.value = 0x5555
custom_action3.action_done = True
custom_action3.action_done = False
I will work on all the points above and aim to issue a PR in time for v3.7.0. |
In order to include For example, the simulator-provided def action_increment(cls, registers, inx, cell, minval=None, maxval=None): to def action_increment(cls, registers, inx, cell, minval=None, maxval=None, **_kwargs):
... Do you consider this an API change? |
For 3.7.0 API changes are allowed, and again much later for 3.8.0. API changes needs to be documented in API_changes.rst. |
I am still working on cleaning up tests and adding to docs. I will wait for the release window for v3.8.0 to open before taking this PR out of draft. |
Thanks for the update. Version 3.8.0 will probably not be before December. But we do merge Pull Requests with API changes, they simply go into "wait_3_8_0" |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
This PR was closed because it has been stalled for 10 days with no activity. |
WIP: Simulator add actions to setvalues
Aims to address #2158:
Please note:
Feedback would be appreciated.