-
Notifications
You must be signed in to change notification settings - Fork 78
Mode enum #407
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
base: master
Are you sure you want to change the base?
Mode enum #407
Changes from 3 commits
0fbcfa5
cdad2aa
46b4868
bbf024e
10d94d0
ba8f207
c2d56e5
a82a9b6
397deb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -28,6 +28,9 @@ | |||
| from .submit_command import HammerSubmitCommand | ||||
| from .units import TemperatureValue, TimeValue, VoltageValue | ||||
|
|
||||
| from enum import Enum | ||||
| from hammer_utils import reverse_dict | ||||
|
|
||||
| __all__ = ['HammerTool'] | ||||
|
|
||||
|
|
||||
|
|
@@ -1128,3 +1131,34 @@ def verbose_tcl_append(cmd: str, output_buffer: List[str]) -> None: | |||
| """ | ||||
| output_buffer.append("""puts "{0}" """.format(cmd.replace('"', '\"'))) | ||||
| output_buffer.append(cmd) | ||||
| class ModeType(Enum): | ||||
| Auto = 1 | ||||
| Empty = 2 | ||||
| Manual = 3 | ||||
| Generate = 4 | ||||
| Generated = 5 | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I'm aware, the modes we use are:
Also, if we are going to create this enum, I think it may be good to also use them in some of the settings.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should change power straps to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, maybe we can do that as a separate issue then?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can just tack it on to #397 .
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Edward, thanks for your comment! I checked defaults.yml and it seems that pin place mode uses
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Jingyi- let's use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, so John's comment above is alluding to that problem. I think the desired action is to use As for use, if you look in the code, right now it uses strings - the intention is to use this enum instead
|
||||
| Append = 6 | ||||
| Prepend = 7 | ||||
|
|
||||
| @classmethod | ||||
| def __mapping(cls) -> Dict[str, "ModeType"]: | ||||
| return { | ||||
| "auto": ModeType.Auto, | ||||
| "empty": ModeType.Empty, | ||||
| "manual": ModeType.Manual, | ||||
| "generate": ModeType.Generated, | ||||
| "generated": ModeType.Generate, | ||||
| "append": ModeType.Append, | ||||
| "prepend": ModeType.Prepend | ||||
| } | ||||
|
|
||||
| @staticmethod | ||||
| def from_str(input_str: str) -> "ModeType": | ||||
| try: | ||||
| return ModeType.__mapping()[input_str] | ||||
| except KeyError: | ||||
| raise ValueError("Invalid mode type: " + str(input_str)) | ||||
|
|
||||
| def __str__(self) -> str: | ||||
| return reverse_dict(ModeType.__mapping())[self] | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.